Repo-wide sweep with the pinned CSharpier 1.3.0 tool. Whitespace and line-wrapping only; OpenNest.Engine.Tests (109) and OpenNest.IO.Tests pass after reformat, full solution builds 0 errors. Added .csharpierignore so csproj/config XML keeps its existing layout (CSharpier's XML wrapping churns attributes with zero benefit). Formatting is now enforceable: dotnet csharpier check . passes.
61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
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;
|
|
}
|
|
}
|