fix(fill): refill clamp gaps in multi-part group fills

A group fill dropped every copy that hit a clamp and left the room it
freed empty. The gaps are now filled with whole copies, through the
gap search the single-part fill already used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-12-01 15:57:57 -05:00
1 parent 5bc39be8ca
commit 096cf9d663
2 files changed
+56 -9

No files matched your search

@@ -449,6 +449,36 @@ public class ClampZoneInteractiveFillTests
Assert.Equal(58, parts.Count);
}
[Fact]
public void GroupFillTakesTheGapsItsDroppedCopiesLeave()
{
// A copy of the two-part group that straddles a clamp is dropped whole; the room that
// leaves beside the clamps must take whole copies again.
var plate = RailPlate(out var zones);
var group = new List<Part>
{
new(RectDrawing(7, 7)),
new(RectDrawing(7, 7), new Vector(7 + PartSpacing, 0)),
};
var footprint = group.Select(part => part.BoundingBox).ToList().GetBoundingBox();
var parts = PlateFillService.FillGroup("Fill", plate, group, plate.WorkArea(),
null, CancellationToken.None);
// The service holds parts off a clamp by the validator's keep-out, which the fillers'
// edge tolerance may reach into by less than the spacing slack.
var keepOuts = zones.Select(zone => Inflated(zone, Edge - NestTolerances.SpacingSlack));
Assert.DoesNotContain(parts, part =>
keepOuts.Any(keepOut => Overlaps(part.BoundingBox, keepOut)));
Assert.Equal(0, parts.Count % group.Count);
var obstacles = zones.Select(zone => Inflated(zone, Edge))
.Concat(parts.Select(part => part.BoundingBox.Offset(PartSpacing))).ToList();
var gaps = new RemnantFinder(plate.WorkArea(), obstacles).FindRemnants();
Assert.DoesNotContain(gaps, gap =>
(gap.Length >= footprint.Length - 1e-6 && gap.Width >= footprint.Width - 1e-6)
|| (gap.Length >= footprint.Width - 1e-6 && gap.Width >= footprint.Length - 1e-6));
}
[Fact]
public void TheClampedRowLinesUpBetweenTheClamps()
{