The previous implementation during the grouping of perimeters using depth-first searches unnecessarily searched nodes that had no impact on grouping, which significantly increased the search space.
Cherry-picked from prusa3d/PrusaSlicer@86309ba939
Co-authored-by: Lukáš Hejl <hejl.lukas@gmail.com>
Especially in cases when the object is composed only of 2 external perimeters and 1 or 2 internal perimeters, the order of perimeters wasn't optimal and differed from the Classic perimeter generator. That caused unnecessary long travels before the external contour was printed.
The ordering of perimeters is slightly inspired by the latest changes in CuraEngine.
Cherry-picked from prusa3d/PrusaSlicer@10875082de
Co-authored-by: Lukáš Hejl <hejl.lukas@gmail.com>