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:
35
OpenNest.Engine/MultiPlateNester.cs
Normal file
35
OpenNest.Engine/MultiPlateNester.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user