feat: add Plate.BuildPerimeterCache with ShapeProfile and convex hull fallback
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -336,6 +336,48 @@ public class CutOffGeometryTests
|
||||
Assert.Equal(8, points.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlatePerimeterCache_ReturnsOneEntryPerPart()
|
||||
{
|
||||
var plate = new Plate(100, 100);
|
||||
plate.Parts.Add(new Part(new Drawing("a", MakeSquare(10))));
|
||||
plate.Parts.Add(new Part(new Drawing("b", MakeCircle(5))));
|
||||
plate.Parts.Add(new Part(new Drawing("c", MakeDiamond(8))));
|
||||
|
||||
var cache = Plate.BuildPerimeterCache(plate);
|
||||
Assert.Equal(3, cache.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlatePerimeterCache_SkipsCutOffParts()
|
||||
{
|
||||
var plate = new Plate(100, 100);
|
||||
plate.Parts.Add(new Part(new Drawing("real", MakeSquare(10))));
|
||||
plate.Parts.Add(new Part(new Drawing("cutoff", new Program()) { IsCutOff = true }));
|
||||
|
||||
var cache = Plate.BuildPerimeterCache(plate);
|
||||
Assert.Single(cache);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlatePerimeterCache_OpenContourUsesConvexHull()
|
||||
{
|
||||
var pgm = new Program();
|
||||
pgm.Codes.Add(new RapidMove(new Vector(0, 0)));
|
||||
pgm.Codes.Add(new LinearMove(new Vector(10, 0)));
|
||||
pgm.Codes.Add(new LinearMove(new Vector(10, 10)));
|
||||
|
||||
var plate = new Plate(100, 100);
|
||||
plate.Parts.Add(new Part(new Drawing("open", pgm)));
|
||||
|
||||
var cache = Plate.BuildPerimeterCache(plate);
|
||||
Assert.Single(cache);
|
||||
|
||||
var part = plate.Parts[0];
|
||||
Assert.True(cache.ContainsKey(part));
|
||||
Assert.NotNull(cache[part]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ShapeProfile_SelectsLargestShapeAsPerimeter()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user