Mesh.TopologyEdges

Hi all!
It seems that Mesh.TopologyEdges Property have a bug. Or, a “misbehaviour”.
With an unwelded mesh it returns the same outputs as if the mesh were welded.

Notice how vertex indexes 4 and 5 never appear even tough the code is iterating over all the edges:


topologyedges bug.gh (14.0 KB)

  private void RunScript(Mesh M, ref object I, ref object J)
  {
    Rhino.Geometry.Collections.MeshTopologyEdgeList edges = M.TopologyEdges;
    List<int> i = new List<int>();
    List<int> j = new List<int>();
    for(int c = 0;c < edges.Count;c++){
      IndexPair pa = edges.GetTopologyVertices(c);
      i.Add(pa.I);
      j.Add(pa.J);
    }
    I = i;
    J = j;
  }

Am I doing something wrong?
Any workaround? Other methods to get all start and end vertex indexes for each edge of a mesh… ?

Hello
Beware the topology vertices index are not the same as index vertices.
You must use this

To get the classical vertex indexes

There is 2 list of vertices

So you’re telling me there is no topology data/methods for unwelded meshes?

No I am telling you that if you want the index of Vertices you have to do that


topologyedges bug.gh (14.5 KB)

  Rhino.Geometry.Collections.MeshTopologyEdgeList edges = M.TopologyEdges;
    List<int> i = new List<int>();
    List<int> j = new List<int>();
    for(int c = 0;c < edges.Count;c++){
      IndexPair pa = edges.GetTopologyVertices(c);
      i.AddRange(M.TopologyVertices.MeshVertexIndices(pa.I));
      j.AddRange(M.TopologyVertices.MeshVertexIndices(pa.J));
    }
    I = i;
    J = j;
1 Like

Thanks a lot, Laurent!
I’m still wondering why I - J are returning:
0 - 4 that edge shouldn’t exist.
2 - 5 that edge shouldn’t exist.
1 - 2 appearing twice.
4 - 5 should exist instead, but it’s not on the output.

Probably the situation it’s a bit more tricky…

At least now I know where to bang my head :sweat_smile:

Thank you again!

You have to understand there is 2 distincts list of Vertices

  1. The vertices we always use because they are outputted by most plugin
    Mesh.Vertices
  2. And the vertices that are used to make the topology
    Mesh.TopologyVertices
    Most of the times they are hidden but they are more useful because if mesh is welded or not they don’t change. At a point for example on a corner of a face there is just one TopologicalVertex and sometime many Vertices

See that