New method to rotate only polygons, not translate.

New free function to_polygons. Whithout this function one needs to construct the ExPolygonCollection, which means a deep copy.
This commit is contained in:
bubnikv 2016-04-10 19:12:32 +02:00
parent 023310882f
commit bcfbe02c8d
2 changed files with 36 additions and 0 deletions

View file

@ -52,6 +52,15 @@ ExPolygon::translate(double x, double y)
}
}
void
ExPolygon::rotate(double angle)
{
contour.rotate(angle);
for (Polygons::iterator it = holes.begin(); it != holes.end(); ++it) {
(*it).rotate(angle);
}
}
void
ExPolygon::rotate(double angle, const Point &center)
{

View file

@ -20,6 +20,7 @@ class ExPolygon
operator Polygons() const;
void scale(double factor);
void translate(double x, double y);
void rotate(double angle);
void rotate(double angle, const Point &center);
double area() const;
bool is_valid() const;
@ -44,6 +45,32 @@ class ExPolygon
Lines lines() const;
};
inline Polygons to_polygons(const ExPolygons &src)
{
Polygons polygons;
for (ExPolygons::const_iterator it = src.begin(); it != src.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;
}
#if SLIC3R_CPPVER > 11
inline Polygons to_polygons(ExPolygons &&src)
{
Polygons polygons;
for (ExPolygons::const_iterator it = src.begin(); it != src.end(); ++it) {
polygons.push_back(std::move(it->contour));
for (Polygons::const_iterator ith = it->holes.begin(); ith != it->holes.end(); ++ith) {
polygons.push_back(std::move(*ith));
}
}
return polygons;
}
#endif
}
// start Boost