mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-17 21:07:40 -05:00
feat(cutting): tab parts by width when the plate has no support bed
With support tabs on and no support bed, nothing was tabbed and nothing said so. A new no-bed width range (NoBedTabMinWidth..NoBedTabMaxWidth, the short side of the part's minimum-area bounding rectangle) now picks the parts to tab instead. SupportTabSettings.Analyze makes the choice for Plan Cutting, hand-placed lead-ins and the pre-post review; without a bed any tab clear of inside corners counts. With no bed and no range, the plan notes that nothing was tabbed. Cutting Settings > Tabs gains the range fields, and the values persist with the cutting parameters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
07499fe1cd
commit
479883e7ac
18 files changed
+500
-52
No files matched your search
@@ -5,26 +5,62 @@ using OpenNest.CNC.CuttingStrategy;
|
||||
namespace OpenNest.Support
|
||||
{
|
||||
/// <summary>
|
||||
/// Cutting settings for a lead-in placed by hand under
|
||||
/// <see cref="CuttingParameters.SupportTabs"/>: the tool cuts where it is clicked, so the
|
||||
/// part is tabbed there when its plate's support bed cannot hold it level. Plan Cutting
|
||||
/// chooses the tab point itself (docs/support-tabs.md).
|
||||
/// Which parts <see cref="CuttingParameters.SupportTabs"/> tabs (docs/support-tabs.md): the
|
||||
/// parts the plate's support bed cannot hold level or, on a plate with no bed, the parts
|
||||
/// whose width is in the settings' no-bed range. Also the cutting settings for a lead-in
|
||||
/// placed by hand: the tool cuts where it is clicked, so the part is tabbed there. Plan
|
||||
/// Cutting chooses the tab point itself.
|
||||
/// </summary>
|
||||
public static class SupportTabSettings
|
||||
{
|
||||
/// <summary>
|
||||
/// The analysis that tabs a part, or null when support tabs are off or the part is
|
||||
/// outside the rule: with a bed, the bed's analysis; without one, a no-bed analysis
|
||||
/// (<see cref="SupportAnalyzer.AnalyzeWithoutBed"/>) of a part whose width is in
|
||||
/// <see cref="CuttingParameters.TabsWithoutBedAt"/>'s range. The part needs a tab when
|
||||
/// the result is complete and not supported; an incomplete result could not be read.
|
||||
/// </summary>
|
||||
/// <param name="insideCornerClearance">
|
||||
/// How far a tab point keeps from an inside corner; 0 keeps it off the corner only.
|
||||
/// </param>
|
||||
public static PartSupport Analyze(CuttingParameters parameters, SupportBed bed, int quadrant,
|
||||
SupportMaterial material, double insideCornerClearance = 0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(material);
|
||||
if (parameters?.SupportTabs != true)
|
||||
return null;
|
||||
if (bed != null)
|
||||
return SupportAnalyzer.Analyze(bed, quadrant, material, insideCornerClearance);
|
||||
if (!parameters.HasNoBedTabRange())
|
||||
return null;
|
||||
if (!material.IsComplete)
|
||||
return SupportAnalyzer.AnalyzeWithoutBed(material, insideCornerClearance);
|
||||
return parameters.TabsWithoutBedAt(SupportAnalyzer.Width(material))
|
||||
? SupportAnalyzer.AnalyzeWithoutBed(material, insideCornerClearance)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether support tabs are on but can tab nothing: the plate has no support bed and the
|
||||
/// settings set no no-bed width range.
|
||||
/// </summary>
|
||||
public static bool SkipsWithoutBed(CuttingParameters parameters, SupportBed bed) =>
|
||||
parameters?.SupportTabs == true && bed == null && !parameters.HasNoBedTabRange();
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="parameters"/> itself, or a copy with tabs enabled when support tabs are
|
||||
/// on, the plate has a support bed, a tab size is set and the bed cannot hold
|
||||
/// <paramref name="part"/> level. The caller's settings are never changed.
|
||||
/// on, a tab size is set and <paramref name="part"/> needs a tab (see <see cref="Analyze"/>).
|
||||
/// The caller's settings are never changed.
|
||||
/// </summary>
|
||||
public static CuttingParameters ForManualLeadIn(CuttingParameters parameters, Plate plate, Part part)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(parameters);
|
||||
if (!parameters.SupportTabs || parameters.TabsEnabled || parameters.TabConfig == null
|
||||
|| plate?.SupportBed == null || part == null)
|
||||
|| plate == null || part == null
|
||||
|| (plate.SupportBed == null && !parameters.HasNoBedTabRange()))
|
||||
return parameters;
|
||||
var support = SupportAnalyzer.Analyze(plate.SupportBed, plate.Quadrant, part);
|
||||
if (!support.IsComplete || support.IsSupported)
|
||||
var support = Analyze(parameters, plate.SupportBed, plate.Quadrant, SupportMaterial.FromPart(part));
|
||||
if (support is not { IsComplete: true, IsSupported: false })
|
||||
return parameters;
|
||||
var tabbed = OwnedCuttingParameters.Copy(parameters);
|
||||
tabbed.TabsEnabled = true;
|
||||
|
||||
Reference in new issue
Block a user