using System;
namespace OpenNest.Engine.Jobs;
/// An immutable requirement, independent of drawing names, UI state, and drawing quantity counters.
public sealed class NestJobPart
{
/// Creates an immutable part requirement.
/// Unique requirement ID.
/// Snapshot of the part geometry.
/// Positive number requested.
/// Placement precedence: higher numbers are placed first and win scarce
/// stock. Zero is the default; negative numbers place after it. Equal priorities are peers.
/// Allowed rotations, or null for automatic rotation.
public NestJobPart(
string id,
PartGeometrySnapshot geometry,
int quantity,
int priority = 0,
RotationPolicy rotation = null
)
{
ArgumentException.ThrowIfNullOrWhiteSpace(id);
ArgumentNullException.ThrowIfNull(geometry);
if (quantity <= 0)
throw new ArgumentOutOfRangeException(nameof(quantity));
Id = id;
Geometry = geometry;
Quantity = quantity;
Priority = priority;
Rotation = rotation ?? RotationPolicy.Automatic;
}
public string Id { get; }
public PartGeometrySnapshot Geometry { get; }
/// Positive number requested; never decremented by placement code.
public int Quantity { get; }
///
/// Placement precedence: a higher number is placed first and wins scarce stock.
/// Zero is the default; negative numbers place after it. Parts with equal priority are peers.
///
public int Priority { get; }
public RotationPolicy Rotation { get; }
///
/// The part may share a common line with copies of itself when the job's
/// allows it (Drawing.AllowCommonLine).
///
public bool AllowCommonLine { get; init; }
}