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:
aj
2026-09-20 16:41:50 -04:00
parent 8e6fa677fb
commit aec0523062
476 changed files with 16592 additions and 7800 deletions
+50 -30
View File
@@ -1,13 +1,17 @@
using OpenNest.Geometry;
using OpenNest.RectanglePacking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using OpenNest.Geometry;
using OpenNest.RectanglePacking;
namespace OpenNest.Engine.Fill
{
public enum ShrinkAxis { Width, Length }
public enum ShrinkAxis
{
Width,
Length,
}
public class ShrinkResult
{
@@ -23,14 +27,16 @@ namespace OpenNest.Engine.Fill
{
public static ShrinkResult Shrink(
Func<NestItem, Box, List<Part>> fillFunc,
NestItem item, Box box,
NestItem item,
Box box,
double spacing,
ShrinkAxis axis,
CancellationToken token = default,
int targetCount = 0,
IProgress<NestProgress> progress = null,
int plateNumber = 0,
List<Part> placedParts = null)
List<Part> placedParts = null
)
{
var startBox = box;
if (targetCount > 0)
@@ -38,8 +44,7 @@ namespace OpenNest.Engine.Fill
var parts = fillFunc(item, startBox);
if (targetCount > 0 && startBox != box
&& (parts == null || parts.Count < targetCount))
if (targetCount > 0 && startBox != box && (parts == null || parts.Count < targetCount))
{
parts = fillFunc(item, box);
}
@@ -47,9 +52,8 @@ namespace OpenNest.Engine.Fill
if (parts == null || parts.Count == 0)
return new ShrinkResult { Parts = parts ?? new List<Part>(), Dimension = 0 };
var shrinkTarget = targetCount > 0
? System.Math.Min(targetCount, parts.Count)
: parts.Count;
var shrinkTarget =
targetCount > 0 ? System.Math.Min(targetCount, parts.Count) : parts.Count;
if (parts.Count > shrinkTarget)
parts = TrimToCount(parts, shrinkTarget, axis);
@@ -62,16 +66,22 @@ namespace OpenNest.Engine.Fill
}
private static void ReportShrinkProgress(
IProgress<NestProgress> progress, int plateNumber,
List<Part> placedParts, List<Part> bestParts,
Box workArea, ShrinkAxis axis, double dim)
IProgress<NestProgress> progress,
int plateNumber,
List<Part> placedParts,
List<Part> bestParts,
Box workArea,
ShrinkAxis axis,
double dim
)
{
if (progress == null)
return;
var allParts = placedParts != null && placedParts.Count > 0
? new List<Part>(placedParts.Count + bestParts.Count)
: new List<Part>(bestParts.Count);
var allParts =
placedParts != null && placedParts.Count > 0
? new List<Part>(placedParts.Count + bestParts.Count)
: new List<Part>(bestParts.Count);
if (placedParts != null && placedParts.Count > 0)
allParts.AddRange(placedParts);
@@ -79,14 +89,17 @@ namespace OpenNest.Engine.Fill
var desc = $"Shrink {axis}: {bestParts.Count} parts, dim={dim:F1}";
NestEngineBase.ReportProgress(progress, new ProgressReport
{
Phase = NestPhase.Custom,
PlateNumber = plateNumber,
Parts = allParts,
WorkArea = workArea,
Description = desc,
});
NestEngineBase.ReportProgress(
progress,
new ProgressReport
{
Phase = NestPhase.Custom,
PlateNumber = plateNumber,
Parts = allParts,
WorkArea = workArea,
Description = desc,
}
);
}
/// <summary>
@@ -94,8 +107,14 @@ namespace OpenNest.Engine.Fill
/// that fits roughly the target count. Scales the shrink axis proportionally
/// from the full-area count down to the target, with margin.
/// </summary>
internal static Box EstimateStartBox(NestItem item, Box box,
double spacing, ShrinkAxis axis, int targetCount, double marginFactor = 1.3)
internal static Box EstimateStartBox(
NestItem item,
Box box,
double spacing,
ShrinkAxis axis,
int targetCount,
double marginFactor = 1.3
)
{
var bbox = item.Drawing.Program.BoundingBox();
if (bbox.Width <= 0 || bbox.Length <= 0)
@@ -105,7 +124,10 @@ namespace OpenNest.Engine.Fill
// Use FillBestFit for a fast, accurate rectangle count on the full box.
var bin = new Bin { Size = new Size(box.Width, box.Length) };
var packItem = new Item { Size = new Size(bbox.Width + spacing, bbox.Length + spacing) };
var packItem = new Item
{
Size = new Size(bbox.Width + spacing, bbox.Length + spacing),
};
var packer = new FillBestFit(bin);
packer.Fill(packItem);
var fullCount = bin.Items.Count;
@@ -130,9 +152,7 @@ namespace OpenNest.Engine.Fill
{
var placedBox = parts.Cast<IBoundable>().GetBoundingBox();
return axis == ShrinkAxis.Width
? placedBox.Right - box.X
: placedBox.Top - box.Y;
return axis == ShrinkAxis.Width ? placedBox.Right - box.X : placedBox.Top - box.Y;
}
/// <summary>