OK you mesh traversal experts out there. I thought I had nailed it, then I closed the GH definition, then reopened it and… nope. Not at all in sync.
So what I’ve been trying to do is to make a component which traverses a mesh (mesh.Vertices[i]) and picks up nearby vertices (around the “center vertex” i) and output all of them nicely in datatrees.
However, I also want the data indexes in the branches to be in sync with the DeconstructMesh component so I can pair the datatree with other additional data. Well, that was the idea. But I don’t seem to be able to get the indexes correctly in sync. That is my problem.
Pictured is the collected data with index offset -1 and +1 (yellow balls, centered index is the red ball in the middle) plus the same index(es), the blue balls, picked from the std DeconstructMesh component.
Clue: The indexes are obviously not in sync (the red and blue balls should be the same vertices). But what am I doing wrong in the code? (C#). I tried to comment so that the code should be readable.
(The code is structured such that I fist collect the vertices into arrays in order to enable using Parallel.For (using arrays is a simple way to avoid data races) and then shuffle the resulting arrays into a Datatree at the end of the method. An option is to expand the vertice-group (“Expand Star” input) from connected vertices into yet another level of connected vertices (the yellow ones pictured).
The gh definition:
Mesh Topology - Simplified.gh (890.7 KB)
Edit: Ops, forgot to say that all the relevant code is in one single method:
private DataTree<GH_Point> GetConnectedTopologyVertices()