Assigning a parametric profile type now auto switches from non parametric geometry to parametric geometry

This commit is contained in:
Dion Moult
2021-10-21 16:28:55 +11:00
parent aee7fbcc79
commit c437ba8f9d
11 changed files with 243 additions and 44 deletions
@@ -22,7 +22,8 @@ class Usecase:
ifcopenshell.util.element.remove_deep2(
self.file,
self.settings["representation"],
extra_subgraph_elements=list(styled_items | presentation_layer_assignments),
also_consider=list(styled_items | presentation_layer_assignments),
do_not_delete=self.file.by_type("IfcGeometricRepresentationContext"),
)
for element in styled_items:
@@ -136,17 +136,21 @@ def remove_deep(ifc_file, element):
ifc_file.unbatch()
def remove_deep2(ifc_file, element, extra_subgraph_elements=[]):
def remove_deep2(ifc_file, element, also_consider=[], do_not_delete=[]):
# Experimental remove deep proposal. No batch for now until this is more certain. See #1812.
# ifc_file.batch()
to_delete = set()
subgraph = list(ifc_file.traverse(element, breadth_first=True))
subgraph.extend(extra_subgraph_elements)
subgraph.extend(also_consider)
subgraph_set = set(subgraph)
subelement_queue = ifc_file.traverse(element, max_levels=1)
while subelement_queue:
subelement = subelement_queue.pop(0)
if subelement.id() and len(set(ifc_file.get_inverse(subelement)) - subgraph_set) == 0:
if (
subelement.id()
and len(set(ifc_file.get_inverse(subelement)) - subgraph_set) == 0
and subelement not in do_not_delete
):
to_delete.add(subelement)
subelement_queue.extend(ifc_file.traverse(subelement, max_levels=1)[1:])
for subelement in to_delete:
@@ -77,3 +77,9 @@ class TestRemoveRepresentation(test.bootstrap.IFC4):
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
assert len(self.file.by_type("IfcPresentationLayerAssignment")) == 1
assert len(self.file.by_type("IfcShapeRepresentation")) == 1
def test_not_purging_geometric_representation_contexts(self):
context = self.file.createIfcGeometricRepresentationSubContext()
representation = self.file.createIfcShapeRepresentation(ContextOfItems=context)
ifcopenshell.api.run("geometry.remove_representation", self.file, representation=representation)
assert len(self.file.by_type("IfcGeometricRepresentationContext")) == 1