diff --git a/OpenNest.Core/Geometry/EllipseConverter.cs b/OpenNest.Core/Geometry/EllipseConverter.cs index 416015a..86097be 100644 --- a/OpenNest.Core/Geometry/EllipseConverter.cs +++ b/OpenNest.Core/Geometry/EllipseConverter.cs @@ -67,6 +67,11 @@ namespace OpenNest.Geometry public static List Convert(Vector center, double semiMajor, double semiMinor, double rotation, double startParam, double endParam, double tolerance = 0.001) { + if (tolerance <= 0) + throw new ArgumentOutOfRangeException(nameof(tolerance), "Tolerance must be positive."); + if (semiMajor <= 0 || semiMinor <= 0) + throw new ArgumentOutOfRangeException("Semi-axis lengths must be positive."); + if (endParam <= startParam) endParam += Angle.TwoPI; diff --git a/OpenNest.IO/Extensions.cs b/OpenNest.IO/Extensions.cs index 3e5d625..bdd818a 100644 --- a/OpenNest.IO/Extensions.cs +++ b/OpenNest.IO/Extensions.cs @@ -1,6 +1,7 @@ using ACadSharp.Entities; using CSMath; using OpenNest.Geometry; +using System; using System.Collections.Generic; using System.Drawing; using System.Linq; @@ -68,8 +69,9 @@ namespace OpenNest.IO { curvePoints = spline.PolygonalVertexes(precision > 0 ? precision : 200); } - catch + catch (Exception ex) { + System.Diagnostics.Debug.WriteLine($"Spline curve evaluation failed: {ex.Message}"); curvePoints = null; } diff --git a/OpenNest.Tests/Bending/SolidWorksBendDetectorTests.cs b/OpenNest.Tests/Bending/SolidWorksBendDetectorTests.cs index 33d102c..2dacdd8 100644 --- a/OpenNest.Tests/Bending/SolidWorksBendDetectorTests.cs +++ b/OpenNest.Tests/Bending/SolidWorksBendDetectorTests.cs @@ -70,7 +70,6 @@ public class SolidWorksBendDetectorTests // changing the entity count. Verify arcs are present and no // spurious closing chord exists. var arcCount = result.Entities.Count(e => e is OpenNest.Geometry.Arc); - var lineCount = result.Entities.Count(e => e is OpenNest.Geometry.Line); var circleCount = result.Entities.Count(e => e is OpenNest.Geometry.Circle); Assert.True(arcCount > 0, "Expected arcs from ellipse conversion");