Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2019-10-25 18:07:55 +0300
committerbubnikv <bubnikv@gmail.com>2019-10-25 18:07:55 +0300
commitf8dc74374c9f64e0f09c01b811deb3b4457598df (patch)
treec81646e30129f7b3a453fded7941437dc62a7541 /src
parentd70b45a51bc3e54983e3749dc02d630cd674096a (diff)
Ported various clipper unit tests from Perl to C++,
the clipper Perl unit tests were removed.
Diffstat (limited to 'src')
-rw-r--r--src/libslic3r/ExPolygon.hpp5
-rw-r--r--src/libslic3r/Polygon.hpp7
2 files changed, 11 insertions, 1 deletions
diff --git a/src/libslic3r/ExPolygon.hpp b/src/libslic3r/ExPolygon.hpp
index 08c4f7a07..7833c9c91 100644
--- a/src/libslic3r/ExPolygon.hpp
+++ b/src/libslic3r/ExPolygon.hpp
@@ -28,6 +28,8 @@ public:
explicit ExPolygon(Polygon &&contour, Polygon &&hole) : contour(std::move(contour)) { holes.emplace_back(std::move(hole)); }
explicit ExPolygon(const Points &contour, const Points &hole) : contour(contour) { holes.emplace_back(hole); }
explicit ExPolygon(Points &&contour, Polygon &&hole) : contour(std::move(contour)) { holes.emplace_back(std::move(hole)); }
+ ExPolygon(std::initializer_list<Point> contour) : contour(contour) {}
+ ExPolygon(std::initializer_list<Point> contour, std::initializer_list<Point> hole) : contour(contour), holes({ hole }) {}
ExPolygon& operator=(const ExPolygon &other) { contour = other.contour; holes = other.holes; return *this; }
ExPolygon& operator=(ExPolygon &&other) { contour = std::move(other.contour); holes = std::move(other.holes); return *this; }
@@ -77,6 +79,9 @@ public:
Lines lines() const;
};
+inline bool operator==(const ExPolygon &lhs, const ExPolygon &rhs) { return lhs.contour == rhs.contour && lhs.holes == rhs.holes; }
+inline bool operator!=(const ExPolygon &lhs, const ExPolygon &rhs) { return lhs.contour != rhs.contour || lhs.holes != rhs.holes; }
+
// Count a nuber of polygons stored inside the vector of expolygons.
// Useful for allocating space for polygons when converting expolygons to polygons.
inline size_t number_polygons(const ExPolygons &expolys)
diff --git a/src/libslic3r/Polygon.hpp b/src/libslic3r/Polygon.hpp
index ad1b32feb..4d53e97e1 100644
--- a/src/libslic3r/Polygon.hpp
+++ b/src/libslic3r/Polygon.hpp
@@ -22,7 +22,8 @@ public:
const Point& operator[](Points::size_type idx) const { return this->points[idx]; }
Polygon() {}
- explicit Polygon(const Points &points): MultiPoint(points) {}
+ explicit Polygon(const Points &points) : MultiPoint(points) {}
+ Polygon(std::initializer_list<Point> points) : MultiPoint(points) {}
Polygon(const Polygon &other) : MultiPoint(other.points) {}
Polygon(Polygon &&other) : MultiPoint(std::move(other.points)) {}
static Polygon new_scale(const std::vector<Vec2d> &points) {
@@ -66,6 +67,10 @@ public:
Point point_projection(const Point &point) const;
};
+inline bool operator==(const Polygon &lhs, const Polygon &rhs) { return lhs.points == rhs.points; }
+inline bool operator!=(const Polygon &lhs, const Polygon &rhs) { return lhs.points != rhs.points; }
+
+
extern BoundingBox get_extents(const Polygon &poly);
extern BoundingBox get_extents(const Polygons &polygons);
extern BoundingBox get_extents_rotated(const Polygon &poly, double angle);