Files
OpenNest/OpenNest.Engine/Jobs/FixedStrategyNestingEngine.cs
T
aj 451841401a refactor(engine): align namespaces with directory layout under OpenNest.Engine
All 132 OpenNest.Engine source files now declare namespaces matching
their nested directories: Jobs/, Jobs/Placement/, Jobs/Adapters/,
Fill/, RectanglePacking/, CirclePacking/, and engine-root types moved
from 'OpenNest' to 'OpenNest.Engine'. RootNamespace updated accordingly.
Consumers (Api, Console, Mcp, Benchmark, Training, desktop app, tests)
gained the explicit usings the move requires; CLAUDE.md updated.
2026-09-21 13:18:34 -04:00

38 lines
1.2 KiB
C#

using System;
using System.Threading;
namespace OpenNest.Engine.Jobs;
/// <summary>
/// Adapts one fixed IPlateNester strategy to the whole-job INestingEngine contract, so it can compete
/// as a full job solver alongside model-submitted engines. Delegates all multi-plate/size selection to
/// NestJobRunner; only the placement strategy key is forced, overriding whatever the job itself declared.
/// </summary>
public sealed class FixedStrategyNestingEngine : INestingEngine
{
private readonly string strategy;
private readonly NestJobRunner runner = new(PlateNesterFactory.Create);
public FixedStrategyNestingEngine(string strategy)
{
if (string.IsNullOrWhiteSpace(strategy))
throw new ArgumentException("Strategy cannot be null or whitespace.", nameof(strategy));
this.strategy = strategy;
}
public NestJobResult Solve(
NestJob job,
IProgress<NestJobProgress> progress = null,
CancellationToken token = default
)
{
ArgumentNullException.ThrowIfNull(job);
var forced = new NestJob(
job.Parts,
job.Plates,
new NestJobOptions(strategy, job.Options.MaxPlates)
);
return runner.Solve(forced, progress, token);
}
}