mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-30 05:41:33 -05:00
fix(irregular): cap Lattice block requests at the rectangle's capacity
Block requests were keyed and charged by every copy still wanted, so a high-demand part (140 copies) spent a large share of the work budget per Fill and never reused a block from one sheet to the next. Later sheets got no Lattice block for the strip beside their large parts: on N26-2J9 a 48 x 96 sheet held 25 small parts where a Fill of the strip holds 32. Requests now ask for at most what the rectangle's area could hold of the part's material. Fill stops at the copies asked only when it could place more, so the patterns are unchanged; they cost less and are shared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aa5675dc64
commit
eaf99fba8b
2 files changed
+53
-5
No files matched your search
@@ -44,6 +44,26 @@ public class IrregularBlockTests
|
||||
Assert.Same(block, catalog.Get(types[0], 7, new Box(0, 0, 60, 40), CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DemandBeyondTheRectanglesCapacityReusesOneFill()
|
||||
{
|
||||
// A 20 x 20 box holds at most 400 / 39 copies of the ell's material, so wanting 40 or 60
|
||||
// asks for the same Fill: one preparation, charged as for the capped copies.
|
||||
var job = Job(new[] { Part("ell", LShape(9, 7, 3), 60, RotationPolicy.Automatic) },
|
||||
new[] { Stock("sheet", 40, 60, spacing: 0.25) });
|
||||
var types = PartCatalog.Build(job);
|
||||
var counter = new WorkCounter();
|
||||
using var catalog = new BlockCatalog(0.25, types, NoPairs, counter, long.MaxValue);
|
||||
var box = new Box(0, 0, 20, 20);
|
||||
var block = catalog.Get(types[0], 60, box, CancellationToken.None);
|
||||
var charged = counter.Value;
|
||||
Assert.NotEmpty(block);
|
||||
Assert.Same(block, catalog.Get(types[0], 40, box, CancellationToken.None));
|
||||
Assert.Equal(1, catalog.PreparationCount);
|
||||
Assert.Equal(charged, counter.Value);
|
||||
Assert.True(charged < 60L * 60 * types[0].Orientations[0].Outline.Count);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0)]
|
||||
[InlineData(2.1)]
|
||||
@@ -115,9 +135,10 @@ public class IrregularBlockTests
|
||||
using var blocks = new BlockCatalog(0.25, types, NoPairs, counter, long.MaxValue);
|
||||
var strip = new Box(0, 0, 200, 2.5);
|
||||
Assert.Empty(blocks.Get(types[0], 20, strip, CancellationToken.None));
|
||||
// Counted and charged as the Fill would have been, so later decisions do not change.
|
||||
// Counted and charged as the Fill would have been, so later decisions do not change: for
|
||||
// the 13 copies the strip's 500 square inches could hold of the ell's 39, not all 20.
|
||||
Assert.Equal(1, blocks.PreparationCount);
|
||||
Assert.Equal(20L * 20 * types[0].Orientations[0].Outline.Count, counter.Value);
|
||||
Assert.Equal(13L * 13 * types[0].Orientations[0].Outline.Count, counter.Value);
|
||||
Assert.Empty(blocks.Band(types[0], 20, strip, CancellationToken.None));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user