From 2cb70a7dea6506bfacfb1e07191d8a392711da2e Mon Sep 17 00:00:00 2001
From: Dmitri Naumov <github@naumov.de>
Date: Sat, 16 Oct 2021 10:42:38 +0200
Subject: [PATCH] [GL] Simplify rotatePolygonPointsToXY ret. value.

The use of unique_ptr is not necessary since the vector
will be destroyed when going out of scope in the MarkNodesOutsideOfPolygon.
---
 GeoLib/AnalyticalGeometry.cpp                    | 16 ++++++++--------
 GeoLib/AnalyticalGeometry.h                      |  2 +-
 .../MeshEditing/MarkNodesOutsideOfPolygon.h      |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp
index aa862d189c9..713b9c14ac8 100644
--- a/GeoLib/AnalyticalGeometry.cpp
+++ b/GeoLib/AnalyticalGeometry.cpp
@@ -442,28 +442,28 @@ void computeAndInsertAllIntersectionPoints(GeoLib::PointVec& pnt_vec,
     }
 }
 
-std::tuple<std::unique_ptr<std::vector<GeoLib::Point*>>, Eigen::Vector3d>
+std::tuple<std::vector<GeoLib::Point*>, Eigen::Vector3d>
 rotatePolygonPointsToXY(GeoLib::Polygon const& polygon_in)
 {
     // 1 copy all points
-    auto polygon_points = std::make_unique<std::vector<GeoLib::Point*>>();
-    polygon_points->reserve(polygon_in.getNumberOfPoints());
+    std::vector<GeoLib::Point*> polygon_points;
+    polygon_points.reserve(polygon_in.getNumberOfPoints());
     for (std::size_t k(0); k < polygon_in.getNumberOfPoints(); k++)
     {
-        polygon_points->push_back(new GeoLib::Point(*(polygon_in.getPoint(k))));
+        polygon_points.push_back(new GeoLib::Point(*(polygon_in.getPoint(k))));
     }
 
     // 2 rotate points
-    auto [plane_normal, d_polygon] = GeoLib::getNewellPlane(*polygon_points);
+    auto [plane_normal, d_polygon] = GeoLib::getNewellPlane(polygon_points);
     Eigen::Matrix3d const rot_mat =
         GeoLib::computeRotationMatrixToXY(plane_normal);
-    GeoLib::rotatePoints(rot_mat, *polygon_points);
+    GeoLib::rotatePoints(rot_mat, polygon_points);
 
     // 3 set z coord to zero
-    std::for_each(polygon_points->begin(), polygon_points->end(),
+    std::for_each(polygon_points.begin(), polygon_points.end(),
                   [](GeoLib::Point* p) { (*p)[2] = 0.0; });
 
-    return {std::move(polygon_points), plane_normal};
+    return {polygon_points, plane_normal};
 }
 
 std::vector<MathLib::Point3d> lineSegmentIntersect2d(
diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h
index 998d277af8d..7820093df65 100644
--- a/GeoLib/AnalyticalGeometry.h
+++ b/GeoLib/AnalyticalGeometry.h
@@ -215,7 +215,7 @@ void computeAndInsertAllIntersectionPoints(PointVec& pnt_vec,
  * @return vector of rotated points and normal based on the original Newell
  * plane
  */
-std::tuple<std::unique_ptr<std::vector<GeoLib::Point*>>, Eigen::Vector3d>
+std::tuple<std::vector<GeoLib::Point*>, Eigen::Vector3d>
 rotatePolygonPointsToXY(GeoLib::Polygon const& polygon_in);
 
 /// Sorts the vector of segments such that the \f$i\f$-th segment is connected
diff --git a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h
index 24d00b01b7c..462f2403202 100644
--- a/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h
+++ b/MeshGeoToolsLib/MeshEditing/MarkNodesOutsideOfPolygon.h
@@ -45,7 +45,7 @@ std::vector<bool> markNodesOutSideOfPolygon(
     // *** mark rotated nodes inside rotated polygon
     {
         // create new polygon using the rotated points
-        GeoLib::Polyline rotated_polyline(*rotated_polygon_points);
+        GeoLib::Polyline rotated_polyline(rotated_polygon_points);
         for (std::size_t k(0); k < polygon.getNumberOfPoints(); k++)
         {
             rotated_polyline.addPoint(k);
@@ -67,7 +67,7 @@ std::vector<bool> markNodesOutSideOfPolygon(
         delete rotated_node;
     }
 
-    for (auto& rot_polygon_pnt : *rotated_polygon_points)
+    for (auto& rot_polygon_pnt : rotated_polygon_points)
     {
         delete rot_polygon_pnt;
     }
-- 
GitLab