Files
OpenNest/OpenNest.Tests/Bending/SolidWorksBendDetectorTests.cs
AJ Isaacs 98e90cc176 fix: preserve bend lines through drawing split — clip, offset, and carry metadata
DrawingSplitter now clips bend lines to each piece's region using
Liang-Barsky line clipping and offsets them to the new origin. Bend
properties (direction, angle, radius, note text) are preserved through
the entire split pipeline instead of being lost during re-import.

CadConverterForm applies the same origin offset to bends before passing
them to the splitter, and creates FileListItems directly from split
results to avoid re-detection overwriting the bend metadata.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 09:24:41 -04:00

55 lines
1.5 KiB
C#

using ACadSharp.IO;
using OpenNest.Bending;
using OpenNest.IO.Bending;
namespace OpenNest.Tests.Bending;
public class SolidWorksBendDetectorTests
{
[Fact]
public void SolidWorksDetector_IsRegistered()
{
var detector = BendDetectorRegistry.GetByName("SolidWorks");
Assert.NotNull(detector);
Assert.Equal("SolidWorks", detector.Name);
}
[Fact]
public void Registry_ContainsSolidWorksDetector()
{
Assert.Contains(BendDetectorRegistry.Detectors,
d => d.Name == "SolidWorks");
}
[Fact]
public void AutoDetect_EmptyDocument_ReturnsEmptyList()
{
var doc = new ACadSharp.CadDocument();
var bends = BendDetectorRegistry.AutoDetect(doc);
Assert.Empty(bends);
}
[Fact]
public void DetectBends_RealDxf_ParsesNotesCorrectly()
{
var path = Path.Combine(AppContext.BaseDirectory, "Bending", "TestData", "4526 A14 PT45.dxf");
Assert.True(File.Exists(path), $"Test DXF not found: {path}");
using var reader = new DxfReader(path);
var doc = reader.Read();
var detector = new SolidWorksBendDetector();
var bends = detector.DetectBends(doc);
Assert.Equal(2, bends.Count);
foreach (var bend in bends)
{
Assert.NotNull(bend.NoteText);
Assert.Equal(BendDirection.Up, bend.Direction);
Assert.Equal(90.0, bend.Angle);
Assert.Equal(0.313, bend.Radius);
}
}
}