mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-28 18:41:35 -05:00
feat(common-line): cut each shared line once through Plan Cutting and the CI Fiber post
N26-295's PT42 pairs saved spacing in slice 1 but every shared edge was still cut twice, costing a pass per edge and risking a freed part tipping under the head on the second pass. Plan Cutting now cuts a plate's common lines once unless the plate is set to cut them twice. Each group is cut member by member, owner before partner (a captured dependency that search and replay enforce, so a kept order cutting the partner first is a constraint conflict): the member's holes, then the shared cuts it owns as open CommonLine centerline cuts entered through the notch on the span's axis, then its remainder pieces, each ramped in from the kerf the shared cut opened. Capture marks the shared spans as tabs on the owned clean copy, so replay's contour accounting proves each perimeter is cut exactly once; a lead that fits at neither end refuses as UnsupportedGeometry naming the span, never shortened. Material still comes from the drawing, so utilization, quantity and overlap results do not change. Members are never support-tabbed; locked or excluded members and broken groups refuse. The CI Fiber post writes shared cuts in the cut-off form with a lead-in and no G41/G42, and remainders in the contour form on their perimeter's compensation side, named by a remainder comment. Cincinnati CL (whose PreApplied mode offsets nothing) and Gravograph refuse such nests, as do the desktop and console for any post without ICommonLinePostProcessor; nothing falls back to a silent double cut. Plate > Arrange > Cut Common Lines Twice keeps slice 1's behavior, persists with the plate and makes an open plan stale. Pre-post review now checks each span is cut once, on its centerline, by the member cut first, and the rapid check treats a finished member's remainders as an obstacle. Compensation start in void and cancel in kerf are unconfirmed on the CI FIBER 4020; release waits on a 3/16 stainless coupon trial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b630b50b7b
commit
f9b2713420
49 files changed
+1905
-73
No files matched your search
@@ -72,7 +72,7 @@ Read the relevant contract before changing its behavior:
|
||||
- [Breakoffs](docs/breakoffs.md): tabbed scrap; `Break`-layer open cuts that are cut but are not material
|
||||
- [Tabbed cutouts](docs/tabbed-cutouts.md): holes cut in pieces around `Tab`-layer spans that are material but never cut; nesting reads material through `NestingMaterial.ForNesting`, so nothing nests in them
|
||||
- [Dimensions](docs/dimensions.md): CAD Converter annotations that store placement only, are measured from the cut geometry when shown and never affect the program
|
||||
- [Common-line cutting](docs/common-line-cutting.md): parts one kerf apart in `Plate.CommonLines` share an edge; spans are derived, never stored, and spacing checks hold group members to the kerf. Each shared edge is still cut twice; single-pass cutting is not built
|
||||
- [Common-line cutting](docs/common-line-cutting.md): parts one kerf apart in `Plate.CommonLines` share an edge; spans are derived, never stored, and spacing checks hold group members to the kerf. Plan Cutting cuts each shared span once (owner first, open `CommonLine` centerline cut, then each member's remainder) unless the plate is set to cut them twice; only posts implementing `ICommonLinePostProcessor` (CI Fiber) may write it, others refuse. Machine trial pending
|
||||
- [Support tabs](docs/support-tabs.md): the nest's support grid, the center-of-gravity check, and Plan Cutting's tab placement for parts the grid cannot hold level
|
||||
- [Material-overlap diagnostics](docs/geometry/visual-overlap-check.md)
|
||||
- [Automatic cutoffs and sequencing](docs/automatic-scrap-cutoffs.md)
|
||||
|
||||
@@ -1013,6 +1013,17 @@ static class NestConsole
|
||||
return false;
|
||||
}
|
||||
|
||||
// A common line cut once needs a post that writes it; none falls back to cutting it twice.
|
||||
try
|
||||
{
|
||||
OpenNest.CNC.CommonLineCuts.EnsurePostable(nest, post);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
Console.Error.WriteLine($"Error: {ex.Message} No output was written.");
|
||||
return false;
|
||||
}
|
||||
|
||||
var verification = PostVerificationAnalyzer.AnalyzeForPost(nest, post);
|
||||
Console.WriteLine(verification.ToDisplayText());
|
||||
if (!verification.CanPost(options.AcknowledgePostRisks))
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenNest.CNC
|
||||
{
|
||||
/// <summary>
|
||||
/// How a planned program cuts a common line once (see docs/common-line-cutting.md). A shared cut
|
||||
/// is a run of <see cref="LayerType.CommonLine"/> moves: an open centerline cut made without
|
||||
/// kerf compensation, with straight leads on its own axis. A remainder (a member's perimeter
|
||||
/// between its shared spans) is an open contour whose rapid is followed directly by one of the
|
||||
/// <see cref="RemainderMarker(RotationType)"/> comments, naming the winding of the perimeter it
|
||||
/// belongs to, so a post compensates it on the perimeter's side even though it encloses nothing.
|
||||
/// </summary>
|
||||
public static class CommonLineCuts
|
||||
{
|
||||
/// <summary>The comment after the rapid into a remainder of a clockwise perimeter.</summary>
|
||||
public const string ClockwiseRemainder = "COMMON LINE REMAINDER CW";
|
||||
|
||||
/// <summary>The comment after the rapid into a remainder of a counterclockwise perimeter.</summary>
|
||||
public const string CounterclockwiseRemainder = "COMMON LINE REMAINDER CCW";
|
||||
|
||||
/// <summary>The remainder comment for a perimeter wound <paramref name="winding"/>.</summary>
|
||||
public static string RemainderMarker(RotationType winding) =>
|
||||
winding == RotationType.CW ? ClockwiseRemainder : CounterclockwiseRemainder;
|
||||
|
||||
/// <summary>The perimeter winding a remainder comment names, or null for any other code.</summary>
|
||||
public static RotationType? RemainderWinding(ICode code) => code switch
|
||||
{
|
||||
Comment { Value: ClockwiseRemainder } => RotationType.CW,
|
||||
Comment { Value: CounterclockwiseRemainder } => RotationType.CCW,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>Whether <paramref name="program"/>'s own codes cut a common line once.</summary>
|
||||
public static bool IsSinglePass(Program program) =>
|
||||
program?.Codes != null && program.Codes.Any(code =>
|
||||
code is LinearMove { Layer: LayerType.CommonLine } or ArcMove { Layer: LayerType.CommonLine }
|
||||
|| RemainderWinding(code) != null);
|
||||
|
||||
/// <summary>
|
||||
/// Refuses, before any output, a nest with a common line cut once when
|
||||
/// <paramref name="postProcessor"/> cannot write shared cuts and remainders: it would cut the
|
||||
/// shared cut with compensation (into a part) or a remainder on the wrong side. Posts never
|
||||
/// fall back to cutting the line twice; set the plate to cut its common lines twice instead.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">The post cannot write the nest.</exception>
|
||||
public static void EnsurePostable(Nest nest, IPostProcessor postProcessor)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(nest);
|
||||
if (postProcessor is ICommonLinePostProcessor)
|
||||
return;
|
||||
for (var p = 0; p < nest.Plates.Count; p++)
|
||||
{
|
||||
var plate = nest.Plates[p];
|
||||
for (var i = 0; i < plate.Parts.Count; i++)
|
||||
if (IsSinglePass(plate.Parts[i]?.Program))
|
||||
throw new InvalidOperationException(
|
||||
$"Plate {p + 1}, part {i + 1} cuts a common line once, but the "
|
||||
+ $"{postProcessor?.Name ?? "selected"} post cannot write single-pass common lines. "
|
||||
+ "Set the plate to cut its common lines twice (Plate > Arrange > Cut Common Lines Twice), "
|
||||
+ "plan cutting again, then post.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A post that writes common lines cut once (<see cref="CommonLineCuts"/>): each shared cut
|
||||
/// without kerf compensation and each remainder compensated on its perimeter's side. Posts
|
||||
/// without it refuse such a nest (<see cref="CommonLineCuts.EnsurePostable"/>).
|
||||
/// </summary>
|
||||
public interface ICommonLinePostProcessor : IPostProcessor
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -379,7 +379,7 @@ namespace OpenNest.CNC
|
||||
{
|
||||
// Cutting strategies emit contour moves on Display; the posts cut them.
|
||||
LayerType.Cut or LayerType.Display or LayerType.Leadin or LayerType.Leadout or LayerType.Break
|
||||
=> CutSimulationStepKind.Cut,
|
||||
or LayerType.CommonLine => CutSimulationStepKind.Cut,
|
||||
LayerType.Scribe => CutSimulationStepKind.Scribe,
|
||||
_ => null, // Tab spans are never cut.
|
||||
};
|
||||
|
||||
@@ -51,7 +51,12 @@ public sealed class LeadMaterialSnapshot
|
||||
/// <summary>Capture a stable, clean, rotation-baked program, applying location once.
|
||||
/// Unsupported or malformed geometry produces an incomplete snapshot; cancellation throws.</summary>
|
||||
public static LeadMaterialSnapshot Capture(Program cleanProgram, Vector location,
|
||||
CancellationToken token = default)
|
||||
CancellationToken token = default) => Capture(cleanProgram, location, token, sharedSpans: false);
|
||||
|
||||
/// <param name="sharedSpans">A common-line member's clean program (docs/common-line-cutting.md):
|
||||
/// its perimeter may carry Tab spans, the shared spans the member never cuts.</param>
|
||||
internal static LeadMaterialSnapshot Capture(Program cleanProgram, Vector location,
|
||||
CancellationToken token, bool sharedSpans)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -141,7 +146,7 @@ public sealed class LeadMaterialSnapshot
|
||||
throw new ArgumentException(ringDisplay.Contains(true)
|
||||
? "A display perimeter must enclose every other contour."
|
||||
: "Material must have exactly one enclosing perimeter.");
|
||||
if (ringTabs[outer].Any(tab => tab))
|
||||
if (!sharedSpans && ringTabs[outer].Any(tab => tab))
|
||||
throw new ArgumentException("A perimeter cannot have tabs.");
|
||||
if (ringDisplay.Where((_, i) => i != outer).Any(display => display))
|
||||
throw new ArgumentException("A display perimeter must enclose every other contour.");
|
||||
|
||||
@@ -65,6 +65,17 @@ public static class LeadPathValidator
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var move = execution.Motions[i];
|
||||
if (!move.Rapid && move.Layer == LayerType.CommonLine)
|
||||
{
|
||||
// A shared cut runs in the kerf between two parts: it may touch no material at all.
|
||||
var (shared, sharedObstacle) = CheckSharedCut(i);
|
||||
if (shared == null)
|
||||
continue;
|
||||
if (isFixed?.Invoke(i) != true || fixedFailures == null)
|
||||
return shared;
|
||||
fixedFailures.Add(new(i, shared, sharedObstacle));
|
||||
continue;
|
||||
}
|
||||
if (move.Layer is not (LayerType.Leadin or LayerType.Leadout))
|
||||
continue;
|
||||
var (failure, obstacle) = CheckMotion(i);
|
||||
@@ -78,6 +89,27 @@ public static class LeadPathValidator
|
||||
// checks rapid travel and contour accounting for the complete program.
|
||||
return new(true, true, null);
|
||||
|
||||
(LeadPathValidationResult Failure, int? Obstacle) CheckSharedCut(int i)
|
||||
{
|
||||
var move = execution.Motions[i];
|
||||
if (move.Curve == null || !double.IsFinite(move.Length) || move.Length <= PostVerificationGeometry.Epsilon)
|
||||
return (new(false, false, "A common-line shared cut is missing, degenerate or inconsistent."), null);
|
||||
if (MaterialContact(move.Curve, target, null, ref budget, token) is { } own)
|
||||
return (new(true, false, $"Common-line shared cut {i} contacts its own part's material ({own}). "
|
||||
+ "Rejoin the parts one kerf apart, then replan."), null);
|
||||
for (var other = 0; other < otherMaterials.Count; other++)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var material = otherMaterials[other];
|
||||
if (ReferenceEquals(material, target) || move.Curve.Extent.IsClearOfQueriesFrom(material.Extent))
|
||||
continue;
|
||||
if (MaterialContact(move.Curve, material, null, ref budget, token) != null)
|
||||
return (new(true, false, "A common-line shared cut contacts or enters another placed material. "
|
||||
+ "Rejoin the parts one kerf apart at the current kerf, then replan."), other);
|
||||
}
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
(LeadPathValidationResult Failure, int? Obstacle) CheckMotion(int i)
|
||||
{
|
||||
var move = execution.Motions[i];
|
||||
@@ -100,6 +132,7 @@ public static class LeadPathValidator
|
||||
var adjacentIndex = groupEdge + step;
|
||||
var genuineJoint = false;
|
||||
var breakLead = false;
|
||||
var sharedLead = false;
|
||||
if (adjacentIndex >= 0 && adjacentIndex < execution.Motions.Count)
|
||||
{
|
||||
var adjacent = execution.Motions[adjacentIndex];
|
||||
@@ -119,6 +152,20 @@ public static class LeadPathValidator
|
||||
allowed = joint;
|
||||
}
|
||||
}
|
||||
// A shared cut lies in the kerf between two parts, so its lead joins no boundary
|
||||
// and may touch none: its joint is the cut's own start (or end for a lead-out).
|
||||
else if (!adjacent.Rapid && adjacent.Layer == LayerType.CommonLine
|
||||
&& adjacent.Curve != null && adjacent.Length > PostVerificationGeometry.Epsilon)
|
||||
{
|
||||
var edge = execution.Motions[groupEdge];
|
||||
var joint = move.Layer == LayerType.Leadin ? edge.End : edge.Curve.Start;
|
||||
var cutJoint = move.Layer == LayerType.Leadin ? adjacent.Curve.Start : adjacent.End;
|
||||
if (joint.DistanceTo(cutJoint) <= PostVerificationGeometry.Epsilon)
|
||||
{
|
||||
genuineJoint = true;
|
||||
sharedLead = true;
|
||||
}
|
||||
}
|
||||
else if (!adjacent.Rapid && adjacent.Layer is LayerType.Cut or LayerType.Display
|
||||
&& adjacent.Curve != null && adjacent.Length > PostVerificationGeometry.Epsilon)
|
||||
{
|
||||
@@ -154,11 +201,13 @@ public static class LeadPathValidator
|
||||
// material is expected there, but touching any of its boundaries is not.
|
||||
var failure = breakLead
|
||||
? MaterialContact(move.Curve, target, null, ref budget, token, allowInterior: true)
|
||||
: CheckMaterial(target, allowed);
|
||||
: CheckMaterial(target, sharedLead ? null : allowed);
|
||||
if (failure != null)
|
||||
return (new(true, false, breakLead
|
||||
? $"Break cut lead motion {i} contacts its part's boundary ({failure}). Try a shorter lead-in or move the tabs."
|
||||
: $"Lead motion {i} contacts or enters target material outside its adjacent contour joint ({failure})."), null);
|
||||
: sharedLead
|
||||
? $"Common-line lead motion {i} contacts its part's material ({failure}). The lead runs along the shared line: shorten the lead-in or lead-out, or cut the common lines twice."
|
||||
: $"Lead motion {i} contacts or enters target material outside its adjacent contour joint ({failure})."), null);
|
||||
var reach = move.Curve.Extent;
|
||||
for (var other = 0; other < otherMaterials.Count; other++)
|
||||
{
|
||||
|
||||
@@ -27,10 +27,17 @@ public sealed class PlateCuttingState
|
||||
private readonly Dictionary<Drawing, DrawingRecord> drawings;
|
||||
private readonly Dictionary<CuttingParameters, string> settings;
|
||||
private readonly CuttingParameters plateSettings;
|
||||
private readonly ObservableList<CommonLineGroup> commonLineList;
|
||||
private readonly CommonLineRecord[] commonLines;
|
||||
private readonly bool cutCommonLinesTwice;
|
||||
|
||||
private PlateCuttingState(Plate plate, PartRecord[] parts, CutOffRecord[] cutOffs,
|
||||
Dictionary<Drawing, DrawingRecord> drawings, Dictionary<CuttingParameters, string> settings)
|
||||
{
|
||||
commonLineList = plate.CommonLines;
|
||||
commonLines = plate.CommonLines.Select(group => new CommonLineRecord(group, group.Kerf,
|
||||
group.Members.ToArray())).ToArray();
|
||||
cutCommonLinesTwice = plate.CutCommonLinesTwice;
|
||||
this.settings = settings;
|
||||
plateSettings = plate.CuttingParameters;
|
||||
Plate = plate;
|
||||
@@ -162,6 +169,18 @@ public sealed class PlateCuttingState
|
||||
|| !Bits(cutOff.HeadLockOvercut, record.HeadLockOvercut) || cutOff.FarEdgeFirst != record.FarEdgeFirst)
|
||||
return $"Cutoff {i + 1} definition changed.";
|
||||
}
|
||||
// Common lines decide which edges each member cuts, and whether they are cut once.
|
||||
if (!ReferenceEquals(plate.CommonLines, commonLineList) || plate.CutCommonLinesTwice != cutCommonLinesTwice
|
||||
|| plate.CommonLines.Count != commonLines.Length)
|
||||
return "Common lines changed.";
|
||||
for (var i = 0; i < commonLines.Length; i++)
|
||||
{
|
||||
var record = commonLines[i];
|
||||
var group = plate.CommonLines[i];
|
||||
if (!ReferenceEquals(group, record.Group) || !Bits(group.Kerf, record.Kerf)
|
||||
|| !group.Members.SequenceEqual(record.Members, ReferenceEqualityComparer.Instance))
|
||||
return $"Common line {i + 1} changed.";
|
||||
}
|
||||
// Part.Rotation derives from the manual flag, PreLeadInRotation and Program.Rotation,
|
||||
// all compared exactly above.
|
||||
return null;
|
||||
@@ -207,6 +226,8 @@ public sealed class PlateCuttingState
|
||||
private sealed record DrawingRecord(Program Program, Program Copy, bool IsCutOff,
|
||||
List<ContourCutPin> Pins, string PinsFingerprint);
|
||||
|
||||
private sealed record CommonLineRecord(CommonLineGroup Group, double Kerf, Part[] Members);
|
||||
|
||||
private sealed record CutOffRecord(CutOff CutOff, Drawing Drawing, CutOffAxis Axis, Vector Position,
|
||||
double? StartLimit, double? EndLimit, IReadOnlyList<CutOffGap> Gaps, double HeadLockOvercut,
|
||||
bool FarEdgeFirst);
|
||||
|
||||
@@ -24,6 +24,16 @@ public sealed record ContourChoice(int ContourOrdinal, int EntityOrdinal, Vector
|
||||
public Vector? Pierce { get; internal init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The shared cuts a common-line member makes before its remainder (see
|
||||
/// docs/common-line-cutting.md): open centerline cuts in part coordinates, each from
|
||||
/// <see cref="CommonLineCutPath.Start"/> to <see cref="CommonLineCutPath.End"/>, with the group's kerf.
|
||||
/// </summary>
|
||||
public sealed record CommonLinePerimeter(double Kerf, IReadOnlyList<CommonLineCutPath> SharedCuts);
|
||||
|
||||
/// <summary>One shared cut on a common line's centerline, in part coordinates and cut direction.</summary>
|
||||
public sealed record CommonLineCutPath(Vector Start, Vector End);
|
||||
|
||||
/// <summary>
|
||||
/// Immutable owned clean contours and settings. Callers supply the clean, already-rotated
|
||||
/// program and keep it stable during Capture. This is not a topology or lead-path verdict.
|
||||
@@ -55,6 +65,10 @@ public sealed class PreparedContours
|
||||
// never-executed DisplayPerimeterTail. Null for an ordinary cut perimeter.
|
||||
private readonly Shape displayOutline;
|
||||
private bool hasCutPerimeter => displayOutline == null;
|
||||
// Set for a common-line member: the perimeter's shared spans are Tab entities, never cut by
|
||||
// this part. It is cut as its shared cuts, then its remainder pieces, from one fixed entry.
|
||||
private readonly CommonLinePerimeter commonLine;
|
||||
private readonly ContourChoice commonLineEntry;
|
||||
|
||||
private PreparedContours(Shape[] shapes, List<Entity> scribes, List<Shape> breakCuts, List<Shape> tabbedCutouts,
|
||||
CuttingParameters parameters)
|
||||
@@ -63,10 +77,12 @@ public sealed class PreparedContours
|
||||
}
|
||||
|
||||
private PreparedContours(Shape[] shapes, List<Entity> scribes, List<Shape> breakCuts, List<Shape> tabbedCutouts,
|
||||
CuttingParameters parameters, Shape displayOutline, PierceZoneMemo pierceZones = null)
|
||||
CuttingParameters parameters, Shape displayOutline, PierceZoneMemo pierceZones = null,
|
||||
CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
this.pierceZones = pierceZones ?? new PierceZoneMemo();
|
||||
this.displayOutline = displayOutline;
|
||||
this.commonLine = commonLine;
|
||||
this.shapes = shapes;
|
||||
this.scribes = scribes;
|
||||
this.breakCuts = breakCuts;
|
||||
@@ -74,11 +90,19 @@ public sealed class PreparedContours
|
||||
this.parameters = parameters;
|
||||
pinned = new ContourChoice[shapes.Length];
|
||||
pinNumbers = new int[shapes.Length];
|
||||
if (commonLine != null)
|
||||
{
|
||||
// The remainder's first piece starts where a shared span ends: the one fixed entry.
|
||||
var perimeter = shapes[^1];
|
||||
var first = ContourCuttingStrategy.TabbedCutoutPieces(perimeter)[0].Entities[0];
|
||||
var entity = perimeter.Entities.IndexOf(first);
|
||||
commonLineEntry = new ContourChoice(shapes.Length - 1, entity, Start(first)) { Owner = this };
|
||||
}
|
||||
}
|
||||
|
||||
private PreparedContours(PreparedContours unpinned, IReadOnlyList<CutPinResolution> pins, CancellationToken token)
|
||||
: this(unpinned.shapes, unpinned.scribes, unpinned.breakCuts, unpinned.tabbedCutouts, unpinned.parameters,
|
||||
unpinned.displayOutline, unpinned.pierceZones)
|
||||
unpinned.displayOutline, unpinned.pierceZones, unpinned.commonLine)
|
||||
{
|
||||
contourParameters = new CuttingParameters[shapes.Length];
|
||||
var rejected = new List<CutPinResolution>();
|
||||
@@ -95,8 +119,9 @@ public sealed class PreparedContours
|
||||
throw new ArgumentException("A pin resolution does not belong to these contours.", nameof(pins));
|
||||
if (pinned[contour] != null)
|
||||
throw new ArgumentException("Two pins resolve to one contour.", nameof(pins));
|
||||
// The emitter tabs only the outside, so a tab elsewhere cannot be cut as pinned.
|
||||
if (pin.Pin.HasTab && contour != PerimeterOrdinal)
|
||||
// The emitter tabs only the outside, so a tab elsewhere cannot be cut as pinned. A
|
||||
// common-line member's outside is cut from its shared spans, never from a pin.
|
||||
if (pin.Pin.HasTab && contour != PerimeterOrdinal || commonLine != null && contour == PerimeterOrdinal)
|
||||
{
|
||||
rejected.Add(pin);
|
||||
continue;
|
||||
@@ -116,7 +141,7 @@ public sealed class PreparedContours
|
||||
// a pinned perimeter keeps its pin's settings: the analysis is only kept for review.
|
||||
private PreparedContours(PreparedContours source, PartSupport support, Vector location, Tab tab)
|
||||
: this(source.shapes, source.scribes, source.breakCuts, source.tabbedCutouts, source.parameters,
|
||||
source.displayOutline, source.pierceZones)
|
||||
source.displayOutline, source.pierceZones, source.commonLine)
|
||||
{
|
||||
for (var contour = 0; contour < Count; contour++)
|
||||
{
|
||||
@@ -155,6 +180,8 @@ public sealed class PreparedContours
|
||||
throw new ArgumentException("Support tabs need a complete analysis with a tab point.", nameof(support));
|
||||
if (!hasCutPerimeter)
|
||||
throw new ArgumentException("A display perimeter is never cut, so it cannot hold a support tab.", nameof(support));
|
||||
if (commonLine != null)
|
||||
throw new ArgumentException("A common-line member is never support-tabbed.", nameof(support));
|
||||
return new PreparedContours(this, support, location, tab);
|
||||
}
|
||||
|
||||
@@ -168,7 +195,16 @@ public sealed class PreparedContours
|
||||
public Vector SupportOrigin => supportOrigin;
|
||||
|
||||
/// <summary>Whether the emitted perimeter is tabbed: by the plate settings, its pin or support.</summary>
|
||||
internal bool PerimeterTabbed => hasCutPerimeter && ParametersFor(PerimeterOrdinal).TabsEnabled;
|
||||
internal bool PerimeterTabbed => hasCutPerimeter && commonLine == null && ParametersFor(PerimeterOrdinal).TabsEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// True for a common-line member (see <see cref="CommonLinePerimeter"/>): its perimeter has one
|
||||
/// fixed entry and is emitted as its shared cuts, then its remainder pieces.
|
||||
/// </summary>
|
||||
public bool IsCommonLinePerimeter => commonLine != null;
|
||||
|
||||
/// <summary>The member's shared cuts and kerf, or null for any other part.</summary>
|
||||
public CommonLinePerimeter CommonLine => commonLine;
|
||||
|
||||
public int Count => shapes.Length;
|
||||
|
||||
@@ -209,10 +245,10 @@ public sealed class PreparedContours
|
||||
/// contour keeps the automatic selection with <paramref name="parameters"/>.
|
||||
/// </summary>
|
||||
public static PreparedContours Capture(Program program, CuttingParameters parameters,
|
||||
IReadOnlyList<CutPinResolution> pins, CancellationToken token = default)
|
||||
IReadOnlyList<CutPinResolution> pins, CancellationToken token = default, CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(pins);
|
||||
var unpinned = Capture(program, parameters, token);
|
||||
var unpinned = Capture(program, parameters, token, commonLine);
|
||||
return pins.Any(p => p?.IsResolved != false) ? new PreparedContours(unpinned, pins, token) : unpinned;
|
||||
}
|
||||
|
||||
@@ -234,7 +270,11 @@ public sealed class PreparedContours
|
||||
|
||||
private CuttingParameters ParametersFor(int contourOrdinal) => contourParameters?[contourOrdinal] ?? parameters;
|
||||
|
||||
public static PreparedContours Capture(Program program, CuttingParameters parameters, CancellationToken token = default)
|
||||
/// <param name="commonLine">For a common-line member: its shared cuts. The program's perimeter
|
||||
/// must carry the member's shared spans on the Tab layer (CommonLineCutting.MarkSharedSpans); it
|
||||
/// is then the perimeter, cut in pieces between them, rather than a tabbed cutout.</param>
|
||||
public static PreparedContours Capture(Program program, CuttingParameters parameters, CancellationToken token = default,
|
||||
CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var ownedParameters = OwnedCuttingParameters.Copy(parameters);
|
||||
@@ -297,6 +337,40 @@ public sealed class PreparedContours
|
||||
if (NominalContourClosure.IsClosed(Start(current.Entities[0]), End(entity)))
|
||||
FinishContour();
|
||||
}
|
||||
if (commonLine != null)
|
||||
{
|
||||
if (displayPerimeter != null || current.Entities.Count != 0)
|
||||
throw new ArgumentException("A common-line member needs one closed cut perimeter.");
|
||||
if (!double.IsFinite(commonLine.Kerf) || commonLine.Kerf <= 0 || commonLine.SharedCuts == null
|
||||
|| commonLine.SharedCuts.Any(c => c == null || c.Start.DistanceTo(c.End) <= PostVerificationGeometry.Epsilon))
|
||||
throw new ArgumentException("A common-line member needs a positive kerf and nondegenerate shared cuts.");
|
||||
// The outside carries the shared spans as tabs; every other contour lies inside it.
|
||||
var outside = tabbedCutouts.Concat(contours).MaxBy(shape => shape.BoundingBox.Width * shape.BoundingBox.Length);
|
||||
if (outside == null || !tabbedCutouts.Contains(outside)
|
||||
|| ContourCuttingStrategy.TabbedCutoutPieces(outside).Count == 0)
|
||||
throw new ArgumentException("A common-line member's perimeter does not carry its shared spans.");
|
||||
// Each remainder piece is pierced in the kerf of the span before it, the external
|
||||
// lead-in's reach back along it: the span must be that long. Never shortened.
|
||||
var reach = ContourCuttingStrategy.CommonLineLeadInReach(ownedParameters.ExternalLeadIn ?? new NoLeadIn());
|
||||
if (reach <= OpenNest.Math.Tolerance.Epsilon)
|
||||
throw new NotSupportedException("A common-line member's remainder needs a lead-in with length: "
|
||||
+ "its compensation starts in the shared kerf along the lead-in. Choose an external lead-in "
|
||||
+ "with length, or cut the common lines twice.");
|
||||
foreach (var piece in ContourCuttingStrategy.TabbedCutoutPieces(outside))
|
||||
{
|
||||
var index = outside.Entities.IndexOf(piece.Entities[0]);
|
||||
var span = outside.Entities[(index + outside.Entities.Count - 1) % outside.Entities.Count];
|
||||
if (span is not Line line || line.Length < reach + PostVerificationGeometry.Epsilon)
|
||||
throw new NotSupportedException(FormattableString.Invariant(
|
||||
$"One of its shared spans is {span.Length:0.####} long, shorter than the {reach:0.####} external lead-in its remainder starts along in that span's kerf. Shorten the lead-in, or cut the common lines twice."));
|
||||
}
|
||||
tabbedCutouts.Remove(outside);
|
||||
contours.Add(outside);
|
||||
foreach (var cut in breakCuts)
|
||||
cut.UpdateBounds();
|
||||
return new(contours.ToArray(), scribes, breakCuts, tabbedCutouts, ownedParameters, null, null,
|
||||
commonLine with { SharedCuts = commonLine.SharedCuts.ToArray() });
|
||||
}
|
||||
if (displayPerimeter != null)
|
||||
{
|
||||
if (current.Entities.Count != 0)
|
||||
@@ -366,6 +440,8 @@ public sealed class PreparedContours
|
||||
var shape = GetShape(contourOrdinal);
|
||||
if (pinned[contourOrdinal] is { } pin)
|
||||
return pin;
|
||||
if (FixedCommonLineEntry(contourOrdinal) is { } fixedEntry)
|
||||
return fixedEntry;
|
||||
var point = shape.ClosestPointTo(approach, out var entity);
|
||||
return Entry(contourOrdinal, shape.Entities.IndexOf(entity), point);
|
||||
}
|
||||
@@ -384,6 +460,8 @@ public sealed class PreparedContours
|
||||
var shape = GetShape(contourOrdinal);
|
||||
if (pinned[contourOrdinal] is { } pin)
|
||||
return new[] { pin };
|
||||
if (FixedCommonLineEntry(contourOrdinal) is { } fixedEntry)
|
||||
return new[] { fixedEntry };
|
||||
var entries = new List<ContourChoice>();
|
||||
entries.Add(ClosestEntry(contourOrdinal, approach));
|
||||
for (var i = 0; i < shape.Entities.Count && entries.Count < maxEntries; i++)
|
||||
@@ -533,6 +611,8 @@ public sealed class PreparedContours
|
||||
var shape = GetShape(contourOrdinal);
|
||||
if (pinned[contourOrdinal] is { } pin)
|
||||
return new[] { new ContourEntryCandidate(pin, AutomaticEntryKind.Pinned) };
|
||||
if (FixedCommonLineEntry(contourOrdinal) is { } fixedEntry)
|
||||
return new[] { new ContourEntryCandidate(fixedEntry, AutomaticEntryKind.Pinned) };
|
||||
if (IsSingleCircle(shape))
|
||||
throw new ArgumentException("Circles have no preferred corners or joints; use the fallback catalog.");
|
||||
return SupportFiltered(contourOrdinal, PreferredCandidates(shape, contourOrdinal, token), SupportEntries.Steadying);
|
||||
@@ -559,6 +639,8 @@ public sealed class PreparedContours
|
||||
var shape = GetShape(contourOrdinal);
|
||||
if (pinned[contourOrdinal] is { } pin)
|
||||
return new[] { new ContourEntryCandidate(pin, AutomaticEntryKind.Pinned) };
|
||||
if (FixedCommonLineEntry(contourOrdinal) is { } fixedEntry)
|
||||
return new[] { new ContourEntryCandidate(fixedEntry, AutomaticEntryKind.Pinned) };
|
||||
var all = IsSingleCircle(shape)
|
||||
? new List<ContourEntryCandidate>()
|
||||
: PreferredCandidates(shape, contourOrdinal, token);
|
||||
@@ -889,7 +971,7 @@ public sealed class PreparedContours
|
||||
var owned = new Shape[shapes.Length];
|
||||
owned[choice.ContourOrdinal] = (Shape)shapes[choice.ContourOrdinal].Clone();
|
||||
return new ContourCuttingStrategy { Parameters = parameters, PierceZones = pierceZones }.EmitCandidateIsolated(
|
||||
owned, scribes.Select(e => e.Clone()).ToList(), choice, contourParameters, PerimeterOrdinal);
|
||||
owned, scribes.Select(e => e.Clone()).ToList(), choice, contourParameters, PerimeterOrdinal, commonLine);
|
||||
}
|
||||
|
||||
// Each prefix is a standalone owned program, including the same scribes and break cuts once.
|
||||
@@ -905,7 +987,7 @@ public sealed class PreparedContours
|
||||
shapes.Select(s => (Shape)s.Clone()).ToArray(), scribes.Select(e => e.Clone()).ToList(), choices,
|
||||
contourParameters, breakCuts.Select(s => (Shape)s.Clone()).ToList(),
|
||||
tabbedCutouts.Select(s => (Shape)s.Clone()).ToList(), PerimeterOrdinal,
|
||||
complete ? (Shape)displayOutline?.Clone() : null);
|
||||
complete ? (Shape)displayOutline?.Clone() : null, commonLine);
|
||||
|
||||
/// <summary>Open break cuts this preparation cuts before its contours.</summary>
|
||||
public int BreakCutCount => breakCuts.Count;
|
||||
@@ -925,8 +1007,9 @@ public sealed class PreparedContours
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var expected = ExecutionMotionReader.ReadSupported(Emit(choices), location, null, token);
|
||||
// Only the outside is tabbed, with its own pin's tab when it is pinned.
|
||||
if (!hasCutPerimeter)
|
||||
// Only the outside is tabbed, with its own pin's tab when it is pinned. A common-line
|
||||
// member's shared spans are accounted as the material's tabs, never as a tab gap.
|
||||
if (!hasCutPerimeter || commonLine != null)
|
||||
return new(this, choices, expected, 0);
|
||||
var perimeter = ParametersFor(PerimeterOrdinal);
|
||||
return new(this, choices, expected, perimeter.TabsEnabled ? perimeter.TabConfig.Size : 0);
|
||||
@@ -959,6 +1042,11 @@ public sealed class PreparedContours
|
||||
// A pinned contour is cut exactly as pinned: no other entry may be emitted for it.
|
||||
if (pinned[choice.ContourOrdinal] is { } pin && pin != choice)
|
||||
throw new ArgumentException("A pinned contour keeps its drawing pin's entry.");
|
||||
// A common-line perimeter is cut from its one fixed entry, after its shared cuts.
|
||||
if (commonLineEntry != null && choice.ContourOrdinal == PerimeterOrdinal
|
||||
&& (choice.EntityOrdinal != commonLineEntry.EntityOrdinal || choice.Point != commonLineEntry.Point
|
||||
|| choice.Pierce != null))
|
||||
throw new ArgumentException("A common-line member's perimeter is cut from its fixed entry.");
|
||||
if (choice.Pierce is { } pierce)
|
||||
{
|
||||
PostVerificationGeometry.Validate(pierce);
|
||||
@@ -967,6 +1055,9 @@ public sealed class PreparedContours
|
||||
}
|
||||
}
|
||||
|
||||
private ContourChoice FixedCommonLineEntry(int contourOrdinal) =>
|
||||
commonLineEntry != null && contourOrdinal == PerimeterOrdinal ? commonLineEntry : null;
|
||||
|
||||
private Shape GetShape(int ordinal) => ordinal < 0 || ordinal >= Count
|
||||
? throw new ArgumentException("Foreign contour ordinal.") : shapes[ordinal];
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@ public sealed class ReleasedContourState
|
||||
// Parts (by caller part number) whose single tab may not hold them level: once cut, their
|
||||
// tabbed perimeter is an obstacle as if cut free, since the part may tip into the head's path.
|
||||
private readonly Func<int, bool> tabMayNotHold;
|
||||
// Common-line members (by caller part number): their outside is cut as open remainder pieces
|
||||
// that end in kerf their shared cuts opened, so once the part's program ends it is cut free.
|
||||
private readonly Func<int, bool> commonLineMember;
|
||||
// How the last analysed part ended: the contours it numbered, and whether nothing it left
|
||||
// (open fragments, deferred findings, a reported tab, a dangling lead-in) can change how
|
||||
// motions appended to it are judged. See Continue.
|
||||
@@ -31,14 +34,24 @@ public sealed class ReleasedContourState
|
||||
/// single tab can steady them): the longest open cut a part leaves, its tabbed
|
||||
/// perimeter, becomes an obstacle when the part ends, closed across its tab gap.</param>
|
||||
public ReleasedContourState(bool reportMissingLeadIns, Func<int, bool> tabMayNotHold)
|
||||
: this(reportMissingLeadIns, tabMayNotHold, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <param name="commonLineMember">Part numbers of common-line members (docs/common-line-cutting.md):
|
||||
/// a member's open cuts are its remainder pieces, which end in kerf its shared cuts opened. They
|
||||
/// need no retention proof, and when the part ends they become one obstacle, closed across its
|
||||
/// shared spans, since the part is then cut free.</param>
|
||||
public ReleasedContourState(bool reportMissingLeadIns, Func<int, bool> tabMayNotHold, Func<int, bool> commonLineMember)
|
||||
{
|
||||
this.reportMissingLeadIns = reportMissingLeadIns;
|
||||
this.tabMayNotHold = tabMayNotHold;
|
||||
this.commonLineMember = commonLineMember;
|
||||
}
|
||||
|
||||
public ReleasedContourState Copy()
|
||||
{
|
||||
var copy = new ReleasedContourState(reportMissingLeadIns, tabMayNotHold)
|
||||
var copy = new ReleasedContourState(reportMissingLeadIns, tabMayNotHold, commonLineMember)
|
||||
{
|
||||
partContours = partContours,
|
||||
partClosed = partClosed,
|
||||
@@ -125,6 +138,7 @@ public sealed class ReleasedContourState
|
||||
var hasLead = false;
|
||||
var contourNumber = contoursBefore;
|
||||
var inBreakCut = false;
|
||||
var member = commonLineMember?.Invoke(part) == true;
|
||||
var reportedTab = false;
|
||||
// The contour last closed, and the one a lead-out has just left it into: a cutout's
|
||||
// lead-out ends in its slug, so the rapid after it must leave over that cutout's own cut.
|
||||
@@ -139,23 +153,27 @@ public sealed class ReleasedContourState
|
||||
var owned = isFixed?.Invoke(index) == true;
|
||||
if (!move.Rapid && move.Layer != LayerType.Leadout)
|
||||
exited = null;
|
||||
if (!move.Rapid && move.Layer == LayerType.Break)
|
||||
if (!move.Rapid && move.Layer is LayerType.Break or LayerType.CommonLine)
|
||||
{
|
||||
// A break cut is intentionally open and retained by its uncut tabs: it is never a
|
||||
// rapid obstacle and never an unexplained fragment, but it is still pierced.
|
||||
// rapid obstacle and never an unexplained fragment, but it is still pierced. A
|
||||
// common line's shared cut runs in the kerf between two parts: it bounds and
|
||||
// retains nothing, so it is never an obstacle and takes no part in the open-cut proof.
|
||||
if (!inBreakCut)
|
||||
{
|
||||
Finish();
|
||||
if (reportMissingLeadIns && !cutoff && !hasLead)
|
||||
Add(new(PostVerificationKind.MissingLeadIn, plate, part, null,
|
||||
"A break cut is missing lead-in geometry.")
|
||||
move.Layer == LayerType.Break ? "A break cut is missing lead-in geometry."
|
||||
: "A common-line shared cut is missing lead-in geometry.")
|
||||
{ Location = move.Curve.Start }, owned);
|
||||
inBreakCut = true;
|
||||
hasLead = false;
|
||||
previous = new CutGroup();
|
||||
previous.Leads.AddRange(leadIns);
|
||||
leadIns.Clear();
|
||||
otherOpen.Add(previous);
|
||||
if (move.Layer == LayerType.Break)
|
||||
otherOpen.Add(previous);
|
||||
}
|
||||
if (move.Curve.Length > PostVerificationGeometry.Epsilon)
|
||||
previous.Curves.Add(move.Curve);
|
||||
@@ -295,9 +313,12 @@ public sealed class ReleasedContourState
|
||||
// pieces a tabbed cutout was cut in, and so does a tabbed perimeter whose lead-out stays
|
||||
// out of its tab: planning and pre-post review prove them alike. Otherwise they need
|
||||
// manual review.
|
||||
// A common-line member's open cuts are its remainder pieces: they end in shared kerf, not at
|
||||
// tabs, and the planner's contour accounting proves they cut its outside exactly once.
|
||||
var remainders = member && !cutoff && unfinished.Count > 0;
|
||||
var retained = !cutoff && (unfinished.Count > 1 || deferred.Count > 0)
|
||||
&& unfinished.All(LeadsClearOpenEnds)
|
||||
&& OpenCutsEncloseNothing(closed, unfinished.Concat(otherOpen).Append(loose).ToList(), token);
|
||||
&& (remainders || unfinished.All(LeadsClearOpenEnds)
|
||||
&& OpenCutsEncloseNothing(closed, unfinished.Concat(otherOpen).Append(loose).ToList(), token));
|
||||
for (var i = deferred.Count - 1; i >= 0 && !retained; i--)
|
||||
deferred[i].Target.Insert(deferred[i].Index, deferred[i].Finding);
|
||||
// Only one open fragment per part can be the planner's own certified tab, so a
|
||||
@@ -309,7 +330,22 @@ public sealed class ReleasedContourState
|
||||
unfinished.Any(chain => chain.Fixed));
|
||||
// A part that may tip once cut is avoided like one cut free. The retention proof above is
|
||||
// unchanged: the part is still attached by its tab, just not held level by it.
|
||||
if (!cutoff && unfinished.Count > 0 && tabMayNotHold?.Invoke(part) == true)
|
||||
if (remainders)
|
||||
{
|
||||
// Its remainder pieces in cutting order, joined across the shared spans between them:
|
||||
// the member's outside, now cut free.
|
||||
var curves = new List<PostVerificationGeometry.Curve>();
|
||||
foreach (var chain in unfinished)
|
||||
{
|
||||
if (curves.Count > 0 && curves[^1].End.DistanceTo(chain.Curves[0].Start) > PostVerificationGeometry.Epsilon)
|
||||
curves.Add(PostVerificationGeometry.Curve.Create(curves[^1].End, chain.Curves[0].Start, null, false));
|
||||
curves.AddRange(chain.Curves);
|
||||
}
|
||||
if (curves[^1].End.DistanceTo(curves[0].Start) > PostVerificationGeometry.Epsilon)
|
||||
curves.Add(PostVerificationGeometry.Curve.Create(curves[^1].End, curves[0].Start, null, false));
|
||||
obstacles.Add(new(part, contourNumber, curves, null));
|
||||
}
|
||||
else if (!cutoff && unfinished.Count > 0 && tabMayNotHold?.Invoke(part) == true)
|
||||
{
|
||||
var perimeter = unfinished.MaxBy(chain => chain.Curves.Sum(curve => curve.Length));
|
||||
var curves = perimeter.Curves.ToList();
|
||||
|
||||
@@ -267,14 +267,16 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
internal Program EmitPrepared(Shape[] shapes, List<Entity> scribes,
|
||||
IReadOnlyList<CuttingPlanning.ContourChoice> choices,
|
||||
IReadOnlyList<CuttingParameters> contourParameters = null, IReadOnlyList<Shape> breakCuts = null,
|
||||
IReadOnlyList<Shape> tabbedCutouts = null, int? perimeterOrdinal = null, Shape displayTail = null)
|
||||
IReadOnlyList<Shape> tabbedCutouts = null, int? perimeterOrdinal = null, Shape displayTail = null,
|
||||
CuttingPlanning.CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
var result = new Program(Mode.Absolute);
|
||||
EmitScribeContours(result, scribes);
|
||||
EmitBreakCuts(result, breakCuts, shapes);
|
||||
foreach (var cutout in tabbedCutouts ?? Array.Empty<Shape>())
|
||||
EmitTabbedCutout(result, cutout);
|
||||
EmitChosenContours(result, shapes, choices, contourParameters, perimeterOrdinal ?? shapes.Length - 1);
|
||||
EmitChosenContours(result, shapes, choices, contourParameters, perimeterOrdinal ?? shapes.Length - 1,
|
||||
commonLine);
|
||||
if (displayTail != null)
|
||||
{
|
||||
// Display only, after every cut: executed reads and posts stop at its marker.
|
||||
@@ -292,11 +294,12 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
// installed on a Part or accepted as a complete plan.
|
||||
internal Program EmitCandidateIsolated(Shape[] shapes, List<Entity> scribes,
|
||||
CuttingPlanning.ContourChoice choice, IReadOnlyList<CuttingParameters> contourParameters = null,
|
||||
int? perimeterOrdinal = null)
|
||||
int? perimeterOrdinal = null, CuttingPlanning.CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
var result = new Program(Mode.Absolute);
|
||||
EmitScribeContours(result, scribes);
|
||||
EmitChosenContours(result, shapes, new[] { choice }, contourParameters, perimeterOrdinal ?? shapes.Length - 1);
|
||||
EmitChosenContours(result, shapes, new[] { choice }, contourParameters, perimeterOrdinal ?? shapes.Length - 1,
|
||||
commonLine);
|
||||
result.Mode = Mode.Incremental;
|
||||
return result;
|
||||
}
|
||||
@@ -307,7 +310,7 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
// prior choices — the differential tests in ContourCandidateEmissionTests pin this.
|
||||
private void EmitChosenContours(Program result, Shape[] shapes,
|
||||
IReadOnlyList<CuttingPlanning.ContourChoice> choices, IReadOnlyList<CuttingParameters> contourParameters,
|
||||
int perimeterOrdinal)
|
||||
int perimeterOrdinal, CuttingPlanning.CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
var shared = Parameters;
|
||||
try
|
||||
@@ -315,6 +318,17 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
var inSlug = false;
|
||||
foreach (var choice in choices)
|
||||
{
|
||||
if (commonLine != null && choice.ContourOrdinal == perimeterOrdinal)
|
||||
{
|
||||
// The rapid out of a cutout's slug before it is still made head up.
|
||||
Parameters = shared;
|
||||
var first = result.Codes.Count;
|
||||
EmitCommonLinePerimeter(result, shapes[perimeterOrdinal], commonLine);
|
||||
if (inSlug && first < result.Codes.Count && result.Codes[first] is RapidMove)
|
||||
result.Codes.Insert(first, new Comment(HeadRaise.Marker));
|
||||
inSlug = false;
|
||||
continue;
|
||||
}
|
||||
// A contour's own settings apply to its emission alone; scribes and every
|
||||
// other contour keep the shared settings.
|
||||
Parameters = contourParameters?[choice.ContourOrdinal] ?? shared;
|
||||
@@ -1566,6 +1580,89 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
: (start, startScrap, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A common-line member's outside, cut once per shared edge (docs/common-line-cutting.md):
|
||||
/// first each shared cut the member owns, an open centerline cut entered and left along
|
||||
/// its own axis with straight leads as long as the external lead-in's and lead-out's
|
||||
/// reach; then each remainder piece (the perimeter between its shared spans, which lie
|
||||
/// on the Tab layer) in the perimeter's own direction. A piece starts where a shared span
|
||||
/// ends. It is pierced in that span's opened kerf on the centerline, the external lead-in's
|
||||
/// reach back along the span, and enters along a straight lead-in that ends at the piece's
|
||||
/// start, so compensation starts in the kerf. It has no lead-out: it ends in the kerf
|
||||
/// at the next shared span. Capture checks that every lead fits; emission never shortens one.
|
||||
/// </summary>
|
||||
private void EmitCommonLinePerimeter(Program program, Shape perimeter, CuttingPlanning.CommonLinePerimeter commonLine)
|
||||
{
|
||||
var winding = DetermineWinding(perimeter);
|
||||
var leadIn = Parameters?.ExternalLeadIn ?? new NoLeadIn();
|
||||
var leadOut = Parameters?.ExternalLeadOut ?? new NoLeadOut();
|
||||
foreach (var cut in commonLine.SharedCuts)
|
||||
program.Codes.AddRange(CommonLineSharedCutCodes(cut, leadIn, leadOut));
|
||||
var entities = perimeter.Entities;
|
||||
foreach (var piece in TabbedCutoutPieces(perimeter))
|
||||
{
|
||||
var first = piece.Entities[0];
|
||||
var index = entities.IndexOf(first);
|
||||
var span = (Line)entities[(index + entities.Count - 1) % entities.Count];
|
||||
var entry = EntityStartPoint(first);
|
||||
program.Codes.Add(new RapidMove(CommonLineRemainderPierce(span, winding, commonLine.Kerf,
|
||||
CommonLineLeadInReach(leadIn))));
|
||||
// Posts compensate a remainder on its perimeter's side: it encloses nothing itself.
|
||||
program.Codes.Add(new Comment(CommonLineCuts.RemainderMarker(winding)));
|
||||
program.Codes.Add(new LinearMove(entry) { Layer = LayerType.Leadin });
|
||||
program.Codes.AddRange(ConvertShapeToMoves(piece, entry));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The pierce of a common-line remainder entered at the end of <paramref name="span"/> (a
|
||||
/// straight shared span of a perimeter wound <paramref name="winding"/>): on the shared
|
||||
/// centerline, half the <paramref name="kerf"/> outside the span, <paramref name="reach"/>
|
||||
/// back along it from the piece's start.
|
||||
/// </summary>
|
||||
internal static Vector CommonLineRemainderPierce(Line span, RotationType winding, double kerf, double reach)
|
||||
{
|
||||
var along = (span.EndPoint - span.StartPoint).Normalize();
|
||||
// Material lies left of a counterclockwise perimeter's travel, so outside is right.
|
||||
var outward = winding == RotationType.CCW ? new Vector(along.Y, -along.X) : new Vector(-along.Y, along.X);
|
||||
return span.EndPoint - along * reach + outward * (kerf / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One shared cut, absolute in its part's frame: a rapid to the pierce on the cut's axis
|
||||
/// before its start, the straight lead-in, the open centerline cut and the straight
|
||||
/// lead-out on past its end, each lead as long as the configured one reaches.
|
||||
/// </summary>
|
||||
internal static List<ICode> CommonLineSharedCutCodes(CuttingPlanning.CommonLineCutPath cut, LeadIn leadIn,
|
||||
LeadOut leadOut)
|
||||
{
|
||||
var codes = new List<ICode>();
|
||||
var along = (cut.End - cut.Start).Normalize();
|
||||
var reach = CommonLineLeadInReach(leadIn);
|
||||
codes.Add(new RapidMove(cut.Start - along * reach));
|
||||
if (reach > Tolerance.Epsilon)
|
||||
codes.Add(new LinearMove(cut.Start) { Layer = LayerType.Leadin });
|
||||
codes.Add(new LinearMove(cut.End) { Layer = LayerType.CommonLine });
|
||||
var exit = CommonLineLeadOutReach(leadOut);
|
||||
if (exit > Tolerance.Epsilon)
|
||||
codes.Add(new LinearMove(cut.End + along * exit) { Layer = LayerType.Leadout });
|
||||
return codes;
|
||||
}
|
||||
|
||||
/// <summary>How far a common-line lead-in reaches: the external lead-in's pierce distance.</summary>
|
||||
internal static double CommonLineLeadInReach(LeadIn leadIn) =>
|
||||
leadIn.GetPiercePoint(Vector.Zero, 0, RotationType.CW).DistanceTo(Vector.Zero);
|
||||
|
||||
/// <summary>How far a common-line shared cut's lead-out reaches: the external lead-out's.</summary>
|
||||
internal static double CommonLineLeadOutReach(LeadOut leadOut)
|
||||
{
|
||||
var reach = 0.0;
|
||||
foreach (var code in leadOut.Generate(Vector.Zero, 0, RotationType.CW))
|
||||
if (code is Motion motion)
|
||||
reach = System.Math.Max(reach, motion.EndPoint.DistanceTo(Vector.Zero));
|
||||
return reach;
|
||||
}
|
||||
|
||||
/// <summary>Whether <paramref name="shape"/> has <see cref="SpecialLayers.Tab"/> spans: a tabbed cutout.</summary>
|
||||
internal static bool IsTabbedCutout(Shape shape) => shape.Entities.Exists(e => e.Layer == SpecialLayers.Tab);
|
||||
|
||||
|
||||
@@ -30,5 +30,13 @@ namespace OpenNest.CNC
|
||||
/// closed contour enclosing every other contour.
|
||||
/// </summary>
|
||||
DisplayPerimeter,
|
||||
|
||||
/// <summary>
|
||||
/// A shared cut of a common-line group (see docs/common-line-cutting.md): an open cut on the
|
||||
/// centerline between two parts placed one kerf apart, which cuts both parts' facing edges
|
||||
/// at once. It is cut without kerf compensation, bounds no material and is never a rapid
|
||||
/// obstacle. Posts that cannot write it refuse the nest.
|
||||
/// </summary>
|
||||
CommonLine,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest
|
||||
{
|
||||
/// <summary>
|
||||
/// One shared cut of a common-line group, cut once on the centerline by <see cref="Owner"/>, the
|
||||
/// member of the pair cut first. <see cref="Partner"/> is cut later; its remainder ends in the
|
||||
/// kerf this cut opened.
|
||||
/// </summary>
|
||||
public sealed record CommonLineSharedCut(CommonLineSpan Span, Part Owner, Part Partner);
|
||||
|
||||
/// <summary>
|
||||
/// How a common-line group is cut once (see docs/common-line-cutting.md): its members in cutting
|
||||
/// order, and each shared cut with the member that cuts it.
|
||||
/// </summary>
|
||||
public sealed record CommonLineCutOrder(CommonLineGroup Group, IReadOnlyList<Part> Members,
|
||||
IReadOnlyList<CommonLineSharedCut> Cuts)
|
||||
{
|
||||
/// <summary>The shared cuts <paramref name="member"/> cuts.</summary>
|
||||
public IEnumerable<CommonLineSharedCut> CutsOwnedBy(Part member) =>
|
||||
Cuts.Where(cut => ReferenceEquals(cut.Owner, member));
|
||||
|
||||
/// <summary>Every span <paramref name="member"/> shares, whoever cuts it.</summary>
|
||||
public IEnumerable<CommonLineSpan> SpansOf(Part member) => Cuts
|
||||
.Where(cut => ReferenceEquals(cut.Owner, member) || ReferenceEquals(cut.Partner, member))
|
||||
.Select(cut => cut.Span);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Single-pass common-line cutting: which member cuts each shared span, and the planner's owned
|
||||
/// clean perimeter with its shared spans marked as never cut by that member.
|
||||
/// </summary>
|
||||
public static class CommonLineCutting
|
||||
{
|
||||
/// <summary>
|
||||
/// The cutting order of an intact group: members breadth-first from its first member along
|
||||
/// shared spans (ties in member order), each shared cut owned by the member cut first. A
|
||||
/// member's remainder therefore only ever ends in kerf cut before it.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException">The group is not intact.</exception>
|
||||
public static CommonLineCutOrder Order(CommonLineGroup group, CommonLineCheck check)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(group);
|
||||
ArgumentNullException.ThrowIfNull(check);
|
||||
if (!check.IsIntact)
|
||||
throw new ArgumentException(check.Problems[0].Message, nameof(check));
|
||||
var members = group.Members;
|
||||
int IndexOf(Part part) => members.ToList().FindIndex(member => ReferenceEquals(member, part));
|
||||
var order = new List<Part>();
|
||||
var seen = new bool[members.Count];
|
||||
var queue = new Queue<int>();
|
||||
queue.Enqueue(0);
|
||||
seen[0] = true;
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var current = members[queue.Dequeue()];
|
||||
order.Add(current);
|
||||
var neighbors = check.Spans
|
||||
.Select(span => ReferenceEquals(span.First, current) ? span.Second
|
||||
: ReferenceEquals(span.Second, current) ? span.First : null)
|
||||
.Where(part => part != null)
|
||||
.Select(IndexOf)
|
||||
.Distinct()
|
||||
.Order();
|
||||
foreach (var next in neighbors)
|
||||
if (!seen[next])
|
||||
{
|
||||
seen[next] = true;
|
||||
queue.Enqueue(next);
|
||||
}
|
||||
}
|
||||
if (order.Count != members.Count)
|
||||
throw new ArgumentException("The common-line group has split into separate pieces.", nameof(check));
|
||||
int Rank(Part part) => order.FindIndex(member => ReferenceEquals(member, part));
|
||||
var cuts = check.Spans
|
||||
.Select(span => Rank(span.First) < Rank(span.Second)
|
||||
? new CommonLineSharedCut(span, span.First, span.Second)
|
||||
: new CommonLineSharedCut(span, span.Second, span.First))
|
||||
.OrderBy(cut => Rank(cut.Owner))
|
||||
.ToList();
|
||||
return new CommonLineCutOrder(group, order, cuts);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A copy of <paramref name="clean"/> (a member's clean program, rotated as placed, in part
|
||||
/// coordinates; placed at <paramref name="location"/>) whose perimeter edges are split at
|
||||
/// every end of <paramref name="spans"/> and whose shared portions are on the
|
||||
/// <see cref="LayerType.Tab"/> layer: material that this member never cuts, because the
|
||||
/// shared cut does. The result is absolute. Only straight top-level moves can share.
|
||||
/// </summary>
|
||||
/// <exception cref="ArgumentException">A span does not lie along the program's edges.</exception>
|
||||
public static Program MarkSharedSpans(Program clean, Vector location, IReadOnlyList<CommonLineSpan> spans,
|
||||
double kerf)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(clean);
|
||||
ArgumentNullException.ThrowIfNull(spans);
|
||||
if (!double.IsFinite(kerf) || kerf <= 0)
|
||||
throw new ArgumentOutOfRangeException(nameof(kerf));
|
||||
var program = (Program)clean.Clone();
|
||||
program.Mode = Mode.Absolute;
|
||||
var local = spans.Select(span => (Start: span.Start - location, End: span.End - location)).ToArray();
|
||||
var covered = new double[local.Length];
|
||||
var codes = new List<ICode>();
|
||||
Vector? position = null;
|
||||
foreach (var code in program.Codes)
|
||||
{
|
||||
if (code is LinearMove line && position is { } start
|
||||
&& line.Layer is LayerType.Cut or LayerType.Display)
|
||||
{
|
||||
codes.AddRange(Split(line, start, local, covered, kerf));
|
||||
position = line.EndPoint;
|
||||
continue;
|
||||
}
|
||||
codes.Add(code);
|
||||
position = code switch
|
||||
{
|
||||
Motion motion => motion.EndPoint,
|
||||
SubProgramCall => null,
|
||||
_ => position,
|
||||
};
|
||||
}
|
||||
for (var i = 0; i < local.Length; i++)
|
||||
if (System.Math.Abs(covered[i] - local[i].Start.DistanceTo(local[i].End)) > CommonLineGeometry.GapTolerance)
|
||||
throw new ArgumentException(FormattableString.Invariant(
|
||||
$"The shared span from ({spans[i].Start.X:0.####}, {spans[i].Start.Y:0.####}) to ({spans[i].End.X:0.####}, {spans[i].End.Y:0.####}) does not lie along one straight edge of the part's program."));
|
||||
program.Codes.Clear();
|
||||
program.Codes.AddRange(codes);
|
||||
return program;
|
||||
}
|
||||
|
||||
// The line split where shared spans one half kerf off it begin and end; shared pieces on Tab.
|
||||
private static IEnumerable<ICode> Split(LinearMove line, Vector start, (Vector Start, Vector End)[] spans,
|
||||
double[] covered, double kerf)
|
||||
{
|
||||
var end = line.EndPoint;
|
||||
var length = start.DistanceTo(end);
|
||||
if (length <= Math.Tolerance.Epsilon)
|
||||
return [line];
|
||||
var direction = new Vector((end.X - start.X) / length, (end.Y - start.Y) / length);
|
||||
var intervals = new List<(double From, double To)>();
|
||||
for (var i = 0; i < spans.Length; i++)
|
||||
{
|
||||
var (a, b) = spans[i];
|
||||
var spanLength = a.DistanceTo(b);
|
||||
if (spanLength <= Math.Tolerance.Epsilon)
|
||||
continue;
|
||||
var along = new Vector((b.X - a.X) / spanLength, (b.Y - a.Y) / spanLength);
|
||||
if (System.Math.Abs(Cross(direction, along)) > 1e-6)
|
||||
continue;
|
||||
var offset = System.Math.Abs(Cross(direction, a - start));
|
||||
if (System.Math.Abs(offset - kerf / 2) > CommonLineGeometry.GapTolerance)
|
||||
continue;
|
||||
var ta = Dot(a - start, direction);
|
||||
var tb = Dot(b - start, direction);
|
||||
var from = System.Math.Max(0, System.Math.Min(ta, tb));
|
||||
var to = System.Math.Min(length, System.Math.Max(ta, tb));
|
||||
if (to - from <= Math.Tolerance.Epsilon)
|
||||
continue;
|
||||
// An end within the snap tolerance of a vertex is that vertex: no sliver is left uncut.
|
||||
if (from <= Math.Tolerance.Epsilon)
|
||||
from = 0;
|
||||
if (length - to <= Math.Tolerance.Epsilon)
|
||||
to = length;
|
||||
covered[i] += to - from;
|
||||
intervals.Add((from, to));
|
||||
}
|
||||
if (intervals.Count == 0)
|
||||
return [line];
|
||||
var pieces = new List<ICode>();
|
||||
var at = 0.0;
|
||||
foreach (var (from, to) in intervals.OrderBy(interval => interval.From))
|
||||
{
|
||||
if (from < at - Math.Tolerance.Epsilon)
|
||||
throw new ArgumentException("Shared spans overlap along one edge.");
|
||||
if (from - at > Math.Tolerance.Epsilon)
|
||||
pieces.Add(new LinearMove(Point(from)) { Layer = line.Layer });
|
||||
pieces.Add(new LinearMove(to >= length ? end : Point(to)) { Layer = LayerType.Tab });
|
||||
at = to;
|
||||
}
|
||||
if (length - at > Math.Tolerance.Epsilon)
|
||||
pieces.Add(new LinearMove(end) { Layer = line.Layer });
|
||||
else if (pieces[^1] is LinearMove last)
|
||||
last.EndPoint = end;
|
||||
return pieces;
|
||||
|
||||
Vector Point(double t) => new(start.X + direction.X * t, start.Y + direction.Y * t);
|
||||
}
|
||||
|
||||
private static double Dot(Vector a, Vector b) => a.X * b.X + a.Y * b.Y;
|
||||
|
||||
private static double Cross(Vector a, Vector b) => a.X * b.Y - a.Y * b.X;
|
||||
}
|
||||
}
|
||||
@@ -186,6 +186,9 @@ namespace OpenNest.Converters
|
||||
if (string.Equals(name, SpecialLayers.DisplayPerimeter.Name, System.StringComparison.OrdinalIgnoreCase))
|
||||
return LayerType.DisplayPerimeter;
|
||||
|
||||
if (string.Equals(name, SpecialLayers.CommonLine.Name, System.StringComparison.OrdinalIgnoreCase))
|
||||
return LayerType.CommonLine;
|
||||
|
||||
return LayerType.Cut;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,9 @@ namespace OpenNest.Converters
|
||||
case LayerType.DisplayPerimeter:
|
||||
return SpecialLayers.DisplayPerimeter;
|
||||
|
||||
case LayerType.CommonLine:
|
||||
return SpecialLayers.CommonLine;
|
||||
|
||||
default:
|
||||
return new Layer(layer.ToString());
|
||||
}
|
||||
|
||||
@@ -4,13 +4,16 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingPlanning;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Diagnostics;
|
||||
|
||||
/// <summary>
|
||||
/// Pre-post review of a plate's common-line groups (<see cref="Plate.CommonLines"/>): every member
|
||||
/// still shares a span one kerf from another member, the group's kerf is still the plate's, and no
|
||||
/// member's lead runs into a partner one kerf away (a lead on a shared edge would cut the partner).
|
||||
/// member's lead or shared cut runs into a partner one kerf away (a lead on a shared edge would cut
|
||||
/// the partner). A plate that cuts its common lines once must cut each shared span exactly once,
|
||||
/// on its centerline, by the member cut first; one set to cut them twice must have no shared cuts.
|
||||
/// Reports only; nothing is repaired, and an unreadable lead check is incomplete, never clear.
|
||||
/// </summary>
|
||||
internal static class CommonLineReview
|
||||
@@ -35,9 +38,87 @@ internal static class CommonLineReview
|
||||
$"'{problem.Part.BaseDrawing.Name}' {problem.Message}")
|
||||
{ Location = problem.Part.BoundingBox?.Center });
|
||||
Leads(plate, plateNumber, group, findings, token);
|
||||
if (check.IsIntact)
|
||||
SharedCuts(plate, plateNumber, group, check, findings, token);
|
||||
}
|
||||
}
|
||||
|
||||
// The shared cuts the members' programs make, against the spans the group derives now.
|
||||
private static void SharedCuts(Plate plate, int plateNumber, CommonLineGroup group, CommonLineCheck check,
|
||||
List<PostVerificationFinding> findings, CancellationToken token)
|
||||
{
|
||||
var cuts = new List<(Part Part, ExecutionMotion Motion)>();
|
||||
foreach (var member in group.Members)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
try
|
||||
{
|
||||
cuts.AddRange(ExecutionMotionReader.Read(member.Program, member.Location, null, token).Motions
|
||||
.Where(motion => !motion.Rapid && motion.Layer == LayerType.CommonLine && motion.Curve != null)
|
||||
.Select(motion => (member, motion)));
|
||||
}
|
||||
catch (Exception exception) when (IsInvalid(exception))
|
||||
{
|
||||
// The rapid check reports the unreadable program.
|
||||
}
|
||||
}
|
||||
if (plate.CutCommonLinesTwice)
|
||||
{
|
||||
if (cuts.Count > 0)
|
||||
findings.Add(new(PostVerificationKind.CommonLine, plateNumber, Number(plate, cuts[0].Part), null,
|
||||
"The plate is set to cut its common lines twice, but this part's program cuts a shared line "
|
||||
+ "once. Plan cutting again before posting.")
|
||||
{ Location = cuts[0].Motion.Curve.Midpoint });
|
||||
return;
|
||||
}
|
||||
foreach (var span in check.Spans)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var covering = cuts.Where(cut => Covers(cut.Motion, span)).ToList();
|
||||
var first = Number(plate, span.First);
|
||||
var second = Number(plate, span.Second);
|
||||
var middle = (span.Start + span.End) * 0.5;
|
||||
if (covering.Count == 0)
|
||||
{
|
||||
findings.Add(new(PostVerificationKind.CommonLine, plateNumber, first, second,
|
||||
"This common line is not cut once on its centerline. Plan cutting cuts each shared line once; "
|
||||
+ "or set the plate to cut its common lines twice.")
|
||||
{ Location = middle });
|
||||
continue;
|
||||
}
|
||||
if (covering.Count > 1)
|
||||
findings.Add(new(PostVerificationKind.CommonLine, plateNumber, first, second,
|
||||
"This common line is cut more than once. Plan cutting again before posting.")
|
||||
{ Location = middle });
|
||||
// The partner's remainder ends in this kerf, so the part that cuts it must come first.
|
||||
var owner = covering[0].Part;
|
||||
var partner = ReferenceEquals(owner, span.First) ? span.Second : span.First;
|
||||
if (Number(plate, owner) is int o && Number(plate, partner) is int p && o > p)
|
||||
findings.Add(new(PostVerificationKind.CommonLine, plateNumber, o, p,
|
||||
"The shared line is cut after the partner whose remainder ends in its kerf. Plan cutting "
|
||||
+ "again, or move the part that cuts it ahead of its partner.")
|
||||
{ Location = middle });
|
||||
}
|
||||
}
|
||||
|
||||
// A shared cut on the span's centerline that covers the whole span.
|
||||
private static bool Covers(ExecutionMotion motion, CommonLineSpan span)
|
||||
{
|
||||
var curve = motion.Curve;
|
||||
if (curve.IsFiniteArc)
|
||||
return false;
|
||||
var length = span.Length;
|
||||
var along = (span.End - span.Start) * (1 / length);
|
||||
double Offset(Vector point) => System.Math.Abs((point.X - span.Start.X) * along.Y - (point.Y - span.Start.Y) * along.X);
|
||||
double At(Vector point) => (point.X - span.Start.X) * along.X + (point.Y - span.Start.Y) * along.Y;
|
||||
var tolerance = CommonLineGeometry.GapTolerance;
|
||||
if (Offset(curve.Start) > tolerance || Offset(curve.End) > tolerance)
|
||||
return false;
|
||||
var from = System.Math.Min(At(curve.Start), At(curve.End));
|
||||
var to = System.Math.Max(At(curve.Start), At(curve.End));
|
||||
return from <= tolerance && to >= length - tolerance;
|
||||
}
|
||||
|
||||
private static void Leads(Plate plate, int plateNumber, CommonLineGroup group,
|
||||
List<PostVerificationFinding> findings, CancellationToken token)
|
||||
{
|
||||
@@ -86,9 +167,11 @@ internal static class CommonLineReview
|
||||
var partner = members[partners[failure.Obstacle!.Value]];
|
||||
var move = execution.Motions[failure.Motion];
|
||||
findings.Add(new(PostVerificationKind.CommonLine, plateNumber, Number(plate, members[i]),
|
||||
Number(plate, partner),
|
||||
$"A lead of '{members[i].BaseDrawing.Name}' runs into '{partner.BaseDrawing.Name}', its "
|
||||
+ "common-line partner one kerf away. Move the lead off the shared edge (Plan Cutting does).")
|
||||
Number(plate, partner), move.Layer == LayerType.CommonLine
|
||||
? $"A shared cut of '{members[i].BaseDrawing.Name}' runs into '{partner.BaseDrawing.Name}', its "
|
||||
+ "common-line partner. Rejoin the parts one kerf apart and plan cutting again."
|
||||
: $"A lead of '{members[i].BaseDrawing.Name}' runs into '{partner.BaseDrawing.Name}', its "
|
||||
+ "common-line partner one kerf away. Move the lead off the shared edge (Plan Cutting does).")
|
||||
{ Location = move.Curve?.Midpoint ?? move.End });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,13 @@ public static class PostVerificationAnalyzer
|
||||
"Clamp/cut-off check: " + exception.Message));
|
||||
}
|
||||
}
|
||||
var obstacles = new ReleasedContourState();
|
||||
// A common-line member cut once ends in open remainder pieces that cut it free.
|
||||
var members = (plate.CommonLines ?? [])
|
||||
.SelectMany(group => group.Members)
|
||||
.Select(member => plate.Parts.IndexOf(member) + 1)
|
||||
.Where(number => number > 0)
|
||||
.ToHashSet();
|
||||
var obstacles = new ReleasedContourState(true, null, members.Count == 0 ? null : members.Contains);
|
||||
Vector? position = startPoint;
|
||||
for (var index = 0; index < plate.Parts.Count; index++)
|
||||
{
|
||||
|
||||
@@ -202,6 +202,19 @@ namespace OpenNest
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cuts every common line twice, as slice 1 did: each member cuts its whole perimeter and
|
||||
/// the second pass runs in kerf the first opened. Off by default: Plan Cutting cuts each
|
||||
/// shared line once and each member's remaining edges after it (see
|
||||
/// docs/common-line-cutting.md). Choose this for a post that cannot write single-pass cuts.
|
||||
/// </summary>
|
||||
public bool CutCommonLinesTwice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True when the plate's common lines are cut once: it has groups and does not cut them twice.
|
||||
/// </summary>
|
||||
public bool CutsCommonLinesOnce => CommonLines.Count > 0 && !CutCommonLinesTwice;
|
||||
|
||||
/// <summary>Removes the common-line group holding <paramref name="part"/>; true when there was one.</summary>
|
||||
public bool RemoveCommonLine(Part part) =>
|
||||
CommonLineGroupOf(part) is { } group && CommonLines.Remove(group);
|
||||
|
||||
@@ -27,14 +27,19 @@ namespace OpenNest
|
||||
/// <summary>A supplied blank's shown-only outside edge: material boundary that is never cut.</summary>
|
||||
public static readonly Layer DisplayPerimeter = new Layer("DISPLAY PERIMETER") { Color = Color.DarkCyan };
|
||||
|
||||
/// <summary>A common-line group's shared cut: an open centerline cut between two parts, not material.</summary>
|
||||
public static readonly Layer CommonLine = new Layer("COMMON LINE") { Color = Color.Teal };
|
||||
|
||||
/// <summary>
|
||||
/// True when an entity converted from a part program describes part material. Rapids
|
||||
/// and scribe/etch marks are excluded: marks are only on the surface, so they never
|
||||
/// bound material and must not affect nesting, collision, area, or validation. Break
|
||||
/// cuts are excluded too: they run through material that stays attached at tabs. Tabs are
|
||||
/// material: they close a tabbed cutout's boundary. A display perimeter is material: it is the
|
||||
/// supplied blank's edge.
|
||||
/// supplied blank's edge. A common line's shared cut is excluded: it runs in the kerf between two
|
||||
/// parts, and their material comes from their perimeters.
|
||||
/// </summary>
|
||||
public static bool IsMaterial(Layer layer) => layer != Rapid && layer != Scribe && layer != Break;
|
||||
public static bool IsMaterial(Layer layer) =>
|
||||
layer != Rapid && layer != Scribe && layer != Break && layer != CommonLine;
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ namespace OpenNest.Undo
|
||||
hash.Add(cutOff.Position.Y);
|
||||
hash.Add(cutOff.Axis);
|
||||
}
|
||||
hash.Add(plate.CutCommonLinesTwice);
|
||||
hash.Add(plate.CommonLines.Count);
|
||||
foreach (var group in plate.CommonLines)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingPlanning;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Geometry;
|
||||
|
||||
namespace OpenNest.Engine.CuttingPlanning;
|
||||
|
||||
/// <summary>
|
||||
/// Capture of a plate's common-line groups cut once (docs/common-line-cutting.md). Each group is
|
||||
/// cut member by member in <see cref="CommonLineCutting.Order"/>'s order: a member's holes, the
|
||||
/// shared cuts it owns (open centerline cuts), then its remainder pieces, which end in kerf those
|
||||
/// shared cuts, or an earlier member's, opened. The owner of a shared cut therefore precedes its
|
||||
/// partner. Shared spans are derived from the placed geometry at capture; a broken group refuses.
|
||||
/// </summary>
|
||||
internal sealed class CommonLineCapture
|
||||
{
|
||||
private readonly Dictionary<Part, Member> members = new(ReferenceEqualityComparer.Instance);
|
||||
|
||||
private CommonLineCapture()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>Null when the request's plate cuts no common line once.</summary>
|
||||
/// <exception cref="NotSupportedException">A group is broken.</exception>
|
||||
internal static CommonLineCapture Of(CuttingPlanRequest request)
|
||||
{
|
||||
var plate = request?.Plate;
|
||||
if (plate == null || !plate.CutsCommonLinesOnce)
|
||||
return null;
|
||||
var capture = new CommonLineCapture();
|
||||
foreach (var group in plate.CommonLines)
|
||||
{
|
||||
var check = CommonLineGeometry.Check(group);
|
||||
if (!check.IsIntact)
|
||||
{
|
||||
var problem = check.Problems[0];
|
||||
throw new NotSupportedException(
|
||||
$"Part {IndexOf(request.Parts, problem.Part) + 1} {problem.Message} Rejoin its common line, "
|
||||
+ "remove it, or cut the plate's common lines twice, then replan.");
|
||||
}
|
||||
var order = CommonLineCutting.Order(group, check);
|
||||
for (var i = 0; i < order.Members.Count; i++)
|
||||
{
|
||||
var part = order.Members[i];
|
||||
if (IndexOf(request.Parts, part) < 0)
|
||||
throw new ArgumentException("A common-line member is not among the planned parts.");
|
||||
capture.members[part] = new Member(order, part, order.SpansOf(part).ToArray(),
|
||||
order.CutsOwnedBy(part).ToArray());
|
||||
}
|
||||
}
|
||||
return capture;
|
||||
}
|
||||
|
||||
/// <summary>Source ordinals of every member, for the rapid checker.</summary>
|
||||
internal IReadOnlySet<int> MemberNumbers(IReadOnlyList<Part> parts) =>
|
||||
members.Keys.Select(part => IndexOf(parts, part) + 1).ToHashSet();
|
||||
|
||||
/// <summary>(part, prerequisite) source ordinals: each shared cut's owner precedes its partner.</summary>
|
||||
internal IReadOnlyList<(int Part, int Prerequisite)> Order(IReadOnlyList<Part> parts) =>
|
||||
members.Values.SelectMany(member => member.Owned)
|
||||
.Select(cut => (IndexOf(parts, cut.Partner), IndexOf(parts, cut.Owner)))
|
||||
.Distinct()
|
||||
.ToArray();
|
||||
|
||||
internal bool IsMember(Part part) => members.ContainsKey(part);
|
||||
|
||||
/// <summary>The member's owned clean program with its shared spans on the Tab layer.</summary>
|
||||
/// <exception cref="NotSupportedException">A span does not lie along the program's edges.</exception>
|
||||
internal Program Mark(Part part, Program ownedClean, Vector location, int ordinal)
|
||||
{
|
||||
var member = members[part];
|
||||
try
|
||||
{
|
||||
return CommonLineCutting.MarkSharedSpans(ownedClean, location, member.Spans, member.Order.Group.Kerf);
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
throw new NotSupportedException($"Part {ordinal + 1} cannot be cut on its common line: {exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The member's shared cuts in part coordinates, each cut from whichever end its straight
|
||||
/// leads fit: the cut, its lead-in and its lead-out may touch no material, and the pierce keeps
|
||||
/// the pierce zone. Leads are never shortened: a cut whose leads fit at neither end refuses,
|
||||
/// naming the span.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">No lead fits a shared cut.</exception>
|
||||
internal CommonLinePerimeter Perimeter(Part part, int ordinal, IReadOnlyList<Part> parts,
|
||||
LeadMaterialSnapshot own, IReadOnlyList<LeadMaterialSnapshot> materials, CuttingParameters parameters,
|
||||
double pierceRadius, CancellationToken token)
|
||||
{
|
||||
var member = members[part];
|
||||
var location = part.Location;
|
||||
var leadIn = parameters.ExternalLeadIn ?? new NoLeadIn();
|
||||
var leadOut = parameters.ExternalLeadOut ?? new NoLeadOut();
|
||||
var cuts = new List<CommonLineCutPath>();
|
||||
foreach (var cut in member.Owned)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var forward = new CommonLineCutPath(cut.Span.Start - location, cut.Span.End - location);
|
||||
var reverse = new CommonLineCutPath(forward.End, forward.Start);
|
||||
string reason = null;
|
||||
CommonLineCutPath chosen = null;
|
||||
foreach (var path in new[] { forward, reverse })
|
||||
{
|
||||
var program = new Program(Mode.Absolute);
|
||||
program.Codes.AddRange(ContourCuttingStrategy.CommonLineSharedCutCodes(path, leadIn, leadOut));
|
||||
var execution = ExecutionMotionReader.ReadSupported(program, location, null, token);
|
||||
var result = LeadPathValidator.Check(execution, own, materials, pierceRadius, token);
|
||||
if (result.IsComplete && result.IsClear)
|
||||
{
|
||||
chosen = path;
|
||||
break;
|
||||
}
|
||||
reason ??= result.Reason;
|
||||
}
|
||||
if (chosen == null)
|
||||
throw new NotSupportedException(FormattableString.Invariant(
|
||||
$"No lead fits the common line between parts {ordinal + 1} and {IndexOf(parts, cut.Partner) + 1} from ({cut.Span.Start.X:0.####}, {cut.Span.Start.Y:0.####}) to ({cut.Span.End.X:0.####}, {cut.Span.End.Y:0.####}) at either end: ")
|
||||
+ reason + " Shorten the external lead-in or lead-out, or cut the plate's common lines twice.");
|
||||
cuts.Add(chosen);
|
||||
}
|
||||
return new CommonLinePerimeter(member.Order.Group.Kerf, cuts);
|
||||
}
|
||||
|
||||
private static int IndexOf(IReadOnlyList<Part> parts, Part part)
|
||||
{
|
||||
for (var i = 0; i < parts.Count; i++)
|
||||
if (ReferenceEquals(parts[i], part))
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
||||
private sealed record Member(CommonLineCutOrder Order, Part Part, IReadOnlyList<CommonLineSpan> Spans,
|
||||
IReadOnlyList<CommonLineSharedCut> Owned);
|
||||
}
|
||||
@@ -75,10 +75,15 @@ internal sealed class CuttingDependencyGraph
|
||||
return cyclic < 0 ? null : cyclic;
|
||||
}
|
||||
|
||||
/// <param name="required">Further (part, prerequisite) ordinals the caller proved, such as a
|
||||
/// common line's owner before its partner.</param>
|
||||
internal static CuttingDependencyGraph Build(IReadOnlyList<DependencyNode> nodes, Box plate,
|
||||
CancellationToken token, Action<CuttingDependencyException> uncertain = null)
|
||||
CancellationToken token, Action<CuttingDependencyException> uncertain = null,
|
||||
IReadOnlyList<(int Part, int Prerequisite)> required = null)
|
||||
{
|
||||
var edges = nodes.Select(_ => new SortedSet<int>()).ToArray();
|
||||
foreach (var (part, prerequisite) in required ?? [])
|
||||
edges[part].Add(prerequisite);
|
||||
for (var cut = 0; cut < nodes.Count; cut++)
|
||||
{
|
||||
if (!nodes[cut].IsCutOff)
|
||||
|
||||
@@ -101,7 +101,21 @@ public sealed class CuttingPlanSnapshot
|
||||
/// rapids may still cross parts their tab holds level.
|
||||
/// </summary>
|
||||
internal ReleasedContourState NewReleasedState() =>
|
||||
new(reportMissingLeadIns: false, tabMayNotHold.Count == 0 ? null : tabMayNotHold.Contains);
|
||||
new(reportMissingLeadIns: false, tabMayNotHold.Count == 0 ? null : tabMayNotHold.Contains,
|
||||
CommonLineMembers.Count == 0 ? null : CommonLineMembers.Contains);
|
||||
|
||||
/// <summary>
|
||||
/// Part numbers (source ordinal + 1) of the members of common-line groups cut once
|
||||
/// (docs/common-line-cutting.md): each member's open remainder cuts free its outside, which is a
|
||||
/// rapid obstacle once its program ends.
|
||||
/// </summary>
|
||||
internal IReadOnlySet<int> CommonLineMembers { get; init; } = new HashSet<int>();
|
||||
|
||||
/// <summary>
|
||||
/// The prerequisites that are common-line order (source ordinals: the member that cuts a shared
|
||||
/// line before its partner), for naming them in findings.
|
||||
/// </summary>
|
||||
internal IReadOnlySet<(int Part, int Prerequisite)> CommonLineOrder { get; init; } = new HashSet<(int, int)>();
|
||||
|
||||
/// <summary>Whole-part prerequisites by source ordinal (cutoffs, inner parts before hosts).</summary>
|
||||
internal CuttingDependencyGraph Dependencies { get; }
|
||||
@@ -135,14 +149,22 @@ public sealed class CuttingPlanSnapshot
|
||||
new(Placements, StartPoint, expansionBudget, Failure, Findings, Regeneration,
|
||||
PreservePartOrder, maxEntries, ExpansionObserver, PlateState, OwnedParameters,
|
||||
Dependencies, BestEffort)
|
||||
{ SupportTabsSkipped = SupportTabsSkipped };
|
||||
{
|
||||
SupportTabsSkipped = SupportTabsSkipped,
|
||||
CommonLineMembers = CommonLineMembers,
|
||||
CommonLineOrder = CommonLineOrder,
|
||||
};
|
||||
|
||||
/// <summary>The same capture planned along its current part order.</summary>
|
||||
internal CuttingPlanSnapshot WithPreservedOrder() =>
|
||||
new(Placements, StartPoint, ExpansionBudget, Failure, Findings, Regeneration,
|
||||
preservePartOrder: true, MaxEntries, ExpansionObserver, PlateState, OwnedParameters,
|
||||
Dependencies, BestEffort)
|
||||
{ SupportTabsSkipped = SupportTabsSkipped };
|
||||
{
|
||||
SupportTabsSkipped = SupportTabsSkipped,
|
||||
CommonLineMembers = CommonLineMembers,
|
||||
CommonLineOrder = CommonLineOrder,
|
||||
};
|
||||
}
|
||||
|
||||
public sealed class FixedProgramPlacement
|
||||
@@ -251,8 +273,13 @@ public sealed class FixedProgramPlacement
|
||||
tabbedPieces--;
|
||||
continue;
|
||||
}
|
||||
// A common-line perimeter, cut last, is several groups: its shared cuts, then its pieces.
|
||||
if (++group >= choices.Count)
|
||||
return null;
|
||||
{
|
||||
if (!Prepared.IsCommonLinePerimeter || choices[^1].ContourOrdinal != Prepared.PerimeterOrdinal)
|
||||
return null;
|
||||
group = choices.Count - 1;
|
||||
}
|
||||
pin = Prepared.PinNumberOf(choices[group].ContourOrdinal);
|
||||
}
|
||||
pins[index] = pin;
|
||||
|
||||
@@ -49,6 +49,9 @@ public static class CuttingPlanService
|
||||
if (part == null || !request.Parts.Any(p => ReferenceEquals(p, part)) || !eligible.Add(part))
|
||||
throw new ArgumentException("Foreign or duplicate eligible placement.");
|
||||
}
|
||||
// Common lines cut once: each member regenerates as its holes, shared cuts and remainder.
|
||||
var commonLines = CommonLineCapture.Of(request);
|
||||
var deferredMembers = new List<(int Placement, Program Clean)>();
|
||||
// Cutoff definitions by drawing reference, as automatic sequencing matches them.
|
||||
var definitions = new Dictionary<Drawing, CutOff>(ReferenceEqualityComparer.Instance);
|
||||
foreach (var cutOff in request.Plate?.CutOffs ?? [])
|
||||
@@ -136,20 +139,33 @@ public static class CuttingPlanService
|
||||
IncrementalClosureDrift.Close(ownedClean);
|
||||
// A baked-in seam overcut encloses no area; left in, the ring touches itself.
|
||||
SeamOvercut.Trim(ownedClean);
|
||||
// A common-line member never cuts its shared spans: they are its material's tabs.
|
||||
var member = request.ConfirmedParameters != null && commonLines?.IsMember(source) == true;
|
||||
if (member)
|
||||
{
|
||||
if (source.LeadInsLocked || request.EligibleParts != null && !eligible.Contains(source))
|
||||
throw new NotSupportedException($"Part {index + 1} shares a common line that is cut once, "
|
||||
+ "so Plan Cutting must regenerate its program: "
|
||||
+ (source.LeadInsLocked ? "unlock its lead-ins" : "include it in the plan")
|
||||
+ ", or cut the plate's common lines twice.");
|
||||
ownedClean = commonLines.Mark(source, ownedClean, source.Location, index);
|
||||
}
|
||||
// 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);
|
||||
var location = source.Location;
|
||||
if (request.ConfirmedParameters != null)
|
||||
{
|
||||
material = LeadMaterialSnapshot.Capture(ownedClean, location, token);
|
||||
material = LeadMaterialSnapshot.Capture(ownedClean, location, token, sharedSpans: member);
|
||||
if (!material.IsComplete)
|
||||
{
|
||||
if (!bestEffort)
|
||||
throw new NotSupportedException(material.Reason);
|
||||
warnings.Add(new(index, source, null, null, PostVerificationKind.Incomplete, material.Reason));
|
||||
}
|
||||
if (!source.LeadInsLocked && (request.EligibleParts == null || eligible.Contains(source)))
|
||||
if (member)
|
||||
deferredMembers.Add((placements.Count, ownedClean));
|
||||
else if (!source.LeadInsLocked && (request.EligibleParts == null || eligible.Contains(source)))
|
||||
{
|
||||
prepared = DrawingPinCapture.Prepare(source, index, ownedClean, request.ConfirmedParameters,
|
||||
warnings, token);
|
||||
@@ -166,14 +182,25 @@ public static class CuttingPlanService
|
||||
placements.Add(new(source, index, source.Location, source.Rotation, source.LeadInsLocked,
|
||||
execution, ownedProgram, prepared, material));
|
||||
}
|
||||
// A member's shared cuts need every part's material: each must fit its leads at one end.
|
||||
var materials = placements.Where(p => !p.IsCutOff && p.Material != null).Select(p => p.Material).ToArray();
|
||||
foreach (var (at, clean) in deferredMembers)
|
||||
{
|
||||
token.ThrowIfCancellationRequested();
|
||||
var placed = placements[at];
|
||||
source = placed.SourcePart;
|
||||
ordinal = placed.SourceOrdinal;
|
||||
placements[at] = CaptureMember(placed, clean, commonLines, request, materials, warnings, bestEffort, token);
|
||||
}
|
||||
// The start can be invalid even when the first rapid has no cutting geometry.
|
||||
placements[0].Execution.RapidDistanceFrom(request.StartPoint);
|
||||
source = null;
|
||||
ordinal = null;
|
||||
var commonLineOrder = commonLines?.Order(request.Parts) ?? [];
|
||||
var dependencies = CuttingDependencyGraph.Build(nodes, request.Plate?.BoundingBox(includeParts: false), token,
|
||||
bestEffort ? exception => warnings.Add(new(exception.Ordinal, request.Parts[exception.Ordinal],
|
||||
exception.Other, exception.Other is int other ? request.Parts[other] : null,
|
||||
PostVerificationKind.Incomplete, exception.Message)) : null);
|
||||
PostVerificationKind.Incomplete, exception.Message)) : null, commonLineOrder);
|
||||
return new(placements, request.StartPoint, request.ExpansionBudget, regeneration: request.ConfirmedParameters != null,
|
||||
preservePartOrder: request.PreservePartOrder, maxEntries: request.MaxEntries,
|
||||
expansionObserver: request.ExpansionObserver, plateState: plateState,
|
||||
@@ -182,6 +209,8 @@ public static class CuttingPlanService
|
||||
dependencies: dependencies, findings: warnings, bestEffort: bestEffort)
|
||||
{
|
||||
SupportTabsSkipped = SupportTabSettings.SkipsForNoRange(request.ConfirmedParameters, request.SupportBed),
|
||||
CommonLineMembers = commonLines?.MemberNumbers(request.Parts) ?? new HashSet<int>(),
|
||||
CommonLineOrder = commonLineOrder.ToHashSet(),
|
||||
};
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -208,6 +237,44 @@ public static class CuttingPlanService
|
||||
[new(ordinal, source, null, null, null, message)]);
|
||||
}
|
||||
|
||||
// A common-line member regenerates from its marked clean program: holes as usual, then its
|
||||
// shared cuts and remainder from one fixed entry. Its leads are checked here, so a lead that
|
||||
// fits nowhere refuses with the span named rather than as a search that ran out.
|
||||
private static FixedProgramPlacement CaptureMember(FixedProgramPlacement placed, Program clean,
|
||||
CommonLineCapture commonLines, CuttingPlanRequest request, IReadOnlyList<LeadMaterialSnapshot> materials,
|
||||
List<CuttingPlanFinding> warnings, bool bestEffort, CancellationToken token)
|
||||
{
|
||||
var source = placed.SourcePart;
|
||||
var index = placed.SourceOrdinal;
|
||||
var parameters = request.ConfirmedParameters;
|
||||
var pierceRadius = parameters.GetPierceZoneRadius();
|
||||
var material = placed.Material;
|
||||
PreparedContours prepared;
|
||||
try
|
||||
{
|
||||
var perimeter = commonLines.Perimeter(source, index, request.Parts, material, materials, parameters,
|
||||
pierceRadius, token);
|
||||
prepared = DrawingPinCapture.Prepare(source, index, clean, parameters, warnings, token, perimeter);
|
||||
if (!bestEffort)
|
||||
{
|
||||
var entry = prepared.Entries(prepared.PerimeterOrdinal, Vector.Zero)[0];
|
||||
var probe = ExecutionMotionReader.ReadSupported(prepared.EmitCandidateForValidation(entry),
|
||||
source.Location, null, token);
|
||||
var lead = LeadPathValidator.Check(probe, material, materials, pierceRadius, token);
|
||||
if (!lead.IsComplete || !lead.IsClear)
|
||||
throw new NotSupportedException("no lead-in fits its common-line remainder in the shared kerf: "
|
||||
+ lead.Reason);
|
||||
}
|
||||
}
|
||||
catch (NotSupportedException exception) when (!exception.Message.StartsWith("Part ", StringComparison.Ordinal)
|
||||
&& !exception.Message.StartsWith("No lead fits", StringComparison.Ordinal))
|
||||
{
|
||||
throw new NotSupportedException($"Part {index + 1}: {exception.Message}", exception);
|
||||
}
|
||||
return new(source, index, placed.Location, placed.Rotation, placed.LeadInsLocked, placed.Execution,
|
||||
placed.CopyProgram(), prepared, material);
|
||||
}
|
||||
|
||||
public static CuttingPlanResult Plan(CuttingPlanRequest request, CancellationToken token = default) =>
|
||||
Plan(Capture(request, token), token);
|
||||
|
||||
@@ -519,6 +586,8 @@ public static class CuttingPlanService
|
||||
$"{subject} cuts the sheet-separating cutoff (part {part.SourceOrdinal + 1}) before part "
|
||||
+ $"{prerequisite.SourceOrdinal + 1}; every part and other cutoff must be cut before the sheet is separated.");
|
||||
var reason = prerequisite.IsCutOff ? "the cutoff crossing it"
|
||||
: snapshot.CommonLineOrder.Contains((violation.Part, violation.Prerequisite))
|
||||
? "the common-line partner that cuts their shared line"
|
||||
: prerequisite.SourcePart.BaseDrawing.CutFirst && !part.SourcePart.BaseDrawing.CutFirst
|
||||
? "the cut-first part" : "the part nested in its cutout";
|
||||
return new(part.SourceOrdinal, part.SourcePart, prerequisite.SourceOrdinal, prerequisite.SourcePart, null,
|
||||
|
||||
@@ -16,21 +16,26 @@ namespace OpenNest.Engine.CuttingPlanning;
|
||||
internal static class DrawingPinCapture
|
||||
{
|
||||
internal static PreparedContours Prepare(Part source, int ordinal, Program ownedClean,
|
||||
CuttingParameters parameters, List<CuttingPlanFinding> warnings, CancellationToken token)
|
||||
CuttingParameters parameters, List<CuttingPlanFinding> warnings, CancellationToken token,
|
||||
CommonLinePerimeter commonLine = null)
|
||||
{
|
||||
var prepared = PreparedContours.Capture(ownedClean, parameters, token);
|
||||
var prepared = PreparedContours.Capture(ownedClean, parameters, token, commonLine);
|
||||
// Pins switched off for this placement (D1's escape hatch) leave it to the plate settings.
|
||||
if (!source.HasActiveDrawingPins)
|
||||
return prepared;
|
||||
// The clean program is the drawing's own program rotated by the part's rotation, so the
|
||||
// resolver maps the source-frame pins onto exactly these contours.
|
||||
var resolutions = CutPinResolver.Resolve(source.BaseDrawing, source.Rotation, prepared, token);
|
||||
var pinned = PreparedContours.Capture(ownedClean, parameters, resolutions, token);
|
||||
var pinned = PreparedContours.Capture(ownedClean, parameters, resolutions, token, commonLine);
|
||||
foreach (var resolution in resolutions.Where(r => !r.IsResolved))
|
||||
warnings.Add(Warning(source, ordinal, resolution, Unresolved(resolution)));
|
||||
foreach (var rejected in pinned.RejectedPins)
|
||||
warnings.Add(Warning(source, ordinal, rejected, $"Drawing pin {rejected.PinIndex + 1} puts a tab on an "
|
||||
+ "internal contour, but only the outside can be tabbed; planned with nest settings."));
|
||||
warnings.Add(Warning(source, ordinal, rejected,
|
||||
pinned.IsCommonLinePerimeter && rejected.ContourOrdinal == pinned.PerimeterOrdinal
|
||||
? $"Drawing pin {rejected.PinIndex + 1} is on the outside, which a common line cuts from its "
|
||||
+ "shared spans; planned with nest settings."
|
||||
: $"Drawing pin {rejected.PinIndex + 1} puts a tab on an "
|
||||
+ "internal contour, but only the outside can be tabbed; planned with nest settings."));
|
||||
return pinned;
|
||||
}
|
||||
|
||||
|
||||
@@ -1256,6 +1256,7 @@ internal static class JointCuttingPlanSearch
|
||||
reason = null;
|
||||
var prepared = source.Prepared;
|
||||
if (snapshot.PierceZoneRadius <= 0 || !prepared.HasCutPerimeter || prepared.IsPinned(prepared.PerimeterOrdinal)
|
||||
|| prepared.IsCommonLinePerimeter
|
||||
|| source.Material is not { IsComplete: true })
|
||||
return [];
|
||||
CountExpansion(source);
|
||||
|
||||
@@ -27,7 +27,8 @@ internal static class SupportTabCapture
|
||||
{
|
||||
var parameters = request.ConfirmedParameters;
|
||||
// A display perimeter is a supplied blank: it is never cut free, so it needs no tab.
|
||||
if (prepared == null || !prepared.HasCutPerimeter || parameters?.TabConfig == null
|
||||
// A common-line member is never support-tabbed: its outside is cut from its shared spans.
|
||||
if (prepared == null || !prepared.HasCutPerimeter || prepared.IsCommonLinePerimeter || parameters?.TabConfig == null
|
||||
|| !SupportTabSettings.CanTab(parameters, request.SupportBed))
|
||||
return prepared;
|
||||
token.ThrowIfCancellationRequested();
|
||||
|
||||
@@ -700,6 +700,13 @@ namespace OpenNest.IO
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||
public List<CommonLineDto> CommonLines { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// True when the plate's common lines are cut twice (<c>Plate.CutCommonLinesTwice</c>).
|
||||
/// Omitted when false: Plan Cutting cuts each shared line once.
|
||||
/// </summary>
|
||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
|
||||
public bool CutCommonLinesTwice { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// The settings the plate's cut-offs were generated with (<c>Plate.CutOffSettings</c>).
|
||||
/// Omitted when unknown; older files regenerate with the reader's defaults.
|
||||
|
||||
@@ -808,6 +808,7 @@ namespace OpenNest.IO
|
||||
|
||||
// Common lines: a group naming a missing part keeps the rest; one left with
|
||||
// fewer than two parts, or with an unusable kerf, is dropped.
|
||||
plate.CutCommonLinesTwice = p.CutCommonLinesTwice;
|
||||
foreach (var group in p.CommonLines ?? new List<CommonLineDto>())
|
||||
{
|
||||
var members = (group?.Parts ?? Array.Empty<int>())
|
||||
|
||||
@@ -486,6 +486,7 @@ namespace OpenNest.IO
|
||||
Parts = parts,
|
||||
CutOffs = cutoffs,
|
||||
CommonLines = commonLines.Count == 0 ? null : commonLines,
|
||||
CutCommonLinesTwice = plate.CutCommonLinesTwice,
|
||||
CutOffSettings = cutoffs.Count == 0 || plate.CutOffSettings is not { } settings ? null
|
||||
: new CutOffSettingsDto
|
||||
{
|
||||
@@ -887,6 +888,9 @@ namespace OpenNest.IO
|
||||
case LayerType.DisplayPerimeter:
|
||||
return ":DISPLAYPERIMETER";
|
||||
|
||||
case LayerType.CommonLine:
|
||||
return ":COMMONLINE";
|
||||
|
||||
default:
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
@@ -292,6 +292,13 @@ namespace OpenNest.IO
|
||||
layer = LayerType.DisplayPerimeter;
|
||||
break;
|
||||
|
||||
|
||||
case "COMMONLINE":
|
||||
|
||||
layer = LayerType.CommonLine;
|
||||
|
||||
break;
|
||||
|
||||
case "SUPPRESSED":
|
||||
suppressed = true;
|
||||
break;
|
||||
@@ -402,6 +409,13 @@ namespace OpenNest.IO
|
||||
layer = LayerType.DisplayPerimeter;
|
||||
break;
|
||||
|
||||
|
||||
case "COMMONLINE":
|
||||
|
||||
layer = LayerType.CommonLine;
|
||||
|
||||
break;
|
||||
|
||||
case "SUPPRESSED":
|
||||
suppressed = true;
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,412 @@
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingPlanning;
|
||||
using OpenNest.CNC.CuttingStrategy;
|
||||
using OpenNest.Diagnostics;
|
||||
using OpenNest.Engine.CuttingPlanning;
|
||||
using OpenNest.Geometry;
|
||||
using OpenNest.IO;
|
||||
|
||||
namespace OpenNest.Tests.CommonLines;
|
||||
|
||||
/// <summary>
|
||||
/// Plan Cutting cuts each common line once (docs/common-line-cutting.md): a group is cut member by
|
||||
/// member, each cutting its holes, then the shared cuts it owns on the centerline, then its
|
||||
/// remainder, which ends in the kerf the shared cut opened. The parts are PT42-like.
|
||||
/// </summary>
|
||||
public class CommonLinePlanningTests
|
||||
{
|
||||
internal const double Kerf = 0.012;
|
||||
internal const double Width = 6;
|
||||
internal const double Height = 12.44;
|
||||
internal const double Chamfer = 0.38;
|
||||
|
||||
internal static CuttingParameters Parameters(double leadIn = 0.25) => new()
|
||||
{
|
||||
ExternalLeadIn = new LineLeadIn { Length = leadIn, ApproachAngle = 90 },
|
||||
InternalLeadIn = new LineLeadIn { Length = leadIn, ApproachAngle = 90 },
|
||||
ExternalLeadOut = new NoLeadOut(),
|
||||
InternalLeadOut = new NoLeadOut(),
|
||||
PierceClearance = 0.05,
|
||||
Kerf = Kerf,
|
||||
};
|
||||
|
||||
/// <summary>A PT42-like drawing: Width x Height with chamfered corners, optionally a round hole.</summary>
|
||||
internal static Drawing Pt42(bool hole = false)
|
||||
{
|
||||
var program = new Program();
|
||||
program.Codes.Add(new RapidMove(Chamfer, 0));
|
||||
program.Codes.Add(new LinearMove(Width - Chamfer, 0));
|
||||
program.Codes.Add(new LinearMove(Width, Chamfer));
|
||||
program.Codes.Add(new LinearMove(Width, Height - Chamfer));
|
||||
program.Codes.Add(new LinearMove(Width - Chamfer, Height));
|
||||
program.Codes.Add(new LinearMove(Chamfer, Height));
|
||||
program.Codes.Add(new LinearMove(0, Height - Chamfer));
|
||||
program.Codes.Add(new LinearMove(0, Chamfer));
|
||||
program.Codes.Add(new LinearMove(Chamfer, 0));
|
||||
if (hole)
|
||||
{
|
||||
program.Codes.Add(new RapidMove(Width / 2 + 0.5, Height / 2));
|
||||
program.Codes.Add(new ArcMove(new Vector(Width / 2 + 0.5, Height / 2), new Vector(Width / 2, Height / 2),
|
||||
RotationType.CCW));
|
||||
}
|
||||
return new Drawing("PT42", program);
|
||||
}
|
||||
|
||||
/// <summary>A plate with <paramref name="count"/> PT42s in a row, one kerf apart and joined.</summary>
|
||||
internal static Plate Row(int count, bool hole = false, double x = 2, double y = 2, Drawing drawing = null)
|
||||
{
|
||||
var plate = new Plate(48, 120) { PartSpacing = 0.25 };
|
||||
drawing ??= Pt42(hole);
|
||||
var parts = new List<Part>();
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var part = new Part(drawing, new Vector(x + i * (Width + Kerf), y));
|
||||
plate.Parts.Add(part);
|
||||
parts.Add(part);
|
||||
}
|
||||
plate.JoinCommonLine(parts, Kerf);
|
||||
return plate;
|
||||
}
|
||||
|
||||
internal static CuttingPlanResult Plan(Plate plate, CuttingParameters parameters = null, bool keepOrder = false) =>
|
||||
CuttingPlanService.Plan(CuttingPlanRequest.ForPlate(plate, Vector.Zero, 20000, parameters ?? Parameters(),
|
||||
preservePartOrder: keepOrder));
|
||||
|
||||
internal static IReadOnlyList<ExecutionMotion> Motions(FixedProgramPlacement proposal) =>
|
||||
ExecutionMotionReader.Read(proposal.CopyProgram(), proposal.Location, null, default).Motions;
|
||||
|
||||
internal static IReadOnlyList<ExecutionMotion> Motions(Part part) =>
|
||||
ExecutionMotionReader.Read(part.Program, part.Location, null, default).Motions;
|
||||
|
||||
internal static string Describe(CuttingPlanResult result) =>
|
||||
$"{result.Status}: " + string.Join(" | ", result.Findings.Select(f => f.Message));
|
||||
|
||||
// The centerline between the parts at positions i and i + 1 of a row.
|
||||
private static double Centerline(int i, double x = 2) => x + (i + 1) * Width + i * Kerf + Kerf / 2;
|
||||
|
||||
private static bool IsCut(ExecutionMotion m) => !m.Rapid && m.Layer is LayerType.Cut or LayerType.Display;
|
||||
|
||||
[Fact]
|
||||
public void Pair_CutsTheSharedLineOnceOnTheCenterline()
|
||||
{
|
||||
var plate = Row(2);
|
||||
|
||||
var result = Plan(plate);
|
||||
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
Assert.True(result.IndependentlyReplayed);
|
||||
var cut = Assert.Single(result.ProposedOrder.SelectMany(Motions), m => m.Layer == LayerType.CommonLine);
|
||||
Assert.Equal(Centerline(0), cut.Curve.Start.X, 9);
|
||||
Assert.Equal(Centerline(0), cut.End.X, 9);
|
||||
Assert.Equal(Height - 2 * Chamfer, cut.Length, 9);
|
||||
// The member that cuts it comes first; its partner's remainder ends in its kerf.
|
||||
Assert.Same(plate.Parts[0], result.ProposedOrder[0].SourcePart);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Row_CutsEachMembersHolesThenItsSharedCutsThenItsRemainder()
|
||||
{
|
||||
var plate = Row(3, hole: true);
|
||||
|
||||
var result = Plan(plate);
|
||||
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
// The group is cut contiguously, owners before partners.
|
||||
Assert.Equal(plate.Parts, result.ProposedOrder.Select(p => p.SourcePart));
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
var motions = Motions(result.ProposedOrder[i]);
|
||||
var hole = motions.ToList().FindLastIndex(m => IsCut(m) && !m.Curve.IsLine);
|
||||
var shared = motions.ToList().FindIndex(m => m.Layer == LayerType.CommonLine);
|
||||
var remainder = motions.ToList().FindIndex(m => IsCut(m) && m.Curve.IsLine);
|
||||
Assert.True(hole >= 0, $"Part {i + 1} cuts no hole.");
|
||||
Assert.True(remainder > hole, $"Part {i + 1} cuts its remainder before its hole.");
|
||||
if (i < 2)
|
||||
Assert.True(shared > hole && shared < remainder, $"Part {i + 1} does not cut hole, shared cut, remainder in order.");
|
||||
else
|
||||
Assert.Equal(-1, shared); // The last member owns no shared cut.
|
||||
}
|
||||
Assert.Equal(2, result.ProposedOrder.SelectMany(Motions).Count(m => m.Layer == LayerType.CommonLine));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Remainders_StartInTheSharedKerf_AndEndOnTheirSpan()
|
||||
{
|
||||
var plate = Row(2);
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
|
||||
foreach (var proposal in result.ProposedOrder)
|
||||
{
|
||||
var motions = Motions(proposal);
|
||||
var lead = motions.Last(m => m.Layer == LayerType.Leadin);
|
||||
// Pierced on the centerline (nothing left to pierce), entering the member's own edge.
|
||||
Assert.Equal(Centerline(0), lead.Start!.Value.X, 9);
|
||||
var edge = ReferenceEquals(proposal.SourcePart, plate.Parts[0]) ? 2 + Width : 2 + Width + Kerf;
|
||||
Assert.Equal(edge, lead.End.X, 9);
|
||||
// The remainder ends at the other end of its shared span, on the member's edge.
|
||||
var last = motions.Last(IsCut);
|
||||
Assert.Equal(edge, last.End.X, 9);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Members_CutTheirPerimeterExactlyOnce_SharedSpansByTheSharedCut()
|
||||
{
|
||||
var plate = Row(2);
|
||||
var part = plate.Parts[0];
|
||||
var spans = CommonLineGeometry.Check(plate.CommonLines[0]).Spans;
|
||||
var marked = CommonLineCutting.MarkSharedSpans(part.BaseDrawing.Program, part.Location, spans, Kerf);
|
||||
var material = LeadMaterialSnapshot.Capture(marked, part.Location, default, sharedSpans: true);
|
||||
Assert.True(material.IsComplete, material.Reason);
|
||||
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
var planned = ExecutionMotionReader.Read(result.ProposedOrder[0].CopyProgram(), part.Location, null, default);
|
||||
Assert.True(ContourProgramVerifier.Verify(planned, material, null, default));
|
||||
|
||||
// Cutting the whole perimeter would cut the shared span a second time.
|
||||
var whole = ExecutionMotionReader.Read(part.BaseDrawing.Program, part.Location, null, default);
|
||||
Assert.False(ContourProgramVerifier.Verify(whole, material, null, default));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SharedCutLeadBlockedAtBothEnds_RefusesNamingTheSpan()
|
||||
{
|
||||
var plate = Row(2, x: 2, y: 2);
|
||||
// Strips just past both notches stop the axial lead-ins and lead-outs.
|
||||
foreach (var y in new[] { 2 - 0.3, 2 + Height + 0.1 })
|
||||
{
|
||||
var strip = new Program();
|
||||
strip.Codes.Add(new RapidMove(0, 0));
|
||||
strip.Codes.Add(new LinearMove(0, 0.2));
|
||||
strip.Codes.Add(new LinearMove(4, 0.2));
|
||||
strip.Codes.Add(new LinearMove(4, 0));
|
||||
strip.Codes.Add(new LinearMove(0, 0));
|
||||
plate.Parts.Add(new Part(new Drawing("strip", strip), new Vector(Centerline(0) - 2, y)));
|
||||
}
|
||||
|
||||
var result = Plan(plate, Parameters(leadIn: 0.5));
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.UnsupportedGeometry, result.Status);
|
||||
Assert.Contains(result.Findings, f => f.Message.Contains("No lead fits the common line between parts 1 and 2"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KeptOrderCuttingThePartnerFirst_IsAConstraintConflict()
|
||||
{
|
||||
var plate = Row(2);
|
||||
plate.Parts.Reorder([plate.Parts[1], plate.Parts[0]]);
|
||||
|
||||
var result = Plan(plate, keepOrder: true);
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.ConstraintConflict, result.Status);
|
||||
Assert.Contains(result.Findings, f => f.Message.Contains("common-line partner that cuts their shared line"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Replay_RefusesARemainderBeforeItsSharedCut()
|
||||
{
|
||||
var plate = Row(2);
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
|
||||
var swapped = CuttingPlanService.ReplayPrograms(result.Snapshot,
|
||||
[result.ProposedOrder[1], result.ProposedOrder[0]], 0, default);
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.InvalidInput, swapped.Status);
|
||||
Assert.Contains(swapped.Findings, f => f.Message.Contains("common-line partner"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Apply_KeepsUtilizationQuantityAndOverlapResults()
|
||||
{
|
||||
var nest = new Nest("N26-295");
|
||||
var plate = Row(3, hole: true);
|
||||
nest.Plates.Add(plate);
|
||||
var drawing = plate.Parts[0].BaseDrawing;
|
||||
nest.Drawings.Add(drawing);
|
||||
var utilization = plate.Utilization();
|
||||
var nested = drawing.Quantity.Nested;
|
||||
var overlaps = plate.HasOverlappingParts(out _);
|
||||
var pairs = PlateOverlapAnalyzer.Analyze(plate.Parts.ToList()).Pairs.Count;
|
||||
var area = plate.Parts.Sum(p => p.BaseDrawing.Area);
|
||||
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
|
||||
Assert.All(plate.Parts.Take(2), p => Assert.True(CommonLineCuts.IsSinglePass(p.Program)));
|
||||
Assert.Equal(utilization, plate.Utilization(), 12);
|
||||
Assert.Equal(nested, drawing.Quantity.Nested);
|
||||
Assert.Equal(overlaps, plate.HasOverlappingParts(out _));
|
||||
Assert.Equal(pairs, PlateOverlapAnalyzer.Analyze(plate.Parts.ToList()).Pairs.Count);
|
||||
Assert.Equal(area, plate.Parts.Sum(p => p.BaseDrawing.Area), 12);
|
||||
Assert.True(CommonLineGeometry.Check(plate.CommonLines[0]).IsIntact);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Applied_PassesPrePostReview()
|
||||
{
|
||||
var nest = new Nest("N26-295");
|
||||
var plate = Row(3, hole: true);
|
||||
plate.CuttingParameters = Parameters();
|
||||
nest.Plates.Add(plate);
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
|
||||
var findings = PostVerificationAnalyzer.Analyze(nest).Findings;
|
||||
|
||||
Assert.DoesNotContain(findings, f => f.Kind is PostVerificationKind.CommonLine or PostVerificationKind.Incomplete
|
||||
or PostVerificationKind.RapidCrossing or PostVerificationKind.MissingLeadIn or PostVerificationKind.PartSpacing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PrePost_ReportsACommonLineLeftUncut()
|
||||
{
|
||||
var nest = new Nest("N26-295");
|
||||
var plate = Row(2);
|
||||
nest.Plates.Add(plate);
|
||||
// Planned to cut twice, then switched back to once without replanning.
|
||||
plate.CutCommonLinesTwice = true;
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
plate.CutCommonLinesTwice = false;
|
||||
|
||||
var finding = Assert.Single(PostVerificationAnalyzer.Analyze(nest).Findings,
|
||||
f => f.Kind == PostVerificationKind.CommonLine);
|
||||
Assert.Contains("not cut once", finding.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CutTwice_CutsEveryMembersWholePerimeterAndNoSharedCut()
|
||||
{
|
||||
var plate = Row(2);
|
||||
plate.CutCommonLinesTwice = true;
|
||||
|
||||
var result = Plan(plate);
|
||||
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
var all = result.ProposedOrder.SelectMany(Motions).ToArray();
|
||||
Assert.DoesNotContain(all, m => m.Layer == LayerType.CommonLine);
|
||||
foreach (var proposal in result.ProposedOrder)
|
||||
{
|
||||
var cuts = Motions(proposal).Where(IsCut).ToArray();
|
||||
Assert.Equal(cuts[0].Curve.Start.X, cuts[^1].End.X, 9);
|
||||
Assert.Equal(cuts[0].Curve.Start.Y, cuts[^1].End.Y, 9);
|
||||
// No lead-in enters the shared edge, which would cut the partner one kerf away.
|
||||
var lead = Motions(proposal).First(m => m.Layer == LayerType.Leadin);
|
||||
var sharedEdge = ReferenceEquals(proposal.SourcePart, plate.Parts[0]) ? 2 + Width : 2 + Width + Kerf;
|
||||
Assert.False(System.Math.Abs(lead.End.X - sharedEdge) < 1e-9
|
||||
&& lead.End.Y > 2 + Chamfer && lead.End.Y < 2 + Height - Chamfer, "A lead-in enters the shared edge.");
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LockedMember_Refuses()
|
||||
{
|
||||
var plate = Row(2);
|
||||
plate.Parts[1].LeadInsLocked = true;
|
||||
|
||||
var result = Plan(plate);
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.UnsupportedGeometry, result.Status);
|
||||
Assert.Contains(result.Findings, f => f.Message.Contains("Part 2 shares a common line"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BrokenGroup_Refuses()
|
||||
{
|
||||
var plate = Row(2);
|
||||
plate.Parts[1].Offset(0.5, 0);
|
||||
|
||||
var result = Plan(plate);
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.UnsupportedGeometry, result.Status);
|
||||
Assert.Contains(result.Findings, f => f.Message.Contains("no longer shares"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LeadInLongerThanASharedSpan_Refuses()
|
||||
{
|
||||
var result = Plan(Row(2), Parameters(leadIn: 12));
|
||||
|
||||
Assert.Equal(CuttingPlanStatus.UnsupportedGeometry, result.Status);
|
||||
Assert.Contains(result.Findings, f => f.Message.Contains("shorter than the 12 external lead-in"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SupportTabs_AreNeverAppliedToMembers()
|
||||
{
|
||||
var plate = Row(2);
|
||||
var single = new Part(plate.Parts[0].BaseDrawing, new Vector(30, 2));
|
||||
plate.Parts.Add(single);
|
||||
var parameters = Parameters();
|
||||
parameters.SupportTabs = true;
|
||||
parameters.TabBySize = true;
|
||||
parameters.TabSizeMinWidth = 0;
|
||||
parameters.TabSizeMaxWidth = 100;
|
||||
parameters.TabConfig = new NormalTab { Size = 0.1 };
|
||||
|
||||
var result = Plan(plate, parameters);
|
||||
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
var perimeter = 2 * (Width + Height) - 8 * Chamfer + 4 * Chamfer * System.Math.Sqrt(2);
|
||||
var alone = result.ProposedOrder.Single(p => ReferenceEquals(p.SourcePart, single));
|
||||
Assert.True(Motions(alone).Where(IsCut).Sum(m => m.Length) < perimeter - 0.05, "The lone part is not tabbed.");
|
||||
foreach (var member in result.ProposedOrder.Where(p => !ReferenceEquals(p.SourcePart, single)))
|
||||
{
|
||||
var cut = Motions(member).Where(IsCut).Sum(m => m.Length);
|
||||
Assert.Equal(perimeter - (Height - 2 * Chamfer), cut, 6);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SwitchingToCutTwiceAfterPlanning_MakesThePlanStale()
|
||||
{
|
||||
var plate = Row(2);
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
|
||||
plate.CutCommonLinesTwice = true;
|
||||
|
||||
Assert.Equal(CuttingCommitStatus.Stale, CuttingPlanService.Apply([result]).Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Applied_RoundTripsThroughTheNestFile()
|
||||
{
|
||||
var nest = new Nest("N26-295");
|
||||
var plate = Row(2);
|
||||
nest.Plates.Add(plate);
|
||||
nest.Drawings.Add(plate.Parts[0].BaseDrawing);
|
||||
var result = Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
var twice = Row(2, drawing: plate.Parts[0].BaseDrawing);
|
||||
twice.CutCommonLinesTwice = true;
|
||||
nest.Plates.Add(twice);
|
||||
|
||||
var path = Path.Combine(Path.GetTempPath(), $"common-line-{Guid.NewGuid():N}.nest");
|
||||
try
|
||||
{
|
||||
new NestWriter(nest).Write(path);
|
||||
var read = new NestReader(path).Read();
|
||||
|
||||
Assert.False(read.Plates[0].CutCommonLinesTwice);
|
||||
Assert.True(read.Plates[1].CutCommonLinesTwice);
|
||||
var parts = read.Plates[0].Parts;
|
||||
Assert.Equal(Motions(plate.Parts[0]).Select(m => (m.Layer, m.End)), Motions(parts[0]).Select(m => (m.Layer, m.End)));
|
||||
Assert.True(CommonLineCuts.IsSinglePass(parts[0].Program));
|
||||
Assert.True(CommonLineCuts.IsSinglePass(parts[1].Program));
|
||||
Assert.DoesNotContain(PostVerificationAnalyzer.Analyze(read).Findings, f => f.PlateNumber == 1
|
||||
&& f.Kind is PostVerificationKind.CommonLine or PostVerificationKind.RapidCrossing);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
using System.Text;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.CNC.CuttingPlanning;
|
||||
using OpenNest.Engine.CuttingPlanning;
|
||||
using OpenNest.Posts.Cincinnati;
|
||||
using OpenNest.Posts.CincinnatiCIFiber;
|
||||
using OpenNest.Posts.GravographIS;
|
||||
|
||||
namespace OpenNest.Tests.CommonLines;
|
||||
|
||||
/// <summary>
|
||||
/// Posting common lines cut once (docs/common-line-cutting.md): the CI Fiber post writes each
|
||||
/// shared cut in the cut-off form with its lead-in and each remainder in the contour form,
|
||||
/// compensated on its perimeter's side; posts that cannot write them refuse the nest.
|
||||
/// </summary>
|
||||
public class CommonLinePostTests
|
||||
{
|
||||
private static Nest PlannedPair()
|
||||
{
|
||||
var nest = new Nest("N26-295") { Thickness = 0.1875, Material = new Material("Mild Steel") };
|
||||
var plate = CommonLinePlanningTests.Row(2);
|
||||
nest.Plates.Add(plate);
|
||||
var result = CommonLinePlanningTests.Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, CommonLinePlanningTests.Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
return nest;
|
||||
}
|
||||
|
||||
private static string Body(string program)
|
||||
{
|
||||
var lines = program.Split("\r\n");
|
||||
var start = Array.IndexOf(lines, "N0:") + 1;
|
||||
var end = Array.LastIndexOf(lines, "/L \"L0\"");
|
||||
return string.Join("\n", lines[start..end]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CIFiber_WritesTheSharedCutUncompensatedAndEachRemainderOnItsPerimetersSide()
|
||||
{
|
||||
var nest = PlannedPair();
|
||||
var post = new CIFiberPostProcessor(new CIFiberPostConfig { ConfigurationName = "CI FIBER 4020" });
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
post.Post(nest, stream);
|
||||
|
||||
// Part 1 cuts the shared line on the centerline (x 8.006), no G41/G42, entered and left
|
||||
// through the notches; then its remainder, pierced in that kerf and compensated G42 as its
|
||||
// counterclockwise perimeter would be. Part 2's remainder enters the same kerf at its other end.
|
||||
const string golden = """
|
||||
( Sheet number - 1 )
|
||||
( Part #1 )
|
||||
( PART:PT42 )
|
||||
V.E.R4=1
|
||||
N1:
|
||||
/L "L0"
|
||||
V.E.R3=1
|
||||
G0X8.006Y2.13
|
||||
/L "L4"
|
||||
G1X8.006Y2.38
|
||||
/L "L6"
|
||||
G1X8.006Y14.06
|
||||
/L "ZHSOFF"
|
||||
N2:
|
||||
/L "L0"
|
||||
V.E.R3=2
|
||||
G0X8.006Y13.81
|
||||
/L "L4"
|
||||
G42
|
||||
G1X8Y14.06
|
||||
/L "L6"
|
||||
G1X7.62Y14.44
|
||||
G1X2.38Y14.44
|
||||
G1X2Y14.06
|
||||
G1X2Y2.38
|
||||
G1X2.38Y2
|
||||
G1X7.62Y2
|
||||
G1X8Y2.38
|
||||
/L "ZHSOFF"
|
||||
( PART END )
|
||||
( Part #2 )
|
||||
( PART:PT42 )
|
||||
V.E.R4=2
|
||||
N3:
|
||||
/L "L0"
|
||||
V.E.R3=3
|
||||
G0X8.006Y2.63
|
||||
/L "L4"
|
||||
G42
|
||||
G1X8.012Y2.38
|
||||
/L "L6"
|
||||
G1X8.392Y2
|
||||
G1X13.632Y2
|
||||
G1X14.012Y2.38
|
||||
G1X14.012Y14.06
|
||||
G1X13.632Y14.44
|
||||
G1X8.392Y14.44
|
||||
G1X8.012Y14.06
|
||||
/L "ZHSOFF"
|
||||
( PART END )
|
||||
""";
|
||||
Assert.Equal(golden.ReplaceLineEndings("\n"), Body(Encoding.UTF8.GetString(stream.ToArray())));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CIFiber_CompensatesAClockwisePerimetersRemaindersG41()
|
||||
{
|
||||
// Imported drawings are wound clockwise: the same pair drawn that way.
|
||||
var drawing = CommonLinePlanningTests.Pt42();
|
||||
var reversed = new Program();
|
||||
var points = drawing.Program.Codes.OfType<Motion>().Select(m => m.EndPoint).Reverse().ToArray();
|
||||
reversed.Codes.Add(new RapidMove(points[0]));
|
||||
foreach (var point in points.Skip(1))
|
||||
reversed.Codes.Add(new LinearMove(point));
|
||||
var nest = new Nest("N26-295") { Thickness = 0.1875, Material = new Material("Mild Steel") };
|
||||
var plate = CommonLinePlanningTests.Row(2, drawing: new Drawing("PT42", reversed));
|
||||
nest.Plates.Add(plate);
|
||||
var result = CommonLinePlanningTests.Plan(plate);
|
||||
Assert.True(result.Status == CuttingPlanStatus.Ready, CommonLinePlanningTests.Describe(result));
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([result]).Status);
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
new CIFiberPostProcessor(new CIFiberPostConfig()).Post(nest, stream);
|
||||
|
||||
var lines = Body(Encoding.UTF8.GetString(stream.ToArray())).Split("\n");
|
||||
Assert.Equal(2, lines.Count(line => line == "G41"));
|
||||
Assert.DoesNotContain("G42", lines);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PostsThatCannotWriteSinglePassCommonLines_RefuseTheNest()
|
||||
{
|
||||
var nest = PlannedPair();
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
var cincinnati = Assert.Throws<InvalidOperationException>(() => new CincinnatiPostProcessor().Post(nest, stream));
|
||||
var gravograph = Assert.Throws<InvalidOperationException>(() => new GravographISPostProcessor().Post(nest, stream));
|
||||
|
||||
Assert.Contains("cannot write single-pass common lines", cincinnati.Message);
|
||||
Assert.Contains("Cut Common Lines Twice", gravograph.Message);
|
||||
Assert.Equal(0, stream.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Host_RefusesAPostWithoutSupport_AndPassesOneWithIt()
|
||||
{
|
||||
var nest = PlannedPair();
|
||||
|
||||
var refused = Assert.Throws<InvalidOperationException>(() =>
|
||||
CommonLineCuts.EnsurePostable(nest, new NoCommonLinePost()));
|
||||
Assert.Contains("Plate 1, part 1 cuts a common line once", refused.Message);
|
||||
CommonLineCuts.EnsurePostable(nest, new CIFiberPostProcessor());
|
||||
|
||||
// Cut twice, nothing is single-pass, so any post may write it.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
var again = CommonLinePlanningTests.Plan(nest.Plates[0]);
|
||||
Assert.Equal(CuttingCommitStatus.Applied, CuttingPlanService.Apply([again]).Status);
|
||||
CommonLineCuts.EnsurePostable(nest, new NoCommonLinePost());
|
||||
}
|
||||
|
||||
private sealed class NoCommonLinePost : IPostProcessor
|
||||
{
|
||||
public string Name => "Plain";
|
||||
public string Author => "Tests";
|
||||
public string Description => "A post that knows nothing of common lines.";
|
||||
public void Post(Nest nest, Stream outputStream) => throw new NotSupportedException();
|
||||
public void Post(Nest nest, string outputFile) => throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
@@ -160,6 +160,8 @@ public class CommonLineTests
|
||||
Assert.Single(ungrouped.Findings, f => f.Kind == PostVerificationKind.PartSpacing);
|
||||
|
||||
nest.Plates[0].JoinCommonLine(new[] { a, b }, Kerf);
|
||||
// Unplanned programs cut every perimeter whole: these plates cut their common lines twice.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
var grouped = PostVerificationAnalyzer.Analyze(nest);
|
||||
Assert.DoesNotContain(grouped.Findings, f => f.Kind is PostVerificationKind.PartSpacing
|
||||
or PostVerificationKind.CommonLine or PostVerificationKind.Overlap);
|
||||
@@ -172,6 +174,8 @@ public class CommonLineTests
|
||||
var b = Chamfered(Width + Kerf, 0);
|
||||
var nest = NestWith(a, b);
|
||||
nest.Plates[0].JoinCommonLine(new[] { a, b }, Kerf);
|
||||
// Unplanned programs cut every perimeter whole: these plates cut their common lines twice.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
b.Offset(-Kerf / 2, 0);
|
||||
|
||||
var findings = PostVerificationAnalyzer.Analyze(nest).Findings;
|
||||
@@ -199,6 +203,8 @@ public class CommonLineTests
|
||||
var b = Chamfered(Width + Kerf, 0);
|
||||
var nest = NestWith(a, b);
|
||||
nest.Plates[0].JoinCommonLine(new[] { a, b }, Kerf);
|
||||
// Unplanned programs cut every perimeter whole: these plates cut their common lines twice.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
b.Offset(1, 0);
|
||||
|
||||
var findings = PostVerificationAnalyzer.Analyze(nest).Findings
|
||||
@@ -215,6 +221,8 @@ public class CommonLineTests
|
||||
var b = Chamfered(Width + Kerf, 0);
|
||||
var nest = NestWith(a, b);
|
||||
nest.Plates[0].JoinCommonLine(new[] { a, b }, Kerf);
|
||||
// Unplanned programs cut every perimeter whole: these plates cut their common lines twice.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
nest.Plates[0].CuttingParameters = new CuttingParameters { Kerf = 0.02 };
|
||||
|
||||
var finding = Assert.Single(PostVerificationAnalyzer.Analyze(nest).Findings,
|
||||
@@ -238,6 +246,8 @@ public class CommonLineTests
|
||||
var b = new Part(new Drawing("plain", Rectangle()), new Vector(Width + Kerf, 0));
|
||||
var nest = NestWith(a, b);
|
||||
nest.Plates[0].JoinCommonLine(new[] { a, b }, Kerf);
|
||||
// Unplanned programs cut every perimeter whole: these plates cut their common lines twice.
|
||||
nest.Plates[0].CutCommonLinesTwice = true;
|
||||
|
||||
var finding = Assert.Single(PostVerificationAnalyzer.Analyze(nest).Findings,
|
||||
f => f.Kind == PostVerificationKind.CommonLine);
|
||||
|
||||
@@ -944,6 +944,22 @@ namespace OpenNest.Controls
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the plate cuts its common lines twice (<see cref="Plate.CutCommonLinesTwice"/>),
|
||||
/// as an undoable edit. False when nothing changed.
|
||||
/// </summary>
|
||||
public bool SetCutCommonLinesTwice(bool twice)
|
||||
{
|
||||
if (Plate == null || Plate.CutCommonLinesTwice == twice)
|
||||
return false;
|
||||
using var change = BeginChange(twice ? "Cut Common Lines Twice" : "Cut Common Lines Once");
|
||||
change.MarkChanged();
|
||||
Plate.CutCommonLinesTwice = twice;
|
||||
Invalidate();
|
||||
change.Complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void AlignSelected(AlignType alignType, LayoutPart fixedPart) =>
|
||||
selection.AlignSelected(alignType, fixedPart);
|
||||
|
||||
|
||||
@@ -40,6 +40,17 @@ namespace OpenNest.Forms.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
// A common line cut once needs a post that writes it; none falls back to cutting it twice.
|
||||
try
|
||||
{
|
||||
CNC.CommonLineCuts.EnsurePostable(nest, postProcessor);
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
MessageBox.Show(owner, ex.Message, postProcessor.Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// Verification runs fresh on every attempt; its consent never outlives this call.
|
||||
using (var verification = new PostVerificationForm(nest, postProcessor))
|
||||
{
|
||||
|
||||
Generated
+12
-1
@@ -158,6 +158,7 @@ namespace OpenNest.Forms
|
||||
toolStripMenuItemCommonLine = new System.Windows.Forms.ToolStripSeparator();
|
||||
mnuPlateJoinCommonLine = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateRemoveCommonLine = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuPlateCutCommonLinesTwice = new System.Windows.Forms.ToolStripMenuItem();
|
||||
mnuSequenceParts = new System.Windows.Forms.ToolStripMenuItem();
|
||||
autoSequenceCurrentPlateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
manualSequenceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
@@ -971,10 +972,11 @@ namespace OpenNest.Forms
|
||||
//
|
||||
// mnuPlateArrange
|
||||
//
|
||||
mnuPlateArrange.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuPlateAlignLeft, mnuPlateAlignRight, mnuPlateAlignTop, mnuPlateAlignBottom, toolStripMenuItem11, mnuPlateAlignHorizontal, mnuPlateAlignVertically, toolStripMenuItem8, mnuPlateEvenlySpaceHorizontal, mnuPlateEvenlySpaceVertical, toolStripMenuItem23, centerPartsToolStripMenuItem, toolStripMenuItem24, mnuPlatePatternTile, mnuPlateExpandSpacing, toolStripMenuItemCommonLine, mnuPlateJoinCommonLine, mnuPlateRemoveCommonLine });
|
||||
mnuPlateArrange.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { mnuPlateAlignLeft, mnuPlateAlignRight, mnuPlateAlignTop, mnuPlateAlignBottom, toolStripMenuItem11, mnuPlateAlignHorizontal, mnuPlateAlignVertically, toolStripMenuItem8, mnuPlateEvenlySpaceHorizontal, mnuPlateEvenlySpaceVertical, toolStripMenuItem23, centerPartsToolStripMenuItem, toolStripMenuItem24, mnuPlatePatternTile, mnuPlateExpandSpacing, toolStripMenuItemCommonLine, mnuPlateJoinCommonLine, mnuPlateRemoveCommonLine, mnuPlateCutCommonLinesTwice });
|
||||
mnuPlateArrange.Name = "mnuPlateArrange";
|
||||
mnuPlateArrange.Size = new System.Drawing.Size(177, 22);
|
||||
mnuPlateArrange.Text = "Arrange";
|
||||
mnuPlateArrange.DropDownOpening += ArrangeMenu_Opening;
|
||||
//
|
||||
// mnuPlateAlignLeft
|
||||
//
|
||||
@@ -1093,6 +1095,14 @@ namespace OpenNest.Forms
|
||||
mnuPlateRemoveCommonLine.Text = "Remove Common Line";
|
||||
mnuPlateRemoveCommonLine.Click += RemoveCommonLine_Click;
|
||||
//
|
||||
// mnuPlateCutCommonLinesTwice
|
||||
//
|
||||
mnuPlateCutCommonLinesTwice.Name = "mnuPlateCutCommonLinesTwice";
|
||||
mnuPlateCutCommonLinesTwice.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateCutCommonLinesTwice.Text = "Cut Common Lines Twice";
|
||||
mnuPlateCutCommonLinesTwice.ToolTipText = "Cut every shared edge with both parts' whole perimeters, for a post that cannot cut a common line once.";
|
||||
mnuPlateCutCommonLinesTwice.Click += CutCommonLinesTwice_Click;
|
||||
//
|
||||
// mnuSequenceParts
|
||||
//
|
||||
mnuSequenceParts.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { autoSequenceCurrentPlateToolStripMenuItem, manualSequenceToolStripMenuItem, sequenceByPathToolStripMenuItem });
|
||||
@@ -1597,6 +1607,7 @@ namespace OpenNest.Forms
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItemCommonLine;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateJoinCommonLine;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateRemoveCommonLine;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuPlateCutCommonLinesTwice;
|
||||
private System.Windows.Forms.ToolStripButton btnSaveAs;
|
||||
private System.Windows.Forms.ToolStripMenuItem centerPartsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripStatusLabel selectionStatusLabel;
|
||||
|
||||
@@ -109,6 +109,21 @@ namespace OpenNest.Forms
|
||||
ShowCommonLineNotice("None of the selected parts share a common line.");
|
||||
}
|
||||
|
||||
private void CutCommonLinesTwice_Click(object sender, EventArgs e)
|
||||
{
|
||||
var plateView = activeForm?.PlateView;
|
||||
if (plateView?.Plate == null)
|
||||
return;
|
||||
plateView.SetCutCommonLinesTwice(!plateView.Plate.CutCommonLinesTwice);
|
||||
}
|
||||
|
||||
private void ArrangeMenu_Opening(object sender, EventArgs e)
|
||||
{
|
||||
var plate = activeForm?.PlateView?.Plate;
|
||||
mnuPlateCutCommonLinesTwice.Checked = plate?.CutCommonLinesTwice == true;
|
||||
mnuPlateCutCommonLinesTwice.Enabled = plate != null;
|
||||
}
|
||||
|
||||
// Native tests capture this notice without opening a modal dialog in session zero.
|
||||
internal System.Action<string> CommonLineNotice { get; set; }
|
||||
|
||||
|
||||
@@ -378,7 +378,15 @@ namespace OpenNest
|
||||
localCut = cutPath;
|
||||
localEtch = etchPath;
|
||||
// Only programs with break cuts or open (tabbed) cuts need a fill apart from the outline path.
|
||||
if (hasOpenCuts || HasBreakCuts(program))
|
||||
// A common-line member cut once leaves its shared spans to the shared cut: its material is
|
||||
// the drawing's, rotated as placed (docs/common-line-cutting.md).
|
||||
if (CNC.CommonLineCuts.IsSinglePass(program))
|
||||
{
|
||||
var clean = (CNC.Program)BasePart.BaseDrawing.Program.Clone();
|
||||
clean.Rotate(BasePart.Rotation - BasePart.BaseDrawing.Program.Rotation);
|
||||
localFill = clean.GetFillPath(Vector.Zero);
|
||||
}
|
||||
else if (hasOpenCuts || HasBreakCuts(program))
|
||||
localFill = program.GetFillPath(Vector.Zero);
|
||||
localLead = BasePart.HasManualLeadIns ? leadPath : null;
|
||||
if (!BasePart.HasManualLeadIns)
|
||||
|
||||
@@ -98,6 +98,8 @@ namespace OpenNest.Posts.Cincinnati
|
||||
HeadHeightLock.EnsurePostable(nest, Config.HasHeadHeightLockCodes(), Name);
|
||||
// M47 raises the head before a marked rapid; the markers must be well formed.
|
||||
HeadRaise.EnsurePostable(nest, true, Name);
|
||||
// Shared cuts and remainders need per-contour compensation this post does not write.
|
||||
CommonLineCuts.EnsurePostable(nest, this);
|
||||
EnsureProcessResolvable(nest);
|
||||
|
||||
// 1. Create variable manager and register standard variables
|
||||
@@ -259,6 +261,8 @@ namespace OpenNest.Posts.Cincinnati
|
||||
DisplayPerimeterTail.EnsurePostable(nest);
|
||||
HeadHeightLock.EnsurePostable(nest, Config.HasHeadHeightLockCodes(), Name);
|
||||
HeadRaise.EnsurePostable(nest, true, Name);
|
||||
// Shared cuts and remainders need per-contour compensation this post does not write.
|
||||
CommonLineCuts.EnsurePostable(nest, this);
|
||||
EnsureProcessResolvable(nest);
|
||||
using var fs = new FileStream(outputFile, FileMode.Create, FileAccess.Write);
|
||||
Post(nest, fs);
|
||||
|
||||
@@ -45,6 +45,19 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
|
||||
/// <summary>Whether the rapid to the pierce raises the head over parts already cut (<see cref="HeadRaise"/>).</summary>
|
||||
public bool Raised { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// True for a common line's shared cut (<see cref="LayerType.CommonLine"/>): an open
|
||||
/// centerline cut made without kerf compensation.
|
||||
/// </summary>
|
||||
public bool IsCommonLine { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// For a common-line remainder, the winding of the perimeter it belongs to
|
||||
/// (<see cref="CommonLineCuts"/>): it is cut as the perimeter, compensated on that side.
|
||||
/// Null for every other contour.
|
||||
/// </summary>
|
||||
public RotationType? RemainderWinding { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,6 +135,13 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
continue;
|
||||
}
|
||||
|
||||
if (CommonLineCuts.RemainderWinding(code) is { } winding)
|
||||
{
|
||||
current ??= new CIFiberContour { Pierce = origin };
|
||||
current.RemainderWinding = winding;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (HeadHeightLock.IsLock(code) || HeadHeightLock.IsUnlock(code))
|
||||
{
|
||||
current ??= new CIFiberContour { Pierce = origin };
|
||||
@@ -180,6 +200,8 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
// only Scribe is reliably a mark. Scribe contours
|
||||
// are dropped by the writer when SkipScribe is on.
|
||||
current.Cuts.Add(absolute);
|
||||
if (layer == LayerType.CommonLine)
|
||||
current.IsCommonLine = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
public sealed class CIFiberPostProcessor
|
||||
: IJsonConfigPostProcessor,
|
||||
IMultiFilePostProcessor,
|
||||
IPostVerificationSupport
|
||||
IPostVerificationSupport,
|
||||
ICommonLinePostProcessor
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
|
||||
@@ -248,12 +248,19 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
contours = contours.Where(c => !IsScribeContour(c)).ToList();
|
||||
|
||||
var isCutOff = part.BaseDrawing.IsCutOff;
|
||||
var perimeter = CIFiberWinding.PerimeterIndex(contours);
|
||||
// A common-line member's outside is its remainders; every closed contour is a hole.
|
||||
var remainders = contours.Any(c => c.RemainderWinding != null);
|
||||
var perimeter = remainders ? -1 : CIFiberWinding.PerimeterIndex(contours);
|
||||
for (var i = 0; i < contours.Count; i++)
|
||||
{
|
||||
contourNumber++;
|
||||
if (isCutOff)
|
||||
WriteCutOffContour(contours[i], contourNumber, w);
|
||||
else if (contours[i].IsCommonLine)
|
||||
WriteCommonLineContour(contours[i], contourNumber, w);
|
||||
else if (contours[i].RemainderWinding is { } winding)
|
||||
// G41 leaves the product right of travel: a clockwise perimeter's side.
|
||||
WriteContour(contours[i], true, contourNumber, w, winding == RotationType.CW);
|
||||
else
|
||||
WriteContour(contours[i], contours[i].IsExterior || i == perimeter, contourNumber, w);
|
||||
}
|
||||
@@ -270,7 +277,8 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
CIFiberFormatter.Line(w, $"G0X{Fmt(contour.Pierce.X)}Y{Fmt(contour.Pierce.Y)}");
|
||||
}
|
||||
|
||||
private void WriteContour(CIFiberContour contour, bool isExterior, int contourNumber, TextWriter w)
|
||||
private void WriteContour(CIFiberContour contour, bool isExterior, int contourNumber, TextWriter w,
|
||||
bool? compensatesLeft = null)
|
||||
{
|
||||
CIFiberFormatter.Line(w, $"N{contourNumber}:");
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerCancel));
|
||||
@@ -302,7 +310,7 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
// way this contour actually runs.
|
||||
CIFiberFormatter.Line(
|
||||
w,
|
||||
CIFiberWinding.CompensatesLeft(contour, isExterior) ? "G41" : "G42"
|
||||
compensatesLeft ?? CIFiberWinding.CompensatesLeft(contour, isExterior) ? "G41" : "G42"
|
||||
);
|
||||
|
||||
var prev = contour.LeadIn.EndPoint;
|
||||
@@ -373,6 +381,43 @@ namespace OpenNest.Posts.CincinnatiCIFiber
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerCutEnd));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A common line's shared cut (docs/common-line-cutting.md): the cut-off form with a real
|
||||
/// lead-in. The line is the beam centerline between two parts one kerf apart, so no
|
||||
/// G41/G42 is selected; the exterior lead macro runs, then the straight lead-in, the cut
|
||||
/// layer, the cut and its lead-out. Unconfirmed on the machine: that a contour after a
|
||||
/// compensated one starts uncompensated, as the post never writes G40.
|
||||
/// </summary>
|
||||
private void WriteCommonLineContour(CIFiberContour contour, int contourNumber, TextWriter w)
|
||||
{
|
||||
if (contour.LeadIn is not (null or LinearMove) || contour.LeadInExtra.Count > 0)
|
||||
throw new InvalidOperationException(
|
||||
$"Contour {contourNumber} is a common-line shared cut with a lead-in that is not one straight move."
|
||||
);
|
||||
|
||||
CIFiberFormatter.Line(w, $"N{contourNumber}:");
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerCancel));
|
||||
CIFiberFormatter.Line(w, $"V.E.R3={contourNumber}");
|
||||
WriteRapidToPierce(contour, w);
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerExteriorLeadin));
|
||||
|
||||
var prev = contour.Pierce;
|
||||
if (contour.LeadIn != null)
|
||||
{
|
||||
CIFiberFormatter.Line(w, FormatMotion(contour.LeadIn, prev));
|
||||
prev = contour.LeadIn.EndPoint;
|
||||
}
|
||||
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerCut));
|
||||
foreach (var cut in contour.Cuts)
|
||||
{
|
||||
CIFiberFormatter.Line(w, FormatMotion(cut, prev));
|
||||
prev = cut.EndPoint;
|
||||
}
|
||||
|
||||
CIFiberFormatter.Line(w, SkippableLine(_config.LayerCutEnd));
|
||||
}
|
||||
|
||||
/// <summary>Source file name without extension, else the drawing name.</summary>
|
||||
private static string PartName(Part part)
|
||||
{
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace OpenNest.Posts.GravographIS
|
||||
if (outputStream == null)
|
||||
throw new ArgumentNullException(nameof(outputStream));
|
||||
|
||||
CNC.CommonLineCuts.EnsurePostable(nest, this);
|
||||
var passes = BuildPasses(Extractor.ExtractLayered(nest));
|
||||
new GravographISWriter(WriterOptions).Write(passes, outputStream);
|
||||
}
|
||||
@@ -80,6 +81,7 @@ namespace OpenNest.Posts.GravographIS
|
||||
{
|
||||
// Refuse before creating the file, so a refusal never empties an existing program.
|
||||
CNC.DisplayPerimeterTail.EnsurePostable(nest);
|
||||
CNC.CommonLineCuts.EnsurePostable(nest, this);
|
||||
using var fs = new FileStream(outputFile, FileMode.Create, FileAccess.Write);
|
||||
Post(nest, fs);
|
||||
}
|
||||
|
||||
@@ -64,9 +64,35 @@ uses the Cincinnati machine-sample convention, not a generic TF5200 laser API:
|
||||
enter and verify it on the machine.
|
||||
- Hole subprogram geometry is inlined. Suppressed moves and, by default,
|
||||
wholly scribe contours are omitted.
|
||||
- Common lines cut once: see [common lines](#common-lines) below.
|
||||
- Files use UTF-8 without a BOM and CRLF lines. Default accuracy is three decimal
|
||||
places: coordinates trim trailing zeros; dimensional header values retain them.
|
||||
|
||||
## Common lines
|
||||
|
||||
A [common line cut once](common-line-cutting.md#cutting-each-shared-line-once) posts in plate
|
||||
order, member by member, each member's holes first:
|
||||
|
||||
- **Shared cut** (`CommonLine` motions): the cut-off form with a real lead-in. `/L "L0"`, restart
|
||||
number, rapid to the pierce on the span's axis, `/L "L4"`, the straight lead-in `G1`, `/L "L6"`,
|
||||
the centerline `G1`, the straight lead-out `G1` when there is one, and `/L "ZHSOFF"`. No
|
||||
`G41`/`G42` is selected: the line is the beam centerline between the two parts.
|
||||
- **Remainder** (an open contour after a `COMMON LINE REMAINDER` comment): the normal contour
|
||||
form with the perimeter macro, `/L "L4"`, `G41` for a clockwise perimeter or `G42` for a
|
||||
counterclockwise one (the side its whole perimeter would get), the straight lead-in that starts
|
||||
in the shared kerf, `/L "L6"`, the open path and `/L "ZHSOFF"`. A member's closed contours are
|
||||
all holes; the post picks no perimeter among them.
|
||||
|
||||
**Unconfirmed on the machine** (release gate, see [common-line cutting](common-line-cutting.md)):
|
||||
|
||||
- compensation start-up on a remainder whose lead-in starts in void (the kerf the shared cut
|
||||
opened) and runs along it;
|
||||
- compensation cancel where a remainder ends in that kerf, and that the next contour starts
|
||||
uncompensated, since the post writes no `G40` (the macros cancel compensation);
|
||||
- whether `L4` runs correctly before an uncompensated shared cut, as for cut-offs.
|
||||
|
||||
Verify on a 3/16 stainless coupon pair on the CI FIBER 4020 and record the result here.
|
||||
|
||||
## Configuration and boundaries
|
||||
|
||||
See [CIFiberPostConfig](../Posts/OpenNest.Posts.CincinnatiCIFiber/CIFiberPostConfig.cs)
|
||||
@@ -126,6 +152,9 @@ cover a square with a hole, kerf side for either winding, coordinate
|
||||
transforms/formatting, lead-in rejection,
|
||||
cut-off sequencing and output, table bounds, suppression/scribe handling, and
|
||||
multi-sheet output in both modes.
|
||||
[Common-line post tests](../OpenNest.Tests/CommonLines/CommonLinePostTests.cs) hold a golden
|
||||
program for a planned two-part pair (shared cut and both remainders), the remainders'
|
||||
compensation side for either winding, and the refusals of posts without support.
|
||||
[Sample regression tests](../OpenNest.Tests/CincinnatiCIFiber/CIFiberSampleRegressionTests.cs)
|
||||
post a nest rebuilt from a Cincinnati machine sample, whose parts carry the
|
||||
sample's own pierce, lead-in and cut moves. Posted unchanged, the program body
|
||||
|
||||
@@ -276,6 +276,14 @@ next time the post is edited.
|
||||
| `G21` | Metric mode | §1.21 |
|
||||
| `G90` | Absolute mode | §1.90 |
|
||||
|
||||
### Common lines
|
||||
|
||||
The post cannot write a [common line cut once](common-line-cutting.md#cutting-each-shared-line-once):
|
||||
it applies one configured `G41`/`G42` side (`DefaultKerfSide`) to every feature and, in
|
||||
`KerfMode.PreApplied`, offsets no geometry, so a shared cut would be compensated into a part and a
|
||||
remainder could not be offset on its perimeter's side. It refuses such a nest before writing
|
||||
anything. Set the plate to cut its common lines twice and plan cutting again to post it here.
|
||||
|
||||
### Kerf compensation
|
||||
|
||||
| Code | Description | Manual |
|
||||
|
||||
+82
-12
@@ -5,13 +5,16 @@ one cut: programs are nominal geometry and the controller offsets each contour b
|
||||
(`G41`/`G42`), so both parts' facing edges are cut on the same centerline. Placing parts this way
|
||||
saves the part spacing along every shared edge, which matters on costly plate.
|
||||
|
||||
## What ships today: kerf-gap groups, cut twice
|
||||
**Release gate.** Cutting a common line once is not yet confirmed on a machine. Before release it
|
||||
needs a 3/16 stainless coupon pair on the CI FIBER 4020: measure both parts' shared edges against
|
||||
nominal and check that compensation starts cleanly in the opened kerf and cancels where a
|
||||
remainder ends in it (see [CI Fiber output](cincinnati-ci-fiber-post-output.md#common-lines)).
|
||||
Until then, **Plate > Arrange > Cut Common Lines Twice** keeps the double cut.
|
||||
|
||||
## Groups
|
||||
|
||||
`Plate.CommonLines` holds `CommonLineGroup`s: the member parts (by reference) and the kerf they
|
||||
were placed at. Each member still cuts its whole perimeter, so every shared edge is cut twice: the
|
||||
second pass runs along the kerf the first one opened. That needs no planner or post change. It
|
||||
costs one extra pass per shared edge, and a part freed by the first pass could tip under the head
|
||||
on the second. **Single-pass cutting (each shared edge cut once) is not implemented yet.**
|
||||
were placed at.
|
||||
|
||||
- **Spans are derived, never stored.** `CommonLineGeometry` pairs straight edges of the members'
|
||||
clean perimeters (leads excluded, holes and arcs never share) that face each other, lie the
|
||||
@@ -24,6 +27,59 @@ on the second. **Single-pass cutting (each shared edge cut once) is not implemen
|
||||
- **Removing a part** from the plate drops it from its group. A group left with one part is
|
||||
removed.
|
||||
|
||||
## Cutting each shared line once
|
||||
|
||||
By default Plan Cutting cuts every shared span once (`Plate.CutsCommonLinesOnce`: the plate has
|
||||
groups and `Plate.CutCommonLinesTwice` is off). Material always comes from the drawings, so a
|
||||
planned member's open program changes no utilization, quantity, overlap or spacing result.
|
||||
|
||||
- **Order.** `CommonLineCutting.Order` takes the members breadth-first from the group's first
|
||||
member along its spans. Each shared cut is owned by the member of its pair that comes first,
|
||||
so the owner precedes its partner (a captured dependency, enforced by search and replay; a kept
|
||||
order that cuts the partner first is a `ConstraintConflict` naming "the common-line partner").
|
||||
The tour treats each such pair like a nested part and its host, so a group is cut as one run.
|
||||
A rule the search learns later may still separate members; the dependency always holds.
|
||||
- **Each member is cut** as: its holes (and break cuts and tabbed cutouts, as for any part), then
|
||||
the shared cuts it owns, then its **remainder**: its perimeter minus every span it shares, in
|
||||
the perimeter's own direction, as one open piece per stretch between spans. Shared cuts are
|
||||
never all cut first: each is cut where the route passes its owner.
|
||||
- **Shared cut:** an open cut on the centerline (`LayerType.CommonLine`), cut without kerf
|
||||
compensation. It is pierced in scrap on the span's own axis, the external lead-in's reach
|
||||
before the span, and entered with a straight lead-in through the end notch; it leaves the same
|
||||
way at the far end with a straight lead-out as long as the external lead-out's reach (none with
|
||||
no lead-out). Capture tries each end in turn: the lead-in, cut and lead-out may touch no
|
||||
material, and the pierce keeps the pierce zone. When no end fits, planning refuses with
|
||||
`UnsupportedGeometry` naming both parts and the span. Leads are never shortened.
|
||||
- **Remainder:** each piece starts where a shared span ends. It is pierced in that span's kerf,
|
||||
on the centerline, the external lead-in's reach back along the span, and enters along a straight
|
||||
lead-in to the piece's start, so compensation starts inside the kerf the shared cut opened; the
|
||||
pierce meets nothing. The comment `COMMON LINE REMAINDER CW` (or `CCW`) after its rapid names
|
||||
the perimeter's winding, so posts compensate it on the perimeter's side. It has no lead-out: it
|
||||
ends in the kerf at the next span. A span shorter than the lead-in's reach, or an external
|
||||
lead-in with no length, refuses with `UnsupportedGeometry`.
|
||||
- **Accounting.** The planner marks each member's shared spans on its owned clean copy as `Tab`
|
||||
spans (`CommonLineCutting.MarkSharedSpans`): material the member never cuts. Replay's contour
|
||||
accounting proves each stretch between them is cut whole, once, as for
|
||||
[tabbed cutouts](tabbed-cutouts.md#verification), and refuses a member that also cuts a span.
|
||||
- **Rapids.** A shared cut is never a rapid obstacle and takes no part in the open-cut retention
|
||||
proof. When a member's program ends, its remainder pieces, joined across its spans, become one
|
||||
obstacle: the part is cut free then.
|
||||
- **Refusals.** A broken group, and a locked member or one a caller left out of the plan, cannot
|
||||
be cut once: rejoin, unlock or include it, or cut the plate's lines twice. A drawing pin on a
|
||||
member's outside is not applied (a warning makes the plan UNVERIFIED); pins on its holes are.
|
||||
Members are never support-tabbed. Remainder pierces in the kerf are held to the pierce zone like
|
||||
any other, so a pierce diameter wider than the kerf refuses them.
|
||||
- **Apply** installs each member's program (holes, shared cuts, remainder); nothing is added to
|
||||
the plate.
|
||||
|
||||
### Cut common lines twice
|
||||
|
||||
**Plate > Arrange > Cut Common Lines Twice** (`Plate.CutCommonLinesTwice`, saved with the nest,
|
||||
undoable) keeps the first slice's behavior: each member cuts its whole perimeter, so every shared
|
||||
edge is cut twice, the second pass running in the kerf the first opened. It needs no post support.
|
||||
It costs one extra pass per shared edge, and a part freed by the first pass could tip under the
|
||||
head on the second. Changing the setting after planning makes the plan stale.
|
||||
|
||||
## Desktop
|
||||
|
||||
- **Plate > Arrange > Join Common Line** slides the selected parts together one kerf apart
|
||||
@@ -39,7 +95,7 @@ on the second. **Single-pass cutting (each shared edge cut once) is not implemen
|
||||
- The plate draws each shared span as a teal dashed centerline. A member that no longer shares a
|
||||
span is outlined in red.
|
||||
- Moving one member moves only that part and breaks the group. Rejoin, or remove the group.
|
||||
- Join and Remove are undoable like any other edit.
|
||||
- Join, Remove and Cut Common Lines Twice are undoable like any other edit.
|
||||
|
||||
## Checks
|
||||
|
||||
@@ -53,9 +109,25 @@ on the second. **Single-pass cutting (each shared edge cut once) is not implemen
|
||||
- a group whose kerf differs from the plate's cutting parameters' kerf (when the plate has
|
||||
them) by more than `GapTolerance`. A group at the wrong kerf would leave a web or cut a sliver.
|
||||
Rejoin it at the current kerf;
|
||||
- a lead-in or lead-out of a member that touches or enters another member's material. A lead on
|
||||
a shared edge would cut the partner one kerf away. An unreadable lead check is incomplete,
|
||||
never clear.
|
||||
- a lead-in, lead-out or shared cut of a member that touches or enters another member's
|
||||
material. A lead on a shared edge would cut the partner one kerf away. An unreadable lead
|
||||
check is incomplete, never clear;
|
||||
- on a plate that cuts its lines once, a span no member's program cuts on its centerline (for
|
||||
example a plate never planned, which would cut it twice), a span cut more than once, and a
|
||||
span cut after the partner whose remainder ends in it;
|
||||
- on a plate set to cut its lines twice, a member program that still cuts one once.
|
||||
- The rapid check treats members' remainders and shared cuts as planning does.
|
||||
|
||||
## Posting
|
||||
|
||||
A program that cuts a common line once (`CommonLineCuts.IsSinglePass`: `CommonLine` motions or
|
||||
remainder comments) posts only through a post that implements `ICommonLinePostProcessor`. The
|
||||
desktop's Post command and the console refuse any other post before verification
|
||||
(`CommonLineCuts.EnsurePostable`), and the built-in posts refuse it themselves; no post falls
|
||||
back to cutting the line twice. Set the plate to cut its lines twice and plan again instead.
|
||||
|
||||
- [Cincinnati CI Fiber](cincinnati-ci-fiber-post-output.md#common-lines): supported.
|
||||
- [Cincinnati CL](cincinnati-post-output.md#common-lines) and Gravograph IS: refuse.
|
||||
|
||||
## File format
|
||||
|
||||
@@ -63,6 +135,4 @@ See [nest file format](nest-file-format.md#common-lines).
|
||||
|
||||
## Planned next
|
||||
|
||||
Single-pass cutting through Plan Cutting and the posts (cut each shared span once on the
|
||||
centerline, then each part's remaining edges with compensation), then automatic common-line
|
||||
placement in fills. Both need machine trials before release.
|
||||
Automatic common-line placement in fills, after the machine trial above.
|
||||
@@ -158,6 +158,13 @@ the final replay enforce them:
|
||||
and prefix emission cuts their pieces after the break cuts and before any contour,
|
||||
entered from the slug without lead-outs; accounting requires each span between tabs cut
|
||||
whole, once.
|
||||
- A plate that cuts its [common lines](common-line-cutting.md#cutting-each-shared-line-once) once
|
||||
captures each group's order: the member that owns a shared cut precedes its partner, and the
|
||||
tour runs the pair like a nested part before its host. A member regenerates from its owned clean
|
||||
copy with its shared spans as tabs: its holes are choices as usual, and its perimeter has one
|
||||
fixed entry whose emission is its shared cuts, then its remainder pieces. Capture checks each
|
||||
shared cut's and remainder's leads against every part's material and refuses one that fits
|
||||
nowhere, naming the span.
|
||||
- A part whose perimeter lies strictly inside a cutout of another part precedes
|
||||
that host. Material bounds (never rapids or scribe marks) only select candidate
|
||||
pairs; containment is proven on native clean material. Touching or crossing boundaries, or material that cannot be
|
||||
|
||||
@@ -119,6 +119,14 @@ nonfinite or nonpositive kerf. Spans are not saved; they are derived from the pl
|
||||
Versions before it ignore the array, so they load the parts one kerf apart and report the
|
||||
pairs as part-spacing findings: never a silently different cut.
|
||||
|
||||
A plate's optional `cutCommonLinesTwice` (`Plate.CutCommonLinesTwice`) is `true` when its
|
||||
common lines are cut twice; it is omitted when false, the default, in which Plan Cutting cuts
|
||||
each shared span once. A program planned that way saves its shared cuts as motions tagged
|
||||
`:COMMONLINE` and puts a `COMMON LINE REMAINDER CW` or `CCW` comment after the rapid into each
|
||||
remainder piece. Versions without single-pass support read those motions as ordinary cuts,
|
||||
which a post would cut with compensation, so such a nest must not be posted from an older
|
||||
version.
|
||||
|
||||
## Plate cutting parameters
|
||||
|
||||
Each plate's optional `cuttingParameters` stores the settings last applied to it.
|
||||
|
||||
@@ -154,8 +154,15 @@ shows the first three check categories, even when there are no findings:
|
||||
before posting.
|
||||
- **Common lines:** a [common-line group](common-line-cutting.md#checks) member that no longer
|
||||
shares an edge one kerf from another member, a group placed for a different kerf than the
|
||||
plate's cutting parameters now use, or a member's lead that touches or enters a partner's
|
||||
material. This line appears in the summary only when there is such a finding.
|
||||
plate's cutting parameters now use, or a member's lead or shared cut that touches or enters a
|
||||
partner's material. On a plate that cuts its common lines once, also a span no member cuts once
|
||||
on its centerline (an unplanned plate would cut it twice), a span cut more than once, or one cut
|
||||
after the partner whose remainder ends in it; on a plate set to cut them twice, a program that
|
||||
still cuts one once. The rapid check treats a member's remainder pieces as cutting the part free
|
||||
when its program ends, and never treats a shared cut as an obstacle. This line appears in the
|
||||
summary only when there is such a finding. Posting a single-pass program through a post that
|
||||
cannot write it is refused before verification runs (see
|
||||
[common-line cutting](common-line-cutting.md#posting)).
|
||||
- **Pierce zones:** with a `PierceDiameter` in the part's (or else the plate's) cutting
|
||||
parameters, every lead-in pierce of every placed program must keep half of it from all part
|
||||
material; see [pierce zones](geometry/pierce-zone.md). This line appears in the summary only
|
||||
|
||||
Reference in new issue
Block a user