mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-25 12:27:40 -05:00
Raster packs each part rotation as a bit mask of its material grown by half the part spacing plus 0.75 cell, so masks that never share a cell keep the spacing and every layout passes the layout check unrepaired. Coarse raster no-fit maps propose positions and a grid four times finer settles them; the job is decoded in 48 greedy variants through the shared stock loop. It is selectable by name, not a Default candidate. Benchmark, 7 real jobs, --parallel 1, 6" minimum salvage: all layouts valid; Irregular's sheet count on 5 jobs in 0.6-2.3 s against 11-78 s, at under 1 to 4% more salvage-credited cost; 3 sheets against 2 on 27K; 24 s on 2J9 (seven stock sizes). Packing tighter and opening the gaps with Fix Spacing saved under 0.1% of cost for up to 25 times the time, so it was left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
66 lines
2.6 KiB
C#
66 lines
2.6 KiB
C#
using System.Reflection;
|
|
using System.Runtime.Loader;
|
|
|
|
try
|
|
{
|
|
if (args.Length != 1)
|
|
throw new ArgumentException("Usage: ReleaseSmoke <extracted-package-directory>");
|
|
|
|
var package = Path.GetFullPath(args[0]);
|
|
// No project references: resolve against the extracted release, never the build tree.
|
|
AssemblyLoadContext.Default.Resolving += (_, name) =>
|
|
{
|
|
var path = Path.Combine(package, name.Name + ".dll");
|
|
return File.Exists(path) ? AssemblyLoadContext.Default.LoadFromAssemblyPath(path) : null;
|
|
};
|
|
|
|
var engineAssemblyPath = Path.Combine(package, "OpenNest.Engine.dll");
|
|
var engineAssembly = Assembly.LoadFrom(engineAssemblyPath);
|
|
var registry = engineAssembly.GetType("OpenNest.Engine.Jobs.NestingEngineRegistry", true)!;
|
|
var create = registry.GetMethod("Create")!;
|
|
|
|
// Every built-in engine the desktop offers must instantiate from the packaged assembly.
|
|
string[] expected =
|
|
[
|
|
"Default", "Rectangles", "Irregular", "Circles", "Raster", "FlatBar",
|
|
"Lattice", "Strip", "Vertical Remnant", "Horizontal Remnant",
|
|
];
|
|
foreach (var name in expected)
|
|
{
|
|
var engine = create.Invoke(null, [name])!;
|
|
if (!string.Equals(engine.GetType().Assembly.Location, engineAssemblyPath, StringComparison.OrdinalIgnoreCase))
|
|
throw new InvalidOperationException($"Engine {name} was not loaded from the release package.");
|
|
Console.WriteLine($"PASS: {name} instantiated from {engineAssemblyPath}");
|
|
}
|
|
|
|
// A selection saved before the engines were renamed must still resolve.
|
|
(string Legacy, string Current)[] renamed =
|
|
[("Opus55NestingEngine", "Irregular"), ("Fill", "Lattice")];
|
|
var resolveName = registry.GetMethod("ResolveName")!;
|
|
foreach (var (legacy, current) in renamed)
|
|
{
|
|
var resolved = resolveName.Invoke(null, [legacy]);
|
|
if (!Equals(resolved, current))
|
|
throw new InvalidOperationException(
|
|
$"Legacy selection {legacy} resolved to '{resolved}', expected {current}.");
|
|
Console.WriteLine($"PASS: legacy selection {legacy} resolves to {current}");
|
|
}
|
|
|
|
// Failure case: an unknown engine must be rejected, so a broken registry cannot pass silently.
|
|
try
|
|
{
|
|
create.Invoke(null, ["ReleaseSmokeMissingEngine"]);
|
|
throw new InvalidOperationException("Unknown engine name was accepted.");
|
|
}
|
|
catch (TargetInvocationException exception) when (exception.InnerException is NotSupportedException)
|
|
{
|
|
Console.WriteLine("PASS: unknown engine name rejected");
|
|
}
|
|
return 0;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Console.Error.WriteLine(exception);
|
|
return 1;
|
|
}
|