The job runner already checked sheet bounds on material contours only, but the benchmark validator and salvage scoring used Part.BoundingBox, which includes scribe/etch moves. A PEP bend tick that ends a hair past the part's edge passed the runner yet failed the benchmark when placed flush to the sheet edge, and it could shrink the credited offcut. Marks only mark the surface, so bounds and salvage now use material only. Benchmark before/after (all five built-in engines, local fixtures, salvage 0.5): no job changed validity or cost. Regression tests pin the new rule: a protruding tick flush to the sheet edge is valid in all four quadrants, and a tick past the parts envelope no longer shrinks salvage (targeted fixture cost 130 -> 120). Co-Authored-By: Codex <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.1 KiB
C#
49 lines
2.1 KiB
C#
using OpenNest.Benchmark;
|
|
using OpenNest.CNC;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Engine.Jobs.Adapters;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Tests.Benchmark;
|
|
|
|
public class NestLayoutCheckMarksTests
|
|
{
|
|
[Theory]
|
|
[InlineData(1)]
|
|
[InlineData(2)]
|
|
[InlineData(3)]
|
|
[InlineData(4)]
|
|
public void EtchTickPastFlushMaterialEdgePassesBoundsAndLeavesSalvageUnchanged(int quadrant)
|
|
{
|
|
var program = new Program();
|
|
program.MoveTo(0, 0);
|
|
program.LineTo(4, 0);
|
|
program.LineTo(4, 3);
|
|
program.LineTo(0, 3);
|
|
program.LineTo(0, 0);
|
|
var clean = new NestJobPart("part", PartGeometrySnapshot.FromProgram(program), 1);
|
|
program.MoveTo(3.75, 2);
|
|
program.Codes.Add(new LinearMove(4.25, 2) { Layer = LayerType.Scribe });
|
|
var marked = new NestJobPart("part", PartGeometrySnapshot.FromProgram(program), 1);
|
|
var stock = new NestPlateStock("sheet", new Size(10, 20), quadrant: quadrant);
|
|
var job = new NestJob(new[] { marked }, new[] { stock },
|
|
new NestJobOptions(salvageRate: 0.5, minimumSalvageDimension: 1));
|
|
var builder = new NestJobResultBuilder(job);
|
|
builder.AddSheet(stock, new[] { (marked.Id, stock.WorkArea.Right - 4, stock.WorkArea.Bottom, 0.0) });
|
|
var result = builder.Build(NestJobStopReason.Completed);
|
|
Assert.Empty(NestLayoutCheck.Violations(job, result));
|
|
var cleanJob = new NestJob(new[] { clean }, job.Plates, job.Options);
|
|
Assert.Equal(NestJobCost.Evaluate(cleanJob, result), NestJobCost.Evaluate(job, result));
|
|
|
|
var materialized = NestResultMaterializer.Materialize(job, result);
|
|
var requirements = new Dictionary<Drawing, (string, int)>
|
|
{
|
|
[materialized.DrawingsByPartId[marked.Id]] = (marked.Id, 1),
|
|
};
|
|
var runs = materialized.Nest.Plates.Select(p => (p, p.Parts.ToList())).ToList();
|
|
Assert.Contains(LegacyNestValidator.Validate(runs, requirements).Violations,
|
|
message => message.Contains("outside the work area"));
|
|
Assert.True(NestValidator.Validate(runs, requirements).Valid);
|
|
}
|
|
}
|