Files
OpenNest/OpenNest.Benchmark/NestValidator.cs
T
7f63c725e6 refactor(engine): expose the layout validation contract to engines
Engines had to reverse-engineer the benchmark validator: Opus55 assumed a
0.01 arc tolerance (the validator uses 0.001), Gpt6Astra added hand-tuned
paddings and copied the validator's check order, Qwen picked its chord
tolerance to stay under a constant it could not reference.

NestTolerances publishes the validator's arc tolerance, the Clipper grid
and SafeClearanceMargin (with its derivation). NestLayoutCheck moves the
benchmark NestValidator's checks into OpenNest.Engine as a public API
(Clears for a part pair, Violations for a whole result); NestValidator is
now a thin wrapper. Verdicts are unchanged: tests compare ordered
violation lists against a frozen copy of the old validator, and a
tangent-disc stress test covers 432 pairs at the safe margin.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 08:54:54 -04:00

31 lines
1.2 KiB
C#

using System.Collections.Generic;
using OpenNest.Engine.Jobs;
namespace OpenNest.Benchmark;
/// <summary>Benchmark validation outcome.</summary>
public class ValidationResult
{
public bool Valid => Violations.Count == 0;
public List<string> Violations { get; } = new();
}
/// <summary>Compatibility wrapper over the shared layout validation contract.</summary>
public static class NestValidator
{
/// <summary>Checks materialized plates using drawing-reference requirement identity.</summary>
public static ValidationResult Validate(
List<(Plate Plate, List<Part> Parts)> plateRuns,
IReadOnlyDictionary<Drawing, (string Name, int Quantity)> requirements)
{
var result = new ValidationResult();
result.Violations.AddRange(NestLayoutCheck.Validate(plateRuns, requirements));
return result;
}
/// <summary>Appends offered-stock, finite-stock and rotation-policy violations.</summary>
public static void ValidateAgainstJob(NestJob job, NestJobResult jobResult,
IReadOnlyDictionary<string, string> displayNames, ValidationResult result) =>
NestLayoutCheck.ValidateAgainstJob(job, jobResult, displayNames, result.Violations);
}