mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-31 09:02:53 +00:00
New ExPolygon::triangulate() method
This commit is contained in:
@@ -176,6 +176,18 @@ ExPolygon::get_trapezoids(Polygons* polygons, double angle) const
|
||||
polygon->rotate(-(PI/2 - angle), Point(0,0));
|
||||
}
|
||||
|
||||
void
|
||||
ExPolygon::triangulate(Polygons* polygons) const
|
||||
{
|
||||
// first make trapezoids
|
||||
Polygons trapezoids;
|
||||
this->get_trapezoids(&trapezoids);
|
||||
|
||||
// then triangulate each trapezoid
|
||||
for (Polygons::iterator polygon = trapezoids.begin(); polygon != trapezoids.end(); ++polygon)
|
||||
polygon->triangulate_convex(polygons);
|
||||
}
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
SV*
|
||||
ExPolygon::to_AV() {
|
||||
|
||||
@@ -29,6 +29,7 @@ class ExPolygon
|
||||
void medial_axis(double max_width, double min_width, Polylines* polylines) const;
|
||||
void get_trapezoids(Polygons* polygons) const;
|
||||
void get_trapezoids(Polygons* polygons, double angle) const;
|
||||
void triangulate(Polygons* polygons) const;
|
||||
|
||||
#ifdef SLIC3RXS
|
||||
void from_SV(SV* poly_sv);
|
||||
|
||||
@@ -168,7 +168,9 @@ Polygon::triangulate_convex(Polygons* polygons) const
|
||||
p.points.push_back(this->points.front());
|
||||
p.points.push_back(*(it-1));
|
||||
p.points.push_back(*it);
|
||||
polygons->push_back(p);
|
||||
|
||||
// this should be replaced with a more efficient call to a merge_collinear_segments() method
|
||||
if (p.area() > 0) polygons->push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user