From 8e464ae1798f49a596fa8ba2ffa892528b6b6156 Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Tue, 22 Dec 2020 11:39:50 +0100
Subject: [PATCH] [MeL] Change signature of getRotationMatrixToGlobal.

---
 MeshLib/ElementCoordinatesMappingLocal.cpp | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp
index eb9fcb1e4af..a12248cc3dc 100644
--- a/MeshLib/ElementCoordinatesMappingLocal.cpp
+++ b/MeshLib/ElementCoordinatesMappingLocal.cpp
@@ -32,11 +32,12 @@ void rotateToLocal(const MeshLib::RotationMatrix& matR2local,
 /// get a rotation matrix to the global coordinates
 /// it computes R in x=R*x' where x is original coordinates and x' is local
 /// coordinates
-void getRotationMatrixToGlobal(const unsigned element_dimension,
-                               const unsigned global_dim,
-                               const std::vector<MathLib::Point3d>& points,
-                               MeshLib::RotationMatrix& matR)
+MeshLib::RotationMatrix getRotationMatrixToGlobal(
+    const unsigned element_dimension,
+    const unsigned global_dim,
+    const std::vector<MathLib::Point3d>& points)
 {
+    Eigen::Matrix3d matR;
     // compute R in x=R*x' where x are original coordinates and x' are local
     // coordinates
     if (element_dimension == 1)
@@ -64,6 +65,7 @@ void getRotationMatrixToGlobal(const unsigned element_dimension,
         // set a transposed matrix
         matR.transposeInPlace();
     }
+    return matR;
 }
 }  // namespace detail
 
@@ -71,7 +73,7 @@ namespace MeshLib
 {
 ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
     const Element& e, const unsigned global_dim)
-    : _global_dim(global_dim), _matR2global(3, 3)
+    : _global_dim(global_dim), _matR2global(Eigen::Matrix3d::Identity())
 {
     assert(e.getDimension() <= global_dim);
     _points.reserve(e.getNumberOfNodes());
@@ -82,14 +84,12 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal(
 
     auto const element_dim = e.getDimension();
 
-    if (global_dim == element_dim)
+    if (global_dim != element_dim)
     {
-        _matR2global.setIdentity();
-        return;
+        _matR2global =
+            detail::getRotationMatrixToGlobal(element_dim, global_dim, _points);
+        detail::rotateToLocal(_matR2global.transpose(), _points);
     }
-
-    detail::getRotationMatrixToGlobal(element_dim, global_dim, _points, _matR2global);
-    detail::rotateToLocal(_matR2global.transpose(), _points);
 }
 
 }  // namespace MeshLib
-- 
GitLab