1
#ifndef slic3r_ExPolygon_hpp_
2
#define slic3r_ExPolygon_hpp_
10
typedef std::vector<ExPolygon> ExPolygons;
17
operator Points() const;
18
operator Polygons() const;
19
void scale(double factor);
20
void translate(double x, double y);
21
void rotate(double angle, const Point ¢er);
23
bool is_valid() const;
24
bool contains_line(const Line &line) const;
25
bool contains_point(const Point &point) const;
26
Polygons simplify_p(double tolerance) const;
27
ExPolygons simplify(double tolerance) const;
28
void simplify(double tolerance, ExPolygons &expolygons) const;
29
void medial_axis(double max_width, double min_width, Polylines* polylines) const;
30
void get_trapezoids(Polygons* polygons) const;
31
void get_trapezoids(Polygons* polygons, double angle) const;
32
void get_trapezoids2(Polygons* polygons) const;
33
void get_trapezoids2(Polygons* polygons, double angle) const;
34
void triangulate(Polygons* polygons) const;
35
void triangulate_pp(Polygons* polygons) const;
36
void triangulate_p2t(Polygons* polygons) const;
39
void from_SV(SV* poly_sv);
40
void from_SV_check(SV* poly_sv);
42
SV* to_SV_pureperl() const;
49
#include <boost/polygon/polygon.hpp>
50
namespace boost { namespace polygon {
52
struct polygon_traits<ExPolygon> {
53
typedef coord_t coordinate_type;
54
typedef Points::const_iterator iterator_type;
55
typedef Point point_type;
57
// Get the begin iterator
58
static inline iterator_type begin_points(const ExPolygon& t) {
59
return t.contour.points.begin();
62
// Get the end iterator
63
static inline iterator_type end_points(const ExPolygon& t) {
64
return t.contour.points.end();
67
// Get the number of sides of the polygon
68
static inline std::size_t size(const ExPolygon& t) {
69
return t.contour.points.size();
72
// Get the winding direction of the polygon
73
static inline winding_direction winding(const ExPolygon& t) {
74
return unknown_winding;
79
struct polygon_mutable_traits<ExPolygon> {
80
//expects stl style iterators
81
template <typename iT>
82
static inline ExPolygon& set_points(ExPolygon& expolygon, iT input_begin, iT input_end) {
83
expolygon.contour.points.assign(input_begin, input_end);
84
// skip last point since Boost will set last point = first point
85
expolygon.contour.points.pop_back();
92
struct geometry_concept<ExPolygon> { typedef polygon_with_holes_concept type; };
95
struct polygon_with_holes_traits<ExPolygon> {
96
typedef Polygons::const_iterator iterator_holes_type;
97
typedef Polygon hole_type;
98
static inline iterator_holes_type begin_holes(const ExPolygon& t) {
99
return t.holes.begin();
101
static inline iterator_holes_type end_holes(const ExPolygon& t) {
102
return t.holes.end();
104
static inline unsigned int size_holes(const ExPolygon& t) {
105
return t.holes.size();
110
struct polygon_with_holes_mutable_traits<ExPolygon> {
111
template <typename iT>
112
static inline ExPolygon& set_holes(ExPolygon& t, iT inputBegin, iT inputEnd) {
113
t.holes.assign(inputBegin, inputEnd);
118
//first we register CPolygonSet as a polygon set
120
struct geometry_concept<ExPolygons> { typedef polygon_set_concept type; };
122
//next we map to the concept through traits
124
struct polygon_set_traits<ExPolygons> {
125
typedef coord_t coordinate_type;
126
typedef ExPolygons::const_iterator iterator_type;
127
typedef ExPolygons operator_arg_type;
129
static inline iterator_type begin(const ExPolygons& polygon_set) {
130
return polygon_set.begin();
133
static inline iterator_type end(const ExPolygons& polygon_set) {
134
return polygon_set.end();
137
//don't worry about these, just return false from them
138
static inline bool clean(const ExPolygons& polygon_set) { return false; }
139
static inline bool sorted(const ExPolygons& polygon_set) { return false; }
143
struct polygon_set_mutable_traits<ExPolygons> {
144
template <typename input_iterator_type>
145
static inline void set(ExPolygons& expolygons, input_iterator_type input_begin, input_iterator_type input_end) {
146
expolygons.assign(input_begin, input_end);