fix(engine): use smallest remaining part as minimum remnant size

Skip remnants that are too small to fit any remaining part, avoiding
wasted fill attempts. Recalculated each iteration as quantities deplete.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-16 13:51:30 -04:00
parent 00ccf82196
commit 0b9a42e84c

View File

@@ -270,7 +270,23 @@ namespace OpenNest
while (madeProgress && !token.IsCancellationRequested)
{
madeProgress = false;
var freeBoxes = finder.FindRemnants(spacing);
// Minimum remnant size = smallest remaining part dimension
var minRemnantDim = double.MaxValue;
foreach (var item in effectiveRemainder)
{
if (localQty[item.Drawing.Name] <= 0)
continue;
var bb = item.Drawing.Program.BoundingBox();
var dim = System.Math.Min(bb.Width, bb.Length);
if (dim < minRemnantDim)
minRemnantDim = dim;
}
if (minRemnantDim == double.MaxValue)
break; // No items with remaining quantity
var freeBoxes = finder.FindRemnants(minRemnantDim);
if (freeBoxes.Count == 0)
break;