From 7c683db06a1155626bbdf1f208518367b4fb4993 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <dmitri.naumov@ufz.de> Date: Tue, 19 Feb 2019 17:05:45 +0100 Subject: [PATCH] [GL] Use const& in getOrientation() for point args --- GeoLib/AnalyticalGeometry.cpp | 7 ++++--- GeoLib/AnalyticalGeometry.h | 6 +++--- GeoLib/Polygon.cpp | 27 +++++++++++++++------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index 026462a5f81..1a22d47307a 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -44,10 +44,11 @@ double getOrientation2d(MathLib::Point3d const& a, namespace GeoLib { -Orientation getOrientation(const GeoLib::Point* p0, const GeoLib::Point* p1, - const GeoLib::Point* p2) +Orientation getOrientation(GeoLib::Point const& p0, + GeoLib::Point const& p1, + GeoLib::Point const& p2) { - double const orientation = ExactPredicates::getOrientation2d(*p0, *p1, *p2); + double const orientation = ExactPredicates::getOrientation2d(p0, p1, p2); if (orientation > 0) return CCW; if (orientation < 0) diff --git a/GeoLib/AnalyticalGeometry.h b/GeoLib/AnalyticalGeometry.h index 4363725d604..08b5c8d6b1b 100644 --- a/GeoLib/AnalyticalGeometry.h +++ b/GeoLib/AnalyticalGeometry.h @@ -41,9 +41,9 @@ enum Orientation * \returns CW (clockwise), CCW (counterclockwise) or COLLINEAR (points are on a * line) */ -Orientation getOrientation(const GeoLib::Point* p0, - const GeoLib::Point* p1, - const GeoLib::Point* p2); +Orientation getOrientation(GeoLib::Point const& p0, + GeoLib::Point const& p1, + GeoLib::Point const& p2); /** * compute a supporting plane (represented by plane_normal and the value d) for the polygon diff --git a/GeoLib/Polygon.cpp b/GeoLib/Polygon.cpp index 57ab9668162..a0c3276a819 100644 --- a/GeoLib/Polygon.cpp +++ b/GeoLib/Polygon.cpp @@ -320,22 +320,25 @@ void Polygon::ensureCCWOrientation () // *** determine orientation GeoLib::Orientation orient; if (0 < min_x_max_y_idx && min_x_max_y_idx < n_pnts - 2) - orient = GeoLib::getOrientation ( - tmp_polygon_pnts[min_x_max_y_idx - 1], - tmp_polygon_pnts[min_x_max_y_idx], - tmp_polygon_pnts[min_x_max_y_idx + 1]); + { + orient = GeoLib::getOrientation(*tmp_polygon_pnts[min_x_max_y_idx - 1], + *tmp_polygon_pnts[min_x_max_y_idx], + *tmp_polygon_pnts[min_x_max_y_idx + 1]); + } else { if (0 == min_x_max_y_idx) - orient = GeoLib::getOrientation ( - tmp_polygon_pnts[n_pnts - 1], - tmp_polygon_pnts[0], - tmp_polygon_pnts[1]); + { + orient = GeoLib::getOrientation(*tmp_polygon_pnts[n_pnts - 1], + *tmp_polygon_pnts[0], + *tmp_polygon_pnts[1]); + } else - orient = GeoLib::getOrientation ( - tmp_polygon_pnts[n_pnts - 2], - tmp_polygon_pnts[n_pnts - 1], - tmp_polygon_pnts[0]); + { + orient = GeoLib::getOrientation(*tmp_polygon_pnts[n_pnts - 2], + *tmp_polygon_pnts[n_pnts - 1], + *tmp_polygon_pnts[0]); + } } if (orient != GeoLib::CCW) -- GitLab