mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-25 11:17:40 -05:00
Raster packs each part rotation as a bit mask of its material grown by half the part spacing plus 0.75 cell, so masks that never share a cell keep the spacing and every layout passes the layout check unrepaired. Coarse raster no-fit maps propose positions and a grid four times finer settles them; the job is decoded in 48 greedy variants through the shared stock loop. It is selectable by name, not a Default candidate. Benchmark, 7 real jobs, --parallel 1, 6" minimum salvage: all layouts valid; Irregular's sheet count on 5 jobs in 0.6-2.3 s against 11-78 s, at under 1 to 4% more salvage-credited cost; 3 sheets against 2 on 27K; 24 s on 2J9 (seven stock sizes). Packing tighter and opening the gaps with Fix Spacing saved under 0.1% of cost for up to 25 times the time, so it was left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.1 KiB
C#
61 lines
2.1 KiB
C#
using OpenNest.Clamps;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Engine.NestingEngines.Raster;
|
|
using OpenNest.Geometry;
|
|
using Xunit;
|
|
using static OpenNest.Engine.Tests.NestingEngines.JobBuilder;
|
|
using static OpenNest.Engine.Tests.NestingEngines.Shapes;
|
|
|
|
namespace OpenNest.Engine.Tests.NestingEngines;
|
|
|
|
public class RasterNestingEngineTests
|
|
{
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(0.02)]
|
|
[InlineData(0.25)]
|
|
[InlineData(1)]
|
|
public void MasksKeepTheSpacingWithoutRepair(double spacing)
|
|
{
|
|
// Arcs, notches and holes: every layout must pass the layout check as decoded.
|
|
var job = Job(
|
|
[
|
|
Part("ring", Ring(6, 3), 6),
|
|
Part("ell", LShape(9, 7, 3), 8),
|
|
Part("tri", Triangle(7, 7), 8),
|
|
Part("disc", Disc(1), 10),
|
|
],
|
|
[Stock("s", 24, 36, spacing)]);
|
|
var result = new RasterNestingEngine().Solve(job);
|
|
LayoutAssert.Valid(job, result);
|
|
Assert.Equal(NestJobStatus.Complete, result.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void SmallPartsNestInHoles()
|
|
{
|
|
// A 1 x 1 square fits a 10-wide ring's 8-wide hole; the sheet only holds the ring.
|
|
var job = Job([Part("ring", Ring(10, 8), 1), Part("square", Rectangle(1, 1), 4)],
|
|
[Stock("s", 10.2, 10.2, 0.1, quantity: 1)]);
|
|
var result = new RasterNestingEngine().Solve(job);
|
|
LayoutAssert.Valid(job, result);
|
|
Assert.Equal(NestJobStatus.Complete, result.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void ClampKeepOutsStayClear()
|
|
{
|
|
var job = Job([Part("ell", LShape(4, 3, 1), 20)],
|
|
[Stock("s", 20, 20, 0.2, clampZones: [new ClampZone("c", new Box(8, 0, 4, 2))])]);
|
|
var result = new RasterNestingEngine().Solve(job);
|
|
LayoutAssert.Valid(job, result);
|
|
Assert.Equal(NestJobStatus.Complete, result.Status);
|
|
}
|
|
|
|
[Fact]
|
|
public void IsRegistered() =>
|
|
Assert.IsType<RasterNestingEngine>(NestingEngineRegistry.Create("Raster"));
|
|
}
|
|
|
|
public sealed class RasterContractTests : EngineContractTests<RasterNestingEngine> { }
|