From 5bc39be8ca83f72d94b039e166daeea6eae3fdf9 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 1 Dec 2026 15:31:25 -0500 Subject: [PATCH] fix(fill): refill clamp gaps when Ctrl+F fills one part The copy tool's Ctrl+F fills through FillGroup, which only dropped the parts that hit a clamp. A single part now fills through FillItem, so it also takes the gaps those drops leave (N26-2J7: 194 -> 195 parts). Co-Authored-By: Claude Opus 5.5 --- .../Jobs/ClampZoneInteractiveFillTests.cs | 15 +++++++++++++++ .../Jobs/Placement/PlateFillService.cs | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/OpenNest.Engine.Tests/Jobs/ClampZoneInteractiveFillTests.cs b/OpenNest.Engine.Tests/Jobs/ClampZoneInteractiveFillTests.cs index 03a2347c..d055c429 100644 --- a/OpenNest.Engine.Tests/Jobs/ClampZoneInteractiveFillTests.cs +++ b/OpenNest.Engine.Tests/Jobs/ClampZoneInteractiveFillTests.cs @@ -434,6 +434,21 @@ public class ClampZoneInteractiveFillTests Assert.Equal(58, parts.Count); } + [Fact] + public void SinglePartGroupFillTakesTheGapBesideTheClamps() + { + // The desktop's Ctrl+F fill passes the copied part as a group of one; it must refill + // the gap the dropped clamp hits leave, as the item fill does. + var plate = RailPlate(out var zones); + var group = new List { new(RectDrawing(15, 7)) }; + + var parts = PlateFillService.FillGroup("Fill", plate, group, plate.WorkArea(), + null, CancellationToken.None); + + AssertClearOfClamps(parts, zones); + Assert.Equal(58, parts.Count); + } + [Fact] public void TheClampedRowLinesUpBetweenTheClamps() { diff --git a/OpenNest.Engine/Jobs/Placement/PlateFillService.cs b/OpenNest.Engine/Jobs/Placement/PlateFillService.cs index 3aabeeab..5dbc6b50 100644 --- a/OpenNest.Engine/Jobs/Placement/PlateFillService.cs +++ b/OpenNest.Engine/Jobs/Placement/PlateFillService.cs @@ -336,6 +336,12 @@ public static partial class PlateFillService if (!InteractiveClamps.HasZones(plate)) return filler.Fill(groupParts, workArea, progress, token); + // One part fills as its drawing (PlateFiller.Fill does the same), so it also gets + // FillItem's refill of the gaps the dropped clamp hits leave. + if (groupParts.Count == 1) + return FillItem(strategy, plate, new NestItem { Drawing = groupParts[0].BaseDrawing }, + workArea, progress, token); + // As FillItem; a copy is dropped whole when any member hits a clamp. var groupSize = groupParts.Count; return FillBesideClamps(filler, plate, workArea, progress, token, (area, sink) =>