From cf1552e79e4f80eb431e1e2eae179c1ef30496e5 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:16:10 -0700 Subject: [PATCH] Simplifies IfxAxis2PlacementLinear, assumes default Axis = (0,0,1) --- .../mapping/IfcAxis2PlacementLinear.cpp | 45 +++---------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp index b11b61b46b..f86f59ac98 100644 --- a/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp +++ b/src/ifcgeom/mapping/IfcAxis2PlacementLinear.cpp @@ -29,10 +29,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst) Logger::Error(std::runtime_error("Location must be IfcPointByDistanceExpression for IfcAxis2PlacementLinear")); } - Eigen::Vector3d o, axis(0, 0, 1), refDirection; - taxonomy::matrix4::ptr m = taxonomy::cast(map(inst->Location())); - o = m->components().col(3).head<3>(); + Eigen::Vector3d o = m->components().col(3).head<3>(); // From 8.9.3.4 IfcAxis2PlacementLinear there are 4 cases that need to be considered // 1) Axis is given but not RefDirection @@ -40,43 +38,12 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcAxis2PlacementLinear* inst) // 3) Neither Axis or RefDirection are provided // 4) Both Axis and RefDirection are provided - const bool hasAxis = inst->Axis() != nullptr; - const bool hasRef = inst->RefDirection() != nullptr; + Eigen::Vector3d z = inst->Axis() ? *taxonomy::cast(map(inst->Axis()))->components_ : Eigen::Vector3d(0,0,1); // Axis is (0,0,1) when omitted + Eigen::Vector3d rd = inst->RefDirection() ? *taxonomy::cast(map(inst->RefDirection()))->components_ : m->components().col(0).head<3>(); // RefDirection is the curve tangent when omitted + Eigen::Vector3d y = z.cross(rd); + Eigen::Vector3d x = y.cross(z); - /* - if (hasAxis != hasRef) { - Logger::Warning("Axis and RefDirection should be specified together", inst); - } - */ - - if (hasAxis && !hasRef) { - taxonomy::direction3::ptr a = taxonomy::cast(map(inst->Axis())); - axis = *a->components_; - - refDirection = m->components().col(0).head<3>(); // RefDirection is the curve tangent when omitted - // refDirection is not necessarily orthogonal to axis. - // axis.cross(refDirection) gives y. y.cross(axis) gives x=refDirection - refDirection = axis.cross(refDirection).cross(axis); - } else if (!hasAxis && hasRef) { - taxonomy::direction3::ptr r = taxonomy::cast(map(inst->RefDirection())); - refDirection = *r->components_; - Eigen::Vector3d up(0, 0, 1); - axis = refDirection.cross(up.cross(refDirection)); - } else if (!hasAxis && !hasRef) { - refDirection = m->components().col(0).head<3>(); // RefDirection is the curve tangent when omitted - Eigen::Vector3d up(0, 0, 1); - axis = refDirection.cross(up.cross(refDirection)); - } else { - taxonomy::direction3::ptr a = taxonomy::cast(map(inst->Axis())); - axis = *a->components_; - - taxonomy::direction3::ptr r = taxonomy::cast(map(inst->RefDirection())); - refDirection = *r->components_; - refDirection = axis.cross(refDirection).cross(axis); // refDirection needs to be orthogonal to axis - } - - // axis and refDirection need to be orthogonal - return taxonomy::make(o, axis, refDirection); + return taxonomy::make(o, z, x); } #endif