mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 15:44:12 -06:00
Remove self-intersections before supplying polygon data to polyPartition and rename triangulate2() to triangulate_pp()
This commit is contained in:
parent
9734a40647
commit
60f640f100
7 changed files with 53 additions and 30 deletions
|
@ -442,14 +442,24 @@ static void traverse_pt(ClipperLib::PolyNodes &nodes, Slic3r::Polygons &retval)
|
|||
}
|
||||
}
|
||||
|
||||
void simplify_polygons(const Slic3r::Polygons &subject, Slic3r::Polygons &retval)
|
||||
void simplify_polygons(const Slic3r::Polygons &subject, Slic3r::Polygons &retval, bool preserve_collinear)
|
||||
{
|
||||
// convert into Clipper polygons
|
||||
ClipperLib::Paths* input_subject = new ClipperLib::Paths();
|
||||
Slic3rMultiPoints_to_ClipperPaths(subject, *input_subject);
|
||||
|
||||
ClipperLib::Paths* output = new ClipperLib::Paths();
|
||||
ClipperLib::SimplifyPolygons(*input_subject, *output, ClipperLib::pftNonZero);
|
||||
|
||||
if (preserve_collinear) {
|
||||
ClipperLib::Clipper c;
|
||||
c.PreserveCollinear(true);
|
||||
c.StrictlySimple(true);
|
||||
c.AddPaths(*input_subject, ClipperLib::ptSubject, true);
|
||||
c.Execute(ClipperLib::ctUnion, *output, ClipperLib::pftNonZero, ClipperLib::pftNonZero);
|
||||
} else {
|
||||
ClipperLib::SimplifyPolygons(*input_subject, *output, ClipperLib::pftNonZero);
|
||||
}
|
||||
|
||||
delete input_subject;
|
||||
|
||||
// convert into Slic3r polygons
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue