From 2fa30be0d0669dc655bde66e93692c6faeec7463 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 14 May 2024 15:43:19 +0500 Subject: [PATCH] small optimization for da1bdc802 On large projects predict dense mesh stage can take 20s+ and reusing attribute value can save up to half of this time. Using indices also helps but it's not that significant and sometimes it's the same time as using attribute names. --- src/blenderbim/blenderbim/bim/import_ifc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/import_ifc.py b/src/blenderbim/blenderbim/bim/import_ifc.py index 9318328dd3..81f20c809e 100644 --- a/src/blenderbim/blenderbim/bim/import_ifc.py +++ b/src/blenderbim/blenderbim/bim/import_ifc.py @@ -609,7 +609,8 @@ class IfcImporter: threshold = 10000 # Just from experience. # The check for CfsFaces/Faces/CoordIndex accommodates invalid data from Cadwork - faces = [len(e.CfsFaces) for e in self.file.by_type("IfcClosedShell") if e.CfsFaces] + # 0 IfcClosedShell.CfsFaces + faces = [len(faces) for e in self.file.by_type("IfcClosedShell") if (faces := e[0])] if faces and max(faces) > threshold: self.ifc_import_settings.should_use_native_meshes = True return @@ -617,12 +618,14 @@ class IfcImporter: if self.file.schema == "IFC2X3": return - faces = [len(e.Faces) for e in self.file.by_type("IfcPolygonalFaceSet") if e.Faces] + # 2 IfcPolygonalFaceSet.Faces + faces = [len(faces) for e in self.file.by_type("IfcPolygonalFaceSet") if (faces := e[2])] if faces and max(faces) > threshold: self.ifc_import_settings.should_use_native_meshes = True return - faces = [len(e.CoordIndex) for e in self.file.by_type("IfcTriangulatedFaceSet") if e.CoordIndex] + # 3 IfcTriangulatedFaceSet.CoordIndex + faces = [len(index) for e in self.file.by_type("IfcTriangulatedFaceSet") if (index := e[3])] if faces and max(faces) > threshold: self.ifc_import_settings.should_use_native_meshes = True