mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-14 01:05:07 -05:00
Fill paired a 9" angle bracket at 90/270 degrees (75 on a 48 x 96 plate) while a hand-laid herringbone at 315/135 holds 84. Its pair touches only at the legs' ends, so it ranked ~888th by pair box area, and pairs are tiled at the pair's own hull angles, never the part's 45-degree edge. The pairs phase now also builds herringbone pairs: the part turned so a hull edge lies along a sheet axis, its 180-degree copy slid onto the row the part makes along that axis, tiled and remnant-filled like best-fit pairs. Fill now finds the 84. The chevron in the learned-angle fixture became a herringbone whatever angles were learned, so a cross replaces it; the learned-angle and Strip mixed nests are re-pinned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using OpenNest.CNC;
|
|
using OpenNest.Engine.Fill;
|
|
using OpenNest.Engine.Jobs;
|
|
using OpenNest.Engine.Jobs.Placement;
|
|
using OpenNest.Geometry;
|
|
using OpenNest.Math;
|
|
|
|
namespace OpenNest.Engine.Tests.Fill;
|
|
|
|
/// <summary>
|
|
/// A reported nest: a 9" angle bracket with 2.5" legs on a 48 x 96 plate. Fill paired brackets
|
|
/// at 90°/270° (75); laid by hand at 315°/135°, each row nests its brackets corner into corner
|
|
/// along the sheet and the reversed row interlocks with it, a herringbone of 84.
|
|
/// </summary>
|
|
public class HerringboneFillTests
|
|
{
|
|
/// <summary>The reported drawing's program, in absolute coordinates.</summary>
|
|
private static Drawing AngleBracket()
|
|
{
|
|
var program = new Program();
|
|
foreach (var (x, y) in new[] { (0.0, 0.0), (-6.25, 3.75), (-6.25, 6.25), (-2.5, 0.0) })
|
|
{
|
|
program.MoveTo(x, y);
|
|
program.ArcTo(new Vector(x, y), new Vector(x - 0.28125, y), RotationType.CCW);
|
|
}
|
|
|
|
program.MoveTo(-7.78125, -1.25);
|
|
program.LineTo(-7.78125, 7.75);
|
|
program.LineTo(-5.28125, 7.75);
|
|
program.LineTo(-5.28125, 2.25);
|
|
program.ArcTo(new Vector(-4.28125, 1.25), new Vector(-4.28125, 2.25), RotationType.CCW);
|
|
program.LineTo(1.21875, 1.25);
|
|
program.LineTo(1.21875, -1.25);
|
|
program.LineTo(-7.78125, -1.25);
|
|
return new Drawing("Angle Bracket", program);
|
|
}
|
|
|
|
[Fact]
|
|
public void FillFindsTheHerringboneOfAngleBrackets()
|
|
{
|
|
var plate = new Plate(new Size(48, 96))
|
|
{
|
|
PartSpacing = 0.25,
|
|
EdgeSpacing = new Spacing(0.5, 0.25, 0.5, 0.25),
|
|
};
|
|
var drawing = AngleBracket();
|
|
|
|
var parts = PlateFillService.FillItem("Fill", plate,
|
|
new NestItem { Drawing = drawing, Quantity = 0 }, plate.WorkArea(), null,
|
|
CancellationToken.None);
|
|
|
|
Assert.Equal(84, parts.Count);
|
|
Assert.Empty(NestLayoutCheck.Validate(new() { (plate, parts) },
|
|
new Dictionary<Drawing, (string, int)> { [drawing] = ("Angle Bracket", 84) }));
|
|
}
|
|
|
|
[Fact]
|
|
public void RotationsLayEachHullEdgeAlongTheSheetInEveryQuarterTurn()
|
|
{
|
|
var degrees = HerringbonePatterns.Rotations(AngleBracket())
|
|
.Select(r => System.Math.Round(Angle.ToDegrees(r)))
|
|
.OrderBy(d => d)
|
|
.ToList();
|
|
|
|
Assert.Equal(new[] { 0.0, 45, 90, 135, 180, 225, 270, 315 }, degrees);
|
|
}
|
|
}
|