2013-07-16 19:04:14 +00:00
|
|
|
#include "ExPolygonCollection.hpp"
|
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
2013-11-21 16:53:50 +00:00
|
|
|
ExPolygonCollection::operator Polygons() const
|
|
|
|
{
|
|
|
|
Polygons polygons;
|
|
|
|
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
|
|
|
|
polygons.push_back(it->contour);
|
|
|
|
for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) {
|
|
|
|
polygons.push_back(*ith);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return polygons;
|
|
|
|
}
|
|
|
|
|
2013-07-16 19:04:14 +00:00
|
|
|
void
|
|
|
|
ExPolygonCollection::scale(double factor)
|
|
|
|
{
|
2013-08-08 00:10:34 +00:00
|
|
|
for (ExPolygons::iterator it = expolygons.begin(); it != expolygons.end(); ++it) {
|
|
|
|
(*it).scale(factor);
|
2013-07-16 19:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExPolygonCollection::translate(double x, double y)
|
|
|
|
{
|
2013-08-08 00:10:34 +00:00
|
|
|
for (ExPolygons::iterator it = expolygons.begin(); it != expolygons.end(); ++it) {
|
|
|
|
(*it).translate(x, y);
|
2013-07-16 19:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExPolygonCollection::rotate(double angle, Point* center)
|
|
|
|
{
|
2013-08-08 00:10:34 +00:00
|
|
|
for (ExPolygons::iterator it = expolygons.begin(); it != expolygons.end(); ++it) {
|
|
|
|
(*it).rotate(angle, center);
|
2013-07-16 19:04:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-21 16:53:50 +00:00
|
|
|
bool
|
|
|
|
ExPolygonCollection::contains_point(const Point* point) const
|
|
|
|
{
|
|
|
|
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
|
|
|
|
if (it->contains_point(point)) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-21 19:25:24 +00:00
|
|
|
void
|
|
|
|
ExPolygonCollection::simplify(double tolerance)
|
|
|
|
{
|
|
|
|
ExPolygons t;
|
|
|
|
for (ExPolygons::const_iterator it = this->expolygons.begin(); it != this->expolygons.end(); ++it) {
|
|
|
|
it->simplify_and_append_to(tolerance, t);
|
|
|
|
}
|
|
|
|
this->expolygons = t;
|
|
|
|
}
|
|
|
|
|
2013-07-16 19:04:14 +00:00
|
|
|
}
|