Feature Request / suggestion for R9 Rhino API - curve intersections

mcneel people -

I always seem to get in trouble when calling API functions that involve curve intersections - such as Intersect.Intersection.CurveCurve, Curve.Extend, Curve.Trim etc. If you pass curves of different dimensions to these functions then the api tends to simply lock up and hang. Could you consider a quick dimension check to the input of these functions and raise an exception or return a null value? While I acknowledge that keeping curve dimensions consistent is on me, it does make debugging complex code irritating at best.

Hi Will,

What will really help is explain what you mean with “curves of different dimensions”.

In my opinion it is up to the developer to sanitize the input as they seem fit. For instance by checking the curve boundingbox intersections or filter by GetLength().

Also: Can provide an example of “curves of different dimensions” and the code that cannot handle them?
That is the minimum requirement for McNeel developers to replicate the issue you run into and fins a possible cause.

-Willem

Willem -

Thanks for the quick response. Consider this case:

spl1 =  rg.LineCurve(spt, spt + perp)

spl1.ChangeDimension(2)

spl1.Extend(rg.CurveEnd.End, rg.CurveExtensionStyle.Line, self.crvs)

In this case self.crvs is a list of curves whose dimension is 2, but a LineCurve has a dimension of 3. Without the call to spl1.ChangeDimension(2), Rhino will lock up indefinitely. I had posted about this issue a while back so I’m aware of the pitfall. I should probably refactor this code to ensure that all curves in the class have a dimension of 3, but I have some reasons not to.

This locks up if r is 2d and split is 3d:

        mpt = split.PointAtNormalizedLength(0.5)
        pc = r.Contains(mpt)

and obviously this hangs too:

inter = rg.Intersect.Intersection.CurveCurve(tanc, crv, tol, tol)

It’s just an annoyance really - having to force stop Rhino every time I make the same mistake and then single step through to find the issue. But an API should really be designed to prevent this behavior and I wouldn’t think that it would add much overhead to these calls to sanity check their inputs.

Hi @will8

Thanks for letting us know about this. I have added a YouTrack item for this RH-89630.

Hi @will8,

All curve you add to the document are 3-D curves. You probably should not be using the above function unless you are building Breps from scratch or are manipulating a Brep’s trim curves.

– Dale

RH-89630 is fixed in Rhino 8 Service Release 25