fix(engine): compute remainder from just-placed parts within current work area
ComputeRemainderStrip used the bounding box of ALL plate parts against the full plate, missing large interior gaps between drawing groups. Now computes remainder within the current work area based on only the parts that were just placed. This lets subsequent drawings fill the gap between previous drawing groups instead of being forced into a tiny strip at the plate edge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -354,10 +354,11 @@ static class NestConsole
|
||||
if (parts.Count > 0)
|
||||
{
|
||||
plate.Parts.AddRange(parts);
|
||||
Compactor.Compact(parts, plate);
|
||||
// TODO: Compactor.Compact(parts, plate);
|
||||
item.Quantity = System.Math.Max(0, item.Quantity - parts.Count);
|
||||
success = true;
|
||||
workArea = ComputeRemainderStrip(plate);
|
||||
var placedBox = parts.Cast<IBoundable>().GetBoundingBox();
|
||||
workArea = ComputeRemainderWithin(workArea, placedBox, plate.PartSpacing);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,22 +386,16 @@ static class NestConsole
|
||||
return (success, sw.ElapsedMilliseconds);
|
||||
}
|
||||
|
||||
static Box ComputeRemainderStrip(Plate plate)
|
||||
static Box ComputeRemainderWithin(Box workArea, Box usedBox, double spacing)
|
||||
{
|
||||
if (plate.Parts.Count == 0)
|
||||
return plate.WorkArea();
|
||||
|
||||
var usedBox = plate.Parts.Cast<IBoundable>().GetBoundingBox();
|
||||
var fullArea = plate.WorkArea();
|
||||
|
||||
var hWidth = fullArea.Right - usedBox.Right - plate.PartSpacing;
|
||||
var hWidth = workArea.Right - usedBox.Right - spacing;
|
||||
var hStrip = hWidth > 0
|
||||
? new Box(usedBox.Right + plate.PartSpacing, fullArea.Y, hWidth, fullArea.Length)
|
||||
? new Box(usedBox.Right + spacing, workArea.Y, hWidth, workArea.Length)
|
||||
: Box.Empty;
|
||||
|
||||
var vHeight = fullArea.Top - usedBox.Top - plate.PartSpacing;
|
||||
var vHeight = workArea.Top - usedBox.Top - spacing;
|
||||
var vStrip = vHeight > 0
|
||||
? new Box(fullArea.X, usedBox.Top + plate.PartSpacing, fullArea.Width, vHeight)
|
||||
? new Box(workArea.X, usedBox.Top + spacing, workArea.Width, vHeight)
|
||||
: Box.Empty;
|
||||
|
||||
return hStrip.Area() >= vStrip.Area() ? hStrip : vStrip;
|
||||
|
||||
Reference in New Issue
Block a user