mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-14 18:21:55 -04:00
fix(clamps): retain complete groups ahead of partial fill tails
This commit is contained in:
1 parent
74544c689a
commit
104b0aef99
2 files changed
+24
-2
No files matched your search
@@ -127,6 +127,26 @@ public class ClampZoneInteractiveFillTests
|
||||
AssertClearOfClamps(result, new Box(15, 0, 1.5, 0.625));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillGroupRetainsCompleteCopiesAheadOfAPartialTrailingCopy()
|
||||
{
|
||||
var drawing = RectDrawing(2, 2);
|
||||
var group = new List<Part>
|
||||
{
|
||||
new(drawing, new Vector(0, 0)), new(drawing, new Vector(3, 0)),
|
||||
};
|
||||
var plate = new Plate(new Size(20, 20)) { PartSpacing = 0 };
|
||||
var area = new Box(0, 0, 8, 2);
|
||||
var original = PlateFillService.FillGroup("Fill", plate, group, area,
|
||||
null, CancellationToken.None);
|
||||
Assert.True(original.Count > group.Count && original.Count % group.Count != 0,
|
||||
$"expected a full copy and partial tail, got {original.Count}");
|
||||
plate.ClampZones.Add(new ClampZone("remote", new Box(18, 0, 1, 0.5)));
|
||||
var clamped = PlateFillService.FillGroup("Fill", plate, group, area,
|
||||
null, CancellationToken.None);
|
||||
Assert.Equal(group.Count, clamped.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillGroupRejectsTheWholeCopyWhenOnlyOneMemberTouchesAClamp()
|
||||
{
|
||||
|
||||
@@ -203,9 +203,11 @@ public static class PlateFillService
|
||||
Box area, List<NestItem> demand = null, List<Part> previouslyPlaced = null,
|
||||
int groupSize = 1)
|
||||
{
|
||||
if (proposed == null || groupSize < 1 || proposed.Count % groupSize != 0)
|
||||
if (proposed == null || groupSize < 1)
|
||||
return;
|
||||
for (var start = 0; start < proposed.Count; start += groupSize)
|
||||
// FillLinear may append an incomplete trailing tile. Keep complete copies
|
||||
// ahead of it, but never expose the incomplete tail as a group.
|
||||
for (var start = 0; start + groupSize <= proposed.Count; start += groupSize)
|
||||
{
|
||||
// A group is one proposal: never return just its frame or just its
|
||||
// insert when a member collides with a clamp or occupied material.
|
||||
|
||||
Reference in new issue
Block a user