feat: add MultiPlateNester with sorting logic

Implements static MultiPlateNester.SortItems with BoundingBoxArea and Size sort orders, covered by two passing xUnit tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 13:48:57 -04:00
parent ebad3577dd
commit 89a4e6b981
2 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
namespace OpenNest
{
public static class MultiPlateNester
{
public static List<NestItem> SortItems(List<NestItem> items, PartSortOrder sortOrder)
{
switch (sortOrder)
{
case PartSortOrder.BoundingBoxArea:
return items
.OrderByDescending(i =>
{
var bb = i.Drawing.Program.BoundingBox();
return bb.Width * bb.Length;
})
.ToList();
case PartSortOrder.Size:
return items
.OrderByDescending(i =>
{
var bb = i.Drawing.Program.BoundingBox();
return System.Math.Max(bb.Width, bb.Length);
})
.ToList();
default:
return items.ToList();
}
}
}
}