diff --git a/src/ifcopenshell-python/test/geom/polyhedral_shapes.py b/src/ifcopenshell-python/test/geom/polyhedral_shapes.py index 56c39c4c3b..2e58809f71 100644 --- a/src/ifcopenshell-python/test/geom/polyhedral_shapes.py +++ b/src/ifcopenshell-python/test/geom/polyhedral_shapes.py @@ -1,4 +1,6 @@ import collections + +import numpy as np import ifcopenshell import ifcopenshell.geom @@ -52,3 +54,32 @@ def test_polyhedral_setting(file): assert len(obj.geometry.faces) == 11 # 10 facets with 1 bound, 1 facet with 2 bounds assert sorted(collections.Counter(map(len, obj.geometry.faces)).items()) == [(1, 10), (2, 1)] + + +def get_edges(inst): + coords = inst.Coordinates.CoordList + for f in inst.Faces: + + def emit(loop): + fcoords = list(map(lambda i: coords[i - 1], loop)) + shifted = fcoords[1:] + [fcoords[0]] + return map(frozenset, zip(fcoords, shifted)) + + yield from emit(f.CoordIndex) + + if f.is_a("IfcIndexedPolygonalFaceWithVoids"): + for inner in f.InnerCoordIndices: + yield from emit(inner) + + +@pytest.mark.parametrize("file", ["geom/polygonal-face-tessellation.ifc"], indirect=True) +@pytest.mark.parametrize("geometry_library", ["opencascade", "cgal", "cgal-simple"]) +def test_correct_edges(file, geometry_library): + s = ifcopenshell.geom.settings() + obj = ifcopenshell.geom.create_shape(s, file[30], geometry_library=geometry_library) + vs = np.array(obj.geometry.verts).reshape((-1, 3)) + eds = np.array(obj.geometry.edges).reshape((-1, 2)) + edge_collection_1 = set(map(lambda t: frozenset(map(tuple, t)), (vs[eds] * 1000).tolist())) + rep = file[30].Representation.Representations[0].Items[0] + edge_collection_2 = set(get_edges(rep)) + assert edge_collection_1 == edge_collection_2