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
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2016-11-08 00:49:11 +0300
committerbubnikv <bubnikv@gmail.com>2016-11-08 00:49:11 +0300
commit5a8173157727495a3ef849a338c7b26a5e618f35 (patch)
tree1d415a905e35877c4632965fcc2aa87f5006f8c6 /xs/src/libslic3r/ExPolygon.cpp
parentaac968162b7636415640332f2225b637d58ae2d4 (diff)
Implemented utility functions to operate over lines, polylines, polygons,
surfaces.
Diffstat (limited to 'xs/src/libslic3r/ExPolygon.cpp')
-rw-r--r--xs/src/libslic3r/ExPolygon.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp
index 71f90179a..f37e2e701 100644
--- a/xs/src/libslic3r/ExPolygon.cpp
+++ b/xs/src/libslic3r/ExPolygon.cpp
@@ -26,24 +26,12 @@ ExPolygon::operator Points() const
ExPolygon::operator Polygons() const
{
- Polygons polygons;
- polygons.reserve(this->holes.size() + 1);
- polygons.push_back(this->contour);
- for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
- polygons.push_back(*it);
- }
- return polygons;
+ return to_polygons(*this);
}
ExPolygon::operator Polylines() const
{
- Polylines polylines;
- polylines.reserve(this->holes.size() + 1);
- polylines.push_back((Polyline)this->contour);
- for (Polygons::const_iterator it = this->holes.begin(); it != this->holes.end(); ++it) {
- polylines.push_back((Polyline)*it);
- }
- return polylines;
+ return to_polylines(*this);
}
void
@@ -583,6 +571,22 @@ BoundingBox get_extents(const ExPolygons &expolygons)
return bbox;
}
+BoundingBox get_extents_rotated(const ExPolygon &expolygon, double angle)
+{
+ return get_extents_rotated(expolygon.contour, angle);
+}
+
+BoundingBox get_extents_rotated(const ExPolygons &expolygons, double angle)
+{
+ BoundingBox bbox;
+ if (! expolygons.empty()) {
+ bbox = get_extents_rotated(expolygons.front().contour, angle);
+ for (size_t i = 1; i < expolygons.size(); ++ i)
+ bbox.merge(get_extents_rotated(expolygons[i].contour, angle));
+ }
+ return bbox;
+}
+
bool remove_sticks(ExPolygon &poly)
{
return remove_sticks(poly.contour) || remove_sticks(poly.holes);