fix: correct Width/Length axis mapping and add spiral center-fill

Box constructor and derived properties (Right, Top, Center, Translate, Offset)
had Width and Length swapped — Length is X axis, Width is Y axis. Corrected
across Core geometry, plate bounding box, rectangle packing, fill algorithms,
tests, and UI renderers.

Added FillSpiral with center remnant detection and recursive FillBest on
the gap between the 4 spiral quadrants. RectFill.FillBest now compares
spiral+center vs full best-fit fairly. BestCombination returns a
CombinationResult record instead of out params.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 21:22:55 -04:00
parent e50a7c82cf
commit c5943e22eb
55 changed files with 433 additions and 257 deletions

View File

@@ -14,16 +14,16 @@ namespace OpenNest.RectanglePacking
public override void Fill(Item item)
{
var ycount = (int)System.Math.Floor((Bin.Length + Tolerance.Epsilon) / item.Length);
var xcount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
var ycount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
var xcount = (int)System.Math.Floor((Bin.Length + Tolerance.Epsilon) / item.Length);
for (int i = 0; i < xcount; i++)
{
var x = item.Width * i + Bin.X;
var x = item.Length * i + Bin.X;
for (int j = 0; j < ycount; j++)
{
var y = item.Length * j + Bin.Y;
var y = item.Width * j + Bin.Y;
var addedItem = item.Clone() as Item;
addedItem.Location = new Vector(x, y);
@@ -35,8 +35,8 @@ namespace OpenNest.RectanglePacking
public override void Fill(Item item, int maxCount)
{
var ycount = (int)System.Math.Floor((Bin.Length + Tolerance.Epsilon) / item.Length);
var xcount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
var ycount = (int)System.Math.Floor((Bin.Width + Tolerance.Epsilon) / item.Width);
var xcount = (int)System.Math.Floor((Bin.Length + Tolerance.Epsilon) / item.Length);
var count = ycount * xcount;
if (count <= maxCount)