mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-04 07:19:24 -05:00
refactor(cutting): remove the unused sequencing and assignment settings
SequenceParameters and AssignmentParameters configured the automatic
part sequencers removed in 9ea495ed (and a PEP-era assignment that was
never implemented). Nothing read them; they were only copied, saved
and fingerprinted. CuttingParameters no longer carries them, and the
SequenceMethod enum goes with them.
Older nest files and desktop settings still load: their "sequencing"
and "assignment" objects are ignored on read and no longer written.
The settings fingerprint is compared in memory only, so dropping the
fields invalidates nothing saved.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9ea495edca
commit
7938fa0de7
15 files changed
+30
-337
No files matched your search
@@ -9,14 +9,6 @@ internal static class OwnedCuttingParameters
|
||||
internal static CuttingParameters Copy(CuttingParameters source)
|
||||
{
|
||||
Exact<CuttingParameters>(source);
|
||||
Exact<SequenceParameters>(source.Sequencing);
|
||||
Exact<AssignmentParameters>(source.Assignment);
|
||||
var sequence = source.Sequencing;
|
||||
var assignment = source.Assignment;
|
||||
if (!Enum.IsDefined(sequence.Method) || !Enum.IsDefined(assignment.Method))
|
||||
throw new ArgumentException("Unsupported sequence method.");
|
||||
if (assignment.Preference == null)
|
||||
throw new ArgumentException("Missing assignment preference.");
|
||||
if (!double.IsFinite(source.LeadInAngleIncrement) || source.LeadInAngleIncrement <= 0
|
||||
|| source.LeadInAngleIncrement > 360)
|
||||
throw new ArgumentException("Angle increment must be in (0, 360] degrees.");
|
||||
@@ -46,26 +38,7 @@ internal static class OwnedCuttingParameters
|
||||
TabSizeMinWidth = Dimension(source.TabSizeMinWidth),
|
||||
TabSizeMaxWidth = Dimension(source.TabSizeMaxWidth),
|
||||
SliceTippingSlugs = source.SliceTippingSlugs,
|
||||
LabelMode = source.LabelMode,
|
||||
Sequencing = new SequenceParameters
|
||||
{
|
||||
Method = sequence.Method,
|
||||
SmallCutoutWidth = Dimension(sequence.SmallCutoutWidth),
|
||||
SmallCutoutHeight = Dimension(sequence.SmallCutoutHeight),
|
||||
MediumCutoutWidth = Dimension(sequence.MediumCutoutWidth),
|
||||
MediumCutoutHeight = Dimension(sequence.MediumCutoutHeight),
|
||||
DistanceMediumSmall = Dimension(sequence.DistanceMediumSmall),
|
||||
AlternateRowsColumns = sequence.AlternateRowsColumns,
|
||||
AlternateCutoutsWithinRowColumn = sequence.AlternateCutoutsWithinRowColumn,
|
||||
MinDistanceBetweenRowsColumns = Dimension(sequence.MinDistanceBetweenRowsColumns),
|
||||
HeatWeight = Dimension(sequence.HeatWeight)
|
||||
},
|
||||
Assignment = new AssignmentParameters
|
||||
{
|
||||
Method = assignment.Method,
|
||||
Preference = assignment.Preference,
|
||||
MinGeometryLength = Dimension(assignment.MinGeometryLength)
|
||||
}
|
||||
LabelMode = source.LabelMode
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,7 @@ namespace OpenNest.CNC.CuttingPlanning;
|
||||
/// Exact text record of cutting settings for detecting in-place edits after capture. It is a
|
||||
/// freshness fingerprint, not a serializer.
|
||||
/// Only the exact built-in settings types are supported — the same set
|
||||
/// <see cref="OwnedCuttingParameters"/> copies: <see cref="CuttingParameters"/>,
|
||||
/// <see cref="SequenceParameters"/>, <see cref="AssignmentParameters"/> and the built-in
|
||||
/// <see cref="OwnedCuttingParameters"/> copies: <see cref="CuttingParameters"/> and the built-in
|
||||
/// lead-in, lead-out and tab types. Every member is written explicitly by type, so nothing is
|
||||
/// discovered reflectively and no code of another type ever runs: each object's runtime type
|
||||
/// is checked before any of its members is read, and any other runtime type (a subclass
|
||||
@@ -102,35 +101,6 @@ internal static class StateFingerprint
|
||||
text.Append("partLabels;");
|
||||
else if (p.LabelMode == PartLabelMode.PartNumber)
|
||||
text.Append("partLabelNumber;");
|
||||
Sequence(p.Sequencing);
|
||||
Assignment(p.Assignment);
|
||||
text.Append('}');
|
||||
}
|
||||
|
||||
private void Sequence(SequenceParameters s)
|
||||
{
|
||||
if (!Begin(s, typeof(SequenceParameters)))
|
||||
return;
|
||||
Int((int)s.Method);
|
||||
Number(s.SmallCutoutWidth);
|
||||
Number(s.SmallCutoutHeight);
|
||||
Number(s.MediumCutoutWidth);
|
||||
Number(s.MediumCutoutHeight);
|
||||
Number(s.DistanceMediumSmall);
|
||||
Flag(s.AlternateRowsColumns);
|
||||
Flag(s.AlternateCutoutsWithinRowColumn);
|
||||
Number(s.MinDistanceBetweenRowsColumns);
|
||||
Number(s.HeatWeight);
|
||||
text.Append('}');
|
||||
}
|
||||
|
||||
private void Assignment(AssignmentParameters a)
|
||||
{
|
||||
if (!Begin(a, typeof(AssignmentParameters)))
|
||||
return;
|
||||
Int((int)a.Method);
|
||||
Text(a.Preference);
|
||||
Number(a.MinGeometryLength);
|
||||
text.Append('}');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace OpenNest.CNC.CuttingStrategy
|
||||
{
|
||||
public class AssignmentParameters
|
||||
{
|
||||
public SequenceMethod Method { get; set; } = SequenceMethod.Advanced;
|
||||
public string Preference { get; set; } = "ILAT";
|
||||
public double MinGeometryLength { get; set; } = 0.01;
|
||||
}
|
||||
}
|
||||
@@ -117,8 +117,5 @@ namespace OpenNest.CNC.CuttingStrategy
|
||||
/// default; a drawing with no label box gets no number, and common-line members get nothing.
|
||||
/// </summary>
|
||||
public PartLabelMode LabelMode { get; set; }
|
||||
|
||||
public SequenceParameters Sequencing { get; set; } = new SequenceParameters();
|
||||
public AssignmentParameters Assignment { get; set; } = new AssignmentParameters();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
namespace OpenNest.CNC.CuttingStrategy
|
||||
{
|
||||
// Values 1-8 match PEP Technology's numbering scheme (value 6 intentionally skipped);
|
||||
// OpenNest's own methods start at 100, outside PEP's range. Saved cutting settings still
|
||||
// carry these values, but nothing orders parts by them: the cut order comes from Plan Cutting
|
||||
// or the user (see docs/plate-heat-map.md#sequencing).
|
||||
public enum SequenceMethod
|
||||
{
|
||||
RightSide = 1,
|
||||
LeastCode = 2,
|
||||
Advanced = 3,
|
||||
BottomSide = 4,
|
||||
EdgeStart = 5,
|
||||
LeftSide = 7,
|
||||
RightSideAlt = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Travel time plus <see cref="SequenceParameters.HeatWeight"/> times the estimated heat
|
||||
/// where each candidate part starts. Its sequencer was removed; see docs/plate-heat-map.md.
|
||||
/// </summary>
|
||||
HeatAware = 100,
|
||||
}
|
||||
|
||||
public class SequenceParameters
|
||||
{
|
||||
/// <summary>The <see cref="HeatWeight"/> new parameters start with, in seconds per °C.</summary>
|
||||
public const double DefaultHeatWeight = 0.15;
|
||||
|
||||
public SequenceMethod Method { get; set; } = SequenceMethod.Advanced;
|
||||
public double SmallCutoutWidth { get; set; } = 1.5;
|
||||
public double SmallCutoutHeight { get; set; } = 1.5;
|
||||
public double MediumCutoutWidth { get; set; } = 8.0;
|
||||
public double MediumCutoutHeight { get; set; } = 8.0;
|
||||
public double DistanceMediumSmall { get; set; }
|
||||
public bool AlternateRowsColumns { get; set; } = true;
|
||||
public bool AlternateCutoutsWithinRowColumn { get; set; } = true;
|
||||
public double MinDistanceBetweenRowsColumns { get; set; } = 0.25;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SequenceMethod.HeatAware"/> only: seconds of travel worth one °C less heat
|
||||
/// where the next part starts. Zero orders by travel alone (nearest neighbor).
|
||||
/// </summary>
|
||||
public double HeatWeight { get; set; } = DefaultHeatWeight;
|
||||
}
|
||||
}
|
||||
@@ -66,59 +66,29 @@ public class CuttingParametersSerializerTests
|
||||
AssertEquivalent(original, RoundTrip(original));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(SequenceMethod.RightSide)]
|
||||
[InlineData(SequenceMethod.LeastCode)]
|
||||
[InlineData(SequenceMethod.Advanced)]
|
||||
[InlineData(SequenceMethod.BottomSide)]
|
||||
[InlineData(SequenceMethod.EdgeStart)]
|
||||
[InlineData(SequenceMethod.LeftSide)]
|
||||
[InlineData(SequenceMethod.RightSideAlt)]
|
||||
[InlineData(SequenceMethod.HeatAware)]
|
||||
public void SettingsRoundTrip_PreservesAllFieldsAndSequenceMethods(SequenceMethod method)
|
||||
[Fact]
|
||||
public void SettingsRoundTrip_PreservesAllFields()
|
||||
{
|
||||
var original = CreateParameters();
|
||||
original.Assignment.Method = method;
|
||||
original.Sequencing.Method = method;
|
||||
|
||||
AssertEquivalent(original, RoundTrip(original));
|
||||
}
|
||||
|
||||
// Settings saved before the sequencing and assignment options were removed still read,
|
||||
// and those options are not written back.
|
||||
[Fact]
|
||||
public void HeatAwareOrder_RoundTripsAsItsNumberWithItsWeight()
|
||||
public void Deserialize_RetiredSequencingAndAssignment_AreIgnored()
|
||||
{
|
||||
var original = new CuttingParameters
|
||||
{
|
||||
Sequencing = new SequenceParameters { Method = SequenceMethod.HeatAware, HeatWeight = 0.4 },
|
||||
};
|
||||
var restored = CuttingParametersSerializer.Deserialize("""
|
||||
{ "kerf": 0.01,
|
||||
"sequencing": { "method": 100, "heatWeight": 0.4, "smallCutoutWidth": 2 },
|
||||
"assignment": { "method": 3, "preference": "ILAT", "minGeometryLength": 0.01 } }
|
||||
""");
|
||||
|
||||
var json = CuttingParametersSerializer.Serialize(original);
|
||||
var restored = CuttingParametersSerializer.Deserialize(json);
|
||||
|
||||
// Written as numbers, not names.
|
||||
Assert.Contains("\"method\":100", json);
|
||||
Assert.Contains("\"heatWeight\":0.4", json);
|
||||
Assert.Equal(SequenceMethod.HeatAware, restored.Sequencing.Method);
|
||||
Assert.Equal(0.4, restored.Sequencing.HeatWeight);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_SequencingWithoutHeatWeight_UsesTheDefaultWeight()
|
||||
{
|
||||
var restored = CuttingParametersSerializer.Deserialize("""{ "sequencing": { "method": 3 } }""");
|
||||
|
||||
Assert.Equal(SequenceMethod.Advanced, restored.Sequencing.Method);
|
||||
Assert.Equal(SequenceParameters.DefaultHeatWeight, restored.Sequencing.HeatWeight);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_NegativeHeatWeight_UsesTheDefaultWeight()
|
||||
{
|
||||
var restored = CuttingParametersSerializer.Deserialize(
|
||||
"""{ "sequencing": { "method": 100, "heatWeight": -2 } }""");
|
||||
|
||||
Assert.Equal(SequenceMethod.HeatAware, restored.Sequencing.Method);
|
||||
Assert.Equal(SequenceParameters.DefaultHeatWeight, restored.Sequencing.HeatWeight);
|
||||
Assert.Equal(0.01, restored.Kerf);
|
||||
var json = CuttingParametersSerializer.Serialize(restored);
|
||||
Assert.DoesNotContain("sequencing", json);
|
||||
Assert.DoesNotContain("assignment", json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -158,8 +128,6 @@ public class CuttingParametersSerializerTests
|
||||
Assert.False(restored.RoundLeadInAngles);
|
||||
Assert.Equal(5, restored.LeadInAngleIncrement);
|
||||
Assert.False(restored.SupportTabs);
|
||||
AssertEquivalent(new AssignmentParameters(), restored.Assignment);
|
||||
AssertEquivalent(new SequenceParameters(), restored.Sequencing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -293,15 +261,15 @@ public class CuttingParametersSerializerTests
|
||||
AssertEquivalent(original, CuttingParametersSerializer.FromDto(parsed));
|
||||
}
|
||||
|
||||
// Nest files read the same DTO with the nest format's options.
|
||||
[Fact]
|
||||
public void DtoRoundTrip_NullAssignmentAndSequencing_RemainNull()
|
||||
public void NestFormat_RetiredSequencingAndAssignment_AreIgnored()
|
||||
{
|
||||
var original = new CuttingParameters { Assignment = null, Sequencing = null };
|
||||
var dto = CuttingParametersSerializer.ToDto(original);
|
||||
var json = JsonSerializer.Serialize(dto, NestFormat.JsonOptions);
|
||||
const string json = """{ "kerf": 0.01, "sequencing": { "method": 3 }, "assignment": { "preference": "ILAT" } }""";
|
||||
|
||||
var parsed = JsonSerializer.Deserialize<CuttingParametersDto>(json, NestFormat.JsonOptions);
|
||||
|
||||
AssertEquivalent(original, CuttingParametersSerializer.FromDto(parsed));
|
||||
Assert.Equal(0.01, CuttingParametersSerializer.FromDto(parsed).Kerf);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -312,16 +280,12 @@ public class CuttingParametersSerializerTests
|
||||
var restored = CuttingParametersSerializer.FromDto(dto);
|
||||
AssertEquivalent(original, restored);
|
||||
|
||||
original.Assignment.Preference = "changed source";
|
||||
original.Sequencing.SmallCutoutWidth = 101;
|
||||
((LineLineLeadIn)original.ExternalLeadIn).Length1 = 102;
|
||||
((BreakerTab)original.TabConfig).BreakerDepth = 103;
|
||||
((LineArcLeadIn)original.TabConfig.TabLeadIn).ArcRadius = 104;
|
||||
((ArcLeadOut)original.TabConfig.TabLeadOut).Radius = 105;
|
||||
AssertEquivalent(CreateParameters(), CuttingParametersSerializer.FromDto(dto));
|
||||
|
||||
dto.Assignment.Preference = "changed snapshot";
|
||||
dto.Sequencing.SmallCutoutWidth = 201;
|
||||
dto.ExternalLeadIn.Length1 = 202;
|
||||
dto.TabConfig.BreakerDepth = 203;
|
||||
dto.TabConfig.TabLeadIn.ArcRadius = 204;
|
||||
@@ -362,25 +326,6 @@ public class CuttingParametersSerializerTests
|
||||
SupportTabs = true,
|
||||
TabConfig = CreateTab("Breaker"),
|
||||
TabsEnabled = true,
|
||||
Assignment = new AssignmentParameters
|
||||
{
|
||||
Method = SequenceMethod.EdgeStart,
|
||||
Preference = "TAIL",
|
||||
MinGeometryLength = 0.37,
|
||||
},
|
||||
Sequencing = new SequenceParameters
|
||||
{
|
||||
Method = SequenceMethod.LeftSide,
|
||||
SmallCutoutWidth = 2.3,
|
||||
SmallCutoutHeight = 3.4,
|
||||
MediumCutoutWidth = 9.5,
|
||||
MediumCutoutHeight = 10.6,
|
||||
DistanceMediumSmall = 1.7,
|
||||
AlternateRowsColumns = false,
|
||||
AlternateCutoutsWithinRowColumn = false,
|
||||
MinDistanceBetweenRowsColumns = 0.8,
|
||||
HeatWeight = 0.35,
|
||||
},
|
||||
};
|
||||
|
||||
private static LeadIn CreateLeadIn(string type) => type switch
|
||||
|
||||
@@ -121,22 +121,6 @@ public class SupportGridPersistenceTests
|
||||
Assert.Equal(0, CuttingParametersSerializer.Deserialize("{}").TabSizeMaxWidth);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void HeatAwarePartOrderRoundTripsInAPlatesCuttingParameters()
|
||||
{
|
||||
var nest = NestWith(null);
|
||||
nest.Plates[0].CuttingParameters = new CuttingParameters
|
||||
{
|
||||
Sequencing = new SequenceParameters { Method = SequenceMethod.HeatAware, HeatWeight = 0.25 },
|
||||
};
|
||||
|
||||
var (restored, _) = RoundTrip(ArchiveBytes(nest));
|
||||
|
||||
var sequencing = restored.Plates[0].CuttingParameters.Sequencing;
|
||||
Assert.Equal(SequenceMethod.HeatAware, sequencing.Method);
|
||||
Assert.Equal(0.25, sequencing.HeatWeight);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SettingsSavedWithTheRetiredTabHeldLengthStillRead()
|
||||
{
|
||||
|
||||
@@ -57,8 +57,6 @@ public class CuttingParametersDto
|
||||
LabelMode != PartLabelMode.Off && System.Enum.IsDefined(LabelMode) ? LabelMode
|
||||
: EtchPartLabels ? PartLabelMode.PartNumberAndBendGroups
|
||||
: PartLabelMode.Off;
|
||||
public SequenceDto Sequencing { get; set; } = new();
|
||||
public AssignmentDto Assignment { get; set; } = new();
|
||||
|
||||
public class LeadInDto
|
||||
{
|
||||
@@ -101,25 +99,4 @@ public class CuttingParametersDto
|
||||
public double BreakerLeadInLength { get; set; }
|
||||
public double BreakerAngle { get; set; }
|
||||
}
|
||||
|
||||
public class SequenceDto
|
||||
{
|
||||
public SequenceMethod Method { get; set; } = SequenceMethod.Advanced;
|
||||
public double SmallCutoutWidth { get; set; } = 1.5;
|
||||
public double SmallCutoutHeight { get; set; } = 1.5;
|
||||
public double MediumCutoutWidth { get; set; } = 8.0;
|
||||
public double MediumCutoutHeight { get; set; } = 8.0;
|
||||
public double DistanceMediumSmall { get; set; }
|
||||
public bool AlternateRowsColumns { get; set; } = true;
|
||||
public bool AlternateCutoutsWithinRowColumn { get; set; } = true;
|
||||
public double MinDistanceBetweenRowsColumns { get; set; } = 0.25;
|
||||
public double HeatWeight { get; set; } = SequenceParameters.DefaultHeatWeight;
|
||||
}
|
||||
|
||||
public class AssignmentDto
|
||||
{
|
||||
public SequenceMethod Method { get; set; } = SequenceMethod.Advanced;
|
||||
public string Preference { get; set; } = "ILAT";
|
||||
public double MinGeometryLength { get; set; } = 0.01;
|
||||
}
|
||||
}
|
||||
@@ -95,8 +95,6 @@ public static class CuttingParametersSerializer
|
||||
NoBedTabMaxWidth = parameters.TabSizeMaxWidth,
|
||||
SliceTippingSlugs = parameters.SliceTippingSlugs,
|
||||
LabelMode = parameters.LabelMode,
|
||||
Sequencing = ToSequenceDto(parameters.Sequencing),
|
||||
Assignment = ToAssignmentDto(parameters.Assignment),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -133,8 +131,6 @@ public static class CuttingParametersSerializer
|
||||
TabSizeMaxWidth = dto.NoBedTabMaxWidth,
|
||||
SliceTippingSlugs = dto.SliceTippingSlugs,
|
||||
LabelMode = dto.ResolvedLabelMode,
|
||||
Sequencing = FromSequenceDto(dto.Sequencing),
|
||||
Assignment = FromAssignmentDto(dto.Assignment),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -277,55 +273,4 @@ public static class CuttingParametersSerializer
|
||||
return tab;
|
||||
}
|
||||
|
||||
private static SequenceDto ToSequenceDto(SequenceParameters parameters) => parameters == null
|
||||
? null
|
||||
: new SequenceDto
|
||||
{
|
||||
Method = parameters.Method,
|
||||
SmallCutoutWidth = parameters.SmallCutoutWidth,
|
||||
SmallCutoutHeight = parameters.SmallCutoutHeight,
|
||||
MediumCutoutWidth = parameters.MediumCutoutWidth,
|
||||
MediumCutoutHeight = parameters.MediumCutoutHeight,
|
||||
DistanceMediumSmall = parameters.DistanceMediumSmall,
|
||||
AlternateRowsColumns = parameters.AlternateRowsColumns,
|
||||
AlternateCutoutsWithinRowColumn = parameters.AlternateCutoutsWithinRowColumn,
|
||||
MinDistanceBetweenRowsColumns = parameters.MinDistanceBetweenRowsColumns,
|
||||
HeatWeight = parameters.HeatWeight,
|
||||
};
|
||||
|
||||
private static SequenceParameters FromSequenceDto(SequenceDto dto) => dto == null
|
||||
? null
|
||||
: new SequenceParameters
|
||||
{
|
||||
Method = dto.Method,
|
||||
SmallCutoutWidth = dto.SmallCutoutWidth,
|
||||
SmallCutoutHeight = dto.SmallCutoutHeight,
|
||||
MediumCutoutWidth = dto.MediumCutoutWidth,
|
||||
MediumCutoutHeight = dto.MediumCutoutHeight,
|
||||
DistanceMediumSmall = dto.DistanceMediumSmall,
|
||||
AlternateRowsColumns = dto.AlternateRowsColumns,
|
||||
AlternateCutoutsWithinRowColumn = dto.AlternateCutoutsWithinRowColumn,
|
||||
MinDistanceBetweenRowsColumns = dto.MinDistanceBetweenRowsColumns,
|
||||
// A negative or nonfinite weight cannot be meant; it reads as the default.
|
||||
HeatWeight = double.IsFinite(dto.HeatWeight) && dto.HeatWeight >= 0
|
||||
? dto.HeatWeight : SequenceParameters.DefaultHeatWeight,
|
||||
};
|
||||
|
||||
private static AssignmentDto ToAssignmentDto(AssignmentParameters parameters) => parameters == null
|
||||
? null
|
||||
: new AssignmentDto
|
||||
{
|
||||
Method = parameters.Method,
|
||||
Preference = parameters.Preference,
|
||||
MinGeometryLength = parameters.MinGeometryLength,
|
||||
};
|
||||
|
||||
private static AssignmentParameters FromAssignmentDto(AssignmentDto dto) => dto == null
|
||||
? null
|
||||
: new AssignmentParameters
|
||||
{
|
||||
Method = dto.Method,
|
||||
Preference = dto.Preference,
|
||||
MinGeometryLength = dto.MinGeometryLength,
|
||||
};
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class CuttingPlanCommitTests
|
||||
case "cutoff-classification": parts[0].BaseDrawing.IsCutOff = true; break;
|
||||
// A regenerated part would otherwise overwrite an edit made after capture.
|
||||
case "part-settings-in-place": parts[0].CuttingParameters.Kerf = 0.125; break;
|
||||
case "part-settings-nested": parts[0].CuttingParameters.Assignment.Preference = "LIAT"; break;
|
||||
case "part-settings-nested": ((LineLeadIn)parts[0].CuttingParameters.InternalLeadIn).Length = 0.2; break;
|
||||
case "plate-settings-in-place": plate.CuttingParameters.PierceClearance = 0.25; break;
|
||||
case "plate-settings-replaced": plate.CuttingParameters = new CuttingParameters(); break;
|
||||
}
|
||||
|
||||
@@ -45,20 +45,7 @@ public class OwnedCuttingParameterTests
|
||||
TabSizeMinWidth = 0.5,
|
||||
TabSizeMaxWidth = 4,
|
||||
RoundLeadInAngles = true,
|
||||
LeadInAngleIncrement = 30,
|
||||
Sequencing = new SequenceParameters
|
||||
{
|
||||
Method = SequenceMethod.LeftSide,
|
||||
SmallCutoutWidth = 2,
|
||||
SmallCutoutHeight = 3,
|
||||
MediumCutoutWidth = 9,
|
||||
MediumCutoutHeight = 10,
|
||||
DistanceMediumSmall = 4,
|
||||
AlternateRowsColumns = false,
|
||||
AlternateCutoutsWithinRowColumn = false,
|
||||
MinDistanceBetweenRowsColumns = 0.3
|
||||
},
|
||||
Assignment = new AssignmentParameters { Method = SequenceMethod.EdgeStart, Preference = "test", MinGeometryLength = 0.04 }
|
||||
LeadInAngleIncrement = 30
|
||||
};
|
||||
var copy = OwnedCuttingParameters.Copy(source);
|
||||
AssertOwnedEqual(source, copy);
|
||||
@@ -99,8 +86,6 @@ public class OwnedCuttingParameterTests
|
||||
|
||||
[Theory]
|
||||
[InlineData("null-settings")]
|
||||
[InlineData("null-sequence")]
|
||||
[InlineData("null-assignment")]
|
||||
[InlineData("null-lead")]
|
||||
[InlineData("null-leadout")]
|
||||
[InlineData("null-tab")]
|
||||
@@ -109,22 +94,17 @@ public class OwnedCuttingParameterTests
|
||||
[InlineData("sweep-zero")]
|
||||
[InlineData("sweep-over")]
|
||||
[InlineData("increment")]
|
||||
[InlineData("enum")]
|
||||
[InlineData("tab-lead")]
|
||||
[InlineData("custom-in")]
|
||||
[InlineData("custom-out")]
|
||||
[InlineData("custom-tab")]
|
||||
[InlineData("custom-settings")]
|
||||
[InlineData("custom-sequence")]
|
||||
[InlineData("custom-assignment")]
|
||||
public void Copy_RejectsInvalidOrUnsupportedSettings(string fault)
|
||||
{
|
||||
var source = new CuttingParameters();
|
||||
switch (fault)
|
||||
{
|
||||
case "null-settings": source = null; break;
|
||||
case "null-sequence": source.Sequencing = null; break;
|
||||
case "null-assignment": source.Assignment = null; break;
|
||||
case "null-lead": source.InternalLeadIn = null; break;
|
||||
case "null-leadout": source.InternalLeadOut = null; break;
|
||||
case "null-tab": source.TabsEnabled = true; break;
|
||||
@@ -133,14 +113,11 @@ public class OwnedCuttingParameterTests
|
||||
case "sweep-zero": source.ExternalLeadIn = new ArcLeadIn { Radius = 0.2, SweepAngle = 0 }; break;
|
||||
case "sweep-over": source.ExternalLeadIn = new ArcLeadIn { Radius = 0.2, SweepAngle = 181 }; break;
|
||||
case "increment": source.LeadInAngleIncrement = 0; break;
|
||||
case "enum": source.Assignment.Method = (SequenceMethod)6; break;
|
||||
case "tab-lead": source.TabConfig = new NormalTab { TabLeadIn = new ArcLeadIn { Radius = double.PositiveInfinity } }; break;
|
||||
case "custom-in": source.InternalLeadIn = new CustomLeadIn(); break;
|
||||
case "custom-out": source.InternalLeadOut = new CustomLeadOut(); break;
|
||||
case "custom-tab": source.TabConfig = new CustomTab(); break;
|
||||
case "custom-settings": source = new CustomParameters(); break;
|
||||
case "custom-sequence": source.Sequencing = new CustomSequence(); break;
|
||||
case "custom-assignment": source.Assignment = new CustomAssignment(); break;
|
||||
}
|
||||
Assert.ThrowsAny<Exception>(() => OwnedCuttingParameters.Copy(source));
|
||||
Assert.ThrowsAny<Exception>(() => PreparedContours.Capture(ExplicitContourTests.Square(false), source));
|
||||
@@ -155,7 +132,7 @@ public class OwnedCuttingParameterTests
|
||||
foreach (var sample in Styles())
|
||||
{
|
||||
var source = new CuttingParameters { ExternalLeadIn = (LeadIn)sample[0], ExternalLeadOut = (LeadOut)sample[1], TabConfig = (Tab)sample[2] };
|
||||
foreach (var owner in new object[] { source, source.Sequencing, source.Assignment, source.ExternalLeadIn, source.ExternalLeadOut, source.TabConfig })
|
||||
foreach (var owner in new object[] { source, source.ExternalLeadIn, source.ExternalLeadOut, source.TabConfig })
|
||||
foreach (var property in owner.GetType().GetProperties().Where(p => p.PropertyType == typeof(double) && !p.Name.Contains("Angle")))
|
||||
{
|
||||
var original = property.GetValue(owner);
|
||||
@@ -170,6 +147,4 @@ public class OwnedCuttingParameterTests
|
||||
private sealed class CustomLeadOut : ArcLeadOut { }
|
||||
private sealed class CustomTab : NormalTab { }
|
||||
private sealed class CustomParameters : CuttingParameters { }
|
||||
private sealed class CustomSequence : SequenceParameters { }
|
||||
private sealed class CustomAssignment : AssignmentParameters { }
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class SettingsFreshnessTests
|
||||
{
|
||||
private static readonly Type[] SupportedTypes =
|
||||
[
|
||||
typeof(CuttingParameters), typeof(SequenceParameters), typeof(AssignmentParameters),
|
||||
typeof(CuttingParameters),
|
||||
typeof(NoLeadIn), typeof(LineLeadIn), typeof(ArcLeadIn), typeof(LineArcLeadIn),
|
||||
typeof(LineLineLeadIn), typeof(CleanHoleLeadIn),
|
||||
typeof(NoLeadOut), typeof(LineLeadOut), typeof(ArcLeadOut),
|
||||
@@ -61,8 +61,6 @@ public class SettingsFreshnessTests
|
||||
[InlineData("lead-out")]
|
||||
[InlineData("tab")]
|
||||
[InlineData("tab-lead-in")]
|
||||
[InlineData("sequence")]
|
||||
[InlineData("assignment")]
|
||||
[InlineData("plate")]
|
||||
public void Plan_CustomNestedOrPlateSettingsType_IsUnsupported(string slot)
|
||||
{
|
||||
@@ -74,8 +72,6 @@ public class SettingsFreshnessTests
|
||||
case "lead-out": settings.InternalLeadOut = new CustomLeadOut(); break;
|
||||
case "tab": settings.TabConfig = new CustomTab(); break;
|
||||
case "tab-lead-in": settings.TabConfig = new NormalTab { TabLeadIn = new CustomLeadIn() }; break;
|
||||
case "sequence": settings.Sequencing = new CustomSequence(); break;
|
||||
case "assignment": settings.Assignment = new CustomAssignment(); break;
|
||||
case "plate": plate.CuttingParameters = new MutatingSettings(); break;
|
||||
}
|
||||
|
||||
@@ -98,7 +94,7 @@ public class SettingsFreshnessTests
|
||||
{
|
||||
case "lead-in": settings.ExternalLeadIn = new CustomLeadIn(); break;
|
||||
case "tab": settings.TabConfig = new CustomTab(); break;
|
||||
case "plate": plate.CuttingParameters.Sequencing = new CustomSequence(); break;
|
||||
case "plate": plate.CuttingParameters.InternalLeadIn = new CustomLeadIn(); break;
|
||||
}
|
||||
|
||||
CuttingCommitResult? commit = null;
|
||||
@@ -239,8 +235,6 @@ public class SettingsFreshnessTests
|
||||
private static CuttingParameters Graph(object instance) => instance switch
|
||||
{
|
||||
CuttingParameters p => p,
|
||||
SequenceParameters s => new CuttingParameters { Sequencing = s },
|
||||
AssignmentParameters a => new CuttingParameters { Assignment = a },
|
||||
LeadIn l => new CuttingParameters { ExternalLeadIn = l },
|
||||
LeadOut l => new CuttingParameters { ExternalLeadOut = l },
|
||||
Tab t => new CuttingParameters { TabConfig = t },
|
||||
@@ -265,10 +259,6 @@ public class SettingsFreshnessTests
|
||||
return new ArcLeadOut { Radius = 7.77 };
|
||||
if (type == typeof(Tab))
|
||||
return new MachineTab { MachineTabId = 77 };
|
||||
if (type == typeof(SequenceParameters))
|
||||
return new SequenceParameters { SmallCutoutWidth = 7.77 };
|
||||
if (type == typeof(AssignmentParameters))
|
||||
return new AssignmentParameters { MinGeometryLength = 7.77 };
|
||||
Assert.Fail($"{member}: type {type.Name} is not fingerprinted; extend StateFingerprint.");
|
||||
return null;
|
||||
}
|
||||
@@ -350,6 +340,4 @@ public class SettingsFreshnessTests
|
||||
private sealed class CustomLeadIn : LineLeadIn { }
|
||||
private sealed class CustomLeadOut : ArcLeadOut { }
|
||||
private sealed class CustomTab : NormalTab { }
|
||||
private sealed class CustomSequence : SequenceParameters { }
|
||||
private sealed class CustomAssignment : AssignmentParameters { }
|
||||
}
|
||||
@@ -214,8 +214,6 @@ public class PartLeadInSerializationTests
|
||||
var first = nest.Plates[0];
|
||||
first.CuttingParameters = Parameters();
|
||||
first.CuttingParameters.MachineName = "Saved machine";
|
||||
first.CuttingParameters.Assignment.Preference = "TAIL";
|
||||
first.CuttingParameters.Sequencing.SmallCutoutWidth = 2.75;
|
||||
first.CuttingParameters.TabConfig = new BreakerTab
|
||||
{
|
||||
Size = 0.3,
|
||||
@@ -234,8 +232,6 @@ public class PartLeadInSerializationTests
|
||||
var parameters = loaded.Plates[0].CuttingParameters;
|
||||
Assert.NotNull(parameters);
|
||||
Assert.Equal("Saved machine", parameters.MachineName);
|
||||
Assert.Equal("TAIL", parameters.Assignment.Preference);
|
||||
Assert.Equal(2.75, parameters.Sequencing.SmallCutoutWidth);
|
||||
Assert.Equal(0.5, Assert.IsType<LineLeadIn>(parameters.ExternalLeadIn).Length);
|
||||
Assert.Equal(0.25, Assert.IsType<LineLeadOut>(parameters.ExternalLeadOut).Length);
|
||||
var tab = Assert.IsType<BreakerTab>(parameters.TabConfig);
|
||||
|
||||
@@ -150,9 +150,8 @@ preserving the old default selection behavior. `OpenNest.IO.CuttingParametersSer
|
||||
cross-platform DTO mapping; the desktop settings serializer delegates to it so
|
||||
existing saved settings keep their JSON contract. Settings are independent of
|
||||
the saved part programs: restoring settings never regenerates those programs.
|
||||
`sequencing.method` is written as its number (100 for the
|
||||
[heat-aware order](plate-heat-map.md#sequencing)) with `sequencing.heatWeight`
|
||||
(seconds per °C); a file without the weight, or with a negative one, reads 0.15.
|
||||
Older files and desktop settings also stored `sequencing` and `assignment` objects for
|
||||
the removed automatic part sequencers; these are ignored on read and no longer written.
|
||||
|
||||
Lead settings are external (the perimeter) and internal (every cutout, full
|
||||
circles included). Older files and desktop settings also stored
|
||||
@@ -392,7 +391,7 @@ files written before the change open in the order they were saved with.
|
||||
|
||||
## Drawing cut-first flag
|
||||
|
||||
A drawing may write `cutFirst: true` to have automatic part sequencing cut its parts
|
||||
A drawing may write `cutFirst: true` to have Plan Cutting and Sequence by Path cut its parts
|
||||
before every other part (see [part sequencing](automatic-scrap-cutoffs.md#part-sequencing));
|
||||
it is omitted when false, so older readers ignore it. Split pieces keep the flag.
|
||||
|
||||
|
||||
@@ -80,9 +80,7 @@ bed, and its heat label says whether the sheet is cooled by air only or by air a
|
||||
A heat-aware part sequencer was tried and removed: the cut order comes from Plan Cutting or the
|
||||
user, and OpenNest keeps no automatic part sequencers (the code is in git history before the
|
||||
commit that removed them). A heat-aware order belongs in Plan Cutting's search once FLIR
|
||||
thermal-camera readings calibrate the model. `SequenceMethod.HeatAware` and
|
||||
`SequenceParameters.HeatWeight` are still read and written with the cutting settings, but nothing
|
||||
orders parts by them. What was tried:
|
||||
thermal-camera readings calibrate the model. What was tried:
|
||||
|
||||
- Order: a forward greedy from the plate's origin corner. The next part was the one with the least
|
||||
travel seconds plus `HeatWeight` (seconds per °C, 0.15 by default) times the estimated
|
||||
|
||||
Reference in new issue
Block a user