Files
OpenNest/OpenNest.Engine/Jobs/NestJob.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

39 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenNest.Engine.Jobs;
/// <summary>One material/unit system's requirements. Collections are copied; all nested values are immutable.</summary>
public sealed class NestJob
{
public NestJob(
IEnumerable<NestJobPart> parts,
IEnumerable<NestPlateStock> plates,
NestJobOptions options = null
)
{
Parts = Own(parts);
Plates = Own(plates);
Options = options ?? new NestJobOptions();
if (
Parts.Select(p => p.Id).Distinct(StringComparer.Ordinal).Count() != Parts.Count
|| Plates.Select(p => p.Id).Distinct(StringComparer.Ordinal).Count() != Plates.Count
)
throw new ArgumentException("Part and stock IDs must each be unique.");
}
public IReadOnlyList<NestJobPart> Parts { get; }
public IReadOnlyList<NestPlateStock> Plates { get; }
public NestJobOptions Options { get; }
internal static IReadOnlyList<T> Own<T>(IEnumerable<T> source)
{
ArgumentNullException.ThrowIfNull(source);
var values = source.ToArray();
if (values.Any(value => value is null))
throw new ArgumentException("Null entries are not allowed.", nameof(source));
return Array.AsReadOnly(values);
}
}