MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / extract_geometry

Method extract_geometry

src/exterior-shell-extractor/main.py:440–619  ·  view source on GitHub ↗
(self, **kwargs)

Source from the content-addressed store, hash-verified

438 @utils.trace
439 # @profile
440 def extract_geometry(self, **kwargs):
441 # not only align facets part of the (potentially concave) input polyhedron, but also align facets resulting from the convex decomposition
442 ALIGN_INNER = True
443
444 s = ifcopenshell.geom.settings(
445 USE_WORLD_COORDS=False,
446 # ITERATOR_OUTPUT=ifcopenshell.ifcopenshell_wrapper.NATIVE,
447 ITERATOR_OUTPUT=ifcopenshell.ifcopenshell_wrapper.TRIANGULATED,
448 DISABLE_OPENING_SUBTRACTIONS=True,
449 )
450
451
452 its = []
453 fffs = []
454
455 data = model_geometry()
456
457
458 for f in self.fs:
459 if kwargs.keys() == {'include'}:
460 kwargs2 = {'include': [e for e in kwargs['include'] if e.wrapped_data.file == f]}
461 else:
462 kwargs2 = kwargs
463 it = ifcopenshell.geom.iterator(s, f, geometry_library="cgal", **kwargs2)
464
465 if not it.initialize():
466 # print(ifcopenshell.get_log())
467 # exit(1)
468 continue
469
470 # convex decomposition is expensive, geometries can be shared, apply product-level transformations after CD and cache results pre-transform
471 cd_cache = {}
472
473 while True:
474 elem = it.get()
475 elem_g_id = elem.geometry.id
476
477
478 if f[int(elem_g_id.split("-")[0])].RepresentationIdentifier != "Box":
479 print(f"[{utils.get_mem()} MB]", "reading", f[elem.id])
480
481 elem = it.get_native()
482 elem2 = None
483 for i in range(elem.geometry.size()):
484 elem_i = elem.geometry.item(i)
485 repitem = f[elem.geometry.item_id(i)]
486
487 if elem_i.num_vertices() < 6:
488 # try and detect single faces used sometime for glass panes which can't
489 # be represented as halfspace intersection and need to be 'solidified'
490 fs = elem_i.facets()
491 axes_ = [f.axis() for f in fs]
492 axes = list(map(utils.to_tuple, axes_))
493 if all(ax == axes[0] for ax in axes):
494 ff = ifcopenshell.file(schema=f.schema)
495 ff.add(*f.by_type("IfcProject"))
496 nelem = ff.add(f[elem.id])
497 body = [rep for rep in nelem.Representation.Representations if rep.RepresentationIdentifier == "Body"][0]

Callers 1

__init__Method · 0.95

Calls 15

definition_is_convexMethod · 0.95
model_geometryClass · 0.85
printFunction · 0.85
splitMethod · 0.80
itemMethod · 0.80
item_idMethod · 0.80
openMethod · 0.80
to_tupleMethod · 0.80
normMethod · 0.80
indexMethod · 0.80
rangeFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected