mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
Fix style lookup in accordance with v0.7 #4844
This commit is contained in:
@@ -334,13 +334,22 @@ namespace {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::pair<IfcSchema::IfcSurfaceStyle*, T*> get_surface_style(const IfcSchema::IfcStyledItem* si) {
|
std::pair<IfcSchema::IfcSurfaceStyle*, T*> get_surface_style(const IfcSchema::IfcStyledItem* si) {
|
||||||
|
std::vector<IfcSchema::IfcPresentationStyle*> prs_styles;
|
||||||
|
|
||||||
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
|
#ifdef SCHEMA_HAS_IfcStyleAssignmentSelect
|
||||||
auto style_assignments = si->Styles();
|
auto style_assignments = si->Styles();
|
||||||
for (auto kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
for (auto kt = style_assignments->begin(); kt != style_assignments->end(); ++kt) {
|
||||||
if (!(*kt)->declaration().is(IfcSchema::IfcPresentationStyleAssignment::Class())) {
|
// Using IfcPresentationStyleAssignment is deprecated, use the direct assignment of a subtype of IfcPresentationStyle instead.
|
||||||
|
auto style_k = (*kt)->as<IfcSchema::IfcPresentationStyle>();
|
||||||
|
if (style_k) {
|
||||||
|
prs_styles.push_back(style_k);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto style_assignment = (*kt)->as<IfcSchema::IfcPresentationStyleAssignment>();
|
||||||
|
if (!style_assignment) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
IfcSchema::IfcPresentationStyleAssignment* style_assignment = (IfcSchema::IfcPresentationStyleAssignment*) *kt;
|
|
||||||
|
|
||||||
// Only in case of 2x3 or old style IfcPresentationStyleAssignment
|
// Only in case of 2x3 or old style IfcPresentationStyleAssignment
|
||||||
auto styles = style_assignment->Styles();
|
auto styles = style_assignment->Styles();
|
||||||
@@ -355,24 +364,30 @@ namespace {
|
|||||||
auto styles = si->Styles();
|
auto styles = si->Styles();
|
||||||
#endif
|
#endif
|
||||||
for (auto lt = styles->begin(); lt != styles->end(); ++lt) {
|
for (auto lt = styles->begin(); lt != styles->end(); ++lt) {
|
||||||
auto style = *lt;
|
auto style_l = (*lt)->as<IfcSchema::IfcPresentationStyle>();
|
||||||
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
|
if (style_l) {
|
||||||
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*) style;
|
prs_styles.push_back(style_l);
|
||||||
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) {
|
|
||||||
if ((*mt)->declaration().is(T::Class())) {
|
|
||||||
return std::make_pair(surface_style, (T*)*mt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined(SCHEMA_HAS_IfcStyleAssignmentSelect) || defined(SCHEMA_HAS_IfcPresentationStyleAssignment)
|
#if defined(SCHEMA_HAS_IfcStyleAssignmentSelect) || defined(SCHEMA_HAS_IfcPresentationStyleAssignment)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::make_pair<IfcSchema::IfcSurfaceStyle*, T*>(0, 0);
|
for (auto& style : prs_styles) {
|
||||||
|
if (style->declaration().is(IfcSchema::IfcSurfaceStyle::Class())) {
|
||||||
|
IfcSchema::IfcSurfaceStyle* surface_style = (IfcSchema::IfcSurfaceStyle*)style;
|
||||||
|
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) {
|
||||||
|
if ((*mt)->template as<T>()) {
|
||||||
|
return std::make_pair(surface_style, (*mt)->as<T>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_pair<IfcSchema::IfcSurfaceStyle*, T*>(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const IfcSchema::IfcStyledItem* find_style(const IfcSchema::IfcRepresentationItem* representation_item) {
|
const IfcSchema::IfcStyledItem* find_style(const IfcSchema::IfcRepresentationItem* representation_item) {
|
||||||
|
|||||||
Reference in New Issue
Block a user