From 6e8d63504028852eeb6f48a727c85e62fef7ff30 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Tue, 24 Oct 2023 18:28:23 -0700 Subject: [PATCH] Adds test of fallback placement for IfcLinearPlacement and reduces number of tests for placement type. Changed to if-else if so inst isn't tested to be every placement type, every time. --- src/ifcgeom/mapping/IfcObjectPlacement.cpp | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/ifcgeom/mapping/IfcObjectPlacement.cpp b/src/ifcgeom/mapping/IfcObjectPlacement.cpp index 34ef7bee61..5c9539bfda 100644 --- a/src/ifcgeom/mapping/IfcObjectPlacement.cpp +++ b/src/ifcgeom/mapping/IfcObjectPlacement.cpp @@ -25,15 +25,23 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) { const IfcSchema::IfcObjectPlacement* relative_to = nullptr; const IfcUtil::IfcBaseInterface* transform; -#ifdef SCHEMA_HAS_IfcLinearPlacement - if (inst->as()) { - transform = inst->as()->RelativePlacement(); - } -#endif + const IfcSchema::IfcAxis2Placement3D* fallback = nullptr; + if (inst->as()) { transform = inst->as()->RelativePlacement(); } - if (inst->as()) { +#ifdef SCHEMA_HAS_IfcLinearPlacement + else if (inst->as()) { +#ifdef SCHEMA_IfcLinearPlacement_HAS_RelativePlacement + transform = inst->as()->RelativePlacement(); + fallback = inst->as()->CartesianPosition(); +#else + // @todo Ifc4x1 and Ifc4x2 don't have RelativePlacement + return nullptr; +#endif + } +#endif + else if (inst->as()) { // @todo a bit harder to map without kernel return nullptr; } @@ -57,17 +65,27 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcObjectPlacement* inst) { } } + taxonomy::ptr result; if (!parent_placement_ignored && relative_to) { // The parent placement of the current is a placement for a type that is // being ignored (Site or Building) or it is the host element of an opening. - return taxonomy::make( + result = taxonomy::make( taxonomy::cast(map(relative_to))->ccomponents() * taxonomy::cast(map(transform))->ccomponents() ); } else { - return map(transform); + result = map(transform); } + if (fallback) { + auto mapped_fallback = taxonomy::cast(map(fallback)); + if (mapped_fallback != result) { + Logger::Warning("Computed placement differs from fallback", inst); + } + } + + return result; + // @todo // m4->components() = offset_and_rotation_ * m4->components(); }