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) =>