feat: fast-path fill and dual-axis shrink for low quantities

For qty 1-2, skip the full 6-strategy pipeline: place a single part
or a best-fit pair directly. For larger low quantities, shrink the
work area in both dimensions (sqrt scaling with 2x margin) before
running strategies, with fallback to full area if insufficient.

- Add TryFillSmallQuantity fast path (qty=1 single, qty=2 best-fit pair)
- Add ShrinkWorkArea with proportional dual-axis reduction
- Extract RunFillPipeline helper from Fill()
- Make ShrinkFiller.EstimateStartBox internal with margin parameter
- Add MaxQuantity to FillContext for strategy-level access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-30 00:38:44 -04:00
parent ab09f835d3
commit e3b388464d
3 changed files with 167 additions and 17 deletions

View File

@@ -94,8 +94,8 @@ namespace OpenNest.Engine.Fill
/// that fits roughly the target count. Scales the shrink axis proportionally
/// from the full-area count down to the target, with margin.
/// </summary>
private static Box EstimateStartBox(NestItem item, Box box,
double spacing, ShrinkAxis axis, int targetCount)
internal static Box EstimateStartBox(NestItem item, Box box,
double spacing, ShrinkAxis axis, int targetCount, double marginFactor = 1.3)
{
var bbox = item.Drawing.Program.BoundingBox();
if (bbox.Width <= 0 || bbox.Length <= 0)
@@ -115,7 +115,7 @@ namespace OpenNest.Engine.Fill
// Scale dimension proportionally: target/full * maxDim, with margin.
var ratio = (double)targetCount / fullCount;
var estimate = maxDim * ratio * 1.3;
var estimate = maxDim * ratio * marginFactor;
estimate = System.Math.Min(estimate, maxDim);
if (estimate <= 0 || estimate >= maxDim)