fix(api): set plate Material from request, add null guards in LoadAsync
- NestRunner now assigns Material to plates from request.Material - NestResponse.LoadAsync uses descriptive exceptions instead of null-forgiving operators - Fix pre-existing FillExtents.Fill signature mismatch (add bestFits parameter) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -67,27 +67,30 @@ public class NestResponse
|
|||||||
using var zip = new ZipArchive(fs, ZipArchiveMode.Read);
|
using var zip = new ZipArchive(fs, ZipArchiveMode.Read);
|
||||||
|
|
||||||
// Read request.json
|
// Read request.json
|
||||||
var requestEntry = zip.GetEntry("request.json");
|
var requestEntry = zip.GetEntry("request.json")
|
||||||
|
?? throw new InvalidOperationException("Missing request.json in .nestquote file");
|
||||||
NestRequest request;
|
NestRequest request;
|
||||||
await using (var stream = requestEntry!.Open())
|
await using (var stream = requestEntry.Open())
|
||||||
{
|
{
|
||||||
request = await JsonSerializer.DeserializeAsync<NestRequest>(stream, JsonOptions);
|
request = await JsonSerializer.DeserializeAsync<NestRequest>(stream, JsonOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read response.json
|
// Read response.json
|
||||||
var responseEntry = zip.GetEntry("response.json");
|
var responseEntry = zip.GetEntry("response.json")
|
||||||
|
?? throw new InvalidOperationException("Missing response.json in .nestquote file");
|
||||||
JsonElement metricsJson;
|
JsonElement metricsJson;
|
||||||
await using (var stream = responseEntry!.Open())
|
await using (var stream = responseEntry.Open())
|
||||||
{
|
{
|
||||||
metricsJson = await JsonSerializer.DeserializeAsync<JsonElement>(stream, JsonOptions);
|
metricsJson = await JsonSerializer.DeserializeAsync<JsonElement>(stream, JsonOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read embedded nest.nest via NestReader(Stream)
|
// Read embedded nest.nest via NestReader(Stream)
|
||||||
var nestEntry = zip.GetEntry("nest.nest");
|
var nestEntry = zip.GetEntry("nest.nest")
|
||||||
|
?? throw new InvalidOperationException("Missing nest.nest in .nestquote file");
|
||||||
Nest nest;
|
Nest nest;
|
||||||
using (var nestMs = new MemoryStream())
|
using (var nestMs = new MemoryStream())
|
||||||
{
|
{
|
||||||
await using (var stream = nestEntry!.Open())
|
await using (var stream = nestEntry.Open())
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(nestMs);
|
await stream.CopyToAsync(nestMs);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ public static class NestRunner
|
|||||||
var plate = new Plate(request.SheetSize)
|
var plate = new Plate(request.SheetSize)
|
||||||
{
|
{
|
||||||
Thickness = request.Thickness,
|
Thickness = request.Thickness,
|
||||||
PartSpacing = request.Spacing
|
PartSpacing = request.Spacing,
|
||||||
|
Material = new Material(request.Material)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build items for this pass with remaining quantities
|
// Build items for this pass with remaining quantities
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ namespace OpenNest
|
|||||||
public List<Part> Fill(Drawing drawing, double rotationAngle = 0,
|
public List<Part> Fill(Drawing drawing, double rotationAngle = 0,
|
||||||
int plateNumber = 0,
|
int plateNumber = 0,
|
||||||
CancellationToken token = default,
|
CancellationToken token = default,
|
||||||
IProgress<NestProgress> progress = null)
|
IProgress<NestProgress> progress = null,
|
||||||
|
List<Engine.BestFit.BestFitResult> bestFits = null)
|
||||||
{
|
{
|
||||||
var pair = BuildPair(drawing, rotationAngle);
|
var pair = BuildPair(drawing, rotationAngle);
|
||||||
if (pair == null)
|
if (pair == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user