Files
OpenNest/OpenNest.Core/CommonLineUsage.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

48 lines
1.8 KiB
C#

namespace OpenNest
{
/// <summary>
/// When automatic nesting and fills may place parts one kerf apart on a common line (see
/// docs/common-line-cutting.md). Only drawings with <see cref="Drawing.AllowCommonLine"/> take part.
/// </summary>
public enum CommonLineUsage
{
/// <summary>Never: engines and fills behave exactly as without common lines.</summary>
Off,
/// <summary>
/// Only when it places more parts (or, in a whole job, uses fewer sheets) than the best
/// layout without common lines; a tie keeps the layout without them.
/// </summary>
WhenItAddsParts,
/// <summary>
/// Whenever it shortens the cut or uses less material, never at the cost of a part:
/// part count still ranks first.
/// </summary>
Whenever,
}
}
namespace OpenNest
{
/// <summary>The names <see cref="CommonLineUsage"/> is saved under (nest files and defaults.json).</summary>
public static class CommonLineUsageNames
{
/// <summary>The saved name, or null for <see cref="CommonLineUsage.Off"/> (omitted).</summary>
public static string Format(CommonLineUsage usage) => usage switch
{
CommonLineUsage.WhenItAddsParts => "whenItAddsParts",
CommonLineUsage.Whenever => "whenever",
_ => null,
};
/// <summary>Reads a saved name case-insensitively; anything else is off.</summary>
public static CommonLineUsage Parse(string name) =>
string.Equals(name, "whenItAddsParts", System.StringComparison.OrdinalIgnoreCase)
? CommonLineUsage.WhenItAddsParts
: string.Equals(name, "whenever", System.StringComparison.OrdinalIgnoreCase)
? CommonLineUsage.Whenever
: CommonLineUsage.Off;
}
}