Detect "Curve is not smooth..." geometrically


#1

Hi @all,

Sometimes i have Nurbscurves making problems with these geometric properties listed in the object “What” dialog text:

Curve is not smooth. If you explode it, it will become two or more curves.

Is there a way to detect this geometrically using python scripting or RhinoCommon ? In Rhino 6 i could use RhinoObject.Description, but that is not possible in Rhino 5.

_
c.


(qythium) #2

I believe this would be equivalent to calling:

curve.GetNextDiscontinuity(Rhino.Geometry.Continuity.G1_continuous, 
                            curve.Domain[0], curve.Domain[1], out t);

which returns true if the curve is not smooth (and a parameter t at the discontinuity location)

You might have to check for G1_locus_continuous if you want to ensure smoothness at the domain endpoints, i.e if the curve is closed.


#3

@qythium,

thank you for your reply. I will try to implement it. Does the discontinuity only happen between start and end point of closed Nurbscurves or do i have to check all segments ?

_
c.


(qythium) #4

Hi @clement,
I’m not sure if I understand your question - but according to the documentation this should test your entire curve object for the first occuring G1 (ie. tangency) discontinuity, you don’t have to manually iterate through segments.

The end points/knots are excluded by default (otherwise all open curves would be considered discontinuous), and specifying Locus Continuity simply says to check them as well.

http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Geometry_Curve_GetNextDiscontinuity.htm
http://developer.rhino3d.com/api/RhinoCommonWin/html/T_Rhino_Geometry_Continuity.htm


#5

Thank you @qythium.


#6

@qythium, i’ve tried that with closed curves and it always returns True using these:

Rhino.Geometry.Continuity.G1_continuous
Rhino.Geometry.Continuity.G1_locus_continuous

I get the same results regardless of the curve having the “Curve is not smooth” or not. Any other ideas how to detect it ?

_
c.


(Dale Fugier) #7

Hi @clement,

Something like this should do it:

def IsCurveKinky(curve_id):
    kinky = False
    if curve_id:
        curve = rs.coercecurve(curve_id, -1, True)
        if curve:
            style = Rhino.Geometry.Continuity.Gsmooth_continuous
            dom = curve.Domain
            t0 = dom.Min
            t1 = dom.Max
            rc, t = curve.GetNextDiscontinuity(style, t0, t1)
            if rc and t0 < t and t < t1:
                kinky = True
    return kinky

– Dale


#8

Thanks @Dale,

i cannot find Gsmooth_continuous in Rhino 5. It gives me a type error:

Message: ‘type’ object has no attribute ‘Gsmooth_continuous’

_
c.


(Dale Fugier) #9

@clement,

Replace this:

style = Rhino.Geometry.Continuity.Gsmooth_continuous

with this:

style = System.Enum.ToObject(Rhino.Geometry.Continuity, 12)

– Dale


#10

Hi @dale, thank you, this works.

If someone else is needing this, it is important to only send Rhino.Geometry.NurbsCurve to the test to prevent false positives.

_
c.


(qythium) #11

Hi @dale, may I know the actual geometric definition of “Gsmooth_continuous”?
The documentation says ‘aesthetic discontinuity’ but it’s not clear what that means - torsional smoothness/G3 or higher? Or some kind of heuristic?

I’ve been using G1 and G2 without issues to evaluate kinks in my use scenario, just curious where that would break down.


(Dale Fugier) #12

Hi @qythium

Gsmooth_continuous means nothing mathematically. Basically, it means at least G2 and as smooth as reasonably possible for the object being queried. Hence the aesthetic discontinuity comment.

– Dale