Skip to content
Snippets Groups Projects
Commit be279760 authored by Ammar Nejati's avatar Ammar Nejati
Browse files

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.
parent 6bafb3fd
No related branches found
No related tags found
1 merge request!423Device/Mask: Mark the Boost functions by using the explicit namespace
Pipeline #47795 passed
......@@ -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()));
}
// ------------------------------------------------------------------------- //
......
......@@ -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);
}
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