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>
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|
|
}
|