Files
OpenNest/OpenNest.Engine/RectanglePacking/FillEngine.cs
T
aj aec0523062 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.
2026-09-20 16:41:50 -04:00

52 lines
1.3 KiB
C#

using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.RectanglePacking
{
internal abstract class FillEngine
{
public FillEngine(Bin bin)
{
Bin = bin;
}
public Bin Bin { get; set; }
public abstract void Fill(Item item);
public abstract void Fill(Item item, int maxCount);
protected List<Item> FillGrid(
Item item,
int rows,
int columns,
int maxCount,
bool columnMajor = true
)
{
var items = new List<Item>();
var outerCount = columnMajor ? columns : rows;
var innerCount = columnMajor ? rows : columns;
for (var i = 0; i < outerCount; i++)
{
for (var j = 0; j < innerCount; j++)
{
var x = (columnMajor ? i : j) * item.Length + item.X;
var y = (columnMajor ? j : i) * item.Width + item.Y;
var clone = item.Clone() as Item;
clone.Location = new Vector(x, y);
items.Add(clone);
if (items.Count == maxCount)
return items;
}
}
return items;
}
}
}