Skip to content

Commit 2dc2997

Browse files
committed
--cache and subtraction in draw.py
1 parent 10b5025 commit 2dc2997

File tree

1 file changed

+20
-8
lines changed
  • src/ifcopenshell-python/ifcopenshell

1 file changed

+20
-8
lines changed

src/ifcopenshell-python/ifcopenshell/draw.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131

3232
W = ifcopenshell.ifcopenshell_wrapper
3333

34-
SETTINGS = ifcopenshell.geom.settings(
35-
# this is required for serialization
36-
APPLY_DEFAULT_MATERIALS=True,
37-
DISABLE_TRIANGULATION=True,
38-
)
39-
4034
WHITE = numpy.array((1.0, 1.0, 1.0))
4135

4236
DO_NOTHING = lambda *args: None
@@ -53,6 +47,8 @@ class draw_settings:
5347
space_names: bool = False
5448
space_areas: bool = False
5549
door_arcs: bool = False
50+
subtract_before_hlr: bool = False
51+
cache: bool = False
5652
css: bool = True
5753
storey_heights: str = "none"
5854
include_entities: str = ""
@@ -61,6 +57,15 @@ class draw_settings:
6157

6258

6359
def main(settings, files, iterators=None, merge_projection=True, progress_function=DO_NOTHING):
60+
61+
geom_settings = ifcopenshell.geom.settings(
62+
# this is required for serialization
63+
APPLY_DEFAULT_MATERIALS = True,
64+
DISABLE_TRIANGULATION = True,
65+
# when not doing booleans, proper solids from shells isn't a requirement
66+
SEW_SHELLS = settings.subtract_before_hlr
67+
)
68+
6469
if not iterators:
6570
iterator_kwargs = {}
6671
if settings.include_entities:
@@ -72,10 +77,15 @@ def main(settings, files, iterators=None, merge_projection=True, progress_functi
7277
# the styles are cleared up.
7378
iterators = list(
7479
map(
75-
functools.partial(ifcopenshell.geom.iterator, SETTINGS, **iterator_kwargs),
80+
functools.partial(ifcopenshell.geom.iterator, geom_settings, **iterator_kwargs),
7681
files,
7782
)
7883
)
84+
85+
if settings.cache:
86+
cache = ifcopenshell.geom.serializers.hdf5("cache.h5", geom_settings)
87+
for it in iterators:
88+
it.set_cache(cache)
7989

8090
def yield_from_iterator(it):
8191
if it.initialize():
@@ -86,7 +96,7 @@ def yield_from_iterator(it):
8696

8797
# Initialize serializer
8898
buffer = ifcopenshell.geom.serializers.buffer()
89-
sr = ifcopenshell.geom.serializers.svg(buffer, SETTINGS)
99+
sr = ifcopenshell.geom.serializers.svg(buffer, geom_settings)
90100

91101
sr.setFile(files[0])
92102
if settings.auto_floorplan:
@@ -113,6 +123,8 @@ def yield_from_iterator(it):
113123
sr.setPrintSpaceAreas(settings.space_areas)
114124
sr.setDrawDoorArcs(settings.door_arcs)
115125
sr.setNoCSS(not settings.css)
126+
if settings.subtract_before_hlr:
127+
sr.setSubtractionSettings(W.ALWAYS)
116128

117129
try:
118130
sh = ['none', 'full', 'left'].index(settings.storey_heights)

0 commit comments

Comments
 (0)