Problem I’m having is that Curve Side's data structure is based on the Curve Input rather that the Point input. So I need to convert the data structure back to Points. In other words, I need to grab item index 0 to -1 for branch {0;X;Y} OR trim the tree and get the corresponding items from a single branch.
For branches {0;0;Y}, that would mean I need item index 0 for branch {0;0;0} to {0;0;2} all the way up to item index 10. OR item 0, 11 and 22 from {0;0} all the way up to item 10, 21 and 32. Essentially, I need to get 11 branches with 3 items each.
Any pointers on how to do this? Get item index 0 to -1 from a series of branches with unequal lengths.gh (106.2 KB)
Use case
I have a series of curves that I’m looking to trim with a method faster than Multiple Curves Intersection:
you mean for each branch take item at index 0 and -1 ? I don’t well understand what you mean
[edit] after having a second look to your definition, my above question looks pretty stupid .___.
you have 117 curves organized in a data tree with 30 branches ( {0} to {29} )
on the other side you have 264 points also organized in 30 branches ( {0} to {29} )
you want each single curve to be compared independently to all the points that lie in the same original branch where the curve comes from, and in order to do that you duplicate each Point branch by the number of curves contained in the corresponding curve_data_tree, then finally graft the Curves in such a way they are one item per branch
the question that comes next is: now that you have compared each curve with the corresponding points, what kind of data you want to extract and why? that’s not really clear to me
why you would like some elements at index 0 and some at index -1 and some other up to index 10
Since each point is compared to all the curves that they may reside in — and the data is organised by curves — I need to restructure the data so that each branch (one for each point) contains all the Curve Side information for the curves it was compared with.
Taking the input curves, there are 3 curves in the first branch, meaning there are three banches for curve side. The initial point is compared against those 3 curves, so, for the first point, I need item index 0 from the first 3 branches. For point 2, I need item index 1 for the first 3 branches, all the way up to index -1 (last one in the list) for the first 3 branches.
Moving to the next point, which is index 0 in branch {0;1;0}, {0;1;1} and {0;1;2}. The point after is index 1 in those branches, all the way up to index -1.
Some points are compared to more curves, e.g. in {0;6}, so I need to grab the first item from the 4 correponding branches, etc.
When I know for each point on which direction it is relative to all the curves it was compared with, I know that if the point is within one of the closed curves, it is a segment that can be trimmed away. So I test if the point is to the left (?) in one of the curves and if it is, it means the segment it is in multiple closed curves and can be culled.
Thanks @inno that’s a smart matching method. Didn’t know you could use the group components like this. Though I’m not exactly sure why, but there still is a minor discrepancy between the two solutions, even though they should be identical. It’s not in the matching as the first two groups have the same result.
The problem is that the Region Union takes 25s, Trim with regions is 65ms and this solution is 21ms. Though if I would be able to use my original tree structure, I’d get it down to 10ms. What I plan to use this on should be near real time and I can get the computation time down further with other optimisations. What I have here is just a small set of curves still.
I have data where the Trim with Regions takes a full second as opposed to 65 ms and that’s about 1/4th of what the script is supposed to be operating on.