From 729ffc9dd676bd1e823180c8b802b44cf11a89b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Thu, 16 Dec 2021 08:56:29 +0100 Subject: [PATCH] Fixed that external travels led inside holes (around the perimeter) instead of inside the model when the avoid crossing perimeters was enabled. Caused by changed behaviour of offset/expand functions when called on CW polygons (holes) after 7ff76d07684858fd937ef2f5d863f105a10f798e. When it is called expand on CW polygons (holes), they shrunk instead of expanded. --- src/libslic3r/GCode/AvoidCrossingPerimeters.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp index 48b9515f7..1b55514ee 100644 --- a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp +++ b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp @@ -1034,24 +1034,30 @@ static Polygons get_boundary_external(const Layer &layer) #endif // Collect all holes for all printed objects and their instances, which will be printed at the same time as passed "layer". for (const PrintObject *object : layer.object()->print()->objects()) { - Polygons polygons_per_obj; + Polygons holes_per_obj; #ifdef INCLUDE_SUPPORTS_IN_BOUNDARY ExPolygons supports_per_obj; #endif if (const Layer *l = object->get_layer_at_printz(layer.print_z, EPSILON); l) - for (const ExPolygon &island : l->lslices) append(polygons_per_obj, island.holes); + for (const ExPolygon &island : l->lslices) + append(holes_per_obj, island.holes); if (support_layer) { auto *layer_below = object->get_first_layer_bellow_printz(layer.print_z, EPSILON); if (layer_below) - for (const ExPolygon &island : layer_below->lslices) append(polygons_per_obj, island.holes); + for (const ExPolygon &island : layer_below->lslices) + append(holes_per_obj, island.holes); #ifdef INCLUDE_SUPPORTS_IN_BOUNDARY append(supports_per_obj, support_layer->support_islands.expolygons); #endif } + // After 7ff76d07684858fd937ef2f5d863f105a10f798e, when expand is called on CW polygons (holes), they are shrunk + // instead of expanded because union that makes CCW from CW isn't called anymore. So let's make it CCW. + polygons_reverse(holes_per_obj); + for (const PrintInstance &instance : object->instances()) { size_t boundary_idx = boundary.size(); - append(boundary, polygons_per_obj); + append(boundary, holes_per_obj); for (; boundary_idx < boundary.size(); ++boundary_idx) boundary[boundary_idx].translate(instance.shift); #ifdef INCLUDE_SUPPORTS_IN_BOUNDARY