From c5e6c3e2c7cfb980f41737b53e5dd6b4438bc644 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Fri, 26 Nov 2021 14:15:51 +0100 Subject: [PATCH] #1897 handle nesting in get_decomposing_entity_impl() --- src/ifcgeom_schema_agnostic/Kernel.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/ifcgeom_schema_agnostic/Kernel.cpp b/src/ifcgeom_schema_agnostic/Kernel.cpp index 72a758649b..1de3d8e335 100644 --- a/src/ifcgeom_schema_agnostic/Kernel.cpp +++ b/src/ifcgeom_schema_agnostic/Kernel.cpp @@ -142,13 +142,13 @@ IfcSchema::IfcObjectDefinition* get_decomposing_entity_impl(IfcSchema::IfcProduc if (!parent) { \ aggregate_of_instance::ptr parents = product->data().getInverse((&IfcSchema::IfcRelAggregates::Class()), -1); \ parents->push(product->data().getInverse((&IfcSchema::IfcRelNests::Class()), -1)); \ - for (aggregate_of_instance::it it = parents->begin(); it != parents->end(); ++it) { \ - IfcSchema::IfcRelDecomposes* decompose = (IfcSchema::IfcRelDecomposes*)*it; \ + for (aggregate_of_instance::it it = parents->begin(); it != parents->end(); ++it) { \ + IfcSchema::IfcRelDecomposes* decompose = (*it)->as(); \ IfcUtil::IfcBaseEntity* ifc_objectdef; \ \ ifc_objectdef = get_RelatingObject(decompose); \ \ - if (product == ifc_objectdef) continue; \ + if (!ifc_objectdef || product == ifc_objectdef) continue; \ parent = ifc_objectdef->as(); \ } \ } \ @@ -170,6 +170,10 @@ namespace { if (aggr != nullptr) { return aggr->RelatingObject(); } + Ifc4::IfcRelNests* nest = decompose->as(); + if (nest != nullptr) { + return nest->RelatingObject(); + } return nullptr; } CREATE_GET_DECOMPOSING_ENTITY(Ifc4); @@ -181,6 +185,10 @@ namespace { if (aggr != nullptr) { return aggr->RelatingObject(); } + Ifc4x1::IfcRelNests* nest = decompose->as(); + if (nest != nullptr) { + return nest->RelatingObject(); + } return nullptr; } CREATE_GET_DECOMPOSING_ENTITY(Ifc4x1); @@ -192,6 +200,10 @@ namespace { if (aggr != nullptr) { return aggr->RelatingObject(); } + Ifc4x2::IfcRelNests* nest = decompose->as(); + if (nest != nullptr) { + return nest->RelatingObject(); + } return nullptr; } CREATE_GET_DECOMPOSING_ENTITY(Ifc4x2); @@ -203,6 +215,10 @@ namespace { if (aggr != nullptr) { return aggr->RelatingObject(); } + Ifc4x3_rc1::IfcRelNests* nest = decompose->as(); + if (nest != nullptr) { + return nest->RelatingObject(); + } return nullptr; } CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc1); @@ -214,6 +230,10 @@ namespace { if (aggr != nullptr) { return aggr->RelatingObject(); } + Ifc4x3_rc2::IfcRelNests* nest = decompose->as(); + if (nest != nullptr) { + return nest->RelatingObject(); + } return nullptr; } CREATE_GET_DECOMPOSING_ENTITY(Ifc4x3_rc2);