mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
Maintain identity and cache styles based on surface-style-shading not styled-item #5486
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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_) {
|
||||
|
||||
@@ -171,6 +171,7 @@ BIND(IfcVector);
|
||||
// BIND(IfcColourRgb);
|
||||
BIND(IfcMaterial); // -> style
|
||||
BIND(IfcStyledItem); // -> style
|
||||
BIND(IfcSurfaceStyle); // -> style
|
||||
|
||||
#ifdef SCHEMA_HAS_IfcCurveSegment
|
||||
BIND(IfcCurveSegment);
|
||||
|
||||
Reference in New Issue
Block a user