55bc1b2fa5
* Initial commit * Repo setup * first working version * Optimised mesh conversion * timers * first pass * format * Format * deleted old file * Working grabbing spatial elements, but not all relationships captured * DFS for spatials, itterator for geometry * Second pass, manual traversal * Ok, this is working nicely now * Cleanup * Convert render materials * property set extraction (#2) * various changes (#4) * Fix for non-app.speckle.systems servers (#5) * don't use https for http server urls (#6) * fix(conversion): Filter only IfcRoot classes (#7) * Filter only IfcRoot classes * vscode config * Feat(prop): Added better property extraction (#8) * Added better property extraction * property sets naming * feat: attach attributes that are on the element type level (#9) * Added better property extraction * property sets naming * Get attributes from element type * tidy up (#10) * Add null check (#11) * ruff (#12) * Rendermaterials inherit material names instead of type + unique id (#14) * lock * ruff check * pre-commit * add license files for the speckleifc subpackage --------- Co-authored-by: Sebastian Witt <sebastian.witt@rwth-aachen.de> Co-authored-by: Gergő Jedlicska <57442769+gjedlicska@users.noreply.github.com> Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
import multiprocessing
|
|
|
|
from ifcopenshell import file, ifcopenshell_wrapper, open, sqlite
|
|
from ifcopenshell.geom import iterator, settings
|
|
|
|
from specklepy.logging.exceptions import SpeckleException
|
|
|
|
|
|
def _create_iterator_settings() -> settings:
|
|
ifc_settings = settings()
|
|
# triangles for now, speckle does support n-gons, but may be less performant
|
|
ifc_settings.set("triangulation-type", ifcopenshell_wrapper.TRIANGLE_MESH)
|
|
# no need to weld verts
|
|
ifc_settings.set("weld-vertices", False)
|
|
# Speckle meshes are all in world coords
|
|
ifc_settings.set("use-world-coords", True)
|
|
# Tiny performance improvement,
|
|
ifc_settings.set("no-wire-intersection-check", True)
|
|
# Rendermaterials inherit the material names instead of type + unique id
|
|
ifc_settings.set("use-material-names", True)
|
|
|
|
# IfcOpenshell defaults to 0.001mm here, which leads to very dense meshes.
|
|
# lowering the mesh quality a bit here leads to meshes
|
|
# that are still much higher quality than webifc
|
|
|
|
# We still need to experiment with the affect on memory usage
|
|
# It may be desirable to lower this further, and increase the angular deflection
|
|
# to compensate. This would allow large meshes to be lower quality,
|
|
# while keeping small meshes relatively similar.
|
|
ifc_settings.set("mesher-linear-deflection", 0.2)
|
|
|
|
return ifc_settings
|
|
|
|
|
|
def open_ifc(file_path: str) -> file:
|
|
ifc_file = open(file_path)
|
|
|
|
if isinstance(ifc_file, file):
|
|
return ifc_file
|
|
else:
|
|
raise SpeckleException(f"file at {file_path} is not a compatible ifc file type")
|
|
|
|
|
|
def create_geometry_iterator(ifc_file: file | sqlite) -> iterator:
|
|
return iterator(_create_iterator_settings(), ifc_file, multiprocessing.cpu_count())
|