mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-05 07:09:25 -05:00
feat(engine): grow edge strips with Expand Spacing
Expand Spacing widened gaps between parts but left each part's strip to the sheet edge at the plate's edge spacing, so past twice that spacing the edge strip became the thinnest web on the plate. A strip takes heat from one cut while a web between parts takes it from two, so each edge strip now holds at least half the spacing (never less than EdgeSpacing). The pair search pushes edge parts inward and only accepts a spacing whose strips hold. The pattern stretch sizes each axis's strips from the smallest gap that axis widens, so stretching along the rows before the rows open does not use up the edge room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6834f2905a
commit
55e8ea6084
6 files changed
+322
-63
No files matched your search
@@ -387,7 +387,31 @@ namespace OpenNest.Engine.Fill
|
||||
var entryLow = bounds.Min(LowOf);
|
||||
var entryHigh = bounds.Max(HighOf);
|
||||
|
||||
// Stretched extent with no shift; null when it is wider than the area.
|
||||
// The smallest gap this stretch widens: between selected parts whose
|
||||
// lattice points differ along this axis. A gap across the other axis
|
||||
// (a row gap while stretching along the rows) is not this axis's to
|
||||
// open, and a shift moves the whole selection, so neither counts.
|
||||
var gaps = new Dictionary<double, double>();
|
||||
double GapAt(double scale)
|
||||
{
|
||||
if (!gaps.TryGetValue(scale, out var gap))
|
||||
gaps[scale] = gap = context.SelectedClearance(
|
||||
horizontal
|
||||
? Positions(scale, 0, ScaleY, shiftY)
|
||||
: Positions(ScaleX, shiftX, scale, 0),
|
||||
(a, b) => System.Math.Abs(Of(lattice[a]) - Of(lattice[b])) > tolerance);
|
||||
return gap;
|
||||
}
|
||||
|
||||
// Where the stretched selection may reach along this axis: each edge
|
||||
// strip at least half the gap this stretch widens.
|
||||
(double Low, double High) Room(double scale)
|
||||
{
|
||||
var limits = context.EdgeLimits(GapAt(scale));
|
||||
return horizontal ? (limits.Left, limits.Right) : (limits.Bottom, limits.Top);
|
||||
}
|
||||
|
||||
// Stretched extent with no shift; null when it is wider than its room.
|
||||
(double Low, double High)? Extent(double scale)
|
||||
{
|
||||
var low = double.MaxValue;
|
||||
@@ -398,7 +422,8 @@ namespace OpenNest.Engine.Fill
|
||||
low = System.Math.Min(low, LowOf(bounds[i]) + move);
|
||||
high = System.Math.Max(high, HighOf(bounds[i]) + move);
|
||||
}
|
||||
return high - low <= areaHigh - areaLow ? (low, high) : null;
|
||||
var room = Room(scale);
|
||||
return high - low <= room.High - room.Low ? (low, high) : null;
|
||||
}
|
||||
|
||||
double ShiftFor(double scale, Placement placement)
|
||||
@@ -410,7 +435,8 @@ namespace OpenNest.Engine.Fill
|
||||
Placement.High => entryHigh - high,
|
||||
_ => (entryLow + entryHigh - low - high) / 2,
|
||||
};
|
||||
return System.Math.Clamp(shift, areaLow - low, areaHigh - high);
|
||||
var room = Room(scale);
|
||||
return System.Math.Clamp(shift, room.Low - low, room.High - high);
|
||||
}
|
||||
|
||||
bool Valid(double scale, Placement placement)
|
||||
|
||||
Reference in new issue
Block a user