[verified] add benchmark baseline and rotation fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using OpenNest.Geometry;
|
||||
using OpenNest.Engine.Jobs;
|
||||
using OpenNest.Engine.Jobs.Adapters;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Engine.Tests.Jobs;
|
||||
|
||||
@@ -101,6 +101,94 @@ public class NestJobGeometryTests
|
||||
Assert.Equal(NestJobStatus.Complete, boundedResult.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LegacyAllow180EquivalentPermitsFlippedCandidate()
|
||||
{
|
||||
var drawing = new Drawing("grain-aligned", TestDrawingFactory.Rectangle(4, 2));
|
||||
drawing.Constraints.StepAngle = System.Math.PI / 2;
|
||||
drawing.Constraints.StartAngle = 0;
|
||||
drawing.Constraints.EndAngle = 0;
|
||||
drawing.Constraints.Allow180Equivalent = true;
|
||||
var job = new NestJob(
|
||||
new[] { DrawingJobMapper.FromDrawing("part", drawing, 1) },
|
||||
new[] { new NestPlateStock("stock", new Size(10, 10), 1) }
|
||||
);
|
||||
|
||||
var result = Solve(job, new NestJobPlacement("part", 0, 4, 2, System.Math.PI));
|
||||
|
||||
Assert.Equal(NestJobStatus.Complete, result.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LegacyItemAllow180EquivalentPermitsFlippedCandidate()
|
||||
{
|
||||
var drawing = new Drawing("grain-aligned", TestDrawingFactory.Rectangle(4, 2));
|
||||
drawing.Constraints.Allow180Equivalent = true;
|
||||
var item = new NestItem
|
||||
{
|
||||
Drawing = drawing,
|
||||
Quantity = 1,
|
||||
StepAngle = System.Math.PI / 2,
|
||||
RotationStart = 0,
|
||||
RotationEnd = 0,
|
||||
};
|
||||
var job = new NestJob(
|
||||
new[] { DrawingJobMapper.FromItem("part", item) },
|
||||
new[] { new NestPlateStock("stock", new Size(10, 10), 1) }
|
||||
);
|
||||
|
||||
var result = Solve(job, new NestJobPlacement("part", 0, 4, 2, System.Math.PI));
|
||||
|
||||
Assert.Equal(NestJobStatus.Complete, result.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BoundedRotationPolicyAcceptsAnEquivalentFullTurn()
|
||||
{
|
||||
var part = new NestJobPart(
|
||||
"part",
|
||||
PartGeometrySnapshot.FromProgram(TestDrawingFactory.Rectangle(4, 2)),
|
||||
1,
|
||||
rotation: RotationPolicy.BoundedSweep(
|
||||
-System.Math.PI / 2,
|
||||
System.Math.PI / 2,
|
||||
System.Math.PI / 2
|
||||
)
|
||||
);
|
||||
var job = new NestJob(
|
||||
new[] { part },
|
||||
new[] { new NestPlateStock("stock", new Size(10, 10), 1) }
|
||||
);
|
||||
|
||||
var result = Solve(job, new NestJobPlacement("part", 0, 0, 4, 3 * System.Math.PI / 2));
|
||||
|
||||
Assert.Equal(NestJobStatus.Complete, result.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BoundedRotationSpanningFullTurnAcceptsGridAngleAndEquivalent()
|
||||
{
|
||||
var part = new NestJobPart(
|
||||
"part",
|
||||
PartGeometrySnapshot.FromProgram(TestDrawingFactory.Rectangle(4, 2)),
|
||||
1,
|
||||
rotation: RotationPolicy.BoundedSweep(0, 7, 1)
|
||||
);
|
||||
var job = new NestJob(
|
||||
new[] { part },
|
||||
new[] { new NestPlateStock("stock", new Size(10, 10), 1) }
|
||||
);
|
||||
|
||||
Assert.Equal(
|
||||
NestJobStatus.Complete,
|
||||
Solve(job, new NestJobPlacement("part", 0, 0, 0, 0)).Status
|
||||
);
|
||||
Assert.Equal(
|
||||
NestJobStatus.Complete,
|
||||
Solve(job, new NestJobPlacement("part", 0, 0, 0, System.Math.PI * 2)).Status
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EdgeTouchingIsAllowedAtZeroSpacingAndRejectedAtPositiveSpacing()
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.Geometry;
|
||||
using Xunit;
|
||||
using OpenNest.Engine.Jobs;
|
||||
using OpenNest.Engine.Jobs.Placement;
|
||||
using OpenNest.Geometry;
|
||||
using Xunit;
|
||||
|
||||
namespace OpenNest.Engine.Tests.Jobs;
|
||||
|
||||
@@ -169,6 +169,22 @@ public class PlateNesterParityTests
|
||||
Assert.Equal(2, ByPart(result)["arc"].Placed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RestrictedRotation_Enumerates180EquivalentFlip()
|
||||
{
|
||||
var anglesMethod = typeof(OrderedPlateNester).GetMethod(
|
||||
"Angles",
|
||||
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static
|
||||
);
|
||||
var policy = RotationPolicy.BoundedSweep(0, 0, System.Math.PI / 2, true);
|
||||
|
||||
var angles = (
|
||||
(IEnumerable<double>)anglesMethod!.Invoke(null, new object[] { policy })!
|
||||
).ToList();
|
||||
|
||||
Assert.Equal(new[] { 0.0, System.Math.PI }, angles);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FixedRotation_Respected()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user