mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-29 22:41:37 -05:00
fix(cutting): plan outlines with a seam gap before an arc, and memoize lead checks
A converted outline whose seam closes within the admitted 1e-6 gap could only be entered at its seam: entered anywhere else, the arc after the seam started off its own circle and every emission was refused as an inconsistent radius. The search then spent its whole budget on that part and the plate never planned. Emission now bridges the gap with a straight move and cuts the arc as drawn; the verifier already admits that slack. An entry on the seam vertex is left as before. Each prefix of a part re-checked its earlier contours' leads against every other part's material. One search now remembers each verdict by the lead curve's exact bits and the material's reference, charging the same native query budget; replay never uses it. On the reported plate the memo alone gives a byte-identical result in 57 s instead of 12 min 47 s; with the seam fix the plate plans Ready in about 17 s. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d317a90f1e
commit
fb505ef0ff
9 files changed
+179
-7
No files matched your search
@@ -48,10 +48,20 @@ public sealed class ContourEntryFeasibility
|
||||
private readonly LeadMaterialSnapshot ownMaterial;
|
||||
private readonly LeadMaterialSnapshot[] materials;
|
||||
private readonly Dictionary<Key, ContourFeasibilityVerdict> cache = new();
|
||||
private readonly LeadContactMemo? leadContacts;
|
||||
|
||||
public ContourEntryFeasibility(PreparedContours prepared, Vector location,
|
||||
LeadMaterialSnapshot ownMaterial, IReadOnlyList<LeadMaterialSnapshot> otherMaterials)
|
||||
: this(prepared, location, ownMaterial, otherMaterials, null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <param name="leadContacts">Shares exact lead/material results with the caller's search.</param>
|
||||
internal ContourEntryFeasibility(PreparedContours prepared, Vector location,
|
||||
LeadMaterialSnapshot ownMaterial, IReadOnlyList<LeadMaterialSnapshot> otherMaterials,
|
||||
LeadContactMemo? leadContacts)
|
||||
{
|
||||
this.leadContacts = leadContacts;
|
||||
this.prepared = prepared ?? throw new ArgumentException("Prepared contours are required.", nameof(prepared));
|
||||
this.ownMaterial = ownMaterial ?? throw new ArgumentException("Own material snapshot is required.", nameof(ownMaterial));
|
||||
if (otherMaterials == null)
|
||||
@@ -110,7 +120,9 @@ public sealed class ContourEntryFeasibility
|
||||
{
|
||||
var program = prepared.EmitCandidateForValidation(choice);
|
||||
var execution = ExecutionMotionReader.Read(program, location, null, token);
|
||||
var result = LeadPathValidator.Check(execution, ownMaterial, materials, token);
|
||||
var result = leadContacts == null
|
||||
? LeadPathValidator.Check(execution, ownMaterial, materials, token)
|
||||
: LeadPathValidator.Check(execution, ownMaterial, materials, leadContacts, token);
|
||||
if (!result.IsComplete)
|
||||
return new(ContourFeasibilityStatus.Incomplete, result.Reason);
|
||||
return result.IsClear
|
||||
|
||||
@@ -195,6 +195,9 @@ internal static class JointCuttingPlanSearch
|
||||
// One feasibility adapter per source part per captured planning attempt: verdicts
|
||||
// memoize per owned choice for the attempt, never statically or across attempts.
|
||||
private readonly Dictionary<int, ContourEntryFeasibility> feasibility = [];
|
||||
// Lead/material verdicts for exact curves, shared by prechecks and prefix checks of this
|
||||
// walk: each prefix repeats its earlier contours' leads. Replay never uses it.
|
||||
private readonly LeadContactMemo leadContacts = new();
|
||||
private readonly HashSet<int> reportedNoFit = [];
|
||||
private readonly Dictionary<int, Entity[]> hostContours = [];
|
||||
|
||||
@@ -624,7 +627,7 @@ internal static class JointCuttingPlanSearch
|
||||
private ContourEntryFeasibility Adapter(FixedProgramPlacement source) =>
|
||||
feasibility.TryGetValue(source.SourceOrdinal, out var known) ? known
|
||||
: feasibility[source.SourceOrdinal] = new ContourEntryFeasibility(
|
||||
source.Prepared, source.Location, source.Material, materials);
|
||||
source.Prepared, source.Location, source.Material, materials, leadContacts);
|
||||
|
||||
private ContourFeasibilityVerdict Evaluate(FixedProgramPlacement source, ContourEntryCandidate candidate)
|
||||
{
|
||||
@@ -741,7 +744,7 @@ internal static class JointCuttingPlanSearch
|
||||
attempt.NoteCrossings(source.SourceOrdinal, findings);
|
||||
// A fixed cutoff has no material or leads to certify; its rapids are still checked.
|
||||
var lead = source.IsCutOff ? new LeadPathValidationResult(true, true, null)
|
||||
: LeadPathValidator.Check(execution, source.Material, materials, isFixed, [], token);
|
||||
: LeadPathValidator.Check(execution, source.Material, materials, isFixed, [], token, leadContacts);
|
||||
if (!lead.IsComplete || !lead.IsClear)
|
||||
rejected.Add(Finding(source, lead.IsComplete ? null : PostVerificationKind.Incomplete, lead.Reason));
|
||||
return findings.Count == 0 && lead.IsComplete && lead.IsClear;
|
||||
|
||||
Reference in new issue
Block a user