feat(ui): wire strip engine into UI auto-nest flow
When Strip is selected in the engine dropdown, RunAutoNest_Click calls StripNestEngine.Nest() instead of sequential FillExact+Pack. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -785,8 +785,35 @@ namespace OpenNest.Forms
|
||||
if (plate != activeForm.PlateView.Plate)
|
||||
activeForm.LoadLastPlate();
|
||||
|
||||
// Split items: Fill produces great results for qty > 1,
|
||||
// Pack is fast for single-quantity items.
|
||||
var anyPlaced = false;
|
||||
|
||||
// Strip engine: use Nest() for multi-drawing strategy.
|
||||
if (NestEngineRegistry.Create(plate) is StripNestEngine)
|
||||
{
|
||||
var stripEngine = new StripNestEngine(plate);
|
||||
var stripParts = await Task.Run(() =>
|
||||
stripEngine.Nest(remaining, progress, token));
|
||||
|
||||
activeForm.PlateView.ClearTemporaryParts();
|
||||
|
||||
if (stripParts.Count > 0 && !token.IsCancellationRequested)
|
||||
{
|
||||
plate.Parts.AddRange(stripParts);
|
||||
activeForm.PlateView.Invalidate();
|
||||
anyPlaced = true;
|
||||
|
||||
// Deduct placed quantities.
|
||||
foreach (var item in remaining)
|
||||
{
|
||||
var placed = stripParts.Count(p =>
|
||||
p.BaseDrawing.Name == item.Drawing.Name);
|
||||
item.Quantity = System.Math.Max(0, item.Quantity - placed);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default: sequential Fill + Pack.
|
||||
var fillItems = remaining
|
||||
.Where(i => i.Quantity > 1)
|
||||
.OrderBy(i => i.Priority)
|
||||
@@ -798,7 +825,6 @@ namespace OpenNest.Forms
|
||||
.ToList();
|
||||
|
||||
var workArea = plate.WorkArea();
|
||||
var anyPlaced = false;
|
||||
|
||||
// Phase 1: Fill each multi-quantity drawing with NestEngine.
|
||||
foreach (var item in fillItems)
|
||||
@@ -829,8 +855,6 @@ namespace OpenNest.Forms
|
||||
|
||||
item.Quantity = System.Math.Max(0, item.Quantity - parts.Count);
|
||||
|
||||
// Compute remainder within the current work area based on
|
||||
// what was just placed — not the full plate bounding box.
|
||||
var placedBox = parts.Cast<IBoundable>().GetBoundingBox();
|
||||
workArea = ComputeRemainderWithin(workArea, placedBox, plate.PartSpacing);
|
||||
}
|
||||
@@ -852,7 +876,6 @@ namespace OpenNest.Forms
|
||||
activeForm.PlateView.Invalidate();
|
||||
anyPlaced = true;
|
||||
|
||||
// Deduct packed quantities.
|
||||
foreach (var item in packItems)
|
||||
{
|
||||
var placed = plate.Parts.Count(p =>
|
||||
@@ -862,6 +885,7 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!anyPlaced)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user