mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 04:21:34 -05:00
refactor(io): persist best fits through an explicit IBestFitStore
Reading a nest used to fill the engine's static BestFitCache as a side effect, which is the only reason OpenNest.IO referenced OpenNest.Engine. Core now defines SavedPairSet/SavedPairResult and IBestFitStore; the mapping to BestFitResult moved verbatim into Engine's BestFitCacheStore. NestReader/NestWriter take the store as an optional BestFitStore property and skip bestfits/ entries without one. Every production reader and writer opts into BestFitCacheStore.Shared, so behaviour is unchanged; the golden round-trip test still matches byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
063362a674
commit
6e66a1efe7
17 files changed
+515
-119
No files matched your search
@@ -9,6 +9,7 @@ using System.Threading;
|
||||
using OpenNest;
|
||||
using OpenNest.Diagnostics;
|
||||
using OpenNest.Engine;
|
||||
using OpenNest.Engine.BestFit;
|
||||
using OpenNest.Engine.Jobs;
|
||||
using OpenNest.Engine.Jobs.Placement;
|
||||
using OpenNest.Geometry;
|
||||
@@ -273,7 +274,7 @@ static class NestConsole
|
||||
// If we have a nest file, load it and optionally add DXFs.
|
||||
if (nestFile != null)
|
||||
{
|
||||
var nest = new NestReader(nestFile).Read();
|
||||
var nest = new NestReader(nestFile) { BestFitStore = BestFitCacheStore.Shared }.Read();
|
||||
|
||||
if (nest.Plates.Count == 0)
|
||||
{
|
||||
@@ -377,7 +378,7 @@ static class NestConsole
|
||||
return;
|
||||
}
|
||||
|
||||
var templateNest = new NestReader(options.TemplateFile).Read();
|
||||
var templateNest = new NestReader(options.TemplateFile) { BestFitStore = BestFitCacheStore.Shared }.Read();
|
||||
var templatePlate = templateNest.PlateDefaults.CreateNew();
|
||||
plate.Quadrant = templatePlate.Quadrant;
|
||||
plate.EdgeSpacing = templatePlate.EdgeSpacing;
|
||||
@@ -599,7 +600,7 @@ static class NestConsole
|
||||
|
||||
var outputFile = NestOutputPath(options);
|
||||
|
||||
new NestWriter(nest).Write(outputFile);
|
||||
new NestWriter(nest) { BestFitStore = BestFitCacheStore.Shared }.Write(outputFile);
|
||||
Console.WriteLine($"Saved: {outputFile}");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user