From c234b98db5c3aead681d7f5a8340774413071a6a Mon Sep 17 00:00:00 2001 From: Pavel Mikus Date: Tue, 28 Mar 2023 21:00:07 +0200 Subject: [PATCH] Fix additional special case for ordering of extra perimeters --- src/libslic3r/PerimeterGenerator.cpp | 16 +++++++++++++--- src/libslic3r/SLAPrint.cpp | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index dc4c2c9cb5..7236f66ff4 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -1019,13 +1019,23 @@ std::tuple, Polygons> generate_extra_perimeters_over overhang_region.end()); if (!overhang_region.empty()) { + // there is a special case, where the first (or last) generated overhang perimeter eats all anchor space. + // When this happens, the first overhang perimeter is also a closed loop, and needs special check + // instead of the following simple is_anchored lambda, which checks only the first and last point (not very useful on closed + // polyline) + bool first_overhang_is_closed_and_anchored = + (overhang_region.front().first_point() == overhang_region.front().last_point() && + !intersection_pl(overhang_region.front().polyline, optimized_lower_slices).empty()); + auto is_anchored = [&lower_layer_aabb_tree](const ExtrusionPath &path) { return lower_layer_aabb_tree.distance_from_lines(path.first_point()) <= 0 || lower_layer_aabb_tree.distance_from_lines(path.last_point()) <= 0; }; - std::reverse(overhang_region.begin(), overhang_region.end()); - auto first_unanchored = std::stable_partition(overhang_region.begin(), overhang_region.end(), is_anchored); - int index_of_first_unanchored = first_unanchored - overhang_region.begin(); + if (!first_overhang_is_closed_and_anchored) { + std::reverse(overhang_region.begin(), overhang_region.end()); + } + auto first_unanchored = std::stable_partition(overhang_region.begin(), overhang_region.end(), is_anchored); + int index_of_first_unanchored = first_unanchored - overhang_region.begin(); overhang_region = sort_extra_perimeters(overhang_region, index_of_first_unanchored, overhang_flow.scaled_spacing()); } } diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 8238a266ee..c4947851b0 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -2,6 +2,7 @@ #include "SLAPrintSteps.hpp" #include "CSGMesh/CSGMeshCopy.hpp" #include "CSGMesh/PerformCSGMeshBooleans.hpp" +#include "format.hpp" #include "Geometry.hpp" #include "Thread.hpp"