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>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using ACadSharp.IO;
|
||||
using OpenNest.Bending;
|
||||
using OpenNest.IO.Bending;
|
||||
|
||||
@@ -27,4 +28,27 @@ public class SolidWorksBendDetectorTests
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,4 +28,10 @@
|
||||
<ProjectReference Include="..\OpenNest.Posts.Cincinnati\OpenNest.Posts.Cincinnati.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Bending\TestData\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user