compas-dev / compas_ifc

COMPAS package for working with IFC files
http://compas.dev/compas_ifc/
MIT License
11 stars 2 forks source link

Support for multiprocessing #6

Closed romanarust closed 2 months ago

romanarust commented 1 year ago

Feature Request

Loading geometry of large IFC models takes a lot of time. There is a magic function in ifcopenshell : ifcopenshell.geom.iterator that takes care of the brep creation and serialisation and is super fast.

see on this page or below a code example : https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples

  import multiprocessing
  import ifcopenshell
  from compas_occ.brep import BRep
  from compas_ifc.model import Model

  model = Model(input_ifc_model)
  settings = ifcopenshell.geom.settings()
  settings.set(settings.USE_PYTHON_OPENCASCADE, True)

  def yield_from_iterator(it):
      while True:
          yield it.get()
          if not it.next():
              break

  it = ifcopenshell.geom.iterator(settings, model.reader._file, multiprocessing.cpu_count())
  it.initialize()
  for serialized_element in yield_from_iterator(it):
      data = serialized_element.data
      geometry = BRep.from_shape(serialized_element.geometry)
Licini commented 2 months ago

Done ; )