diff --git a/OpenNest.Core/Diagnostics/PlateOverlapAnalyzer.cs b/OpenNest.Core/Diagnostics/PlateOverlapAnalyzer.cs index a602a97c..72c8af06 100644 --- a/OpenNest.Core/Diagnostics/PlateOverlapAnalyzer.cs +++ b/OpenNest.Core/Diagnostics/PlateOverlapAnalyzer.cs @@ -339,6 +339,7 @@ public static class PlateOverlapAnalyzer { new Vector(zone.Left, zone.Bottom), new Vector(zone.Right, zone.Bottom), new Vector(zone.Right, zone.Top), new Vector(zone.Left, zone.Top), + new Vector(zone.Left, zone.Bottom), // Regions repeat their closing vertex exactly. }; var centre = new Vector((zone.Left + zone.Right) / 2, (zone.Bottom + zone.Top) / 2); return new PlateOverlapPair(part.Input.Id, ClampFindingSlot.IdFor(clamp.Ordinal), part.Input.Name, diff --git a/OpenNest.Tests/Diagnostics/PlateOverlapAnalyzerClampZoneTests.cs b/OpenNest.Tests/Diagnostics/PlateOverlapAnalyzerClampZoneTests.cs index 673e3efe..60f5dd38 100644 --- a/OpenNest.Tests/Diagnostics/PlateOverlapAnalyzerClampZoneTests.cs +++ b/OpenNest.Tests/Diagnostics/PlateOverlapAnalyzerClampZoneTests.cs @@ -214,6 +214,22 @@ public class PlateOverlapAnalyzerClampZoneTests Assert.Equal(overlaps, report.ClampFindings.Any(f => f.PartBName.Contains("tiny"))); } + // Region vertices repeat their closing vertex (PlateOverlapRegion contract); the desktop + // overlay drops the last vertex, so an open tiny-clamp rectangle drew as a triangle. + [Fact] + public void TinyClampFindingRegionIsAClosedRectangle() + { + var tiny = new ClampZone("tiny", new Box(8, 0, 1e-5, 1e-5)); + var parts = new List { new(Square("p", 2), new Vector(7.5, 0)) }; + + var report = PlateOverlapAnalyzer.Analyze(PlateOverlapAnalyzer.Capture(parts, new[] { tiny })); + + var region = Assert.Single(Assert.Single(report.ClampFindings).Regions); + Assert.Equal(5, region.Vertices.Count); + Assert.Equal(region.Vertices[0], region.Vertices[^1]); + Assert.Equal(4, region.Vertices.Take(4).Distinct().Count()); + } + // PM 407f5eb7: real material, not the 0.001 arc flattening, decides a tiny clamp. [Theory] [InlineData("rect", 8.00002, 0.5, true)]