Use taxonomy::matrix4 instead of Eigen::Matrix4d in profile helper which has default constructor to identity

This commit is contained in:
Thomas Krijnen
2023-04-10 14:22:27 +02:00
parent 11a515a025
commit 8329a1dea1
14 changed files with 34 additions and 45 deletions
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+8 -8
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(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);
}
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
auto s1 = profile_helper(m4, {
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+2 -3
View File
@@ -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<taxonomy::matrix4>(map(inst->Position()));
m4 = m.ccomponents();
m4 = as<taxonomy::matrix4>(map(inst->Position()));
}
return profile_helper(m4, {
+3 -3
View File
@@ -70,7 +70,7 @@ taxonomy::loop* ifcopenshell::geometry::polygon_from_points(const std::vector<ta
return loop;
}
taxonomy::loop* ifcopenshell::geometry::profile_helper(Eigen::Matrix4d& m4, const std::vector<profile_point>& points) {
taxonomy::loop* ifcopenshell::geometry::profile_helper(const taxonomy::matrix4& m4, const std::vector<profile_point>& 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.);
+1 -1
View File
@@ -25,7 +25,7 @@ namespace ifcopenshell {
taxonomy::loop* polygon_from_points(const std::vector<taxonomy::point3>& ps, bool external = true);
taxonomy::loop* profile_helper(Eigen::Matrix4d& m4, const std::vector<profile_point>& points);
taxonomy::loop* profile_helper(const taxonomy::matrix4& m4, const std::vector<profile_point>& points);
taxonomy::loop* fillet_loop(taxonomy::loop* lp, double radius);
}