Support removing representations from IFC models that do not correctly follow the convention that mapped representations come from types

This commit is contained in:
Dion Moult
2022-08-01 11:23:35 +10:00
parent f86f988d6e
commit d654110fc1
2 changed files with 18 additions and 4 deletions
+2 -2
View File
@@ -120,8 +120,8 @@ def get_representation_ifc_parameters(geometry, obj=None, should_sync_changes_fi
def remove_representation(ifc, geometry, obj=None, representation=None):
element = ifc.get_entity(obj)
if geometry.is_mapped_representation(representation) or geometry.is_type_product(element):
type = geometry.get_element_type(element)
type = geometry.get_element_type(element)
if type and (geometry.is_mapped_representation(representation) or geometry.is_type_product(element)):
representation = geometry.resolve_mapped_representation(representation)
data = geometry.get_representation_data(representation)
if data and geometry.has_data_users(data):
+16 -2
View File
@@ -320,9 +320,9 @@ class TestGetRepresentationIfcParameters:
class TestRemoveRepresentation:
def test_removing_an_actively_used_mapped_representation_by_remapping_usages_to_an_empty(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.is_mapped_representation("mapped_rep").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(True)
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.has_data_users("data").should_be_called().will_return(True)
@@ -337,16 +337,29 @@ class TestRemoveRepresentation:
def test_removing_an_unused_mapped_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.is_mapped_representation("mapped_rep").should_be_called().will_return(True)
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.is_mapped_representation("mapped_rep").should_be_called().will_return(True)
geometry.resolve_mapped_representation("mapped_rep").should_be_called().will_return("representation")
geometry.get_representation_data("representation").should_be_called().will_return(None)
ifc.run("geometry.unassign_representation", product="type", representation="representation").should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="mapped_rep")
def test_remove_a_mapped_representation_by_an_element_with_no_type(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.get_element_type("element").should_be_called().will_return(None)
geometry.get_representation_data("representation").should_be_called().will_return("data")
geometry.has_data_users("data").should_be_called().will_return(True)
geometry.replace_object_with_empty("obj").should_be_called()
ifc.run(
"geometry.unassign_representation", product="element", representation="representation"
).should_be_called()
ifc.run("geometry.remove_representation", representation="representation").should_be_called()
subject.remove_representation(ifc, geometry, obj="obj", representation="representation")
def test_removing_an_actively_used_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.is_mapped_representation("representation").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(False)
geometry.get_representation_data("representation").should_be_called().will_return("data")
@@ -360,6 +373,7 @@ class TestRemoveRepresentation:
def test_removing_an_unused_representation(self, ifc, geometry):
ifc.get_entity("obj").should_be_called().will_return("element")
geometry.get_element_type("element").should_be_called().will_return("type")
geometry.is_mapped_representation("representation").should_be_called().will_return(False)
geometry.is_type_product("element").should_be_called().will_return(False)
geometry.get_representation_data("representation").should_be_called().will_return(None)