Files
OpenNest/OpenNest.Engine/Jobs/NestJobPart.cs
T
ajandClaude Opus 5.5 b026bd19d2 feat(common-line): place parts on common lines automatically at a chosen level
Slice 3 of common-line cutting. On costly plate (N26-295: 3/16 RA310S at about
$2,500 a sheet) pairing parts one kerf apart fits the part the spacing cannot:
the last plate's 38 parts fit on one 48x120 with Auto Nest only with pairs.

- Drawing Properties gains "Allow common line" (Drawing.AllowCommonLine, off by
  default because customer edge-quality needs vary). The nest's CommonLineUsage
  (Off / When it adds parts / Whenever available) is set in Auto Nest and seeded
  from Tools > Nest Defaults; both persist (nest.json, defaults.json).
- NestPipeline runs the ordinary solve, then, with a level on, trials where
  eligible parts are offered as kerf-gap pair compounds. Placed pairs expand into
  parts plus explicit NestJobCommonLine groups, are validated again, and
  CommonLineRanking keeps a trial only by the level: count first, then sheets;
  "when it adds parts" keeps the plain layout on a tie, "whenever" also takes a
  shorter cut or less material, never at the cost of a part. Engines, FillScore
  and their comparers are unchanged; Off asks the engine exactly what it did.
- NestLayoutCheck exempts members only through a sheet's explicit group list and
  only when the job allows common lines; materializing and committing create
  Plate.CommonLines.
- Server nesting writes common-line jobs as version 3 and replays the recorded
  trial answers, so the desktop binds the same groups.
- Fill Area honors the level through a PlateFillService overload.
- The benchmark gains --common-lines <level> --kerf <k>.

Benchmark (synthetic nests + N26-295, --parallel 1): with no flag and with
--common-lines off every engine matches the base commit; with a level on no
layout becomes invalid and three runs save a sheet at equal nested area.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 19:38:00 -05:00

52 lines
2.0 KiB
C#

using System;
namespace OpenNest.Engine.Jobs;
/// <summary>An immutable requirement, independent of drawing names, UI state, and drawing quantity counters.</summary>
public sealed class NestJobPart
{
/// <summary>Creates an immutable part requirement.</summary>
/// <param name="id">Unique requirement ID.</param>
/// <param name="geometry">Snapshot of the part geometry.</param>
/// <param name="quantity">Positive number requested.</param>
/// <param name="priority">Placement precedence: higher numbers are placed first and win scarce
/// stock. Zero is the default; negative numbers place after it. Equal priorities are peers.</param>
/// <param name="rotation">Allowed rotations, or null for automatic rotation.</param>
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; }
/// <summary>Positive number requested; never decremented by placement code.</summary>
public int Quantity { get; }
/// <summary>
/// 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.
/// </summary>
public int Priority { get; }
public RotationPolicy Rotation { get; }
/// <summary>
/// The part may share a common line with copies of itself when the job's
/// <see cref="NestJobOptions.CommonLineUsage"/> allows it (<c>Drawing.AllowCommonLine</c>).
/// </summary>
public bool AllowCommonLine { get; init; }
}