From 8329a1dea1de9d539aed86f76c3b6ca1d9472071 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 10 Apr 2023 14:22:27 +0200 Subject: [PATCH] Use taxonomy::matrix4 instead of Eigen::Matrix4d in profile helper which has default constructor to identity --- src/ifcgeom/mapping/IfcCShapeProfileDef.cpp | 5 ++--- .../mapping/IfcCraneRailAShapeProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcEllipseProfileDef.cpp | 16 ++++++++-------- src/ifcgeom/mapping/IfcIShapeProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcLShapeProfileDef.cpp | 5 ++--- .../mapping/IfcRectangleHollowProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcRectangleProfileDef.cpp | 5 ++--- .../mapping/IfcRoundedRectangleProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcTShapeProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcUShapeProfileDef.cpp | 5 ++--- src/ifcgeom/mapping/IfcZShapeProfileDef.cpp | 5 ++--- src/ifcgeom/profile_helper.cpp | 6 +++--- src/ifcgeom/profile_helper.h | 2 +- 14 files changed, 34 insertions(+), 45 deletions(-) diff --git a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp index 074372d812..c09a8bfbf4 100644 --- a/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCShapeProfileDef.cpp @@ -47,14 +47,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCShapeProfileDef* inst) { return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp index 8ee3d446b4..dc544aa923 100644 --- a/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcCraneRailAShapeProfileDef.cpp @@ -37,14 +37,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcCraneRailAShapeProfileDef* double bd2 = inst->BaseDepth2() * length_unit_; double bd3 = inst->BaseDepth3() * length_unit_; - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp index b60894dcfd..5e853e5f7c 100644 --- a/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcEllipseProfileDef.cpp @@ -32,23 +32,23 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcEllipseProfileDef* inst) { const bool rotated = ry > rx; - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } if (ry > rx) { + // @todo is a copy necesary here or can this be done in place? auto m4_copy = m4; - m4 << - -m4_copy.col(1), - m4_copy.col(0), - m4_copy.col(2), - m4_copy.col(3); + m4.components() << + -m4_copy.components().col(1), + m4_copy.components().col(0), + m4_copy.components().col(2), + m4_copy.components().col(3); std::swap(rx, ry); } diff --git a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp index bce2ef5b51..40ebd4442b 100644 --- a/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcIShapeProfileDef.cpp @@ -85,14 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcIShapeProfileDef* inst) { return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp index 1ad4968552..6a74da17e1 100644 --- a/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcLShapeProfileDef.cpp @@ -85,14 +85,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcLShapeProfileDef* inst) { xy = (a1*c2 - a2*c1) / det; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp index 52e7123051..f20b05bb8b 100644 --- a/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleHollowProfileDef.cpp @@ -41,14 +41,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleHollowProfileDef* return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } auto s1 = profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp index e909984d47..e33c46e892 100644 --- a/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRectangleProfileDef.cpp @@ -34,14 +34,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRectangleProfileDef* inst) return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp index 87a509d199..2ff5832af3 100644 --- a/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcRoundedRectangleProfileDef.cpp @@ -35,14 +35,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcRoundedRectangleProfileDef return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp index fee75707f8..723f289555 100644 --- a/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTShapeProfileDef.cpp @@ -99,14 +99,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTShapeProfileDef* inst) { xy = y - d2; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp index ae84240754..09ed65c850 100644 --- a/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcTrapeziumProfileDef.cpp @@ -40,14 +40,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcTrapeziumProfileDef* inst) return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp index a63e726e06..1d7abbec52 100644 --- a/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcUShapeProfileDef.cpp @@ -58,14 +58,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcUShapeProfileDef* inst) { return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp index ebd96c8ada..da2a5840aa 100644 --- a/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp +++ b/src/ifcgeom/mapping/IfcZShapeProfileDef.cpp @@ -49,14 +49,13 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcZShapeProfileDef* inst) { return nullptr; } - Eigen::Matrix4d m4; + taxonomy::matrix4 m4; bool has_position = true; #ifdef SCHEMA_IfcParameterizedProfileDef_Position_IS_OPTIONAL has_position = !!inst->Position(); #endif if (has_position) { - taxonomy::matrix4 m = as(map(inst->Position())); - m4 = m.ccomponents(); + m4 = as(map(inst->Position())); } return profile_helper(m4, { diff --git a/src/ifcgeom/profile_helper.cpp b/src/ifcgeom/profile_helper.cpp index c107599c10..e5f960a3d3 100644 --- a/src/ifcgeom/profile_helper.cpp +++ b/src/ifcgeom/profile_helper.cpp @@ -70,7 +70,7 @@ taxonomy::loop* ifcopenshell::geometry::polygon_from_points(const std::vector& points) { +taxonomy::loop* ifcopenshell::geometry::profile_helper(const taxonomy::matrix4& m4, const std::vector& points) { /* TopoDS_Vertex* vertices = new TopoDS_Vertex[numVerts]; for (int i = 0; i < numVerts; i++) { @@ -99,7 +99,7 @@ taxonomy::loop* ifcopenshell::geometry::profile_helper(Eigen::Matrix4d& m4, cons } */ - const bool has_position = !m4.isIdentity(); + const bool has_position = !m4.is_identity(); // @todo precision @@ -108,7 +108,7 @@ taxonomy::loop* ifcopenshell::geometry::profile_helper(Eigen::Matrix4d& m4, cons std::transform(points.begin(), points.end(), std::back_inserter(ps), [&has_position, &m4](const profile_point& p) { if (has_position) { Eigen::Vector4d v(p.xy[0], p.xy[1], 0., 1.); - v = m4 * v; + v = m4.ccomponents() * v; return taxonomy::point3(v(0), v(1), 0.); } else { return taxonomy::point3(p.xy[0], p.xy[1], 0.); diff --git a/src/ifcgeom/profile_helper.h b/src/ifcgeom/profile_helper.h index 6cd1111b2d..d563e3387f 100644 --- a/src/ifcgeom/profile_helper.h +++ b/src/ifcgeom/profile_helper.h @@ -25,7 +25,7 @@ namespace ifcopenshell { taxonomy::loop* polygon_from_points(const std::vector& ps, bool external = true); - taxonomy::loop* profile_helper(Eigen::Matrix4d& m4, const std::vector& points); + taxonomy::loop* profile_helper(const taxonomy::matrix4& m4, const std::vector& points); taxonomy::loop* fillet_loop(taxonomy::loop* lp, double radius); }