Files
OpenNest/OpenNest.Engine/Jobs/EngineNameResolver.cs
T
ajandClaude Opus 5.5 44372d129e feat(ui): rename the Fill engine to Lattice and describe engines
"Fill" said nothing about what the engine does, since every engine fills.
It is now Lattice, and Fill stays an alias, so saved selections, scripts
and API requests keep working. Engine descriptions are rewritten in plain
language and shown beside each name in the desktop engine lists; the main
toolbar's tooltip also says when Fill Area falls back to Lattice.

Docs also cover the leftover placement from the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-01 21:17:16 -05:00

46 lines
1.5 KiB
C#

#nullable enable
using System;
using OpenNest.Engine.Jobs.Placement;
namespace OpenNest.Engine.Jobs;
public enum EngineNameKind
{
FillStrategy,
JobEngine,
Unknown,
}
/// <param name="Name">The trimmed caller name.</param>
/// <param name="FillStrategy">Canonical strategy name when <see cref="Kind"/> is FillStrategy.</param>
public readonly record struct EngineNameClassification(EngineNameKind Kind, string Name, string? FillStrategy)
{
public bool IsFillStrategy => Kind == EngineNameKind.FillStrategy;
public bool IsJobEngine => Kind == EngineNameKind.JobEngine;
}
/// <summary>
/// Classifies a name from a front end selector that accepts both single-plate fill strategies
/// (<see cref="PlateFillService"/>) and whole-job engines (<see cref="NestingEngineRegistry"/>).
/// Fill strategies win, so "Lattice" and "Strip" resolve as strategies; an omitted name means
/// <see cref="PlateFillService.DefaultStrategy"/>. Front ends keep their own message wording.
/// </summary>
public static class EngineNameResolver
{
public static EngineNameClassification Classify(string? name)
{
var trimmed = name?.Trim() ?? string.Empty;
try
{
return new(EngineNameKind.FillStrategy, trimmed, PlateFillService.ResolveStrategy(trimmed));
}
catch (NotSupportedException)
{
var kind = NestingEngineRegistry.ResolveName(trimmed) != null
? EngineNameKind.JobEngine
: EngineNameKind.Unknown;
return new(kind, trimmed, null);
}
}
}