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.
58 lines
1.9 KiB
C#
58 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Engine.Fill;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.Engine.Strategies
|
|
{
|
|
public class LinearFillStrategy : IFillStrategy
|
|
{
|
|
public string Name => "Linear";
|
|
public NestPhase Phase => NestPhase.Linear;
|
|
public int Order => 400;
|
|
|
|
public List<Part> Fill(FillContext context)
|
|
{
|
|
var angles = context.SharedState.TryGetValue("AngleCandidates", out var cached)
|
|
? (List<double>)cached
|
|
: new List<double> { 0, Angle.HalfPI };
|
|
|
|
var workArea = context.WorkArea;
|
|
var comparer = context.Policy?.Comparer ?? new DefaultFillComparer();
|
|
var preferred = context.Policy?.PreferredDirection;
|
|
|
|
return FillHelpers.BestOverAngles(
|
|
context,
|
|
angles,
|
|
angle =>
|
|
{
|
|
var engine = new FillLinear(workArea, context.Plate.PartSpacing)
|
|
{
|
|
Label = "Linear",
|
|
};
|
|
var result = FillHelpers.FillWithDirectionPreference(
|
|
dir => engine.Fill(context.Item.Drawing, angle, dir),
|
|
preferred,
|
|
comparer,
|
|
workArea
|
|
);
|
|
|
|
if (result != null && result.Count > 0)
|
|
{
|
|
context.AngleResults.Add(
|
|
new AngleResult
|
|
{
|
|
AngleDeg = Angle.ToDegrees(angle),
|
|
Direction = preferred ?? NestDirection.Horizontal,
|
|
PartCount = result.Count,
|
|
}
|
|
);
|
|
}
|
|
|
|
return result;
|
|
},
|
|
"Linear"
|
|
);
|
|
}
|
|
}
|
|
}
|