using System; using System.Threading; using OpenNest.Engine.Jobs; using OpenNest.Engine.Qwen38FlashNext.Engine; namespace OpenNest.Engine.Qwen38FlashNext; /// /// Independent whole-job nesting engine: bottom-left-first placement over convex /// No-Fit-Polygons with an exact material-clearance gate, driven sheet by sheet by a /// greedy demand scheduler. /// /// Per sheet, parts are demanded in the engine's own order (priority, then the /// largest material area, then id) and each requirement is drained greedily. For a part instance the engine enumerates its /// legal orientations (policy angles, or 0/90/180/270 plus the rotating-calipers /// minimum bounding rectangle for automatic rotation), builds for every placed part a /// convex NFP as placedHull (+) disk(spacing) (+) reflect(candidateHull) via its own /// Minkowski edge-merge, generates the corner-point feasible-region candidates (anchor /// box corners, NFP vertices, NFP-edge/box-line slides), and places the instance at the /// lowest-leftmost candidate whose exact material clearance the engine's collision gate /// accepts (cached-triangulation clip with a sound fast-shell prefilter). Which stock /// the next sheet uses is chosen by re-packing each available size and committing the /// trial that delivers the cheapest plate area per unit of part area placed; the /// job stops when demand is met, stock runs out, nothing further can be placed, or the /// plate cap is hit. See Engine/ for the placement core and README.md for the design /// write-up. /// /// /// The engine is self-contained: it calls no built-in , /// nester, filler, or runner, and is deterministic - identical input, identical layout. /// /// public sealed class Qwen38FlashNextNestingEngine : INestingEngine { public NestJobResult Solve( NestJob job, IProgress? progress = null, CancellationToken token = default ) { ArgumentNullException.ThrowIfNull(job); token.ThrowIfCancellationRequested(); var preparation = new PartPreparation(job.Parts); var solver = new JobSolver(job, preparation); return solver.Solve(progress, token); } }