fix(rectangles): keep large-spacing clamp blocks off the clamp

When part spacing exceeds a clamp's inflated span the per-axis block
interval [zone - clearance + s, zone + clearance] inverts. The old
collapse to the zone centerline was not conservative: a part could
start exactly on the centerline with material inside the clamp
(PM d86d22c9 - the probe rail Box(0,0,5,0.625) at part spacing 4
completed at y=0.3125). Per decision D11, an inverted span now blocks
a zero-extent line at the clamp edge facing the sheet interior:
zone max + clearance when the zone center is in the bin's lower half
on that axis, else zone min - clearance + s, so interior-side parts
keep the exact bottom-edge clearance and the unavoidable extra
exclusion lands toward the nearer sheet edge.

Failing-first: the PM probe fixture in quadrants 1-4 and two X-inverted
fixtures (mid-rail and far-rail) were red on ab50900 against an
independent material-vs-inflated-footprint oracle; all six now pass.
Non-inverted spans stay bit-for-bit identical: four keep-row layout
digests captured from the unfixed ab50900 packer are unchanged, the
between-clamp rows still pack the gap, and the three zero-clamp C2
baseline hashes are untouched. Full Engine suite 929 passed/2 existing
skips.
This commit is contained in:
aj committed 2026-10-13 18:15:49 -04:00
1 parent 83ae1a48f0
commit 3f0a2703fd
2 files changed
+176 -9

No files matched your search

@@ -90,9 +90,14 @@ internal static class SheetPacker
/// inflated-box model an item at position p covers material [p, p + size] plus a trailing
/// part-spacing tail; blocking bin-local [zone - clearance + s, zone + clearance] per axis
/// therefore means exactly: item material keeps at least the bottom-edge clearance from
/// every clamp side, without paying any extra part-spacing tax there. A span that
/// degenerates because the spacing exceeds the inflated zone collapses to the zone
/// centerline - conservative (it forbids crossing the clamp), never permissive.
/// every clamp side, without paying any extra part-spacing tax there. When s exceeds the
/// inflated span the interval inverts (decision D11): block a zero-extent line at the
/// clamp edge facing the sheet interior — at (zone max + clearance) when the zone center
/// lies in the lower half of the bin on that axis, else at (zone min - clearance + s).
/// Parts on the interior side then keep the exact clearance; the unavoidable extra
/// exclusion (s - extent - 2*clearance) lands on the side toward the nearer sheet edge.
/// The old collapse to the zone centerline was NOT conservative: an item could start
/// exactly on the centerline with material inside the clamp.
/// Empty zone lists change nothing: the free list evolves bit-identically (C2).
/// </summary>
private static void BlockClamps(MaxRectsSheet sheet, NestPlateStock stock, Box work, double s)
@@ -110,17 +115,24 @@ internal static class SheetPacker
var right = x0(b.Right) + clearance;
if (right <= left)
{
var centerX = x0((b.Left + b.Right) * 0.5);
left = centerX;
right = centerX;
var center = x0((b.Left + b.Right) * 0.5);
// D11: the interior-facing clamp edge (toward the farther sheet edge).
var line = center < sheet.Width * 0.5
? x0(b.Right) + clearance
: x0(b.Left) - clearance + s;
left = line;
right = line;
}
var bottom = y0(b.Bottom) - clearance + s;
var top = y0(b.Top) + clearance;
if (top <= bottom)
{
var centerY = y0((b.Bottom + b.Top) * 0.5);
bottom = centerY;
top = centerY;
var center = y0((b.Bottom + b.Top) * 0.5);
var line = center < sheet.Height * 0.5
? y0(b.Top) + clearance
: y0(b.Bottom) - clearance + s;
bottom = line;
top = line;
}
sheet.Block(new Rect(left, bottom, right - left, top - bottom));
}