edit_object_placement optimization for objects with subchildren #4035

1) We were iterating over same subchildren 2 or more times.
2) There is no need to change subchildren position at all since their parent position is already adjusted.

Explained here in detail - https://github.com/IfcOpenShell/IfcOpenShell/issues/4035#issuecomment-1822824352
This commit is contained in:
Andrej730
2023-11-22 18:50:09 +05:00
parent 9429e478fe
commit 0da210b732
2 changed files with 44 additions and 2 deletions
@@ -100,6 +100,8 @@ class Usecase:
if not placement:
return []
results = []
# NOTE: we ignore subchildren as we already adjust position for their parent
# therefore they're not present in `results` and `should_transform_children` should be `True`
for referenced_placement in placement.ReferencedByPlacements:
matrix = ifcopenshell.util.placement.get_local_placement(referenced_placement)
for obj in referenced_placement.PlacesObject:
@@ -111,8 +113,7 @@ class Usecase:
# Feature elements affect the geometry of their parent, and
# so logically should always move with the parent.
continue
results.append({"product": obj, "matrix": matrix, "is_si": False, "should_transform_children": False})
results.extend(self.get_children_settings(referenced_placement))
results.append({"product": obj, "matrix": matrix, "is_si": False, "should_transform_children": True})
return results
def get_relative_placement(self, placement_rel_to):