mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-27 07:11:06 -04:00
Library drawings travel as a single-drawing, zero-plate .nest archive so the server stores opaque bytes and the client reuses NestWriter/NestReader. A characterization test first proves that shape round-trips the program, hole programs, source entities and suppression, offset, material, bends and units. Packages are canonical: fixed archive and nest timestamps, zero nest quantity and no best-fit caches. The same drawing content therefore has the same bytes and SHA-256, which later revision checks rely on to tell geometry changes from detail-only edits. Read checks the archive's own declaration before the lenient nest reader, which would otherwise default unknown units and drop empty plates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using OpenNest.Bending;
|
|
using OpenNest.Converters;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.IO.Tests;
|
|
|
|
/// <summary>
|
|
/// A code-built, neutrally named library drawing: a rounded outside, a hole, a scribe
|
|
/// mark, a bend, source entities with one suppressed, and a nonzero source offset.
|
|
/// </summary>
|
|
internal static class DrawingPackageFixture
|
|
{
|
|
public static Drawing Build()
|
|
{
|
|
var entities = new List<Entity>
|
|
{
|
|
new Line(0, 0, 10, 0),
|
|
new Line(10, 0, 10, 4),
|
|
new Arc(8, 4, 2, 0, System.Math.PI / 2),
|
|
new Line(8, 6, 0, 6),
|
|
new Line(0, 6, 0, 0),
|
|
new Circle(3, 3, 1),
|
|
new Line(5, 2, 7, 2) { Layer = SpecialLayers.Scribe },
|
|
new Line(20, 20, 21, 21),
|
|
};
|
|
var drawing = new Drawing("Synthetic bracket", ConvertGeometry.ToProgram(entities.Take(7).ToList()))
|
|
{
|
|
Customer = "Synthetic customer",
|
|
Material = new Material("Synthetic Steel") { Grade = "Grade A", Density = 0.284 },
|
|
Priority = 3,
|
|
SourceEntities = entities,
|
|
};
|
|
drawing.SuppressedEntityIds.Add(entities[7].Id);
|
|
drawing.Source.Path = "synthetic.dxf";
|
|
drawing.Source.Offset = new Vector(3.5, -2.25);
|
|
drawing.Bends.Add(new Bend
|
|
{
|
|
StartPoint = new Vector(0, 3),
|
|
EndPoint = new Vector(10, 3),
|
|
Direction = BendDirection.Up,
|
|
Angle = 90,
|
|
Radius = 0.125,
|
|
NoteText = "UP 90",
|
|
});
|
|
drawing.Quantity.Required = 12;
|
|
return drawing;
|
|
}
|
|
}
|