feat(api): add NestStrategy, NestRequestPart, NestRequest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 08:26:51 -04:00
parent b6bd7eda6e
commit 84679b40ce
4 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Api;
public class NestRequest
{
public IReadOnlyList<NestRequestPart> Parts { get; init; } = [];
public Size SheetSize { get; init; } = new(60, 120);
public string Material { get; init; } = "Steel, A1011 HR";
public double Thickness { get; init; } = 0.06;
public double Spacing { get; init; } = 0.1;
public NestStrategy Strategy { get; init; } = NestStrategy.Auto;
public CutParameters Cutting { get; init; } = CutParameters.Default;
}

View File

@@ -0,0 +1,9 @@
namespace OpenNest.Api;
public class NestRequestPart
{
public string DxfPath { get; init; }
public int Quantity { get; init; } = 1;
public bool AllowRotation { get; init; } = true;
public int Priority { get; init; } = 0;
}

View File

@@ -0,0 +1,3 @@
namespace OpenNest.Api;
public enum NestStrategy { Auto }

View File

@@ -0,0 +1,45 @@
using OpenNest.Api;
using OpenNest.Geometry;
namespace OpenNest.Tests.Api;
public class NestRequestTests
{
[Fact]
public void Default_Request_HasSensibleDefaults()
{
var request = new NestRequest();
Assert.Empty(request.Parts);
Assert.Equal(60, request.SheetSize.Width);
Assert.Equal(120, request.SheetSize.Length);
Assert.Equal("Steel, A1011 HR", request.Material);
Assert.Equal(0.06, request.Thickness);
Assert.Equal(0.1, request.Spacing);
Assert.Equal(NestStrategy.Auto, request.Strategy);
Assert.NotNull(request.Cutting);
}
[Fact]
public void Parts_Accessible_AfterConstruction()
{
var request = new NestRequest
{
Parts = [new NestRequestPart { DxfPath = "test.dxf", Quantity = 5 }]
};
Assert.Single(request.Parts);
Assert.Equal("test.dxf", request.Parts[0].DxfPath);
Assert.Equal(5, request.Parts[0].Quantity);
}
[Fact]
public void NestRequestPart_Defaults()
{
var part = new NestRequestPart { DxfPath = "part.dxf" };
Assert.Equal(1, part.Quantity);
Assert.True(part.AllowRotation);
Assert.Equal(0, part.Priority);
}
}