From d4f543d2ad0bc5402d1e1cc62b94be53fdee1708 Mon Sep 17 00:00:00 2001 From: Richard Brice <37087370+RickBrice@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:58:21 -0700 Subject: [PATCH] Implemented placement handling with transformation matrix. --- src/ifcgeom/mapping/IfcCurveSegment.cpp | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCurveSegment.cpp b/src/ifcgeom/mapping/IfcCurveSegment.cpp index 727032895d..7d81a29eed 100644 --- a/src/ifcgeom/mapping/IfcCurveSegment.cpp +++ b/src/ifcgeom/mapping/IfcCurveSegment.cpp @@ -416,17 +416,9 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveSegment* inst) { std::vector polygon; - auto placement = inst->Placement(); - auto location = placement->Location(); - auto Cx = location->as()->Coordinates()[0]; - auto Cy = location->as()->Coordinates()[1]; - auto ref_dir = placement->as()->RefDirection(); - auto dx = ref_dir->DirectionRatios()[0]; - auto dy = ref_dir->DirectionRatios()[1]; - auto angle = atan2(dy, dx); - - auto cos_angle = cos(angle); - auto sin_angle = sin(angle); + // @todo - for some reason this isn't working, the matrix gets all messed up + //const auto& transformation_matrix = taxonomy::cast(map(inst->Placement()))->ccomponents(); + auto transformation_matrix = taxonomy::cast(map(inst->Placement()))->ccomponents(); auto length = cse.length(); if (0.001 < fabs(length)) @@ -435,14 +427,8 @@ taxonomy::ptr mapping::map_impl(const IfcSchema::IfcCurveSegment* inst) { auto u = length * i / NUM_SEGMENTS; auto p = cse(u); - auto xl = p(0); - auto yl = p(1); - auto z = p(2); - - auto x = xl * cos_angle - yl * sin_angle + Cx; - auto y = xl * sin_angle + yl * cos_angle + Cy; - - polygon.push_back(taxonomy::make(x,y,z)); + auto result = transformation_matrix * Eigen::Vector4d(p(0),p(1),p(2), 1.); + polygon.push_back(taxonomy::make(result(0),result(1),result(2))); } }