| 16 | } |
| 17 | |
| 18 | bool ifcopenshell::geometry::kernels::AbstractKernel::convert(const taxonomy::ptr item, IfcGeom::ConversionResults& results) { |
| 19 | if (settings_.get<settings::CacheShapes>().get()) { |
| 20 | auto it = cache_.find(item); |
| 21 | if (it != cache_.end()) { |
| 22 | results = it->second; |
| 23 | Logger::Notice("Cache hit #" + std::to_string(item->instance->as<IfcUtil::IfcBaseEntity>()->id()) + |
| 24 | " -> #" + std::to_string(it->first->instance->as<IfcUtil::IfcBaseEntity>()->id())); |
| 25 | return true; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | auto with_exception_handling = [&](auto fn) { |
| 30 | try { |
| 31 | return fn(); |
| 32 | } catch (std::exception& e) { |
| 33 | Logger::Error(e, item->instance); |
| 34 | return false; |
| 35 | } catch (...) { |
| 36 | // @todo we can't log OCCT exceptions here, can we do some reraising to solve this? |
| 37 | return false; |
| 38 | } |
| 39 | }; |
| 40 | auto without_exception_handling = [](auto fn) { |
| 41 | return fn(); |
| 42 | }; |
| 43 | auto process_with_upgrade = [&]() { |
| 44 | try { |
| 45 | return dispatch_conversion<0>::dispatch(this, item->kind(), item, results); |
| 46 | } catch (const not_implemented_error&) { |
| 47 | return dispatch_with_upgrade<0>::dispatch(this, item, results); |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | bool res; |
| 52 | if (propagate_exceptions) { |
| 53 | res = without_exception_handling(process_with_upgrade); |
| 54 | } else { |
| 55 | res = with_exception_handling(process_with_upgrade); |
| 56 | } |
| 57 | |
| 58 | if (settings_.get<settings::CacheShapes>().get() && res) { |
| 59 | cache_.insert({ item, results }); |
| 60 | } |
| 61 | |
| 62 | return res; |
| 63 | } |
| 64 | |
| 65 | const Settings& ifcopenshell::geometry::kernels::AbstractKernel::settings() const |
| 66 | { |