From be279760cb78fe5eb4f39bfc4d03efc805df3da5 Mon Sep 17 00:00:00 2001
From: Ammar Nejati <a.nejati@fz-juelich.de>
Date: Mon, 25 Oct 2021 16:19:40 +0200
Subject: [PATCH] Device/Mask: Mark the Boost functions by using the explicit
 namespace

The used functions from `boost/geometry` are marked by using `boost::geometry`
namespace in order to make clear which functions are used from the Boost library.
This conforms also with the other parts of the codebase, eg.,
`Device/InputOutput/boost_streams`.

Unneeded included headers are removed.
---
 Device/Mask/Line.cpp    | 15 ++++++---------
 Device/Mask/Polygon.cpp | 26 +++++++++++++-------------
 2 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/Device/Mask/Line.cpp b/Device/Mask/Line.cpp
index b006bf85738..93ebca92e8c 100644
--- a/Device/Mask/Line.cpp
+++ b/Device/Mask/Line.cpp
@@ -17,14 +17,11 @@
 #include "Base/Utils/Algorithms.h"
 
 #include <boost/geometry.hpp>
-#include <boost/geometry/geometries/linestring.hpp>
-#include <boost/geometry/geometries/point_xy.hpp>
 #include <limits>
 
-using namespace boost::geometry;
-typedef model::d2::point_xy<double> point_t;
-typedef model::box<point_t> box_t;
-typedef model::linestring<point_t> line_t;
+typedef boost::geometry::model::d2::point_xy<double> point_t;
+// typedef model::box<point_t> box_t;
+typedef boost::geometry::model::linestring<point_t> line_t;
 
 Line::Line(double x1, double y1, double x2, double y2)
     : IShape2D("Line"), m_x1(x1), m_y1(y1), m_x2(x2), m_y2(y2)
@@ -38,7 +35,7 @@ bool Line::contains(double x, double y) const
     line.push_back(point_t(m_x1, m_y1));
     line.push_back(point_t(m_x2, m_y2));
 
-    double d = distance(p, line);
+    double d = boost::geometry::distance(p, line);
 
     return d < std::numeric_limits<double>::epsilon();
 }
@@ -58,8 +55,8 @@ bool Line::contains(const Bin1D& binx, const Bin1D& biny) const
     line_points.push_back(point_t(m_x1, m_y1));
     line_points.push_back(point_t(m_x2, m_y2));
 
-    return intersects(line_t(box_points.begin(), box_points.end()),
-                      line_t(line_points.begin(), line_points.end()));
+    return boost::geometry::intersects(line_t(box_points.begin(), box_points.end()),
+                                       line_t(line_points.begin(), line_points.end()));
 }
 
 // ------------------------------------------------------------------------- //
diff --git a/Device/Mask/Polygon.cpp b/Device/Mask/Polygon.cpp
index ccbe31bd57c..6431f79e1e9 100644
--- a/Device/Mask/Polygon.cpp
+++ b/Device/Mask/Polygon.cpp
@@ -16,16 +16,12 @@
 #include "Base/Axis/Bin.h"
 
 #include <boost/geometry.hpp>
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/polygon.hpp>
-
-using namespace boost::geometry;
 
 //! The private data for polygons to hide boost dependency from the header
 class PolygonPrivate {
 public:
-    typedef model::d2::point_xy<double> point_t;
-    typedef model::polygon<point_t> polygon_t;
+    typedef boost::geometry::model::d2::point_xy<double> point_t;
+    typedef boost::geometry::model::polygon<point_t> polygon_t;
     polygon_t polygon;
     void init_from(const std::vector<double>& x, const std::vector<double>& y);
     void get_points(std::vector<double>& xpos, std::vector<double>& ypos);
@@ -40,8 +36,8 @@ void PolygonPrivate::init_from(const std::vector<double>& x, const std::vector<d
     std::vector<point_t> points;
     for (size_t i = 0; i < x.size(); ++i)
         points.push_back(point_t(x[i], y[i]));
-    assign_points(polygon, points);
-    correct(polygon);
+    boost::geometry::assign_points(polygon, points);
+    boost::geometry::correct(polygon);
 }
 
 void PolygonPrivate::get_points(std::vector<double>& xpos, std::vector<double>& ypos)
@@ -97,18 +93,22 @@ Polygon::~Polygon()
 
 bool Polygon::contains(double x, double y) const
 {
-    //    return within(PolygonPrivate::point_t(x, y), m_d->polygon); // not including borders
-    return covered_by(PolygonPrivate::point_t(x, y), m_d->polygon); // including borders
+    // not including borders
+    // return within(PolygonPrivate::point_t(x, y), m_d->polygon);
+
+    // including borders
+    return boost::geometry::covered_by(PolygonPrivate::point_t(x, y),
+                                       m_d->polygon);
 }
 
 bool Polygon::contains(const Bin1D& binx, const Bin1D& biny) const
 {
-    return contains(binx.center(), biny.center());
+    return Polygon::contains(binx.center(), biny.center());
 }
 
 double Polygon::getArea() const
 {
-    return area(m_d->polygon);
+    return boost::geometry::area(m_d->polygon);
 }
 
 void Polygon::getPoints(std::vector<double>& xpos, std::vector<double>& ypos) const
@@ -118,5 +118,5 @@ void Polygon::getPoints(std::vector<double>& xpos, std::vector<double>& ypos) co
 
 void Polygon::print(std::ostream& ostr) const
 {
-    ostr << wkt<PolygonPrivate::polygon_t>(m_d->polygon);
+    ostr << boost::geometry::wkt<PolygonPrivate::polygon_t>(m_d->polygon);
 }
-- 
GitLab