fix(engine): use required spacing, not a sampled gap, when resequencing shrink-fill strips
SortStrips measured the gap between only the first two strips in original placement order and replayed that single value between every strip after reordering by height/width. Real (non-uniform) geometry produces varying inter-strip gaps, so resequencing could expand the total footprint beyond the plate's already-fitted work area, crashing StripPlateNester with "Candidate placement falls outside the usable stock area." Using the actual required spacing guarantees the resequenced span never exceeds the original, since real gaps are always >= spacing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -219,8 +219,10 @@ namespace OpenNest.Engine.Fill
|
||||
if (strips.Count <= 1)
|
||||
return;
|
||||
|
||||
var gap = stripMin(strips[1]) - stripMax(strips[0]);
|
||||
|
||||
// Use the required clearance as the inter-strip gap, not a gap sampled from one
|
||||
// original pair: actual placement gaps vary for irregular/mixed-size geometry, and
|
||||
// replaying a larger sampled gap across every reordered pair can push the trailing
|
||||
// strip past the original (already plate-fitted) footprint.
|
||||
strips.Sort((a, b) => sortMetric(a).CompareTo(sortMetric(b)));
|
||||
|
||||
var pos = primaryEdge(parts[0].BoundingBox);
|
||||
@@ -236,7 +238,7 @@ namespace OpenNest.Engine.Fill
|
||||
part.Offset(offset);
|
||||
}
|
||||
|
||||
pos = stripMax(s) + gap;
|
||||
pos = stripMax(s) + spacing;
|
||||
}
|
||||
|
||||
parts.Clear();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="OpenNest.Tests" />
|
||||
<InternalsVisibleTo Include="OpenNest.Engine.Tests" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenNest.Core\OpenNest.Core.csproj" />
|
||||
|
||||
Reference in New Issue
Block a user