feat: add auto-tab size range fields to CuttingParameters
Add AutoTabMinSize and AutoTabMaxSize properties to enable automatic tab assignment based on part size. Update CuttingParametersSerializer for round-trip serialization and add tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,9 @@ namespace OpenNest.CNC.CuttingStrategy
|
|||||||
|
|
||||||
public double PierceClearance { get; set; } = 0.0625;
|
public double PierceClearance { get; set; } = 0.0625;
|
||||||
|
|
||||||
|
public double AutoTabMinSize { get; set; }
|
||||||
|
public double AutoTabMaxSize { get; set; }
|
||||||
|
|
||||||
public Tab TabConfig { get; set; }
|
public Tab TabConfig { get; set; }
|
||||||
public bool TabsEnabled { get; set; }
|
public bool TabsEnabled { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using OpenNest.CNC.CuttingStrategy;
|
||||||
|
using OpenNest.Forms;
|
||||||
|
|
||||||
|
namespace OpenNest.Tests.CuttingStrategy;
|
||||||
|
|
||||||
|
public class CuttingParametersSerializerTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void RoundTrip_PreservesAutoTabFields()
|
||||||
|
{
|
||||||
|
var original = new CuttingParameters
|
||||||
|
{
|
||||||
|
AutoTabMinSize = 0.5,
|
||||||
|
AutoTabMaxSize = 3.0,
|
||||||
|
ExternalLeadIn = new LineLeadIn { Length = 0.25, ApproachAngle = 90 }
|
||||||
|
};
|
||||||
|
|
||||||
|
var json = CuttingParametersSerializer.Serialize(original);
|
||||||
|
var restored = CuttingParametersSerializer.Deserialize(json);
|
||||||
|
|
||||||
|
Assert.Equal(0.5, restored.AutoTabMinSize);
|
||||||
|
Assert.Equal(3.0, restored.AutoTabMaxSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Deserialize_MissingAutoTabFields_DefaultsToZero()
|
||||||
|
{
|
||||||
|
var json = "{\"externalLeadIn\":{\"type\":\"None\"},\"externalLeadOut\":{\"type\":\"None\"},\"internalLeadIn\":{\"type\":\"None\"},\"internalLeadOut\":{\"type\":\"None\"},\"arcCircleLeadIn\":{\"type\":\"None\"},\"arcCircleLeadOut\":{\"type\":\"None\"},\"tabsEnabled\":false,\"tabWidth\":0.25,\"pierceClearance\":0.0625}";
|
||||||
|
|
||||||
|
var restored = CuttingParametersSerializer.Deserialize(json);
|
||||||
|
|
||||||
|
Assert.Equal(0.0, restored.AutoTabMinSize);
|
||||||
|
Assert.Equal(0.0, restored.AutoTabMaxSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
<ProjectReference Include="..\OpenNest.Engine\OpenNest.Engine.csproj" />
|
<ProjectReference Include="..\OpenNest.Engine\OpenNest.Engine.csproj" />
|
||||||
<ProjectReference Include="..\OpenNest.IO\OpenNest.IO.csproj" />
|
<ProjectReference Include="..\OpenNest.IO\OpenNest.IO.csproj" />
|
||||||
<ProjectReference Include="..\OpenNest.Posts.Cincinnati\OpenNest.Posts.Cincinnati.csproj" />
|
<ProjectReference Include="..\OpenNest.Posts.Cincinnati\OpenNest.Posts.Cincinnati.csproj" />
|
||||||
|
<ProjectReference Include="..\OpenNest\OpenNest.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Text.Json;
|
|||||||
|
|
||||||
namespace OpenNest.Forms
|
namespace OpenNest.Forms
|
||||||
{
|
{
|
||||||
internal static class CuttingParametersSerializer
|
public static class CuttingParametersSerializer
|
||||||
{
|
{
|
||||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||||
{
|
{
|
||||||
@@ -23,7 +23,9 @@ namespace OpenNest.Forms
|
|||||||
ArcCircleLeadOut = ToLeadOutDto(p.ArcCircleLeadOut),
|
ArcCircleLeadOut = ToLeadOutDto(p.ArcCircleLeadOut),
|
||||||
TabsEnabled = p.TabsEnabled,
|
TabsEnabled = p.TabsEnabled,
|
||||||
TabWidth = p.TabConfig?.Size ?? 0.25,
|
TabWidth = p.TabConfig?.Size ?? 0.25,
|
||||||
PierceClearance = p.PierceClearance
|
PierceClearance = p.PierceClearance,
|
||||||
|
AutoTabMinSize = p.AutoTabMinSize,
|
||||||
|
AutoTabMaxSize = p.AutoTabMaxSize
|
||||||
};
|
};
|
||||||
return JsonSerializer.Serialize(dto, JsonOptions);
|
return JsonSerializer.Serialize(dto, JsonOptions);
|
||||||
}
|
}
|
||||||
@@ -44,7 +46,9 @@ namespace OpenNest.Forms
|
|||||||
ArcCircleLeadOut = FromLeadOutDto(dto.ArcCircleLeadOut),
|
ArcCircleLeadOut = FromLeadOutDto(dto.ArcCircleLeadOut),
|
||||||
TabsEnabled = dto.TabsEnabled,
|
TabsEnabled = dto.TabsEnabled,
|
||||||
TabConfig = new NormalTab { Size = dto.TabWidth },
|
TabConfig = new NormalTab { Size = dto.TabWidth },
|
||||||
PierceClearance = dto.PierceClearance
|
PierceClearance = dto.PierceClearance,
|
||||||
|
AutoTabMinSize = dto.AutoTabMinSize,
|
||||||
|
AutoTabMaxSize = dto.AutoTabMaxSize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +113,8 @@ namespace OpenNest.Forms
|
|||||||
public bool TabsEnabled { get; set; }
|
public bool TabsEnabled { get; set; }
|
||||||
public double TabWidth { get; set; }
|
public double TabWidth { get; set; }
|
||||||
public double PierceClearance { get; set; }
|
public double PierceClearance { get; set; }
|
||||||
|
public double AutoTabMinSize { get; set; }
|
||||||
|
public double AutoTabMaxSize { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private class LeadInDto
|
private class LeadInDto
|
||||||
|
|||||||
Reference in New Issue
Block a user