Every nesting-geometry consumer filtered only rapids, so scribe/etch moves counted as part material. An etch tick that ends a hair outside the outline (PEP bend ticks start on the notch edge) made the part "open geometry leaving the material region": the job validator threw and every built-in engine plus Gpt6Astra crashed on real PEP jobs (PT75, drawing 4980 A01 PT77). Marks are only on the surface, so they should never affect placement, collision, area, or validation. - SpecialLayers.IsMaterial excludes Rapid and Scribe; used by drawing area, canonical angle, part collision, PartGeometry, plate perimeter, best-fit/pair evaluation, rotation analysis, GPU evaluators, and both validators. Timing, display, splitting and posts still see marks. - ConvertGeometry also maps the saved SCRIBE layer name to Scribe, so programs rebuilt from stored entities keep their marks. - NestReader repairs older files (e.g. PepNestExport output) whose programs saved etch as cut moves while source entities kept SCRIBE. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
2.3 KiB
C#
86 lines
2.3 KiB
C#
using System.Linq;
|
|
using OpenNest.CNC;
|
|
using OpenNest.Converters;
|
|
using OpenNest.Geometry;
|
|
|
|
namespace OpenNest.Tests.Converters;
|
|
|
|
public class ConvertGeometryLayerTests
|
|
{
|
|
private static Program ProgramFor(Entity entity)
|
|
{
|
|
var shape = new Shape();
|
|
shape.Entities.Add(entity);
|
|
return ConvertGeometry.ToProgram(shape);
|
|
}
|
|
|
|
[Fact]
|
|
public void AddLine_EngraveLayer_TagsScribe()
|
|
{
|
|
var line = new Line(0, 0, 1, 0) { Layer = new Layer("ENGRAVE") };
|
|
|
|
var pgm = ProgramFor(line);
|
|
|
|
Assert.All(pgm.Codes.OfType<LinearMove>(), m => Assert.Equal(LayerType.Scribe, m.Layer));
|
|
}
|
|
|
|
[Fact]
|
|
public void AddLine_EtchLayer_TagsScribe()
|
|
{
|
|
var line = new Line(0, 0, 1, 0) { Layer = new Layer("etch") };
|
|
|
|
var pgm = ProgramFor(line);
|
|
|
|
Assert.All(pgm.Codes.OfType<LinearMove>(), m => Assert.Equal(LayerType.Scribe, m.Layer));
|
|
}
|
|
|
|
[Fact]
|
|
public void AddLine_SavedScribeLayer_TagsScribe()
|
|
{
|
|
// Marks are stored on the SCRIBE layer; rebuilding a program from stored entities
|
|
// must keep them marks rather than turning them into cut moves.
|
|
var line = new Line(0, 0, 1, 0) { Layer = SpecialLayers.Scribe };
|
|
|
|
var pgm = ProgramFor(line);
|
|
|
|
Assert.All(pgm.Codes.OfType<LinearMove>(), m => Assert.Equal(LayerType.Scribe, m.Layer));
|
|
}
|
|
|
|
[Fact]
|
|
public void AddArc_EngraveLayer_TagsScribe()
|
|
{
|
|
var arc = new Arc(new Vector(0, 0), 1, 0, System.Math.PI / 2)
|
|
{
|
|
Layer = new Layer("ENGRAVE"),
|
|
};
|
|
|
|
var pgm = ProgramFor(arc);
|
|
|
|
var arcs = pgm.Codes.OfType<ArcMove>().ToList();
|
|
Assert.NotEmpty(arcs);
|
|
Assert.All(arcs, m => Assert.Equal(LayerType.Scribe, m.Layer));
|
|
}
|
|
|
|
[Fact]
|
|
public void AddCircle_EngraveLayer_TagsScribe()
|
|
{
|
|
var circle = new Circle(0, 0, 1) { Layer = new Layer("ENGRAVE") };
|
|
|
|
var pgm = ProgramFor(circle);
|
|
|
|
var arcs = pgm.Codes.OfType<ArcMove>().ToList();
|
|
Assert.NotEmpty(arcs);
|
|
Assert.All(arcs, m => Assert.Equal(LayerType.Scribe, m.Layer));
|
|
}
|
|
|
|
[Fact]
|
|
public void AddLine_DefaultLayer_StaysCut()
|
|
{
|
|
var line = new Line(0, 0, 1, 0) { Layer = new Layer("0") };
|
|
|
|
var pgm = ProgramFor(line);
|
|
|
|
Assert.All(pgm.Codes.OfType<LinearMove>(), m => Assert.Equal(LayerType.Cut, m.Layer));
|
|
}
|
|
}
|