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

Method convert

src/ifcgeom/AbstractKernel.cpp:18–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18bool 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
65const Settings& ifcopenshell::geometry::kernels::AbstractKernel::settings() const
66{

Callers

nothing calls this directly

Calls 10

NoticeFunction · 0.85
to_stringFunction · 0.85
fnFunction · 0.85
ErrorFunction · 0.50
getMethod · 0.45
findMethod · 0.45
endMethod · 0.45
idMethod · 0.45
kindMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected