mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-28 15:53:00 +00:00
Extract space generation algorithms to ifcopenshell.util
Move Blender-independent space generation algorithms from Bonsai (GPL) to ifcopenshell.util (LGPL): - ifcopenshell.util.shape.bisect_mesh_plane_vf: vectorized numpy triangle/plane intersection for mesh bisection - ifcopenshell.util.element.iter_top_connections: walker for IfcRelConnectsElements(TOP) relationships - ifcopenshell.util.space: new module with get_boundary_lines, get_space_polygon, get_auto_space_height and height detection helpers — all operating on IFC geometry without Blender Bonsai's tool/spatial.py now delegates to these utilities via thin wrappers, keeping only Blender-specific concerns (cache management with depsgraph invalidation, UI property reads). tool/wall.py iter_wall_slab_connections delegates to ifcopenshell.util.element.iter_top_connections. Added 22 tests: 6 for bisect_mesh_plane_vf, 10 for space generation algorithms, 4 for iter_top_connections, 2 Bonsai integration tests for cache behavior. Generated with the assistance of an AI coding tool.
This commit is contained in:
@@ -1392,3 +1392,47 @@ class TestCopyDeepIFC4(test.bootstrap.IFC4):
|
||||
element2 = subject.copy_deep(self.file, element)
|
||||
assert element2.Segments[0][0] == (1, 2)
|
||||
assert element2.Segments[1][0] == (3, 4)
|
||||
|
||||
|
||||
class TestIterTopConnections(test.bootstrap.IFC4):
|
||||
def test_yields_top_connected_element(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
rel = self.file.createIfcRelConnectsElements(
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatingElement=slab,
|
||||
RelatedElement=wall,
|
||||
Description="TOP",
|
||||
)
|
||||
results = list(subject.iter_top_connections(wall))
|
||||
assert len(results) == 1
|
||||
assert results[0][0] == slab
|
||||
assert results[0][1] == rel
|
||||
|
||||
def test_returns_empty_when_no_connections(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
assert list(subject.iter_top_connections(wall)) == []
|
||||
|
||||
def test_filters_non_top_description(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
self.file.createIfcRelConnectsElements(
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatingElement=slab,
|
||||
RelatedElement=wall,
|
||||
Description="BOTTOM",
|
||||
)
|
||||
assert list(subject.iter_top_connections(wall)) == []
|
||||
|
||||
def test_filters_non_rel_connects_elements(self):
|
||||
wall = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWall")
|
||||
slab = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcSlab")
|
||||
self.file.createIfcRelConnectsPathElements(
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatingElement=slab,
|
||||
RelatedElement=wall,
|
||||
Description="ATPATH",
|
||||
RelatingConnectionType="ATPATH",
|
||||
RelatedConnectionType="ATPATH",
|
||||
)
|
||||
assert list(subject.iter_top_connections(wall)) == []
|
||||
|
||||
Reference in New Issue
Block a user