Curve intersection segments


#1

Hi
I have closed curve intersecting with another (whatever is it closed or open ). How to decide which segment is in inside of the closed curve? (Rhino SDK functions)
See picture…

Thanks
Filip


(Menno Deij - van Rijswijk) #2

I’m not sure about which functions to use in the C++ SDK but I would approach this as follows:

Provided that the curves are all planar - otherwise temporarily project the control points of all curves to the plane of interest - you can use the Curve.Contains() method (this exists in RhinoCommon as the link below but surely it also exists in the C++ SDK)

http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Geometry_Curve_Contains.htm

This method takes a Point3d as input. For that I would use the point in the middle of the curve segment. If you are careful, determine the parameter of the curve segment at half the length of the curve. But faster is to use the mid-point of curve segment domain.

So, in pseudo code you would get:


List segments = domainCurve.IntersectWith(otherCurve)
foreach segment in segments:
    Point mid = segment.PointAt(segment.Domain.Mid)
    PointContainment pc = domainCurve.Contains(mid)
    if pc == PointContainment.Inside:
      //segment is inside
    if pc == PointContainment.Outside:
      // segment is outside
    if pc == PointContainment.Unset:
      // there is no inside/outside relationship
    if pc == PointContainment.Coincident:
      // the point is on the edge

#3

I know that is the only way (by looking mid point in parameter domain) but I don’t know how to realize this.
By the way the curves are not planar and I don’t know which functions to use.
Thanks Menno I will try again…


#4

Actually I’m trying to divide the closed curve into four closed curves (picture above). If you have any different ideas, please share…