mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-10 03:14:14 -04:00
test(cutting): keep both edge selections in corner classification theory
Scoped dotnet format removed the unused entityIndex parameter from TraversedBackwards_SquareCornersStayConvex, leaving MemberData supplying two values to a one-parameter theory (8 xUnit failures at test discovery). The parameter is now genuinely used: each geometric corner is classified from both adjacent entities of the reversed contour.
This commit is contained in:
1 parent
e75f68dbb6
commit
ed35b94e7f
1 file changed
+15
-3
@@ -94,11 +94,12 @@ public class AutomaticCornerClassificationTests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(CcwSquareCorners))]
|
||||
public void TraversedBackwards_SquareCornersStayConvex(Vector corner)
|
||||
public void TraversedBackwards_SquareCornersStayConvex(Vector corner, int entityIndex)
|
||||
{
|
||||
var shape = CwSquare();
|
||||
// Same geometric corners; entity order is reversed, so look the vertex up by position.
|
||||
var (entity, point) = NearestVertex(shape, corner);
|
||||
// Same geometric corners; entity order is reversed, so look the vertex up by position
|
||||
// and alternate between the two entities adjacent to it.
|
||||
var (entity, point) = AdjacentToVertex(shape, corner, entityIndex);
|
||||
|
||||
Assert.True(ContourCuttingStrategy.TryClassifyAutomaticStartCorner(
|
||||
shape, point, entity, out var found));
|
||||
@@ -232,6 +233,17 @@ public class AutomaticCornerClassificationTests
|
||||
: null;
|
||||
}
|
||||
|
||||
private static (Entity Entity, Vector Point) AdjacentToVertex(Shape shape, Vector vertex, int entityIndex)
|
||||
{
|
||||
// The two entities of the reversed contour that touch this geometric vertex;
|
||||
// entityIndex alternates between them so both edge selections are covered.
|
||||
var adjacent = shape.Entities
|
||||
.Where(e => StartOf(e).DistanceTo(vertex) <= 1e-9 || EndOf(e).DistanceTo(vertex) <= 1e-9)
|
||||
.ToList();
|
||||
Assert.Equal(2, adjacent.Count);
|
||||
return (adjacent[entityIndex % 2], vertex);
|
||||
}
|
||||
|
||||
private static (Entity Entity, Vector Point) NearestVertex(Shape shape, Vector approximate)
|
||||
{
|
||||
Entity? best = null;
|
||||
|
||||
Reference in new issue
Block a user