mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-06 11:39:25 -05:00
Plan Cutting cut dense runs of small neighboring parts back to back, so thin sheets built up heat in one area (N26-2F2 sheet 2). An opt-in CuttingParameters.HeatWeight (s of travel per degree C, saved per material and thickness; 0 = off) lets the tour compare the plain tour with two cutting fronts and 2x2-6x6 blocks, scored by travel, 2 s per jump and the old Gaussian heat estimate fed by the Cut Simulator's feeds. A move to another block across parts already cut is a designed head raise: the strict search raises that arrival and replay marks it HEAD RAISE, counted in HeatRaises, not HeadRaises. Locked programs and cut-offs cannot carry the mark, so they are reached head-down only as a last resort. The user approved raising the head to jump between blocks, since these small parts can be tabbed. At weight 0 nothing runs: fingerprint, serializer and plans are unchanged (corpus part-order and characterization digests pass). On the 121-part 0.12 in sheet, weight 0.1 lowers the hottest-zone P95 by 37% for 11% more cut time, with 37 designed raises and no fallback raises. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.8 KiB
C#
79 lines
2.8 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, int? callCode = null)
|
|
{
|
|
Start = start;
|
|
End = end;
|
|
Rapid = rapid;
|
|
Layer = layer;
|
|
Curve = curve;
|
|
HeadRaised = headRaised;
|
|
Code = code;
|
|
CallCode = callCode;
|
|
}
|
|
|
|
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; }
|
|
|
|
/// <summary>
|
|
/// For a motion inside a sub-program, the index of the read program's own call that runs it;
|
|
/// null for the program's own motions.
|
|
/// </summary>
|
|
internal int? CallCode { 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, CallCode);
|
|
|
|
/// <summary>This rapid made with the head raised, as if marked (<see cref="HeadRaise"/>).</summary>
|
|
internal ExecutionMotion WithHeadRaised() => new(Start, End, Rapid, Layer, Curve, headRaised: true, Code, CallCode);
|
|
}
|