mapping binding - never overwrite already set item->instance

1) this way code should be more straightforward
2) this allows us not to reimplement mapping.get_surface_style logic in IfcGeomWrapper as it will be already handled in map_impl(const IfcSchema::IfcStyledItem* inst) and the resulting item->instance is not overridden by IfcStyledItem.
This commit is contained in:
Andrej730
2024-06-21 14:44:25 +05:00
committed by Andrej
parent 301cdf6504
commit 68d3539a86
2 changed files with 1 additions and 20 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
try { \
item = map_impl(inst->as<IfcSchema::T>()); \
if (item != nullptr) { \
if (!(item->instance && inst->as<IfcSchema::IfcMaterial>())) { \
if (item->instance == nullptr) { \
item->instance = inst; \
} \
try { \
-19
View File
@@ -200,8 +200,6 @@ std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) {
%extend ifcopenshell::geometry::taxonomy::style {
size_t instance_id() const {
// @todo for some reason we have the IfcStyledItem/IfcMaterial here, but
// BlenderBIM expects IfcSurfaceStyle/IfcMaterial
if (self->instance == nullptr) {
return 0;
}
@@ -209,23 +207,6 @@ std::string taxonomy_item_repr(ifcopenshell::geometry::taxonomy::item::ptr i) {
if ((ent = self->instance->as<IfcUtil::IfcBaseEntity>()) == nullptr) {
return 0;
}
if (ent->declaration().name() == "IfcStyledItem") {
aggregate_of_instance::ptr styles = *ent->get("Styles");
if (styles->size() == 1) {
ent = (*styles->begin())->as<IfcUtil::IfcBaseEntity>();
// < IFC4X3.
if (ent->declaration().name() == "IfcPresentationStyleAssignment") {
aggregate_of_instance::ptr styles = *ent->get("Styles");
if (styles->size() == 1) {
ent = (*styles->begin())->as<IfcUtil::IfcBaseEntity>();
} else {
return 0;
}
}
} else {
return 0;
}
}
return ent->data().id();
}
}