mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-22 11:07:41 -05:00
FrontierPacker.Fill was one 165-line method: three local functions (Track, Block, PrepareBlocks) closed over nine variables of the fill in progress, the seated-parts pass repeated Block's parallel loop inline, and the placement loop carried its retirement rules between them. Choose kept its leader in seven loose variables behind a local function, and BestVertex took twelve parameters, four of them outs that every TryLowest threaded back out. Every pass of the engine goes through this class, so the next change to the placement rule had to be made inside all of that. Fill now reads as its steps: TrackDemand, Seat, PrepareBlocks, then Choose and Place until nothing fits. The fill in progress is a Sheet (copies left, regions, pairs, blocks, parts placed, front) passed to each step, the leader of a choice is a Leader that Consider updates, and a candidate's point and scores travel as one Spot, with the inner-fit box and the piece's box as Extents. The repeated expressions have one definition each: the part's reach along the front axis, a region losing what a part blocks, the parallel blocking pass, the two retirements of emptied regions and pairs, and the "lower across, then lower leading edge" tie-break shared by Choose and BestVertex. The tolerances and the block limits (two preparations per fill, four types, three copies) are named constants. PackAxis, Placed and SheetFill, which the whole engine uses, have their own files. The constructor keeps its shape: most call sites name its optional arguments already. The two that passed positional nulls now name them. No layout changes, and no change to the order work is metered or to the parallel passes: a placement still blocks one pass per part. Traced before and after: every progress report, plan, alternative, repeat batch, tail re-plan (with its work-meter reading) and final result of 70 solves (one to three stocks, mixed spacings, finite stock, a sheet cap, priorities, explicit costs with salvage and both offcut axes, clamp rails, outlined sheets, oversize parts, all four quadrants, grouped and banded jobs, four engine settings, seven searches until cancelled), the poses and work-meter reading of 2,298 direct Fill calls (pairs, blocks, type weights, group ranks, reach, within, seated parts, a starting front, clamps, outline and cutout boundaries with obstacles, pair-only orientations), and six cutout proposals. The traces are byte-identical. Engine suite and the problem-nest corpus's auto-nest area pass. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
18 lines
712 B
C#
18 lines
712 B
C#
#nullable enable
|
|
using System.Collections.Generic;
|
|
using OpenNest.Engine.Jobs;
|
|
|
|
namespace OpenNest.Engine.NestingEngines.Irregular;
|
|
|
|
/// <summary>A part on a sheet: its orientation with the reference point at (X, Y).</summary>
|
|
internal sealed record Placed(Orientation Orientation, double X, double Y)
|
|
{
|
|
public double Left => X + Orientation.MinX;
|
|
public double Right => X + Orientation.MaxX;
|
|
public double Bottom => Y + Orientation.MinY;
|
|
public double Top => Y + Orientation.MaxY;
|
|
}
|
|
|
|
/// <summary>One sheet of a stock with the parts packed on it, in placement order, and their area.</summary>
|
|
internal sealed record SheetFill(NestPlateStock Stock, IReadOnlyList<Placed> Parts, double PartArea);
|