mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 19:28:14 -06:00
One step further to the C++ Supports.
This commit is contained in:
parent
1a1eaa0810
commit
d8be4de6cf
8 changed files with 500 additions and 395 deletions
|
@ -1004,4 +1004,25 @@ void safety_offset(ClipperLib::Paths* paths)
|
|||
scaleClipperPolygons(*paths, 1.0/CLIPPER_OFFSET_SCALE);
|
||||
}
|
||||
|
||||
Polygons top_level_islands(const Slic3r::Polygons &polygons)
|
||||
{
|
||||
ClipperLib::Paths input;
|
||||
Slic3rMultiPoints_to_ClipperPaths(polygons, &input);
|
||||
// init Clipper
|
||||
ClipperLib::Clipper clipper;
|
||||
clipper.Clear();
|
||||
// perform union
|
||||
clipper.AddPaths(input, ClipperLib::ptSubject, true);
|
||||
ClipperLib::PolyTree polytree;
|
||||
clipper.Execute(ClipperLib::ctUnion, polytree, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd);
|
||||
// Convert only the top level islands to the output.
|
||||
Polygons out;
|
||||
out.reserve(polytree.ChildCount());
|
||||
for (int i = 0; i < polytree.ChildCount(); ++i) {
|
||||
out.push_back(Polygon());
|
||||
ClipperPath_to_Slic3rMultiPoint(polytree.Childs[i]->Contour, &out.back());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
Loading…
Add table
Add a link
Reference in a new issue