diff --git a/Geometry_Engine/Query/IsClosed.cs b/Geometry_Engine/Query/IsClosed.cs index bd563c772..c6d11c99c 100644 --- a/Geometry_Engine/Query/IsClosed.cs +++ b/Geometry_Engine/Query/IsClosed.cs @@ -67,8 +67,7 @@ public static bool IsClosed(this NurbsCurve curve, double tolerance = Tolerance. if (curve == null || curve.ControlPoints == null || curve.ControlPoints.Count < 2) return false; - // TODO: This does not take into account periodic curves - return curve.ControlPoints.First() == curve.ControlPoints.Last(); + return curve.ControlPoints.First().SquareDistance(curve.ControlPoints.Last()) <= tolerance * tolerance || curve.IsPeriodic(); } /***************************************************/ diff --git a/Geometry_Engine/Query/IsPeriodic.cs b/Geometry_Engine/Query/IsPeriodic.cs index 81e36017f..c574d1401 100644 --- a/Geometry_Engine/Query/IsPeriodic.cs +++ b/Geometry_Engine/Query/IsPeriodic.cs @@ -31,6 +31,18 @@ public static partial class Query /**** Public Methods ****/ /***************************************************/ + public static bool IsPeriodic(this NurbsCurve curve) + { + int multiplicity = 1; + + while (curve.Knots[multiplicity - 1] == curve.Knots[multiplicity]) + multiplicity++; + + return (multiplicity != curve.Degree()); + } + + /***************************************************/ + public static bool IsPeriodic(this NurbsSurface surface) { int uMultiplicity = 1;