myenvis / EnVis

1 stars 0 forks source link

FreeCAD: avoid recomputation of each individual shapes #33

Open vocx-fc opened 4 years ago

vocx-fc commented 4 years ago

In FreeCAD's importIFC.py the DEBUG parameter controls whether the topological Shape is recomputed every time during IFC import.

# if preferences['DEBUG'] is on, recompute after each shape
if preferences['DEBUG']: FreeCAD.ActiveDocument.recompute()

We could define a second variable that is different from DEBUG to control this recalculation only. We could also add the corresponding option to the preferences page of the importer.

if preferences['RECOMPUTE']: FreeCAD.ActiveDocument.recompute()

Ideally recomputing at the end of the import, or not recomputing at all should speed up the import. However, recomputing sometimes cannot be avoided. Every object that uses the Shape of another object must be recomputed before using that Shape, otherwise an error will be produced. We must check if it's possible to avoid this recomputation depending on the types of objects that are imported (could we selectively recompute some, and not others? Add a whitelist to the preferences?).

This is related to #7 and #12.

haraldg commented 4 years ago

Thanks for the interesting info. I tried the "skip recomputes" option recently (import time went down from 38s to 23s) and it actually broke the importer in subtle and not so subtle ways. I didn't investigate further. Also the final recompute after importing took several seconds, so the speedup wasn't all that relevant anyway.

Can you maybe do some rough timings, how much the DEBUG related recomputing contributes to overall import time? If I understand the structure of the importer correctly, then it first just adds the objects and only adds relationships between the objects in a final step. So maybe doing incremental recomputes doesn't cause lots of unnecessary recomputes anyway?