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:
@@ -270,7 +270,23 @@ namespace OpenNest
|
|||||||
while (madeProgress && !token.IsCancellationRequested)
|
while (madeProgress && !token.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
madeProgress = false;
|
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)
|
if (freeBoxes.Count == 0)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user