Trim with regions - sped up

To create the geometry of crossing streets, I’d like to speed up the Trim with Regions operation. The desired end result should not have curves crossing over (such as in the light grey sidewalks below):

Such a feat is simple to do with a Trim with Regions.


Where each branch corresponds to a type of street section:

The downside however is that it is much slower than a multiple curve intersection. So I’m thinking that if I can use multiple curves intersection, then test for whether a segment midpoint is contained by the curve that I trim with, the segment can be culled. However, I can’t quite get the data trees to match up.


Trim with regions sped up.gh (156.8 KB)

I think Trim with Regions is pretty fast :face_with_tongue:. Although the multiple curves intersection (mcx) component can work faster, testing for containment afterwards might actually take longer?

That’s what I ended up seeing. Check here:
Trim with regions sped up_c.gh (162.9 KB)

Trim with regions can be sped up too with an MCX and supplying the correct curves to trim in advance (so there are no curves that don’t intersect). I got close here, but the Regions to Trim with are incorrect.

Trim with regions sped up.gh (203.8 KB)

I’d like to see that :slight_smile:

Well at least with Region Union it does, so I’d like to compare here too.

:thinking:

How slow was your trim with regions originally, if you don’t mind me asking?

When I first opened it seemed ‘fast’ enough:

This is with 9 curves and I’ll likely have some 40-50-ish curves for my masterplan. It’s about equally quick on my end. But if I can make it 1/6th quicker by preprocessing, that would be nice.
Since I can’t visualise the end result, I don’t know if all the curves end up intersecting correctly on beforehand.
They can easily overshoot or fall short.


Yet the visualisation only shows one street in an intersection:

Only after the intersection will I be able to know if there were any curves that require a rework (I do this all only with the orange lines from the earlier picture).

That’s why, I was trying to use the shattered segment parameters to find which curves intersected so I only do a containment check between the shattered segment midpoint and the curve(s) at their start/ end point (the ones that are used for the actual trimming). If a segment is contained in the curve that intersected it originally, it has to be trimmed away. I hope I’m making sense here.
Also each branch in MCX corresponds to a section zone (sidewalk, road, bicycle lane), so for the 250 intersection points I have know, I’d have 500 containment checks tops. Less if I filter out the long segments.

Nice. I was trying to study your .gh file but there are a couple of components that don’t show up because I don’t have the plugin(s).

As far as I can tell, I’ve only used Human (for a stand alone colored preview) and Pufferfish’s Curve Middle. I’ve replaced those components here:
Trim with regions sped up_no plugins.gh (200.8 KB)
Do note that the Custom Preview Component’s colours are way off and aren’t really distinctive enough now.

How did you end up doing?

This is what I’m talking about:


I don’t think these were ‘curve middle’ components.

Oh, 1st one is Dispatch Indices from Pufferfish, teh 2nd one is Sasquatch’s RegEx Split.

@inno this is a continuation of:

I decided to try the flattened Multiple Curves intersection first, which is in the file below. However, there’s still something wrong with the shatter, I grouped the likely problematic components.


Trim with Regions - sped up.gh (103.4 KB)

oh yes, I think the problem is here:

in detail, this location:

you create a set of the indexes of the intersecting curves, then use member index to retrieve their relative position in order to get shatter parameters

for instance, here curve at index 4 and 5 do not appear in the list, meaning there should be no shattering parameters for curves at index/branch 4 nor 5:

still, there are branches for shattering parameters of curves 4 and 5 in the output tree, and that happens because there wasn’t even an interrogation to Member Index about indexes 4 or 5 :slight_smile:

a maybe better way to do that is to create a Serie which is as long as the initial Curve List, and use that Serie to interrogate Member Index instead, this is how the tree with shattering parameters changes:

Trim with Regions - sped up_inno.gh (93.1 KB)

these are the shattered end-points before the above (these ones circled in red should not exist indeed):

and these are the ones after the change: