New ->translate() method for ExPolygon::XS

This commit is contained in:
Alessandro Ranellucci 2013-07-11 14:13:30 +02:00
parent e0052b01d3
commit 3037b42b47
2 changed files with 27 additions and 4 deletions

View file

@ -20,6 +20,7 @@ class ExPolygon
Polygons holes;
SV* arrayref();
void scale(double factor);
void translate(double x, double y);
};
#define scale_polygon(poly, factor) \
@ -28,6 +29,12 @@ class ExPolygon
(*pit).y *= factor; \
}
#define translate_polygon(poly, x, y) \
for (Polygon::iterator pit = (poly).begin(); pit != (poly).end(); ++pit) { \
(*pit).x += x; \
(*pit).y += y; \
}
void
ExPolygon::scale(double factor)
{
@ -37,6 +44,15 @@ ExPolygon::scale(double factor)
}
}
void
ExPolygon::translate(double x, double y)
{
translate_polygon(contour, x, y);
for (Polygons::iterator it = holes.begin(); it != holes.end(); ++it) {
translate_polygon(*it, x, y);
}
}
void
perl2polygon(SV* poly_sv, Polygon& poly)
{