Skip to content

Commit

Permalink
small optimization for da1bdc8
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Andrej730 committed May 14, 2024
1 parent c50149a commit 2fa30be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/blenderbim/blenderbim/bim/import_ifc.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,20 +609,23 @@ def predict_dense_mesh(self):
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

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

Expand Down

0 comments on commit 2fa30be

Please sign in to comment.