refactor(posts): move post-processor projects under Posts/
Group the Cincinnati and GravographIS plugin projects in a Posts/ folder so new machine posts have one home. Project names, namespaces, and the runtime Posts/ deploy target are unchanged; only relative paths in the solution and project references move.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenNest.Posts.Cincinnati;
|
||||
|
||||
public sealed class MaterialLibraryResolver
|
||||
{
|
||||
private const double ThicknessTolerance = 0.001;
|
||||
|
||||
private readonly List<MaterialLibraryEntry> _materialLibraries;
|
||||
private readonly List<EtchLibraryEntry> _etchLibraries;
|
||||
private readonly string _selectedLibrary;
|
||||
|
||||
public MaterialLibraryResolver(CincinnatiPostConfig config)
|
||||
{
|
||||
_materialLibraries = config.MaterialLibraries ?? new List<MaterialLibraryEntry>();
|
||||
_etchLibraries = config.EtchLibraries ?? new List<EtchLibraryEntry>();
|
||||
_selectedLibrary = config.SelectedLibrary ?? "";
|
||||
}
|
||||
|
||||
public string ResolveCutLibrary(string materialName, double thickness, string gas)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_selectedLibrary))
|
||||
return EnsureLibExtension(_selectedLibrary);
|
||||
|
||||
var entry = _materialLibraries.FirstOrDefault(e =>
|
||||
string.Equals(e.Material, materialName, StringComparison.OrdinalIgnoreCase)
|
||||
&& System.Math.Abs(e.Thickness - thickness) <= ThicknessTolerance
|
||||
&& string.Equals(e.Gas, gas, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
|
||||
return EnsureLibExtension(entry?.Library ?? "");
|
||||
}
|
||||
|
||||
public string ResolveEtchLibrary(string gas)
|
||||
{
|
||||
var entry = _etchLibraries.FirstOrDefault(e =>
|
||||
string.Equals(e.Gas, gas, StringComparison.OrdinalIgnoreCase)
|
||||
);
|
||||
|
||||
return EnsureLibExtension(entry?.Library ?? "");
|
||||
}
|
||||
|
||||
private static string EnsureLibExtension(string library)
|
||||
{
|
||||
if (string.IsNullOrEmpty(library))
|
||||
return library;
|
||||
|
||||
if (!library.EndsWith(".lib", StringComparison.OrdinalIgnoreCase))
|
||||
return library + ".lib";
|
||||
|
||||
return library;
|
||||
}
|
||||
|
||||
public static string ResolveGas(Nest nest, CincinnatiPostConfig config)
|
||||
{
|
||||
return !string.IsNullOrEmpty(nest.AssistGas) ? nest.AssistGas : config.DefaultAssistGas;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user