@@ -1309,8 +1309,7 @@ void PrintObject::detect_surfaces_type()
13091309 Layer *upper_layer = (idx_layer + 1 < this ->layer_count ()) ? m_layers[idx_layer + 1 ] : nullptr ;
13101310 Layer *lower_layer = (idx_layer > 0 ) ? m_layers[idx_layer - 1 ] : nullptr ;
13111311 // collapse very narrow parts (using the safety offset in the diff is not enough)
1312- const float offset_top = layerm->flow (frExternalPerimeter).scaled_width () / 10 .f ;
1313- const float offset_bottom = layerm->flow (frExternalPerimeter).scaled_width ();
1312+ const float offset = layerm->flow (frExternalPerimeter).scaled_width () / 10 .f ;
13141313
13151314 ExPolygons layerm_slices_surfaces = to_expolygons (layerm->slices .surfaces );
13161315 // no_perimeter_full_bridge allow to put bridges where there are nothing, hence adding area to slice, that's why we need to start from the result of PerimeterGenerator.
@@ -1325,7 +1324,7 @@ void PrintObject::detect_surfaces_type()
13251324 ExPolygons upper_slices = interface_shells ?
13261325 diff_ex (layerm_slices_surfaces, upper_layer->m_regions [region_id]->slices .surfaces , ApplySafetyOffset::Yes) :
13271326 diff_ex (layerm_slices_surfaces, upper_layer->lslices , ApplySafetyOffset::Yes);
1328- surfaces_append (top, opening_ex (upper_slices, offset_top ), stTop);
1327+ surfaces_append (top, opening_ex (upper_slices, offset ), stTop);
13291328 } else {
13301329 // if no upper layer, all surfaces of this one are solid
13311330 // we clone surfaces because we're going to clear the slices collection
@@ -1351,7 +1350,7 @@ void PrintObject::detect_surfaces_type()
13511350 bottom,
13521351 opening_ex (
13531352 diff_ex (layerm_slices_surfaces, lower_layer->lslices , ApplySafetyOffset::Yes),
1354- offset_bottom ),
1353+ offset ),
13551354 surface_type_bottom_other);
13561355 // if user requested internal shells, we need to identify surfaces
13571356 // lying on other slices not belonging to this region
@@ -1365,7 +1364,7 @@ void PrintObject::detect_surfaces_type()
13651364 intersection (layerm_slices_surfaces, lower_layer->lslices ), // supported
13661365 lower_layer->m_regions [region_id]->slices .surfaces ,
13671366 ApplySafetyOffset::Yes),
1368- offset_bottom ),
1367+ offset ),
13691368 stBottom);
13701369 }
13711370#endif
@@ -1383,14 +1382,22 @@ void PrintObject::detect_surfaces_type()
13831382 if (! top.empty () && ! bottom.empty ()) {
13841383 const auto cracks = intersection_ex (top, bottom);
13851384 if (!cracks.empty ()) {
1386- const float small_crack_threshold = -offset_bottom ;
1385+ const float small_crack_threshold = -layerm-> flow (frExternalPerimeter). scaled_width () * 1.5 ;
13871386
13881387 for (const auto & crack : cracks) {
13891388 if (offset_ex (crack, small_crack_threshold).empty ()) {
1389+ // For small cracks, if it's part of a large bottom surface, then it should be added to bottom as well
1390+ if (std::any_of (bottom.begin (), bottom.end (), [&crack, small_crack_threshold](const Surface& s) {
1391+ const auto & se = s.expolygon ;
1392+ return diff_ex (crack, se, ApplySafetyOffset::Yes).empty ()
1393+ && se.area () > crack.area () * 2
1394+ && !offset_ex (diff_ex (se, crack), small_crack_threshold).empty ();
1395+ })) continue ;
1396+
13901397 // Crack too small, leave it as part of the top surface, remove it from bottom surfaces
13911398 Surfaces bot_tmp;
13921399 for (auto & b : bottom) {
1393- surfaces_append (bot_tmp, diff_ex (b.expolygon , crack), b.surface_type );
1400+ surfaces_append (bot_tmp, diff_ex (b.expolygon , offset_ex ( crack, -small_crack_threshold) ), b.surface_type );
13941401 }
13951402 bottom = std::move (bot_tmp);
13961403 }
0 commit comments