mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-22 12:17:43 -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>
74 lines
3.1 KiB
C#
74 lines
3.1 KiB
C#
using OpenNest.CNC;
|
|
using OpenNest.Engine.BestFit;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Engine.Jobs.Placement;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Engine.Tests.Fill;
|
|
|
|
/// <summary>
|
|
/// A reported nest: 30 x 7.5 J-shaped bars (a 3.6" bar with a 2" leg at one end) on a 48 x 96
|
|
/// plate. Pairs stack bar on bar with each leg tucked just past the other bar's end. Best fit
|
|
/// sampled the pair's offset along the bars a quarter inch apart and landed 0.2" short of the
|
|
/// leg's contact, so two columns of pairs left a 29.8" strip, too short for a 30" bar: Fill
|
|
/// placed 30. With the pair settled against both contacts the strip is 30.2" and holds nine
|
|
/// more, as laid out by hand (33): three pairs stood on end, one more bar dropped 2.3" beside
|
|
/// them so its leg passes under its neighbor's, and a pair lying under all seven.
|
|
/// </summary>
|
|
public class JBarFillTests
|
|
{
|
|
private static Plate JBarPlate() =>
|
|
new(new Size(48, 96))
|
|
{
|
|
PartSpacing = 0.3,
|
|
EdgeSpacing = new Spacing(0.3, 0.75, 0.3, 0.25),
|
|
};
|
|
|
|
/// <summary>The reported drawing's outline, in absolute coordinates.</summary>
|
|
private static Drawing JBar()
|
|
{
|
|
var program = new Program();
|
|
program.MoveTo(-2.21875, -2.5126780932);
|
|
program.LineTo(-2.21875, 0.625);
|
|
program.ArcTo(new Vector(-1.96875, 0.875), new Vector(-1.96875, 0.625), RotationType.CW);
|
|
program.LineTo(27.53125, 0.875);
|
|
program.ArcTo(new Vector(27.78125, 0.625), new Vector(27.53125, 0.625), RotationType.CW);
|
|
program.LineTo(27.78125, -5.625);
|
|
program.ArcTo(new Vector(25.78125, -5.625), new Vector(26.78125, -5.625), RotationType.CW);
|
|
program.LineTo(25.78125, -0.875);
|
|
program.LineTo(25.71875, -0.875);
|
|
program.LineTo(25.71875, -2.5126780932);
|
|
program.ArcTo(new Vector(25.46875, -2.7626780932), new Vector(25.46875, -2.5126780932), RotationType.CW);
|
|
program.LineTo(-1.96875, -2.7626780932);
|
|
program.ArcTo(new Vector(-2.21875, -2.5126780932), new Vector(-1.96875, -2.5126780932), RotationType.CW);
|
|
return new Drawing("J-Bar", program);
|
|
}
|
|
|
|
[Fact]
|
|
public void BestFitSettlesThePairAgainstBothContacts()
|
|
{
|
|
var fits = new BestFitFinder(48, 96).FindBestFits(JBar(), spacing: 0.3);
|
|
|
|
// Leg 2" + spacing 0.3" past a 30" bar: 32.3" end to end, not 32.5".
|
|
var tightest = fits
|
|
.Where(f => f.Keep && System.Math.Min(f.BoundingWidth, f.BoundingHeight) < 8)
|
|
.Min(f => System.Math.Max(f.BoundingWidth, f.BoundingHeight));
|
|
Assert.Equal(32.3, tightest, 4);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillLeavesAStripThatHoldsNineMore()
|
|
{
|
|
var plate = JBarPlate();
|
|
var drawing = JBar();
|
|
|
|
var parts = PlateFillService.FillItem("Fill", plate,
|
|
new NestItem { Drawing = drawing, Quantity = 0 }, plate.WorkArea(), null,
|
|
CancellationToken.None);
|
|
|
|
Assert.Equal(33, parts.Count);
|
|
Assert.Empty(NestLayoutCheck.Validate(new() { (plate, parts) },
|
|
new Dictionary<Drawing, (string, int)> { [drawing] = ("J-Bar", 33) }));
|
|
}
|
|
}
|