mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
remove_representation to consider representation item's layers too
and purge layers if they are out of items as they become invalid
This commit is contained in:
@@ -47,6 +47,7 @@ class Usecase:
|
||||
for subelement in self.file.traverse(self.settings["representation"]):
|
||||
if subelement.is_a("IfcRepresentationItem"):
|
||||
[styled_items.add(s) for s in subelement.StyledByItem or []]
|
||||
[presentation_layer_assignments.add(s) for s in subelement.LayerAssignment]
|
||||
# IfcTessellatedFaceSet inverses
|
||||
[textures.add(t) for t in getattr(subelement, "HasTextures", []) or []]
|
||||
[colours.add(t) for t in getattr(subelement, "HasColours", []) or []]
|
||||
|
||||
@@ -79,14 +79,14 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcStyledItem")) == 1
|
||||
|
||||
def test_purging_presentation_layers(self):
|
||||
def test_purging_representation_presentation_layers(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 0
|
||||
|
||||
def test_not_purging_presentation_layers_still_in_use(self):
|
||||
def test_not_purging_representation_presentation_layers_still_in_use(self):
|
||||
representation = self.file.createIfcShapeRepresentation()
|
||||
representation2 = self.file.createIfcShapeRepresentation()
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[representation, representation2])
|
||||
@@ -94,6 +94,23 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
|
||||
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
|
||||
|
||||
def test_purging_representation_item_presentation_layers(self):
|
||||
item = self.file.createIfcExtrudedAreaSolid()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 0
|
||||
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 0
|
||||
|
||||
def test_not_purging_representation_item_presentation_layers_still_in_use(self):
|
||||
item, item2 = self.file.createIfcExtrudedAreaSolid(), self.file.createIfcExtrudedAreaSolid()
|
||||
representation = self.file.createIfcShapeRepresentation(Items=[item])
|
||||
representation2 = self.file.createIfcShapeRepresentation(Items=[item2])
|
||||
layer = self.file.createIfcPresentationLayerAssignment(AssignedItems=[item, item2])
|
||||
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
|
||||
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
|
||||
assert len(self.file.by_type("IfcExtrudedAreaSolid")) == 1
|
||||
|
||||
def test_not_purging_geometric_representation_contexts(self):
|
||||
context = self.file.createIfcGeometricRepresentationSubContext()
|
||||
representation = self.file.createIfcShapeRepresentation(ContextOfItems=context)
|
||||
|
||||
Reference in New Issue
Block a user