mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-02 03:08:49 -04:00
DefaultPlateFiller.PackArea (Default, Strip and both Remnant strategies) now packs leftover parts with the shared maximal-rectangles packer instead of bottom-left corner points. Every fit rule and pick mode is tried; the layout placing the most parts, then box area, per priority tier wins, and the strategy's own fill comparer breaks ties so remnant strategies keep their clear side. PackBottomLeft and PackEngine are removed. Rectangle-lane benchmark (91 strict + 77 boxable jobs) against the old packer: no strategy lost a valid layout; Default, Vertical Remnant, Horizontal Remnant and Strip complete 2-3 more strict jobs, and Strip gains a valid one. Cost on jobs complete in both runs falls for every strategy (Default -0.6% strict, -2.7% boxable). Default is about 7-10% slower on the changed jobs. Golden layouts for Default and both Remnant strategies are re-captured; each is complete, passes NestLayoutCheck and repeats exactly.
64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.Engine.RectanglePacking
|
|
{
|
|
internal static class BinConverter
|
|
{
|
|
public static Bin CreateBin(Box area, double partSpacing)
|
|
{
|
|
var bin = new Bin { Location = area.Location, Size = area.Size };
|
|
|
|
bin.Width += partSpacing;
|
|
bin.Length += partSpacing;
|
|
|
|
return bin;
|
|
}
|
|
|
|
public static Item ToItem(NestItem item, double partSpacing, int id = 0)
|
|
{
|
|
var box = item.Drawing.Program.BoundingBox();
|
|
|
|
box.Width += partSpacing;
|
|
box.Length += partSpacing;
|
|
|
|
return new Item
|
|
{
|
|
Id = id,
|
|
Location = box.Location,
|
|
Size = box.Size,
|
|
};
|
|
}
|
|
|
|
public static List<Part> ToParts(Bin bin, List<NestItem> items)
|
|
{
|
|
var parts = new List<Part>();
|
|
|
|
foreach (var item in bin.Items)
|
|
{
|
|
var nestItem = items[item.Id];
|
|
var part = ToPart(item, nestItem.Drawing);
|
|
parts.Add(part);
|
|
}
|
|
|
|
return parts;
|
|
}
|
|
|
|
private static Part ToPart(Item item, Drawing dwg)
|
|
{
|
|
var part = new Part(dwg);
|
|
|
|
if (item.IsRotated)
|
|
part.Rotate(Angle.HalfPI);
|
|
|
|
var boundingBox = part.Program.BoundingBox();
|
|
var offset = item.Location - boundingBox.Location;
|
|
|
|
part.Offset(offset);
|
|
|
|
return part;
|
|
}
|
|
}
|
|
}
|