refactor(engine): thread explicit placement strategy through multi-plate orchestrators

This commit is contained in:
aj
2026-09-21 20:22:45 -04:00
parent 856dbfd8af
commit f36e124039
5 changed files with 242 additions and 29 deletions
+12 -5
View File
@@ -5,6 +5,7 @@ using System.Linq;
using System.Threading;
using OpenNest.Engine;
using OpenNest.Engine.BestFit;
using OpenNest.Engine.Jobs.Placement;
using OpenNest.Geometry;
using OpenNest.Math;
@@ -18,7 +19,8 @@ namespace OpenNest.Engine
double salvageRate,
Plate templatePlate,
IProgress<NestProgress> progress = null,
CancellationToken token = default
CancellationToken token = default,
string strategy = null
)
{
if (
@@ -29,6 +31,10 @@ namespace OpenNest.Engine
)
return null;
// Explicit strategy at the top-level boundary (null/empty = Default, unknown = throw);
// the size search never consults the process-global engine registry.
var resolvedStrategy = PlateFillService.ResolveStrategy(strategy);
// Find the minimum dimension needed to fit the largest part,
// skipping items that are too large for every plate option.
var minPartWidth = 0.0;
@@ -94,7 +100,8 @@ namespace OpenNest.Engine
salvageRate,
templatePlate,
progress,
token
token,
resolvedStrategy
);
if (result == null)
continue;
@@ -149,7 +156,8 @@ namespace OpenNest.Engine
double salvageRate,
Plate templatePlate,
IProgress<NestProgress> progress,
CancellationToken token
CancellationToken token,
string strategy
)
{
// Create a temporary plate with candidate size + settings from template.
@@ -178,8 +186,7 @@ namespace OpenNest.Engine
})
.ToList();
var engine = NestEngineRegistry.Create(tempPlate);
var parts = engine.Nest(clonedItems, progress, token);
var parts = PlateFillService.Nest(strategy, tempPlate, clonedItems, progress, token);
if (parts == null || parts.Count == 0)
return null;