Sort mesh edges

Hi,

But I have strange issue, I am sorting edges of the mesh.
But mesh edges are sorted when I plug grasshopper wires 3x times,

The code is quite simple and attached below.

The code part that does this is here, it is basically adjacency of vertex and neighbor edges

  public  int[][] VE(Mesh mesh) {

    int[][] veSorted = new int[mesh.TopologyVertices.Count][];

    for (int i = 0; i < mesh.TopologyVertices.Count; i++) {

      veSorted[i] = new int[mesh.TopologyVertices.ConnectedEdgesCount(i)];
      mesh.TopologyVertices.SortEdges(i);

      for (int j = 0; j < mesh.TopologyVertices.ConnectedEdgesCount(i); j++) {

        veSorted[i][j] = mesh.TopologyVertices.ConnectedEdge(i, j);
      }
    }

    return veSorted;
  }

OldMotorbike.gh (436.5 KB)

More simply how can I correctly sort mesh faces around vertex correctly?

My idea was to take sortEdges function and then take adjacent faces one by one.

@Petras_Vestartas, i’ve done this a while ago using polar sorting in a plane. The origin of the plane is the central vertex which is shared by all faces surrounding it. The normal of the plane is the vertex normal.

Maybe attached script helps. You can try it out by dragging the script over Rhino, then pick point objects (in random order) around the world xy origin.

Function_SortPointsPolar.rvb (2.4 KB)

after the points are sorted, a closed polyline is created through the points. Be warned, it is vb-script and a bit old :wink:

_
c.

Thank you :slight_smile:

This translator still works well:
https://www.carlosag.net/tools/codetranslator/