mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-25 11:17:40 -05:00
fix(fill): keep interlocked pairs that end within tolerance of an inner edge
With clamps on the sheet, Fill Area's clamp-clear check allowed only 1e-6 of overhang at an area edge that is not the sheet's, while the fillers allow the geometry tolerance at every edge. An interlocked pair whose partner ended a few millionths past the selected box lost both parts, so a box that holds two pairs of triangles got two singles. Inner edges sit at least the part spacing (or a clamp keep-out's spacing slack) from material, so allow the tolerance there when the spacing covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d4ad7a6201
commit
95e933b1ea
2 files changed
+30
-3
No files matched your search
@@ -247,6 +247,28 @@ public class ClampZoneInteractiveFillTests
|
||||
AssertClearOfClamps(parts, new Box(5, 0, 1, 0.5));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FillAreaKeepsToleranceOverhangAtAnInnerEdgeHeldOffByPartSpacing()
|
||||
{
|
||||
// A fill's interlocked partner can end a few millionths past the selected box (the
|
||||
// fillers' geometry tolerance); with clamps on the sheet both partners were dropped.
|
||||
var plate = MakePlate(new ClampZone("front-1", ZoneA));
|
||||
var area = new Box(30, 5, 4, 10);
|
||||
var overhang = OpenNest.Math.Tolerance.Epsilon * 0.5;
|
||||
var drawing = RectDrawing(2, 2);
|
||||
var item = new NestItem { Drawing = drawing };
|
||||
var proposed = new List<Part>
|
||||
{
|
||||
new(drawing, new Vector(area.Left, area.Bottom)),
|
||||
new(drawing, new Vector(area.Right - 2 + overhang, area.Bottom + 3)),
|
||||
};
|
||||
|
||||
var parts = PlateFillService.FillDroppingClampHits((_, _, _) => proposed.ToList(),
|
||||
plate, item, new List<NestItem> { item }, area, null, CancellationToken.None);
|
||||
|
||||
Assert.Equal(2, parts.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PackAreaNeverPacksInsideClampKeepOut()
|
||||
{
|
||||
|
||||
@@ -541,10 +541,15 @@ public static partial class PlateFillService
|
||||
{
|
||||
var bounds = part.BoundingBox;
|
||||
var full = plate.WorkArea();
|
||||
// The packer permits a tiny overhang only at a real sheet edge,
|
||||
// never across a remnant boundary cut by a clamp or another part.
|
||||
double Slack(double edge, double sheet) => System.Math.Abs(edge - sheet) < 1e-9
|
||||
// The fillers permit the geometry tolerance's overhang at every edge of their area. A
|
||||
// sheet edge always allows it. An inner edge is an occupant (or cut-off) held off by the
|
||||
// part spacing, or a clamp keep-out inflated by at least the spacing slack, so the
|
||||
// overhang stays inside that margin when the spacing is at least the slack; the material
|
||||
// checks below still confirm occupants and clamps. Without that margin, hold the edge.
|
||||
var innerSlack = plate.PartSpacing >= NestTolerances.SpacingSlack
|
||||
? NestTolerances.WorkAreaSlack : 1e-6;
|
||||
double Slack(double edge, double sheet) => System.Math.Abs(edge - sheet) < 1e-9
|
||||
? NestTolerances.WorkAreaSlack : innerSlack;
|
||||
if (bounds.Left < area.Left - Slack(area.Left, full.Left)
|
||||
|| bounds.Right > area.Right + Slack(area.Right, full.Right)
|
||||
|| bounds.Bottom < area.Bottom - Slack(area.Bottom, full.Bottom)
|
||||
|
||||
Reference in new issue
Block a user