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);
|
var dxf = Dxf.Import(path);
|
||||||
|
|
||||||
RemoveDuplicateArcs(dxf.Entities);
|
RemoveDuplicateArcs(dxf.Entities);
|
||||||
|
RemoveZeroSweepArcs(dxf.Entities);
|
||||||
|
|
||||||
var bends = new List<Bend>();
|
var bends = new List<Bend>();
|
||||||
if (options.DetectBends && dxf.Document != null)
|
if (options.DetectBends && dxf.Document != null)
|
||||||
@@ -156,6 +157,12 @@ namespace OpenNest.IO
|
|||||||
return drawing;
|
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)
|
internal static void RemoveDuplicateArcs(List<Entity> entities)
|
||||||
{
|
{
|
||||||
var circles = entities.OfType<Circle>().ToList();
|
var circles = entities.OfType<Circle>().ToList();
|
||||||
|
|||||||
Reference in New Issue
Block a user