mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-15 13:35:34 -05:00
feat(nesting): nest higher priority numbers first
Priority worked like a rank (lower first) with a default of 0, and the Edit Drawing form stopped at 0, so moving one part ahead of the rest meant renumbering every other drawing. Higher-first lets a user raise a single part to 1 and leave everything else at the default. Every engine, filler and candidate comparer now serves the highest tier first. Stored values keep their order: - .nest files add `nestPriority` and keep writing the negated value under `priority`, so older readers nest in the same order; files without `nestPriority` are negated on read. Drawing packages strip both, so package hashes are unchanged. - Library settings send both keys the same way for older clients. - Server schema v18 negates stored drawing priorities (an older server refuses the upgraded database). - Job documents move to version 2; version 1 jobs are converted, and an older worker refuses version 2 instead of reversing the order. The Edit Drawing form now accepts negative priorities and says higher numbers nest first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2721375e8b
commit
fbc23d6b64
51 files changed
+364
-79
No files matched your search
@@ -16,7 +16,7 @@ internal enum PickMode
|
||||
}
|
||||
|
||||
/// <summary>A box type to pack.</summary>
|
||||
/// <param name="Priority">Demand tier; lower numbers are served first.</param>
|
||||
/// <param name="Priority">Demand tier; higher numbers are served first.</param>
|
||||
/// <param name="Sizes">Allowed packing sizes (one per orientation), already grown by any spacing.</param>
|
||||
/// <param name="Area">Ranking area: larger boxes win score ties and go first in ordered mode.</param>
|
||||
internal sealed record PackType(int Priority, IReadOnlyList<(double Width, double Height)> Sizes, double Area);
|
||||
@@ -25,9 +25,9 @@ internal sealed record PackType(int Priority, IReadOnlyList<(double Width, doubl
|
||||
internal readonly record struct PackPlacement(int Type, int Size, double X, double Y);
|
||||
|
||||
/// <summary>
|
||||
/// Packs box types onto one <see cref="MaxRectsSheet"/> under a fit rule and pick mode. Lower
|
||||
/// priority numbers are always served first: a higher-number type is only placed when no
|
||||
/// lower-number type still fits anywhere. Deterministic: ties resolve by input order.
|
||||
/// Packs box types onto one <see cref="MaxRectsSheet"/> under a fit rule and pick mode. Higher
|
||||
/// priority numbers are always served first: a lower-number type is only placed when no
|
||||
/// higher-number type still fits anywhere. Deterministic: ties resolve by input order.
|
||||
/// </summary>
|
||||
internal static class MaxRectsPacker
|
||||
{
|
||||
@@ -60,7 +60,7 @@ internal static class MaxRectsPacker
|
||||
{
|
||||
// Free space only shrinks, so a size that fails once never fits again on this sheet.
|
||||
var dead = types.Select(t => new bool[t.Sizes.Count]).ToArray();
|
||||
var tiers = types.Select(t => t.Priority).Distinct().Order().ToArray();
|
||||
var tiers = types.Select(t => t.Priority).Distinct().OrderDescending().ToArray();
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ internal static class MaxRectsPacker
|
||||
var order = Enumerable
|
||||
.Range(0, types.Count)
|
||||
.Where(t => types[t].Sizes.Count > 0)
|
||||
.OrderBy(t => types[t].Priority)
|
||||
.OrderByDescending(t => types[t].Priority)
|
||||
.ThenByDescending(t => types[t].Area)
|
||||
.ThenBy(t => t);
|
||||
|
||||
|
||||
Reference in new issue
Block a user