Hi, I was wondering if there is any method in Rhinocommon similar to the Multiple Curves Intersection Component in Grasshopper, I been using combinations to test for intersections with the CurveCurve() method, but I don’t really know if there is any faster algorithm. Thanks!

Ciao Antonio,

Multiple Curves Intersection is just a Curve-Curve intersection with a “lower strict” cross reference.

If you have a list of curves you could do something like:

a=curves.Count();

for (int i = 0; i < (a-1); i++){

for (int j = (i+1); j < a; j++){

Rhino.Geometry.Intersect.Intersection.CurveCurve(curves[i], curves[j], tolerance, overlaptolerance);

// here use your Rhino.Geometry.Intersect.CurveIntersections found

}

}

It shouldn’t be any slower than another method that still use Rhinocommon… i think.

It could be faster if you check if the curve is a line/circle, so you could use other intersection methods (that are probably faster with that kind of curves).

Hi I thought of something similar but its not clear to me if this is faster than generating the combinations first, and then just doing less intersections… Thanks

There might be another bottleneck: If your curve is “heavy” (it has many control points) there will be a significant slow down. It might be worth checking.

Furthermore, if you can filter out those who won’t intersect, this will increase performance.

and last but not least, multithreading for many intersections might also be beneficial.

Adding to the question, anyone knows if there is a method for testing if a set curves overlaps??, this can be done with intersect but I’m not sure if a method like that exist, either for curves or planar surfaces. Thanks

I don’t think there is a method in RhinoCommon that checks for curve-overlaps.

You’ll have to use *Intersect.Intersection.CurveCurve()* method and analyze intesectionEvents => curves overlap if any event has property *IsOverlap == True*.

The question is how large set of curves is (number of curves)…

Indeed that’s the only Method (other than Ccx) around for some pre-checks (using a BoundingBox speeds up the whole story):

Antonio,

Are your curves all on a common plane? I have a fast intersection method for curves on a common plane.

Could you send me an example model?

As far as results go point intersections are pretty straight forward but when many overlaps are coincident things can get pretty complicated. Have you thought about what kind of results you need for overlaps?

**Hi**, Yes they are all in a common plane, they are all polylines(not complex polygons) , they don’t really need to be rectangles. As results, I don’t really need point intersection, but a Boolean indicating if the curve intersects or not. ???

My goal is to use a method like that for “simplifying” the operations describe **here**:

**Region Boolean Operations** : It would be very nice if this components were able to output the indices of the curves that take part in the operations.

**Overlaping** : Relations between every curve, in ether a (0 = no overlap, 1 = overlaps in the boundary, 2 = overlaps). This is really an approximation.

**Curves Herarchy** : Pretty much this script by Peter : A better approach replicating 'Curves in Curves'

Here is the file they are very simple set of curves, nothing really crazy.

For Region Boolean Operations I was able to script a component that works purely on combinatorics and Binary Masking, but I’m still wondering if there’s is a less innocent approach. Thanks

I was under the impression the problem was that iterating over all pairs was too slow and you were looking for a faster solution. However, with a simple collection of curves like in your example intersecting every pair should be fast enough.

From scanning over this thread though It seems like there is more going on here.

First you are looking at planar subdivision problems as opposed to just finding intersections of generally open curves ( like Intersection.CurveCurve ). That is the plane is divided into regions bounded by these curves. All the original curves are closed hence defining input regions. After the regions are intersected you get resulting regions. Each resulting region is a part (connected component) of the intersection of some input regions. From all this information you could find relations between input regions like A contained in B and then form composite regions like B- A which would remove A from B.

Well, I deviate of topic a little bit, sorry there , I also recognize that on the file that I upload, the cases were very small and simple(I’m gonna upload a better test set later), but what is not clear to me is that iterating over all curves makes the problem scale very fast **n ( n − 1)/2**, for this simple cases yes, but when is over **100 curves** it becomes fairly inefficient.

It would be nice to filter the curve first and in that way reducing the number of calculations.

It also appears to me that the **Multiple Intersection Component** is not really doing that because it solve “10 time faster” than by iterating over all curves. Thanks

Yes, recently doing some components for splitting polygons, I was looking at the methods of the **PolylineCurve** Class and found a method call **PlanarCurveCollision()**, that detects when two curves overlap and has as an output a Boolean value. Thanks all for the help!!!.

**Method:** https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_PlanarCurveCollision.htm