Files
OpenNest/OpenNest.Engine/RectanglePacking/FillEngine.cs
T
aj 451841401a refactor(engine): align namespaces with directory layout under OpenNest.Engine
All 132 OpenNest.Engine source files now declare namespaces matching
their nested directories: Jobs/, Jobs/Placement/, Jobs/Adapters/,
Fill/, RectanglePacking/, CirclePacking/, and engine-root types moved
from 'OpenNest' to 'OpenNest.Engine'. RootNamespace updated accordingly.
Consumers (Api, Console, Mcp, Benchmark, Training, desktop app, tests)
gained the explicit usings the move requires; CLAUDE.md updated.
2026-09-21 13:18:34 -04:00

52 lines
1.3 KiB
C#

using System.Collections.Generic;
using OpenNest.Geometry;
namespace OpenNest.Engine.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;
}
}
}