Optimise region union - find overlaps amongst multiple sets

I am looking to optimise region union operations. By checking for curve intersection prior to region union, I can shave off a lot of time for when there are no unions. But when there are, supplying only the intersecting curve regions, I can also reduce the computation time by half.


However, this becomes more complicated when there are three or more curves that need to be unioned. In this case, I would need to convert all intersecting curve pairs to lists of curves that all union together. In this example,it concerns indices 0,6,7 and 3, 8, 11 that should be fed into the Region Union component. How do I find partially overlapping lists and the included numbers?


Optimise region Union.gh (20.1 KB)

Like this maybe?

Optimise region Union point-in-curve.gh (28.3 KB)

I want to find the intersecting curves prior to performing Region Union as that saves a lot of time (see the 1st screenshot with a region union with all curves and a region union with only the intersecting curves fed into it). This is a lists/ brances/ set problem of finding overlap between branches and putting those overlapping branches together in a single branch.

E: Trim with Regions > join outside curves is likely even faster and that’s important, because it’ll be part of a script that runs realtime all the time as drafting aide.

1 Like

I have this script by @DanielPiker which I think does what you want.

sets_c#.gh (11.5 KB)
Optimise region Union point-in-curve_set.gh (35.2 KB)

1 Like

Thanks, that does the trick!
If anyone can think up a native Grasshopper solution, be my guest!

1 Like

If you’re just looking to get the regions, Curve.CreateBooleanRegions also does the trick fast and simple:



250508_OptimiseRegionUnion_00.gh (16.3 KB)

I don’t think it has been implemented as a standard Grasshopper component yet, but the scripting components/RhinoCommon are native. So there shouldn’t be any dependency issues.

1 Like

Nope, Curve Boolean is slated for GH2:

That said, with Elefront and another Trim with Regions component, I found a faster solution than Region Union.


2025-05-08 - Optimise region Union.gh (45.9 KB)

It is also possible to do this without the region trim, which may speed thing up further, but I’m not gonna be bothered with the required tree matching in the red group…


2025-05-08 - Optimise region Union.gh (47.4 KB)

Hi @martinsiegrist do you have the source of that C# from Mr @DanielPiker? :grimacing:

You mean the post where he shared it?

Is it definitely by me? I don’t remember writing that script

I thought it was. Might be very old from the old Grasshopper3d forum? At some point I started putting links to the source into the Grasshopper definitions but not in this file.

With the help of the date in the Grasshopper file, I found the topic:

Sets question - Grasshopper - McNeel Forum

The script seems to be by David Rutten.

VoilĂ , found it:

Page 2 of David Rutten’s posts on the old Grasshopper3d forum…

image

image

1 Like