style: apply CSharpier formatting to all C# sources
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.
This commit is contained in:
@@ -25,8 +25,10 @@ public class FillPipelineTests
|
||||
|
||||
engine.Fill(item, plate.WorkArea(), null, System.Threading.CancellationToken.None);
|
||||
|
||||
Assert.True(engine.PhaseResults.Count >= FillStrategyRegistry.Strategies.Count,
|
||||
$"Expected phase results from all active strategies, got {engine.PhaseResults.Count}");
|
||||
Assert.True(
|
||||
engine.PhaseResults.Count >= FillStrategyRegistry.Strategies.Count,
|
||||
$"Expected phase results from all active strategies, got {engine.PhaseResults.Count}"
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -36,14 +38,21 @@ public class FillPipelineTests
|
||||
var engine = new DefaultNestEngine(plate);
|
||||
var item = new NestItem { Drawing = MakeRectDrawing(20, 10) };
|
||||
|
||||
var parts = engine.Fill(item, plate.WorkArea(), null, System.Threading.CancellationToken.None);
|
||||
var parts = engine.Fill(
|
||||
item,
|
||||
plate.WorkArea(),
|
||||
null,
|
||||
System.Threading.CancellationToken.None
|
||||
);
|
||||
|
||||
Assert.True(parts.Count > 0);
|
||||
Assert.True(engine.WinnerPhase == NestPhase.Pairs ||
|
||||
engine.WinnerPhase == NestPhase.Linear ||
|
||||
engine.WinnerPhase == NestPhase.RectBestFit ||
|
||||
engine.WinnerPhase == NestPhase.Extents ||
|
||||
engine.WinnerPhase == NestPhase.Custom);
|
||||
Assert.True(
|
||||
engine.WinnerPhase == NestPhase.Pairs
|
||||
|| engine.WinnerPhase == NestPhase.Linear
|
||||
|| engine.WinnerPhase == NestPhase.RectBestFit
|
||||
|| engine.WinnerPhase == NestPhase.Extents
|
||||
|| engine.WinnerPhase == NestPhase.Custom
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -10,7 +10,10 @@ public class FillStrategyRegistryTests
|
||||
{
|
||||
var strategies = FillStrategyRegistry.Strategies;
|
||||
|
||||
Assert.True(strategies.Count >= 6, $"Expected at least 6 built-in strategies, got {strategies.Count}");
|
||||
Assert.True(
|
||||
strategies.Count >= 6,
|
||||
$"Expected at least 6 built-in strategies, got {strategies.Count}"
|
||||
);
|
||||
Assert.Contains(strategies, s => s.Name == "Pairs");
|
||||
Assert.Contains(strategies, s => s.Name == "RectBestFit");
|
||||
Assert.Contains(strategies, s => s.Name == "Extents");
|
||||
@@ -25,8 +28,10 @@ public class FillStrategyRegistryTests
|
||||
var strategies = FillStrategyRegistry.Strategies;
|
||||
|
||||
for (var i = 1; i < strategies.Count; i++)
|
||||
Assert.True(strategies[i].Order >= strategies[i - 1].Order,
|
||||
$"Strategy '{strategies[i].Name}' (Order={strategies[i].Order}) should not precede '{strategies[i - 1].Name}' (Order={strategies[i - 1].Order})");
|
||||
Assert.True(
|
||||
strategies[i].Order >= strategies[i - 1].Order,
|
||||
$"Strategy '{strategies[i].Name}' (Order={strategies[i].Order}) should not precede '{strategies[i - 1].Name}' (Order={strategies[i - 1].Order})"
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -35,7 +35,9 @@ public class StrategyOverlapTests
|
||||
if (drawing is null)
|
||||
return; // Skip if test DXF not available
|
||||
|
||||
_output.WriteLine($"Drawing bbox: {drawing.Program.BoundingBox().Width:F2} x {drawing.Program.BoundingBox().Length:F2}");
|
||||
_output.WriteLine(
|
||||
$"Drawing bbox: {drawing.Program.BoundingBox().Width:F2} x {drawing.Program.BoundingBox().Length:F2}"
|
||||
);
|
||||
|
||||
var strategies = FillStrategyRegistry.Strategies.ToList();
|
||||
var item = new NestItem { Drawing = drawing };
|
||||
@@ -59,12 +61,17 @@ public class StrategyOverlapTests
|
||||
context.SharedState["BestRotation"] = classification.PrimaryAngle;
|
||||
context.SharedState["Classification"] = classification;
|
||||
context.SharedState["AngleCandidates"] = new AngleCandidateBuilder().Build(
|
||||
item, classification, context.WorkArea);
|
||||
item,
|
||||
classification,
|
||||
context.WorkArea
|
||||
);
|
||||
|
||||
var parts = strategy.Fill(context);
|
||||
var count = parts?.Count ?? 0;
|
||||
|
||||
_output.WriteLine($"\n{strategy.GetType().Name} (Phase: {strategy.Phase}, Order: {strategy.Order}): {count} parts");
|
||||
_output.WriteLine(
|
||||
$"\n{strategy.GetType().Name} (Phase: {strategy.Phase}, Order: {strategy.Order}): {count} parts"
|
||||
);
|
||||
|
||||
if (count == 0)
|
||||
continue;
|
||||
@@ -83,7 +90,9 @@ public class StrategyOverlapTests
|
||||
|
||||
if (hasOverlaps)
|
||||
{
|
||||
failures.Add($"{strategy.GetType().Name} ({strategy.Phase}): {pts.Count} collision pts, {count} parts");
|
||||
failures.Add(
|
||||
$"{strategy.GetType().Name} ({strategy.Phase}): {pts.Count} collision pts, {count} parts"
|
||||
);
|
||||
|
||||
// Show overlapping pair details
|
||||
for (var a = 0; a < parts.Count; a++)
|
||||
@@ -92,16 +101,27 @@ public class StrategyOverlapTests
|
||||
{
|
||||
var ba = parts[a].BoundingBox;
|
||||
var bb = parts[b].BoundingBox;
|
||||
var oX = System.Math.Min(ba.Right, bb.Right) - System.Math.Max(ba.Left, bb.Left);
|
||||
var oY = System.Math.Min(ba.Top, bb.Top) - System.Math.Max(ba.Bottom, bb.Bottom);
|
||||
if (oX <= OpenNest.Math.Tolerance.Epsilon || oY <= OpenNest.Math.Tolerance.Epsilon)
|
||||
var oX =
|
||||
System.Math.Min(ba.Right, bb.Right) - System.Math.Max(ba.Left, bb.Left);
|
||||
var oY =
|
||||
System.Math.Min(ba.Top, bb.Top) - System.Math.Max(ba.Bottom, bb.Bottom);
|
||||
if (
|
||||
oX <= OpenNest.Math.Tolerance.Epsilon
|
||||
|| oY <= OpenNest.Math.Tolerance.Epsilon
|
||||
)
|
||||
continue;
|
||||
|
||||
if (parts[a].Intersects(parts[b], out var pairPts) && pairPts.Count > 0)
|
||||
{
|
||||
_output.WriteLine($" [{a}] vs [{b}]: {pairPts.Count} pts, bbox overlap: {oX:F4} x {oY:F4}");
|
||||
_output.WriteLine($" [{a}]: loc=({parts[a].Location.X:F4},{parts[a].Location.Y:F4}) rot={OpenNest.Math.Angle.ToDegrees(parts[a].Rotation):F2}°");
|
||||
_output.WriteLine($" [{b}]: loc=({parts[b].Location.X:F4},{parts[b].Location.Y:F4}) rot={OpenNest.Math.Angle.ToDegrees(parts[b].Rotation):F2}°");
|
||||
_output.WriteLine(
|
||||
$" [{a}] vs [{b}]: {pairPts.Count} pts, bbox overlap: {oX:F4} x {oY:F4}"
|
||||
);
|
||||
_output.WriteLine(
|
||||
$" [{a}]: loc=({parts[a].Location.X:F4},{parts[a].Location.Y:F4}) rot={OpenNest.Math.Angle.ToDegrees(parts[a].Rotation):F2}°"
|
||||
);
|
||||
_output.WriteLine(
|
||||
$" [{b}]: loc=({parts[b].Location.X:F4},{parts[b].Location.Y:F4}) rot={OpenNest.Math.Angle.ToDegrees(parts[b].Rotation):F2}°"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,5 +134,4 @@ public class StrategyOverlapTests
|
||||
|
||||
Assert.Empty(failures);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ public class StripeFillerTests
|
||||
/// Builds a simple side-by-side pair BestFitResult for a rectangular drawing.
|
||||
/// Places two copies next to each other along the X axis with the given spacing.
|
||||
/// </summary>
|
||||
private static List<BestFitResult> MakeSideBySideBestFits(
|
||||
Drawing drawing, double spacing)
|
||||
private static List<BestFitResult> MakeSideBySideBestFits(Drawing drawing, double spacing)
|
||||
{
|
||||
var bb = drawing.Program.BoundingBox();
|
||||
var w = bb.Length;
|
||||
@@ -71,10 +70,15 @@ public class StripeFillerTests
|
||||
{
|
||||
var pattern = MakeRectPattern(20, 10);
|
||||
var angle = StripeFiller.FindAngleForTargetSpan(
|
||||
pattern.Parts, 20.0, NestDirection.Horizontal);
|
||||
pattern.Parts,
|
||||
20.0,
|
||||
NestDirection.Horizontal
|
||||
);
|
||||
|
||||
Assert.True(System.Math.Abs(angle) < 0.05,
|
||||
$"Expected angle near 0, got {OpenNest.Math.Angle.ToDegrees(angle):F1}°");
|
||||
Assert.True(
|
||||
System.Math.Abs(angle) < 0.05,
|
||||
$"Expected angle near 0, got {OpenNest.Math.Angle.ToDegrees(angle):F1}°"
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -82,12 +86,17 @@ public class StripeFillerTests
|
||||
{
|
||||
var pattern = MakeRectPattern(20, 10);
|
||||
var angle = StripeFiller.FindAngleForTargetSpan(
|
||||
pattern.Parts, 22.0, NestDirection.Horizontal);
|
||||
pattern.Parts,
|
||||
22.0,
|
||||
NestDirection.Horizontal
|
||||
);
|
||||
|
||||
var rotated = FillHelpers.BuildRotatedPattern(pattern.Parts, angle);
|
||||
var span = rotated.BoundingBox.Length;
|
||||
Assert.True(System.Math.Abs(span - 22.0) < 0.5,
|
||||
$"Expected span ~22, got {span:F2} at {OpenNest.Math.Angle.ToDegrees(angle):F1}°");
|
||||
Assert.True(
|
||||
System.Math.Abs(span - 22.0) < 0.5,
|
||||
$"Expected span ~22, got {span:F2} at {OpenNest.Math.Angle.ToDegrees(angle):F1}°"
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -95,7 +104,10 @@ public class StripeFillerTests
|
||||
{
|
||||
var pattern = MakeRectPattern(20, 10);
|
||||
var angle = StripeFiller.FindAngleForTargetSpan(
|
||||
pattern.Parts, 30.0, NestDirection.Horizontal);
|
||||
pattern.Parts,
|
||||
30.0,
|
||||
NestDirection.Horizontal
|
||||
);
|
||||
|
||||
Assert.True(angle >= 0 && angle <= System.Math.PI / 2);
|
||||
}
|
||||
@@ -105,7 +117,11 @@ public class StripeFillerTests
|
||||
{
|
||||
var pattern = MakeRectPattern(20, 10);
|
||||
var (angle, waste, count) = StripeFiller.ConvergeStripeAngle(
|
||||
pattern.Parts, 120.0, 0.5, NestDirection.Horizontal);
|
||||
pattern.Parts,
|
||||
120.0,
|
||||
0.5,
|
||||
NestDirection.Horizontal
|
||||
);
|
||||
|
||||
Assert.True(count >= 5, $"Expected at least 5 pairs, got {count}");
|
||||
Assert.True(waste < 18.0, $"Expected waste < 18, got {waste:F2}");
|
||||
@@ -117,7 +133,11 @@ public class StripeFillerTests
|
||||
// 10x5 pattern: short side (5) oriented along axis, so more pairs fit
|
||||
var pattern = MakeRectPattern(10, 5);
|
||||
var (angle, waste, count) = StripeFiller.ConvergeStripeAngle(
|
||||
pattern.Parts, 100.0, 0.0, NestDirection.Horizontal);
|
||||
pattern.Parts,
|
||||
100.0,
|
||||
0.0,
|
||||
NestDirection.Horizontal
|
||||
);
|
||||
|
||||
Assert.True(count >= 10, $"Expected at least 10 pairs, got {count}");
|
||||
Assert.True(waste < 1.0, $"Expected low waste, got {waste:F2}");
|
||||
@@ -128,7 +148,11 @@ public class StripeFillerTests
|
||||
{
|
||||
var pattern = MakeRectPattern(10, 20);
|
||||
var (angle, waste, count) = StripeFiller.ConvergeStripeAngle(
|
||||
pattern.Parts, 120.0, 0.5, NestDirection.Vertical);
|
||||
pattern.Parts,
|
||||
120.0,
|
||||
0.5,
|
||||
NestDirection.Vertical
|
||||
);
|
||||
|
||||
Assert.True(count >= 5, $"Expected at least 5 pairs, got {count}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user