Skip to content

Fix missing infill layers (fill_surface_by_multilines & fill_surface_trapezoidal bug fix)#12516

Merged
ianalexis merged 5 commits into
OrcaSlicer:mainfrom
RF47:Fillrectilinear-&-Filltrapezoidal-BugFix
Feb 28, 2026
Merged

Fix missing infill layers (fill_surface_by_multilines & fill_surface_trapezoidal bug fix)#12516
ianalexis merged 5 commits into
OrcaSlicer:mainfrom
RF47:Fillrectilinear-&-Filltrapezoidal-BugFix

Conversation

@RF47

@RF47 RF47 commented Feb 27, 2026

Copy link
Copy Markdown
Collaborator

Description

Problem
When generating rectilinear infill, the surface is contracted by half the line width to avoid excessive overlap with perimeters. This contraction can cause the original ExPolygon to split into multiple separate Polygons. The previous code incorrectly handled this case by:

// if contraction results in empty polygon, use original surface
const ExPolygon &intersection_surface = contracted.empty() ? surface->expolygon : contracted.front();

This returns only the first polygon of the vector, which is why some sectors are left without infill lines.
I used the overloads that accept ExPolygons as an argument to avoid this problem.

Before:

image image

After:

image image

Fix #12510

@RF47 RF47 requested a review from ianalexis February 27, 2026 23:07
This reverts commit 0de21ad.
@RF47 RF47 changed the title fill_surface_by_multilines & fill_surface_trapezoidal bug fix fill_surface_by_multilines bug fix Feb 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes missing rectilinear infill in cases where contracting the surface by half line width splits the original ExPolygon into multiple polygons, by keeping the contracted geometry as ExPolygons and using overloads that accept multi-polygons.

Changes:

  • Preserve the contracted result as ExPolygons (instead of taking only .front()), and intersect infill lines against all resulting polygons.
  • Update the connect_infill call-site to work with the multi-polygon boundary representation.
  • Minor formatting/whitespace cleanup in the affected block.
Comments suppressed due to low confidence (3)

src/libslic3r/Fill/FillRectilinear.cpp:3027

  • contracted/intersection_surface are both declared const and intersection_surface is initialized via the ternary, which forces an extra copy of the ExPolygons in the non-empty case. Consider keeping contracted non-const and moving it into intersection_surface (or assigning into a single ExPolygons variable) to avoid copying potentially large polygons in this hot path.
    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;

src/libslic3r/Fill/FillRectilinear.cpp:3042

  • connect_infill(..., to_polygons(intersection_surface), ...) materializes a full Polygons copy (including all points) just to immediately take pointers inside Fill::connect_infill. Since there is already an overload taking std::vector<const Polygon*>, consider using to_polygon_ptrs(intersection_surface) and calling the pointer-based overload to avoid copying large geometry.
            connect_infill(std::move(fill_lines), to_polygons(intersection_surface), get_extents(surface->expolygon.contour), polylines_out,
                           this->spacing, params);

src/libslic3r/Fill/FillRectilinear.cpp:3031

  • This change fixes a regression where contracting by half line width can split the surface into multiple polygons, but there doesn’t appear to be a unit/regression test covering the multi-island contraction case for rectilinear/multiline infill. Please add a test (e.g., in tests/fff_print/test_fill.cpp) that constructs an ExPolygon which splits after offset_ex(-0.5*spacing) and asserts infill is produced in all resulting islands.
    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);


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@RF47 RF47 marked this pull request as ready for review February 28, 2026 00:42
@RF47 RF47 added the bug-fix label Feb 28, 2026
@RF47 RF47 marked this pull request as draft February 28, 2026 01:37
@RF47 RF47 marked this pull request as ready for review February 28, 2026 02:19
@RF47 RF47 changed the title fill_surface_by_multilines bug fix fill_surface_by_multilines & fill_surface_trapezoidal bug fix Feb 28, 2026
@RF47 RF47 changed the title fill_surface_by_multilines & fill_surface_trapezoidal bug fix Fix missing infill layers (fill_surface_by_multilines & fill_surface_trapezoidal bug fix) Feb 28, 2026
@RF47 RF47 marked this pull request as draft February 28, 2026 21:40
@RF47 RF47 marked this pull request as ready for review February 28, 2026 21:43

@ianalexis ianalexis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@ianalexis ianalexis merged commit 0ef8a79 into OrcaSlicer:main Feb 28, 2026
23 of 24 checks passed
@RF47 RF47 deleted the Fillrectilinear-&-Filltrapezoidal-BugFix branch February 28, 2026 21:56
@SoftFever

Copy link
Copy Markdown
Collaborator

Nice fix, thanks!

SoftFever pushed a commit that referenced this pull request Mar 1, 2026
…trapezoidal bug fix) (#12516)

* FillRectilinear bugfix

* cleaning

* Revert "cleaning"

This reverts commit 0de21ad.

* Filltrapezoidal is OK

* Filltrapezoidal fix 2
dbaarda pushed a commit to dbaarda/OrcaSlicer that referenced this pull request Mar 3, 2026
* upstream/main: (34 commits)
  Fix Bambu LAN printing with legacy network plugin (OrcaSlicer#12582)
  WIP: Parallelize macOS CI builds by splitting arm64 and x86_64 into separate jobs (OrcaSlicer#12562)
  VOLUMIC profils updates (OrcaSlicer#12565)
  Fix wiki redirection (OrcaSlicer#12569)
  Fix Celsius symbol not showing on G-code viewer (OrcaSlicer#12567)
  Revert "Revert "Set NSWindow color space to sRGB on macOS"" (OrcaSlicer#12546)
  Improve and complement the pt-BR translation (OrcaSlicer#12550)
  fix build errors on Linux with Clang 20 and GTK warnings (OrcaSlicer#12507)
  Fix "Glidlines" "gridlines locale (OrcaSlicer#12529)
  fix: typo "Glidlines" → "Gridlines" in View menu tooltip (OrcaSlicer#12527)
  Fix missing infill layers (fill_surface_by_multilines & fill_surface_trapezoidal bug fix) (OrcaSlicer#12516)
  fix missing translations for Canvas Toolbar Menu
  update profile version
  update locale
  Add option for hiding / showing gridlines (OrcaSlicer#10545)
  update locale and Simplified/Tranditional Chinese translation
  Enhancement: Enabling base patterns (infill) for Organic supports (OrcaSlicer#12141)
  I18n: Preview translations minor fix (Ukrainian) (OrcaSlicer#12504)
  update locale
  Fix: Init Serialized options (OrcaSlicer#12489)
  ...
Xipit pushed a commit to Xipit/OrcaSlicer that referenced this pull request Mar 16, 2026
…trapezoidal bug fix) (OrcaSlicer#12516)

* FillRectilinear bugfix

* cleaning

* Revert "cleaning"

This reverts commit 0de21ad.

* Filltrapezoidal is OK

* Filltrapezoidal fix 2
davidjdixon pushed a commit to davidjdixon/OrcaSlicer that referenced this pull request Mar 21, 2026
…trapezoidal bug fix) (OrcaSlicer#12516)

* FillRectilinear bugfix

* cleaning

* Revert "cleaning"

This reverts commit 0de21ad.

* Filltrapezoidal is OK

* Filltrapezoidal fix 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing infill in some layers

4 participants