Skip to content
Snippets Groups Projects
Commit 2cb70a7d authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[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.
parent b76a5e54
No related branches found
No related tags found
No related merge requests found
......@@ -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(
......
......@@ -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
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment