mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-31 00:52:51 +00:00
Better polymorphism for ExPolygon::XS->rotate
This commit is contained in:
@@ -20,7 +20,7 @@ class ExPolygon
|
||||
SV* arrayref();
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void _rotate(double angle, Point* center);
|
||||
void rotate(double angle, Point* center);
|
||||
};
|
||||
|
||||
typedef std::vector<ExPolygon> ExPolygons;
|
||||
@@ -44,11 +44,11 @@ ExPolygon::translate(double x, double y)
|
||||
}
|
||||
|
||||
void
|
||||
ExPolygon::_rotate(double angle, Point* center)
|
||||
ExPolygon::rotate(double angle, Point* center)
|
||||
{
|
||||
contour._rotate(angle, center);
|
||||
contour.rotate(angle, center);
|
||||
for (Polygons::iterator it = holes.begin(); it != holes.end(); ++it) {
|
||||
(*it)._rotate(angle, center);
|
||||
(*it).rotate(angle, center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ void
|
||||
ExPolygonCollection::rotate(double angle, Point* center)
|
||||
{
|
||||
for (ExPolygons::iterator it = expolygons.begin(); it != expolygons.end(); ++it) {
|
||||
(*it)._rotate(angle, center);
|
||||
(*it).rotate(angle, center);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,14 @@ point2perl(Point& point) {
|
||||
return sv_bless(newRV_noinc((SV*)av), gv_stashpv("Slic3r::Point", GV_ADD));
|
||||
}
|
||||
|
||||
void
|
||||
perl2point(SV* point_sv, Point& point)
|
||||
{
|
||||
AV* point_av = (AV*)SvRV(point_sv);
|
||||
point.x = (unsigned long)SvIV(*av_fetch(point_av, 0, 0));
|
||||
point.y = (unsigned long)SvIV(*av_fetch(point_av, 1, 0));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -18,7 +18,7 @@ class Polygon
|
||||
Points points;
|
||||
void scale(double factor);
|
||||
void translate(double x, double y);
|
||||
void _rotate(double angle, Point* center);
|
||||
void rotate(double angle, Point* center);
|
||||
};
|
||||
|
||||
typedef std::vector<Polygon> Polygons;
|
||||
@@ -42,7 +42,7 @@ Polygon::translate(double x, double y)
|
||||
}
|
||||
|
||||
void
|
||||
Polygon::_rotate(double angle, Point* center)
|
||||
Polygon::rotate(double angle, Point* center)
|
||||
{
|
||||
for (Points::iterator it = points.begin(); it != points.end(); ++it) {
|
||||
(*it).rotate(angle, center);
|
||||
@@ -58,10 +58,7 @@ perl2polygon(SV* poly_sv, Polygon& poly)
|
||||
|
||||
for (unsigned int i = 0; i < num_points; i++) {
|
||||
SV** point_sv = av_fetch(poly_av, i, 0);
|
||||
AV* point_av = (AV*)SvRV(*point_sv);
|
||||
Point& p = poly.points[i];
|
||||
p.x = (unsigned long)SvIV(*av_fetch(point_av, 0, 0));
|
||||
p.y = (unsigned long)SvIV(*av_fetch(point_av, 1, 0));
|
||||
perl2point(*point_sv, poly.points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user