feat: serialize plate optimizer settings in nest files
Add PlateOptions and SalvageRate properties to the Nest class and round-trip them through NestWriter/NestReader via a new PlateOptionDto. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using OpenNest.Collections;
|
||||
using OpenNest.Geometry;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenNest
|
||||
{
|
||||
@@ -51,6 +52,10 @@ namespace OpenNest
|
||||
|
||||
public PlateSettings PlateDefaults { get; set; }
|
||||
|
||||
public List<PlateOption> PlateOptions { get; set; } = new();
|
||||
|
||||
public double SalvageRate { get; set; } = 0.5;
|
||||
|
||||
public Plate CreatePlate()
|
||||
{
|
||||
var plate = PlateDefaults.CreateNew();
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace OpenNest.IO
|
||||
public PlateDefaultsDto PlateDefaults { get; init; } = new();
|
||||
public List<DrawingDto> Drawings { get; init; } = new();
|
||||
public List<PlateDto> Plates { get; init; } = new();
|
||||
public List<PlateOptionDto> PlateOptions { get; init; } = new();
|
||||
public double SalvageRate { get; init; } = 0.5;
|
||||
}
|
||||
|
||||
public record PlateDefaultsDto
|
||||
@@ -153,6 +155,13 @@ namespace OpenNest.IO
|
||||
public string NoteText { get; init; } = "";
|
||||
}
|
||||
|
||||
public record PlateOptionDto
|
||||
{
|
||||
public double Width { get; init; }
|
||||
public double Length { get; init; }
|
||||
public double Cost { get; init; }
|
||||
}
|
||||
|
||||
public record BestFitSetDto
|
||||
{
|
||||
public double PlateWidth { get; init; }
|
||||
|
||||
@@ -192,6 +192,18 @@ namespace OpenNest.IO
|
||||
nest.PlateDefaults.PartSpacing = pd.PartSpacing;
|
||||
nest.PlateDefaults.EdgeSpacing = new Spacing(pd.EdgeSpacing.Left, pd.EdgeSpacing.Bottom, pd.EdgeSpacing.Right, pd.EdgeSpacing.Top);
|
||||
|
||||
// Plate optimizer settings
|
||||
nest.SalvageRate = dto.SalvageRate;
|
||||
if (dto.PlateOptions != null)
|
||||
{
|
||||
nest.PlateOptions = dto.PlateOptions.Select(o => new PlateOption
|
||||
{
|
||||
Width = o.Width,
|
||||
Length = o.Length,
|
||||
Cost = o.Cost,
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
// Drawings
|
||||
foreach (var d in drawingMap.OrderBy(k => k.Key))
|
||||
nest.Drawings.Add(d.Value);
|
||||
|
||||
@@ -88,7 +88,14 @@ namespace OpenNest.IO
|
||||
},
|
||||
PlateDefaults = BuildPlateDefaultsDto(),
|
||||
Drawings = BuildDrawingDtos(),
|
||||
Plates = BuildPlateDtos()
|
||||
Plates = BuildPlateDtos(),
|
||||
PlateOptions = nest.PlateOptions?.Select(o => new PlateOptionDto
|
||||
{
|
||||
Width = o.Width,
|
||||
Length = o.Length,
|
||||
Cost = o.Cost,
|
||||
}).ToList() ?? new(),
|
||||
SalvageRate = nest.SalvageRate,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user