fix(io): remove zero-sweep arcs during DXF import
DXF files can contain degenerate arcs where start angle equals end angle (zero sweep), often left as construction artifacts by CAD software. These create spurious shapes in ShapeBuilder — e.g. SULLYS-033.dxf showed 5 loops instead of 4 (3 cutouts + perimeter). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,6 +27,7 @@ namespace OpenNest.IO
|
||||
var dxf = Dxf.Import(path);
|
||||
|
||||
RemoveDuplicateArcs(dxf.Entities);
|
||||
RemoveZeroSweepArcs(dxf.Entities);
|
||||
|
||||
var bends = new List<Bend>();
|
||||
if (options.DetectBends && dxf.Document != null)
|
||||
@@ -156,6 +157,12 @@ namespace OpenNest.IO
|
||||
return drawing;
|
||||
}
|
||||
|
||||
internal static void RemoveZeroSweepArcs(List<Entity> entities)
|
||||
{
|
||||
entities.RemoveAll(e =>
|
||||
e is Arc arc && arc.StartAngle.IsEqualTo(arc.EndAngle, Tolerance.ChainTolerance));
|
||||
}
|
||||
|
||||
internal static void RemoveDuplicateArcs(List<Entity> entities)
|
||||
{
|
||||
var circles = entities.OfType<Circle>().ToList();
|
||||
|
||||
Reference in New Issue
Block a user