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.
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using OpenNest.Engine.Fill;
|
|
|
|
namespace OpenNest.Engine.Strategies
|
|
{
|
|
public class PairsFillStrategy : IFillStrategy
|
|
{
|
|
private static readonly AsyncLocal<bool> active = new();
|
|
|
|
public string Name => "Pairs";
|
|
public NestPhase Phase => NestPhase.Pairs;
|
|
public int Order => 100;
|
|
|
|
public List<Part> Fill(FillContext context)
|
|
{
|
|
// Prevent recursive PairFiller — remnant fills within PairFiller
|
|
// create a new engine that runs the full pipeline, which would
|
|
// invoke PairsFillStrategy again, causing deep recursion.
|
|
if (active.Value)
|
|
return null;
|
|
|
|
if (context.PartType == PartType.Circle)
|
|
return null;
|
|
|
|
active.Value = true;
|
|
try
|
|
{
|
|
var comparer = context.Policy?.Comparer;
|
|
var dedup = GridDedup.GetOrCreate(context.SharedState);
|
|
var filler = new PairFiller(context.Plate, comparer, dedup);
|
|
var result = filler.Fill(
|
|
context.Item,
|
|
context.WorkArea,
|
|
context.Token,
|
|
context.ReportProgress
|
|
);
|
|
|
|
context.SharedState["BestFits"] = result.BestFits;
|
|
|
|
return result.Parts;
|
|
}
|
|
finally
|
|
{
|
|
active.Value = false;
|
|
}
|
|
}
|
|
}
|
|
}
|