mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +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)
|
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_definitions(-D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR)
|
||||||
|
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
cmake_policy(SET CMP0074 NEW)
|
cmake_policy(SET CMP0074 NEW)
|
||||||
cmake_policy(SET CMP0078 NEW)
|
cmake_policy(SET CMP0078 NEW)
|
||||||
|
|||||||
@@ -430,10 +430,8 @@ namespace {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
IfcSchema::IfcSurfaceStyle *surface_style = nullptr;
|
|
||||||
for (auto& style : prs_styles) {
|
for (auto& style : prs_styles) {
|
||||||
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
|
if (auto surface_style = style->as<IfcSchema::IfcSurfaceStyle>()) {
|
||||||
surface_style = (IfcSchema::IfcSurfaceStyle*)style;
|
|
||||||
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
if (surface_style->Side() != IfcSchema::IfcSurfaceSide::IfcSurfaceSide_NEGATIVE) {
|
||||||
auto styles_elements = surface_style->Styles();
|
auto styles_elements = surface_style->Styles();
|
||||||
for (auto mt = styles_elements->begin(); mt != styles_elements->end(); ++mt) {
|
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) {
|
bool process_colour(IfcSchema::IfcColourRgb* colour, double* rgb) {
|
||||||
@@ -546,6 +544,21 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
|||||||
return nullptr;
|
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>();
|
taxonomy::style::ptr surface_style = taxonomy::make<taxonomy::style>();
|
||||||
surface_style->instance = style;
|
surface_style->instance = style;
|
||||||
if (settings_.get<settings::UseMaterialNames>().get() && style->Name()) {
|
if (settings_.get<settings::UseMaterialNames>().get() && style->Name()) {
|
||||||
@@ -611,7 +624,6 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcStyledItem* inst) {
|
|||||||
return surface_style;
|
return surface_style;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
taxonomy::ptr mapping::map(const IfcBaseInterface* inst) {
|
||||||
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
|
auto iden = inst->as<IfcUtil::IfcBaseClass>()->identity();
|
||||||
if (use_caching_) {
|
if (use_caching_) {
|
||||||
|
|||||||
@@ -171,6 +171,7 @@ BIND(IfcVector);
|
|||||||
// BIND(IfcColourRgb);
|
// BIND(IfcColourRgb);
|
||||||
BIND(IfcMaterial); // -> style
|
BIND(IfcMaterial); // -> style
|
||||||
BIND(IfcStyledItem); // -> style
|
BIND(IfcStyledItem); // -> style
|
||||||
|
BIND(IfcSurfaceStyle); // -> style
|
||||||
|
|
||||||
#ifdef SCHEMA_HAS_IfcCurveSegment
|
#ifdef SCHEMA_HAS_IfcCurveSegment
|
||||||
BIND(IfcCurveSegment);
|
BIND(IfcCurveSegment);
|
||||||
|
|||||||
Reference in New Issue
Block a user