diff --git a/Applications/Utils/MeshGeoTools/VerticalSliceFromLayers.cpp b/Applications/Utils/MeshGeoTools/VerticalSliceFromLayers.cpp index e7cf307cfe7afc2b8d792af6cc1eeb24e239788c..e6a2d691783c5a6135939a741b8e3cbc96166a74 100644 --- a/Applications/Utils/MeshGeoTools/VerticalSliceFromLayers.cpp +++ b/Applications/Utils/MeshGeoTools/VerticalSliceFromLayers.cpp @@ -196,11 +196,8 @@ void rotateGeometryToXY(std::vector<GeoLib::Point*>& points, // compute the plane normal auto const [plane_normal, d] = GeoLib::getNewellPlane(points.begin(), points.end()); - // ToDo (TF) remove when computeRotationMatrixToXY uses Eigen - MathLib::Vector3 const tmp_plane_normal( - {plane_normal[0], plane_normal[1], plane_normal[2]}); // rotate points into x-y-plane - GeoLib::computeRotationMatrixToXY(tmp_plane_normal, rotation_matrix); + GeoLib::computeRotationMatrixToXY(plane_normal, rotation_matrix); GeoLib::rotatePoints(rotation_matrix, points.begin(), points.end()); GeoLib::AABB aabb(points.begin(), points.end()); diff --git a/GeoLib/AnalyticalGeometry-impl.h b/GeoLib/AnalyticalGeometry-impl.h index 9944d7e00352076c0e5381b49a3bf4c147e749df..267ad1784f98a91367095e1e0a0a62fdf1356fa5 100644 --- a/GeoLib/AnalyticalGeometry-impl.h +++ b/GeoLib/AnalyticalGeometry-impl.h @@ -118,8 +118,7 @@ void compute3DRotationMatrixToX(MathLib::Vector3 const& v, } template <class T_MATRIX> -void computeRotationMatrixToXY(MathLib::Vector3 const& n, - T_MATRIX & rot_mat) +void computeRotationMatrixToXY(Eigen::Vector3d const& n, T_MATRIX& rot_mat) { // check if normal points already in the right direction if (n[0] == 0 && n[1] == 0) { @@ -178,7 +177,7 @@ void computeRotationMatrixToXY(MathLib::Vector3 const& n, return; } - double h1(1 / n.getLength()); + double const h1(1 / n.norm()); // general case: calculate entries of rotation matrix rot_mat(0, 0) = n[2] / h0; @@ -219,13 +218,10 @@ MathLib::DenseMatrix<double> rotatePointsToXY(InputIterator1 p_pnts_begin, // compute the plane normal auto const [plane_normal, d] = GeoLib::getNewellPlane(p_pnts_begin, p_pnts_end); - // ToDo (TF) remove when computeRotationMatrixToXY uses Eigen - MathLib::Vector3 const tmp_plane_normal( - {plane_normal[0], plane_normal[1], plane_normal[2]}); // rotate points into x-y-plane MathLib::DenseMatrix<double> rot_mat(3, 3); - computeRotationMatrixToXY(tmp_plane_normal, rot_mat); + computeRotationMatrixToXY(plane_normal, rot_mat); rotatePoints(rot_mat, r_pnts_begin, r_pnts_end); for (auto it = r_pnts_begin; it != r_pnts_end; ++it) diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index b1a9d2ea72730e337575e596e5072f643f19ab23..9415245efb6652836a4aad4ff91b85f1ab16da5a 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -103,7 +103,7 @@ void compute3DRotationMatrixToX(MathLib::Vector3 const& v, T_MATRIX & rot_mat); * @param rot_mat 3x3 rotation matrix */ template <class T_MATRIX> -void computeRotationMatrixToXY(MathLib::Vector3 const& n, T_MATRIX& rot_mat); +void computeRotationMatrixToXY(Eigen::Vector3d const& n, T_MATRIX& rot_mat); /** * rotate points according to the rotation matrix diff --git a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h index 2a2cada7114d7bc7dcc397bf03c771a2a6f2484b..4b7612b37b84f681fc7ea1cd6fc4eb995525d0b3 100644 --- a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h +++ b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h @@ -27,8 +27,11 @@ std::vector<bool> markNodesOutSideOfPolygon( std::vector<MeshLib::Node*> const& nodes, GeoLib::Polygon const& polygon) { // *** rotate polygon to xy_plane - MathLib::Vector3 normal; - GeoLib::Polygon rot_polygon(GeoLib::rotatePolygonToXY(polygon, normal)); + MathLib::Vector3 tmp_normal; + GeoLib::Polygon rot_polygon(GeoLib::rotatePolygonToXY(polygon, tmp_normal)); + // ToDo (TF) remove when computeRotationMatrixToXY accepts Eigen normal + auto const normal = Eigen::Map<Eigen::Vector3d>( + const_cast<double*>(tmp_normal.getCoords())); // *** rotate mesh nodes to xy-plane // 1 copy all mesh nodes to GeoLib::Points diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp index 9b1b9151e246d0b3a1a7d060c778fa36aad411fa..9f683adcaf1159a04278a34bbe35533aa14bfc96 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.cpp +++ b/MeshLib/ElementCoordinatesMappingLocal.cpp @@ -58,12 +58,8 @@ void getRotationMatrixToGlobal(const unsigned element_dimension, { // get plane normal auto const [plane_normal, d] = GeoLib::getNewellPlane(points); - // ToDo (TF) remove when computeRotationMatrixToXY uses Eigen - MathLib::Vector3 const tmp_plane_normal( - {plane_normal[0], plane_normal[1], plane_normal[2]}); - // compute a rotation matrix to XY - GeoLib::computeRotationMatrixToXY(tmp_plane_normal, matR); + GeoLib::computeRotationMatrixToXY(plane_normal, matR); // set a transposed matrix matR.transposeInPlace(); } diff --git a/Tests/GeoLib/TestComputeRotationMatrix.cpp b/Tests/GeoLib/TestComputeRotationMatrix.cpp index 403db5e6cbf6a1a7a7691be189487f527e57d06a..b2fd851ecf18e7cfaad241d250c3dbe05ecd650b 100644 --- a/Tests/GeoLib/TestComputeRotationMatrix.cpp +++ b/Tests/GeoLib/TestComputeRotationMatrix.cpp @@ -24,7 +24,7 @@ auto test3equal = [](double a, double b, double c, double const* result) TEST(GeoLib, ComputeRotationMatrixToXYnegative) { - MathLib::Vector3 const n(0.0, -1.0, 0.0); + Eigen::Vector3d const n({0.0, -1.0, 0.0}); MathLib::DenseMatrix<double> rot_mat(3,3,0.0); GeoLib::computeRotationMatrixToXY(n, rot_mat); @@ -50,7 +50,7 @@ TEST(GeoLib, ComputeRotationMatrixToXYnegative) TEST(GeoLib, ComputeRotationMatrixToXYpositive) { - MathLib::Vector3 const n(0.0, 1.0, 0.0); + Eigen::Vector3d const n{0.0, 1.0, 0.0}; MathLib::DenseMatrix<double> rot_mat(3,3,0.0); GeoLib::computeRotationMatrixToXY(n, rot_mat);