mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-21 04:27:40 -05:00
When no search finds a route that keeps every rapid off parts already cut, Plan Cutting used to offer only an unverified safest route needing explicit acceptance. Cincinnati's own software instead raises the head for such a rapid. Now the safest-route fallback marks each planner-chosen rapid that still crosses cut parts with a HEAD RAISE comment, and the plan is Ready with every raise listed. The strict search never marks a rapid, and the batch prefers fewer broken checks, then fewer raises, then less travel, so a plate that can be cut head-down never gets one. The reader flags marked rapids and the checker sets their crossings apart, in replay and pre-post verification alike. The Cincinnati CL post writes M47 before a marked rapid whatever the M47 mode (the distance-based safety raise is unchanged); the CI Fiber post writes a new Head raise block and refuses marked nests while it is blank, since its raise code is unconfirmed. Rapids into locked programs, cut-offs and hole sub-programs are never marked and keep their findings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using OpenNest.Diagnostics;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.CNC.CuttingPlanning;
|
|
|
|
/// <summary>Owned value motions; no references to live programs, instructions or settings.</summary>
|
|
public sealed class OwnedExecution
|
|
{
|
|
internal OwnedExecution(IEnumerable<ExecutionMotion> motions)
|
|
{
|
|
Motions = Array.AsReadOnly(motions.ToArray());
|
|
}
|
|
|
|
public IReadOnlyList<ExecutionMotion> Motions { get; }
|
|
public Vector DeparturePoint => Motions[^1].End;
|
|
public bool HasCuttingContour => Motions.Any(move => !move.Rapid
|
|
&& move.Layer is LayerType.Cut or LayerType.Display
|
|
&& move.Length > PostVerificationGeometry.Epsilon);
|
|
|
|
public double RapidDistanceFrom(Vector arrival)
|
|
{
|
|
PostVerificationGeometry.Validate(arrival);
|
|
var total = 0.0;
|
|
for (var index = 0; index < Motions.Count; index++)
|
|
{
|
|
var move = Motions[index];
|
|
if (move.Rapid && (index == 0 ? arrival : move.Start) is { } start)
|
|
total += start.DistanceTo(move.End);
|
|
}
|
|
return total;
|
|
}
|
|
}
|
|
|
|
/// <summary>An immutable motion value; native line/arc geometry stays private to Core.</summary>
|
|
public sealed class ExecutionMotion
|
|
{
|
|
internal ExecutionMotion(Vector? start, Vector end, bool rapid, LayerType layer,
|
|
PostVerificationGeometry.Curve curve, bool headRaised = false, int? code = null)
|
|
{
|
|
Start = start;
|
|
End = end;
|
|
Rapid = rapid;
|
|
Layer = layer;
|
|
Curve = curve;
|
|
HeadRaised = headRaised;
|
|
Code = code;
|
|
}
|
|
|
|
public Vector? Start { get; }
|
|
public Vector End { get; }
|
|
public bool Rapid { get; }
|
|
public LayerType Layer { get; }
|
|
|
|
/// <summary>A rapid made with the head raised over parts already cut (<see cref="HeadRaise"/>).</summary>
|
|
public bool HeadRaised { get; }
|
|
|
|
/// <summary>
|
|
/// The index of the code this motion runs in the read program's own codes; null for a motion
|
|
/// inside a sub-program and for the rapid a program that opens with a cut is given.
|
|
/// </summary>
|
|
public int? Code { get; }
|
|
public double Length => Curve?.Length ?? 0;
|
|
internal PostVerificationGeometry.Curve Curve { get; }
|
|
internal ExecutionMotion WithStart(Vector? start) => new(start, End, Rapid, Layer, Curve, HeadRaised, Code);
|
|
}
|