mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-21 22:37:41 -05:00
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>
This commit is contained in:
1 parent
f9b2713420
commit
b026bd19d2
61 files changed
+2155
-118
No files matched your search
@@ -52,6 +52,12 @@ public sealed class NestDefaults
|
||||
/// </summary>
|
||||
public Guid? MachineId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The common-line usage new nests start with (<see cref="Nest.CommonLineUsage"/>). Off by
|
||||
/// default; saved as <c>commonLineUsage</c> and omitted when off.
|
||||
/// </summary>
|
||||
public CommonLineUsage CommonLineUsage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The built-in defaults used when no file exists and for every field
|
||||
/// that is missing or invalid. Matches the historical
|
||||
@@ -176,6 +182,9 @@ public sealed class NestDefaults
|
||||
&& Guid.TryParse(machineId.GetString(), out var machine) && machine != Guid.Empty)
|
||||
defaults.MachineId = machine;
|
||||
|
||||
if (dto.CommonLineUsage is { ValueKind: JsonValueKind.String } usage)
|
||||
defaults.CommonLineUsage = CommonLineUsageNames.Parse(usage.GetString());
|
||||
|
||||
return defaults;
|
||||
}
|
||||
|
||||
@@ -201,6 +210,7 @@ public sealed class NestDefaults
|
||||
PartSpacing = plate.PartSpacing,
|
||||
EdgeSpacing = plate.EdgeSpacing,
|
||||
MachineId = nest.Machine?.Id,
|
||||
CommonLineUsage = nest.CommonLineUsage,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,6 +231,19 @@ public sealed class NestDefaults
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="FromPlate(Units, Plate)"/>, keeping the settings a plate does not hold (the
|
||||
/// common-line usage) from <paramref name="saved"/>, the defaults being replaced, so saving a
|
||||
/// plate as the defaults never resets them.
|
||||
/// </summary>
|
||||
public static NestDefaults FromPlate(Units units, Plate plate, NestDefaults saved)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(saved);
|
||||
var defaults = FromPlate(units, plate);
|
||||
defaults.CommonLineUsage = saved.CommonLineUsage;
|
||||
return defaults;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// These defaults in <paramref name="units"/>: plate size and spacings are converted
|
||||
/// (25.4 mm per inch) and rounded to four decimals; the quadrant is kept. Returns a copy
|
||||
@@ -239,6 +262,7 @@ public sealed class NestDefaults
|
||||
EdgeSpacing = new Spacing(Convert(EdgeSpacing.Left), Convert(EdgeSpacing.Bottom),
|
||||
Convert(EdgeSpacing.Right), Convert(EdgeSpacing.Top)),
|
||||
MachineId = MachineId,
|
||||
CommonLineUsage = CommonLineUsage,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -253,6 +277,7 @@ public sealed class NestDefaults
|
||||
plate.Quadrant = Quadrant;
|
||||
plate.PartSpacing = PartSpacing;
|
||||
plate.EdgeSpacing = EdgeSpacing;
|
||||
nest.CommonLineUsage = CommonLineUsage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -282,6 +307,8 @@ public sealed class NestDefaults
|
||||
Top = EdgeSpacing.Top,
|
||||
},
|
||||
MachineId = MachineId is { } machineId ? JsonSerializer.SerializeToElement(machineId.ToString()) : null,
|
||||
CommonLineUsage = CommonLineUsageNames.Format(CommonLineUsage) is { } usage
|
||||
? JsonSerializer.SerializeToElement(usage) : null,
|
||||
};
|
||||
|
||||
return JsonSerializer.Serialize(dto, JsonOptions);
|
||||
@@ -316,6 +343,8 @@ public sealed class NestDefaults
|
||||
// Raw JSON for the same reason as Units.
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public JsonElement? MachineId { get; init; }
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public JsonElement? CommonLineUsage { get; init; }
|
||||
}
|
||||
|
||||
private sealed record SizeDto
|
||||
|
||||
Reference in new issue
Block a user