From 1aee8a0783f4a6162938147f043cdd7d3dddc384 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Tue, 17 Jun 2025 19:22:16 +0800 Subject: [PATCH] Don't split tiny cracks on first layer (#9917) Don't split tiny cracks on first layer to get an uninterrupted bottom surface --- src/libslic3r/PrintObject.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 5b53ac07b1..9d12806122 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1382,24 +1382,26 @@ void PrintObject::detect_surfaces_type() if (! top.empty() && ! bottom.empty()) { const auto cracks = intersection_ex(top, bottom); if (!cracks.empty()) { - const float small_crack_threshold = -layerm->flow(frExternalPerimeter).scaled_width() * 1.5; - - for (const auto& crack : cracks) { - if (offset_ex(crack, small_crack_threshold).empty()) { - // For small cracks, if it's part of a large bottom surface, then it should be added to bottom as well - if (std::any_of(bottom.begin(), bottom.end(), [&crack, small_crack_threshold](const Surface& s) { - const auto& se = s.expolygon; - return diff_ex(crack, se, ApplySafetyOffset::Yes).empty() - && se.area() > crack.area() * 2 - && !offset_ex(diff_ex(se, crack), small_crack_threshold).empty(); - })) continue; + if (lower_layer) { // Only detect small cracks for non-first layer, because first layer should always be bottom + const float small_crack_threshold = -layerm->flow(frExternalPerimeter).scaled_width() * 1.5; + + for (const auto& crack : cracks) { + if (offset_ex(crack, small_crack_threshold).empty()) { + // For small cracks, if it's part of a large bottom surface, then it should be added to bottom as well + if (std::any_of(bottom.begin(), bottom.end(), [&crack, small_crack_threshold](const Surface& s) { + const auto& se = s.expolygon; + return diff_ex(crack, se, ApplySafetyOffset::Yes).empty() + && se.area() > crack.area() * 2 + && !offset_ex(diff_ex(se, crack), small_crack_threshold).empty(); + })) continue; - // Crack too small, leave it as part of the top surface, remove it from bottom surfaces - Surfaces bot_tmp; - for (auto& b : bottom) { - surfaces_append(bot_tmp, diff_ex(b.expolygon, offset_ex(crack, -small_crack_threshold)), b.surface_type); + // Crack too small, leave it as part of the top surface, remove it from bottom surfaces + Surfaces bot_tmp; + for (auto& b : bottom) { + surfaces_append(bot_tmp, diff_ex(b.expolygon, offset_ex(crack, -small_crack_threshold)), b.surface_type); + } + bottom = std::move(bot_tmp); } - bottom = std::move(bot_tmp); } }