mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-22 23:47:40 -05:00
Fill placed 30 J-shaped bars (30 x 7.5, 0.3 spacing) on a 48 x 96 sheet where
33 fit by hand. With pairs settled tight (07f30c12), two columns leave a 30.2"
strip, but the grid topped its last column up with single halves of pairs
and took that strip. The work that reached 33 was done on 2026-11-09 and left
uncommitted; this ports it onto master.
- PairFiller also tiles each pair grid with whole pairs only (FillLinear
PartialCopies = false), after the others, and refills the strip it leaves;
that grid wins only by placing more parts. Only fills without a quantity
try it: in Auto Nest's capped fills it ended N26-2ER's sheet at 103.83
instead of 103.08. The cutout lattice turns it off, since it crops its fill.
- GridEndInserter completes a strip's densest pair grid: it moves the grid
to each corner, slides copies of its parts in from the open sides and fills
the strip beyond. The J-bar strip takes three pairs stood on end, one more
bar beside them and a pair underneath: 33 parts, as laid out by hand.
Corpus: the J-bar fill places 33 (baseline 30), N26-29X keeps 136, and
every auto-nest nest keeps its saved layout.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.4 KiB
C#
49 lines
2.4 KiB
C#
#nullable enable
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using OpenNest.Engine.BestFit;
|
|
using OpenNest.Engine.Jobs.Adapters;
|
|
using OpenNest.Engine.Jobs.Placement.Fillers;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Engine.Jobs.Placement;
|
|
|
|
/// <summary>
|
|
/// Runs the Fill strategy for one private drawing on a private plate, for callers that turn the
|
|
/// result into job poses. The caller owns the drawing and must call
|
|
/// <see cref="BestFitCache.Invalidate"/> for it when finished.
|
|
/// </summary>
|
|
internal static class PrivatePlateFill
|
|
{
|
|
/// <param name="length">X extent of the plate and work area.</param>
|
|
/// <param name="width">Y extent of the plate and work area.</param>
|
|
/// <param name="quantity">Copies wanted; zero fills the whole area.</param>
|
|
/// <param name="wholePairGrids">See <see cref="PlateFiller.WholePairGrids"/>.</param>
|
|
internal static List<Part> Run(Drawing drawing, RotationPolicy rotation, double spacing,
|
|
double length, double width, int quantity, CancellationToken token, bool wholePairGrids = true)
|
|
{
|
|
var plate = new Plate(new Size(width, length)) { PartSpacing = spacing };
|
|
// The drawing is private: stabilize this cache entry before Fill's candidate pruning.
|
|
// Cancelling stops the wait; the search finishes in the background and fills the cache.
|
|
var fits = BestFitCache.GetOrCompute(drawing, plate.Size.Length, plate.Size.Width, spacing,
|
|
token);
|
|
var sorted = fits.OrderBy(f => f.RotatedArea).ThenBy(f => f.Candidate.StrategyIndex)
|
|
.ThenBy(f => f.Candidate.Part2Rotation).ThenBy(f => f.Candidate.Part2Offset.X)
|
|
.ThenBy(f => f.Candidate.Part2Offset.Y).ThenBy(f => f.OptimalRotation).ToArray();
|
|
fits.Clear();
|
|
fits.AddRange(sorted);
|
|
// A positive quantity lets supporting strategies avoid surplus rows. Zero still
|
|
// fills the whole area (the cutout lattice caller requires an uncapped lattice).
|
|
var filler = new PlateFiller(plate) { StopAtQuantity = true, WholePairGrids = wholePairGrids };
|
|
return filler.Fill(new NestItem
|
|
{
|
|
Drawing = drawing,
|
|
Quantity = quantity,
|
|
RotationStart = rotation.Start,
|
|
RotationEnd = rotation.End,
|
|
StepAngle = DrawingJobMapper.LegacyStep(rotation),
|
|
}, new Box(0, 0, length, width), null!, token);
|
|
}
|
|
}
|