From 4b928b413b2c860e0b9ea87128b95e3121315a66 Mon Sep 17 00:00:00 2001 From: RF47 <162915171+RF47@users.noreply.github.com> Date: Fri, 27 Feb 2026 19:38:07 -0300 Subject: [PATCH] FillRectilinear bugfix --- src/libslic3r/Fill/FillRectilinear.cpp | 29 ++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/Fill/FillRectilinear.cpp b/src/libslic3r/Fill/FillRectilinear.cpp index 775b3e8b42..3711b8ed00 100644 --- a/src/libslic3r/Fill/FillRectilinear.cpp +++ b/src/libslic3r/Fill/FillRectilinear.cpp @@ -3021,24 +3021,25 @@ bool FillRectilinear::fill_surface_by_multilines(const Surface *surface, FillPar multiline_fill(fill_lines, params, spacing); // Contract surface polygon by half line width to avoid excesive overlap with perimeter - ExPolygons contracted = offset_ex(surface->expolygon, -float(scale_(0.5 * this->spacing))); - - // if contraction results in empty polygon, use original surface - const ExPolygon &intersection_surface = contracted.empty() ? surface->expolygon : contracted.front(); + const ExPolygons contracted = offset_ex(surface->expolygon, -float(scale_(0.5 * this->spacing))); + + // if contraction results in empty ExPolygons, use original surface + const ExPolygons intersection_surface = contracted.empty() ? ExPolygons{surface->expolygon} : contracted; // Intersect polylines with perimeter fill_lines = intersection_pl(std::move(fill_lines), intersection_surface); - if ((params.pattern == ipLateralLattice || params.pattern == ipLateralHoneycomb ) && params.multiline >1 ) - remove_overlapped(fill_lines, line_width); + if ((params.pattern == ipLateralLattice || params.pattern == ipLateralHoneycomb) && params.multiline > 1) + remove_overlapped(fill_lines, line_width); if (!fill_lines.empty()) { - if (params.dont_connect()) { + if (params.dont_connect()) { if (fill_lines.size() > 1) fill_lines = chain_polylines(std::move(fill_lines)); append(polylines_out, std::move(fill_lines)); } else - connect_infill(std::move(fill_lines), intersection_surface, polylines_out, this->spacing, params); + connect_infill(std::move(fill_lines), to_polygons(intersection_surface), get_extents(surface->expolygon.contour), polylines_out, + this->spacing, params); } return true; @@ -3265,10 +3266,10 @@ bool FillRectilinear::fill_surface_trapezoidal( multiline_fill(polylines, params, spacing); // Contract surface polygon by half line width to avoid excesive overlap with perimeter - ExPolygons contracted = offset_ex(expolygon, -float(scale_(0.5 * this->spacing))); + const ExPolygons contracted = offset_ex(expolygon, -float(scale_(0.5 * this->spacing))); // if contraction results in empty polygon, use original surface - const ExPolygon &intersection_surface = contracted.empty() ? expolygon : contracted.front(); + const ExPolygons &intersection_surface = contracted.empty() ? ExPolygons{expolygon} : contracted; // Intersect polylines with offset expolygon polylines = intersection_pl(std::move(polylines), intersection_surface); @@ -3284,7 +3285,13 @@ bool FillRectilinear::fill_surface_trapezoidal( // Connect infill lines using offset expolygon int infill_start_idx = polylines_out.size(); if (!polylines.empty()) { - Slic3r::Fill::chain_or_connect_infill(std::move(polylines), intersection_surface, polylines_out, this->spacing, params); + if (params.dont_connect()) { + if (polylines.size() > 1) + polylines = chain_polylines(std::move(polylines)); + append(polylines_out, std::move(polylines)); + } else + connect_infill(std::move(polylines), to_polygons(intersection_surface), get_extents(surface->expolygon.contour), polylines_out, + this->spacing, params); // Rotate back the infill lines to original orientation if (std::abs(base_angle) >= EPSILON) {