diff --git a/src/ifcgeom/Iterator.h b/src/ifcgeom/Iterator.h index c2d1c61eb5..722a39db24 100644 --- a/src/ifcgeom/Iterator.h +++ b/src/ifcgeom/Iterator.h @@ -171,6 +171,10 @@ namespace IfcGeom { converter_ = new ifcopenshell::geometry::Converter(geometry_library_, ifc_file, settings_); std::vector reps; + if (num_threads_ != 1) { + // @todo this shouldn't be necessary with properly immutable taxonomy items + converter_->mapping()->use_caching() = false; + } converter_->mapping()->get_representations(reps, filters_); for (auto& task : reps) { diff --git a/src/ifcgeom/abstract_mapping.h b/src/ifcgeom/abstract_mapping.h index 9601e54685..aeda275dd3 100644 --- a/src/ifcgeom/abstract_mapping.h +++ b/src/ifcgeom/abstract_mapping.h @@ -28,6 +28,8 @@ namespace geometry { class abstract_mapping { protected: Settings settings_; + + bool use_caching_ = true; public: abstract_mapping(Settings& s) : settings_(s) {} @@ -45,6 +47,9 @@ namespace geometry { const Settings& settings() const { return settings_; } Settings& settings() { return settings_; } + + bool use_caching() const { return use_caching_; } + bool& use_caching() { return use_caching_; } }; namespace impl { diff --git a/src/ifcgeom/mapping/mapping.cpp b/src/ifcgeom/mapping/mapping.cpp index 95d2a880b0..0cbc9909e1 100644 --- a/src/ifcgeom/mapping/mapping.cpp +++ b/src/ifcgeom/mapping/mapping.cpp @@ -520,9 +520,11 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) { taxonomy::ptr mapping::map(const IfcBaseInterface* inst) { auto iden = inst->as()->identity(); - auto it = cache_.find(iden); - if (it != cache_.end()) { - return it->second; + if (use_caching_) { + auto it = cache_.find(iden); + if (it != cache_.end()) { + return it->second; + } } taxonomy::ptr item = nullptr; @@ -532,7 +534,7 @@ taxonomy::ptr mapping::map(const IfcBaseInterface* inst) { #include "bind_convert_impl.i" - if (item) { + if (use_caching_ && item) { cache_.insert({ iden, item }); } else {