Console --engine now names a jobs engine for --autonest (solved once through NestingEngineRegistry.Create and committed onto the plate) or a built-in fill strategy for single-plate fill through the public PlateFillService; unknown names exit with the valid choices instead of consulting the process-global legacy registry. MCP nesting tools take an explicit engine argument per call with the session default, never read process-global active-engine state, and reject whole-job engine names on single-plate fill tools. NestingEngineRegistry gains an explicit Create (name) resolution; PlateFillService gains a public ResolveStrategy and a plate-number Nest overload used by interactive callers.
69 lines
1.9 KiB
C#
69 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace OpenNest.Mcp
|
|
{
|
|
public class NestSession
|
|
{
|
|
public Nest Nest { get; set; }
|
|
public List<Plate> Plates { get; } = new();
|
|
public List<Drawing> Drawings { get; } = new();
|
|
|
|
/// <summary>
|
|
/// Session-default engine/strategy name used by nesting tools when a call does not pass
|
|
/// an explicit <c>engine</c> argument. Instance state only — the process-global legacy
|
|
/// registry is never read or written.
|
|
/// </summary>
|
|
public string DefaultEngineName { get; set; } = "Default";
|
|
|
|
public Plate GetPlate(int index)
|
|
{
|
|
if (Nest != null && index < Nest.Plates.Count)
|
|
return Nest.Plates[index];
|
|
|
|
var adjustedIndex = index - (Nest?.Plates.Count ?? 0);
|
|
if (adjustedIndex >= 0 && adjustedIndex < Plates.Count)
|
|
return Plates[adjustedIndex];
|
|
|
|
return null;
|
|
}
|
|
|
|
public Drawing GetDrawing(string name)
|
|
{
|
|
if (Nest != null)
|
|
{
|
|
foreach (var d in Nest.Drawings)
|
|
{
|
|
if (d.Name == name)
|
|
return d;
|
|
}
|
|
}
|
|
|
|
foreach (var d in Drawings)
|
|
{
|
|
if (d.Name == name)
|
|
return d;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public List<Plate> AllPlates()
|
|
{
|
|
var all = new List<Plate>();
|
|
if (Nest != null)
|
|
all.AddRange(Nest.Plates);
|
|
all.AddRange(Plates);
|
|
return all;
|
|
}
|
|
|
|
public List<Drawing> AllDrawings()
|
|
{
|
|
var all = new List<Drawing>();
|
|
if (Nest != null)
|
|
all.AddRange(Nest.Drawings);
|
|
all.AddRange(Drawings);
|
|
return all;
|
|
}
|
|
}
|
|
}
|