Create List in C#

Using the code below, I can retrieve adjacent face indices for a mesh edge.

I currently get just one index and I don’t know how to put all indeces into one list? … Ok it’s a tree

How does that work?

{
Rhino.Geometry.Collections.MeshTopologyEdgeList MTE = M.TopologyEdges;

for(int i = 0; i < MTE.Count;i++){
  index = MTE.GetConnectedFaces(i);
}

}

Are you after Mesh connectivity matters? (3 classes (V, E, F) meaning 9 possible combos: VV, VE, VF … blah, blah). If so we are talking DataTrees of type int.

For instance (these work on Mesh Lists thus conn trees are 2 dim collections):

Note: for vertices use TopologyVertices indexing that is NOT the same as Vertices indexing.

The documentation is clear here
https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Collections_MeshTopologyEdgeList_GetConnectedFaces.htm

public int GetConnectedFaces( int topologyEdgeIndex)

It is an array of int which are faces index.

If you are in Mesh Topology
dont’ use GetTopologicalIndenticalVertices, it doesn’t work
Use instead mesh.TopologyVertices.TopologyVertexIndex

cf.

Sorry I don’t understand most of the above.

I solved it like this for now:

No you don’t (unless index is an out param):

MTE.GetConnectedFaces(faceIndex) yiels an array of type int.

So (there’s issues with char < and >):

DataTree < int > EF = new DataTree < int > ();
for(int i = 0; i< MF.Count;i++){
int [ ] ef = MTE.GetConnectedFaces(i);
EF.AddRange(ef, new GH_Path(i));
}

Given the opportunity:

  1. Always check your Mesh for islands: Mesh [ ] pieces = m.SplitDisjointPieces();
  2. Always run the mesh.Vertices.CombineIdentical(true, true) Method.

20_04_19_face_connectivity.gh (9.9 KB)

The output is what I want.

Thanks Peter!

NOTE: for(int i = 0; i< MF.Count;i++) NOT MTE.

So … this is the proper way to cut the mustard (minus validity checks etc etc) on EF, FE conn matters. Notice the obvious: 2 dim conn trees … either due to the split (islands) or the input List.

PS: The MTV (not required) is provited in order to encourage you to do the remaining 7 connectivity trees.

Mesh_connectivity_FE_EF_V1.gh (127.4 KB)

1 Like