mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 05:31:34 -05:00
feat(labels): etch each bend's group letter beside its bend line
A part bent two ways listed its bend groups in the label box, which did not say which bend was which. Each bend now gets its own circled letter beside its line, just past the band the bend rolls through, on either side and at the largest of the label text sizes that fits. The letters need no label box, so the box holds the part number only and the groups are no longer etched in it. The nest's units size the letters, so Plan Cutting callers pass them. The CAD Converter previews the letters for any part with bends. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5e378206d
commit
ae14101554
23 files changed
+880
-266
No files matched your search
@@ -83,15 +83,16 @@ public sealed class CuttingPlanBatch
|
||||
/// and <see cref="MaximumBudgetMultiplier"/>. The caller passes the operator's setting; the
|
||||
/// worker never reads it.
|
||||
/// </param>
|
||||
/// <param name="units">The nest's units, which size etched bend letters (docs/label-box.md).</param>
|
||||
public static CuttingPlanBatch Capture(IReadOnlyList<Plate> plates, CuttingParameters confirmedParameters,
|
||||
bool preservePartOrder, IReadOnlyList<int> plateNumbers = null, CancellationToken token = default,
|
||||
double budgetMultiplier = DefaultBudgetMultiplier) =>
|
||||
Capture(plates, confirmedParameters, preservePartOrder, plateNumbers, null, token, budgetMultiplier);
|
||||
double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches) =>
|
||||
Capture(plates, confirmedParameters, preservePartOrder, plateNumbers, null, token, budgetMultiplier, units);
|
||||
|
||||
/// <param name="reorderBudget">Overrides the new-order budget (tests); null gives <see cref="PlateBudget"/>.</param>
|
||||
internal static CuttingPlanBatch Capture(IReadOnlyList<Plate> plates, CuttingParameters confirmedParameters,
|
||||
bool preservePartOrder, IReadOnlyList<int> plateNumbers, int? reorderBudget, CancellationToken token,
|
||||
double budgetMultiplier = DefaultBudgetMultiplier)
|
||||
double budgetMultiplier = DefaultBudgetMultiplier, Units units = Units.Inches)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plates);
|
||||
ArgumentNullException.ThrowIfNull(confirmedParameters);
|
||||
@@ -125,7 +126,7 @@ public sealed class CuttingPlanBatch
|
||||
// over the same owned geometry, programs and freshness record.
|
||||
var captured = CuttingPlanService.Capture(CuttingPlanRequest.ForPlate(plate,
|
||||
expansionBudget: budget, confirmedParameters: confirmedParameters,
|
||||
preservePartOrder: preservePartOrder), token);
|
||||
preservePartOrder: preservePartOrder, units: units), token);
|
||||
var keepOrder = preservePartOrder ? captured : captured.WithPreservedOrder();
|
||||
var reorder = preservePartOrder ? null
|
||||
: reorderBudget is { } reorderLimit ? captured.WithSearchLimits(reorderLimit, captured.MaxEntries) : captured;
|
||||
@@ -133,7 +134,8 @@ public sealed class CuttingPlanBatch
|
||||
var fallback = reorder ?? keepOrder;
|
||||
if (fallback.Failure == CuttingPlanStatus.UnsupportedGeometry)
|
||||
fallback = CuttingPlanService.Capture(CuttingPlanRequest.ForPlate(plate,
|
||||
confirmedParameters: confirmedParameters, preservePartOrder: preservePartOrder), token, bestEffort: true);
|
||||
confirmedParameters: confirmedParameters, preservePartOrder: preservePartOrder, units: units),
|
||||
token, bestEffort: true);
|
||||
entries[index] = new(plate, plateNumbers?[index] ?? index + 1, reorder, keepOrder, overlap, fallback);
|
||||
}
|
||||
return new(entries, owned);
|
||||
|
||||
@@ -38,10 +38,10 @@ public sealed class CuttingPlanRequest
|
||||
/// </summary>
|
||||
public static CuttingPlanRequest ForPlate(Plate plate, Vector startPoint = default, int expansionBudget = 20000,
|
||||
CuttingParameters confirmedParameters = null, IEnumerable<Part> eligibleParts = null,
|
||||
bool preservePartOrder = false, int maxEntries = 16) =>
|
||||
bool preservePartOrder = false, int maxEntries = 16, Units units = Units.Inches) =>
|
||||
new(plate?.Parts, startPoint, expansionBudget, confirmedParameters, eligibleParts,
|
||||
preservePartOrder, maxEntries)
|
||||
{ Plate = plate, SupportBed = plate?.SupportBed, SupportQuadrant = plate?.Quadrant ?? 1 };
|
||||
{ Plate = plate, SupportBed = plate?.SupportBed, SupportQuadrant = plate?.Quadrant ?? 1, Units = units };
|
||||
|
||||
/// <summary>The plate scope, or null for a detached part list that cannot be applied.</summary>
|
||||
public Plate Plate { get; private init; }
|
||||
@@ -55,6 +55,12 @@ public sealed class CuttingPlanRequest
|
||||
|
||||
/// <summary>The sheet quadrant that places <see cref="SupportBed"/> on the parts' coordinates.</summary>
|
||||
public int SupportQuadrant { get; init; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The units the parts are drawn in (the nest's), which size the bend letters etched beside
|
||||
/// bend lines (docs/label-box.md).
|
||||
/// </summary>
|
||||
public Units Units { get; init; } = Units.Inches;
|
||||
public CuttingParameters ConfirmedParameters { get; }
|
||||
public IReadOnlyList<Part> EligibleParts { get; }
|
||||
public bool PreservePartOrder { get; }
|
||||
|
||||
@@ -71,6 +71,8 @@ public static class CuttingPlanService
|
||||
var identities = new HashSet<Part>(ReferenceEqualityComparer.Instance);
|
||||
// Every part's box, read once, for slug slices to keep clear of parts nested in a cutout.
|
||||
Box[] partBoxes = null;
|
||||
// Where each drawing's bend letters go: the same for all its parts, so found once.
|
||||
var bendSpots = new Dictionary<Drawing, List<BendLabelSpot>>(ReferenceEqualityComparer.Instance);
|
||||
// The sheet every planned lead must stay on; none for a detached part list or a plate
|
||||
// with no usable size, which the pre-post plate edge check reports instead.
|
||||
var plateSize = request.Plate?.Size;
|
||||
@@ -165,8 +167,17 @@ public static class CuttingPlanService
|
||||
// The label is etched, never material: clean bounds and lead material skip scribe
|
||||
// moves, and the planner emits them like any other mark (docs/label-box.md).
|
||||
else if (request.ConfirmedParameters?.LabelMode is { } labelMode && labelMode != PartLabelMode.Off)
|
||||
PartLabels.AddTo(ownedClean, source.BaseDrawing, source.Rotation,
|
||||
request.Plate?.GrainAngle ?? 0, labelMode);
|
||||
{
|
||||
var grain = request.Plate?.GrainAngle ?? 0;
|
||||
PartLabels.AddTo(ownedClean, source.BaseDrawing, source.Rotation, labelMode);
|
||||
// Each bend's own group letter beside its line, so the groups can be told apart.
|
||||
if (labelMode == PartLabelMode.PartNumberAndBendGroups)
|
||||
{
|
||||
if (!bendSpots.TryGetValue(source.BaseDrawing, out var spots))
|
||||
bendSpots[source.BaseDrawing] = spots = BendLabels.Spots(source.BaseDrawing, request.Units);
|
||||
BendLabels.AddTo(ownedClean, source.BaseDrawing, spots, source.Rotation, grain);
|
||||
}
|
||||
}
|
||||
// Material extent only: remote rapids and scribe marks must not widen it, or a
|
||||
// genuine insert could fail the containment prefilter.
|
||||
var cleanBounds = NestedPartContainment.CleanBounds(ownedClean, source.Location, token);
|
||||
|
||||
Reference in new issue
Block a user