Maintain identity and cache styles based on surface-style-shading not styled-item #5486

This commit is contained in:
Thomas Krijnen
2024-10-10 16:48:30 +02:00
parent dc1842dbe8
commit 189bcd5ad6
3 changed files with 20 additions and 5 deletions
+2
View File
@@ -27,6 +27,8 @@ if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif()
add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0078 NEW)
+17 -5
View File
@@ -430,10 +430,8 @@ namespace {
}
#endif
IfcSchema::IfcSurfaceStyle *surface_style = nullptr;
for (auto& style : prs_styles) {
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
surface_style = (IfcSchema::IfcSurfaceStyle*)style;
if (auto surface_style = style->as<IfcSchema::IfcSurfaceStyle>()) {
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
auto styles_elements = surface_style->Styles();
for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
@@ -444,7 +442,7 @@ namespace {
}
}
}
return std::make_pair(surface_style, nullptr);
return std::make_pair(nullptr, nullptr);
}
bool process_colour(IfcSchema::IfcColourRgb* colour, double* rgb) {
@@ -546,6 +544,21 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
return nullptr;
}
// map and not map_impl otherwise no caching
return map(style);
}
taxonomy::ptr mapping::map_impl(const IfcSchema::IfcSurfaceStyle* style) {
auto styles = style->Styles();
IfcSchema::IfcSurfaceStyleShading* shading = nullptr;
for (auto& s : *styles) {
if (shading = s->as<IfcSchema::IfcSurfaceStyleShading>()) {
break;
}
}
if (shading == nullptr) {
return nullptr;
}
taxonomy::style::ptr surface_style = taxonomy::make<taxonomy::style>();
surface_style->instance = style;
if (settings_.get<settings::UseMaterialNames>().get() && style->Name()) {
@@ -611,7 +624,6 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
return surface_style;
}
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
if (use_caching_) {
+1
View File
@@ -171,6 +171,7 @@ BIND(IfcVector);
// BIND(IfcColourRgb);
BIND(IfcMaterial); // -> style
BIND(IfcStyledItem); // -> style
BIND(IfcSurfaceStyle); // -> style
#ifdef SCHEMA_HAS_IfcCurveSegment
BIND(IfcCurveSegment);