Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry_Engine: IsPeriodic added and IsClosed fixed for NurbsCurve #1360

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Geometry_Engine/Query/IsClosed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/***************************************************/
Expand Down
12 changes: 12 additions & 0 deletions Geometry_Engine/Query/IsPeriodic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down