From 276077964d059c081bddc3a0c20a6760fac276ce Mon Sep 17 00:00:00 2001 From: Laurens Oostwegel Date: Sun, 7 Nov 2021 10:51:09 +0100 Subject: [PATCH] ifccityjson: refactor GeometryIO class --- src/ifccityjson/geometry.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/ifccityjson/geometry.py b/src/ifccityjson/geometry.py index cff2f7b5e1..23e843a902 100644 --- a/src/ifccityjson/geometry.py +++ b/src/ifccityjson/geometry.py @@ -128,9 +128,12 @@ class GeometryIO: # print(triangle) def create_IFC_surface(self, IFC_model, geometry, surface_id=None): - faces = None + faces = [] + if surface_id is not None: face_ids = geometry.surfaces[surface_id]["surface_idx"] + if face_ids is None: + return # there is no geometry faces = list(map(lambda face_id: geometry.boundaries[face_id[0]][face_id[1]], face_ids)) else: faces = geometry.boundaries @@ -147,20 +150,20 @@ class GeometryIO: # exterior face vertices = [] for vertex in face[0]: - polyloop = IFC_model.create_entity("IfcPolyLoop", vertices) - outerbound = IFC_model.create_entity("IfcFaceOuterBound", polyloop, True) vertices.append(self.get_vertex(IFC_model, vertex)) + polyloop = IFC_model.create_entity("IfcPolyLoop", Polygon=vertices) + outerbound = IFC_model.create_entity("IfcFaceOuterBound", Bound=polyloop, Orientation=True) # return if only exterior face if len(face) == 1: - return IFC_model.create_entity("IfcFace", [outerbound]) + return IFC_model.create_entity("IfcFace", Bounds=[outerbound]) - # interior face + # return IFC_model.create_entity("IfcFace", [outerbound]) + # interior face BUGS innerbounds = [] for interior_face in face[1:]: for vertex in interior_face: - polyloop = IFC_model.create_entity("IfcPolyLoop", vertices) - innerbounds.append(IFC_model.create_entity("IfcFaceBound", polyloop, True)) - return IFC_model.create_entity("IfcFace", [outerbound] + innerbounds) - vertices.append(self.get_vertex(IFC_model, vertex)) + polyloop = IFC_model.create_entity("IfcPolyLoop", Polygon=vertices) + innerbounds.append(IFC_model.create_entity("IfcFaceBound", Bound=polyloop, Orientation=False)) + return IFC_model.create_entity("IfcFace", Bounds=[outerbound] + innerbounds)