mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-24 00:57:39 -05:00
The Cutting Parameters dialog had grown taller than many screens. It now
puts the leads in a column of their own beside Tabs, Cutouts, Marks and
Pierce (about 780 x 580 instead of 410 x 985). The Place Lead-in side
panel and Machine Configuration keep the single stacked column. The tab
size range is one "Narrow side from ... to ..." row, with its details in
tooltips.
Since e1ccd692 every tabbed part counts as steady, but "Tab alone holds
parts up to" (TabHeldMaxLength, default 6) still picked short parts' tab
points from the center-of-gravity line and treated every tab as equally
steady in the last-resort entry fallback. The setting is removed: every
part the support grid cannot hold level is tabbed and held by its tab,
however long it is. Settings and nests saved with the old value read
unchanged and ignore it.
The problem-nest corpus (entries, every nest) plans identically to master.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
6.0 KiB
C#
109 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using OpenNest.CNC;
|
|
using OpenNest.CNC.CuttingPlanning;
|
|
using OpenNest.Diagnostics;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Support;
|
|
|
|
namespace OpenNest.Engine.CuttingPlanning;
|
|
|
|
/// <summary>
|
|
/// Capture-time support tabs for one regenerated part (docs/support-tabs.md): with
|
|
/// <see cref="CNC.CuttingStrategy.CuttingParameters.SupportTabs"/> on, a part the support bed
|
|
/// cannot hold level, or by size (no bed, or <see cref="CNC.CuttingStrategy.CuttingParameters.TabBySize"/>)
|
|
/// a part in the size range (<see cref="SupportTabSettings.Analyze"/>), has its perimeter tabbed where the tab steadies
|
|
/// it; a pinned perimeter
|
|
/// keeps its pin (the drawing wins) and only carries the analysis for replay to review. A
|
|
/// supported part, a missing tab configuration or material the analyzer cannot read leave the
|
|
/// preparation as it was.
|
|
/// </summary>
|
|
internal static class SupportTabCapture
|
|
{
|
|
internal static PreparedContours Prepare(PreparedContours prepared, Program ownedClean, Vector location,
|
|
CuttingPlanRequest request, CancellationToken token)
|
|
{
|
|
var parameters = request.ConfirmedParameters;
|
|
// A display perimeter is a supplied blank: it is never cut free, so it needs no tab.
|
|
// 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();
|
|
// The clean program is the drawing's own, rotated as placed: its material at the
|
|
// part's location is the material that drops onto the bed. The tab keeps clear of
|
|
// inside corners by twice its size.
|
|
var support = SupportTabSettings.Analyze(parameters, request.SupportBed, request.SupportQuadrant,
|
|
SupportMaterial.FromProgram(ownedClean, location),
|
|
SupportAnalyzer.InsideCornerClearance(parameters.TabConfig.Size));
|
|
if (support is not { IsComplete: true, IsSupported: false } || support.BestTabPoint == null)
|
|
return prepared;
|
|
return prepared.WithSupportTab(support, location, parameters.TabConfig);
|
|
}
|
|
|
|
/// <summary>
|
|
/// A note for a planned support-tabbed part whose tab, at its perimeter entry, sits in an
|
|
/// inside corner because no lead-in fits clear of one. Advisory: it never refuses or
|
|
/// downgrades a plan. A part cut with no tab at all is <see cref="Review"/>'s warning.
|
|
/// </summary>
|
|
internal static IEnumerable<CuttingPlanFinding> Notes(FixedProgramPlacement planned)
|
|
{
|
|
var prepared = planned.Prepared;
|
|
if (prepared?.Support == null || prepared.IsPinned(prepared.PerimeterOrdinal)
|
|
|| planned.ContourChoices.FirstOrDefault(c => c.ContourOrdinal == prepared.PerimeterOrdinal) is not { } entry
|
|
|| prepared.IsClearOfInsideCorners(entry))
|
|
yield break;
|
|
var tab = entry.Point + planned.Location;
|
|
var at = FormattableString.Invariant($"({tab.X:0.####}, {tab.Y:0.####})");
|
|
yield return JointCuttingPlanSearch.Finding(planned, null,
|
|
$"Its support tab at {at} is in an inside corner, because no lead-in fits clear of one; "
|
|
+ "its nub will be hard to grind flush.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// A <see cref="PostVerificationKind.PartSupport"/> warning when a regenerated part its bed
|
|
/// cannot hold level is cut with no tab at all: its drawing pin cuts its outside untabbed.
|
|
/// A tabbed part counts as steady wherever its tab is. Null otherwise. Like other warnings it
|
|
/// makes the proposal UNVERIFIED.
|
|
/// </summary>
|
|
internal static CuttingPlanFinding Review(FixedProgramPlacement source, IReadOnlyList<ContourChoice> choices)
|
|
{
|
|
var prepared = source.Prepared;
|
|
if (prepared?.Support is not { } support || choices == null)
|
|
return null;
|
|
var perimeter = choices.FirstOrDefault(c => c.ContourOrdinal == prepared.PerimeterOrdinal);
|
|
if (perimeter == null)
|
|
return null;
|
|
if (prepared.PerimeterTabbed)
|
|
return null;
|
|
var part = source.SourceOrdinal + 1;
|
|
var held = !support.HasBed
|
|
? FormattableString.Invariant($"is {support.Width:0.####} wide, in the width range tabbed by size,")
|
|
: support.Margin == double.NegativeInfinity
|
|
? "rests on no support contact"
|
|
: support.Margin < 0
|
|
? FormattableString.Invariant($"has its center of gravity {-support.Margin:0.####} outside its support contacts")
|
|
: FormattableString.Invariant($"has its center of gravity only {support.Margin:0.####} inside its support contacts");
|
|
var why = $"drawing pin {prepared.PinNumberOf(prepared.PerimeterOrdinal)} cuts its outside without a tab";
|
|
var needs = support.HasBed ? FormattableString.Invariant($" (needs {support.RequiredMargin:0.####})") : "";
|
|
return new CuttingPlanFinding(source.SourceOrdinal, source.SourcePart, null, null,
|
|
PostVerificationKind.PartSupport, $"Part {part} {held}{needs} and {why}; it may tip once cut free.");
|
|
}
|
|
|
|
/// <summary>
|
|
/// One plan note when support tabs are on but go by size (no support bed, or by size chosen)
|
|
/// and the settings set no size range, so no part was tabbed. Advisory, like <see cref="Notes"/>.
|
|
/// </summary>
|
|
internal static IEnumerable<CuttingPlanFinding> Skipped(CuttingPlanSnapshot snapshot)
|
|
{
|
|
if (snapshot.SupportTabsSkipped)
|
|
yield return new CuttingPlanFinding(null, null, null, null, null,
|
|
snapshot.OwnedParameters?.TabBySize == true
|
|
? "Tabs by size are on, but no width range is set, so no part was tabbed."
|
|
: "Support tabs are on, but the plate has no support bed and no width range is set for "
|
|
+ "plates without one, so no part was tabbed.");
|
|
}
|
|
}
|