How to Find Edge Vertices of a 2D mesh,How to Find Edge Vertices of a 2D mesh

I want to only Red point please help me,

I’ve posted an answer to a similar question over here. Does that help? Keep in mind this approach does only work when you have shared vertices all across the mesh. So any UV seam is considered an outer edge as well.

Ive done lots of 3D mesh problems like this in WPF so let me take a crack.

First, if you had an array of the points/vertices, alongside the triangle indicies, you can create a list of edges like this: (pseudocode warning…)

    public class MainClass
    {
        private void GetEdges()
        {
            Point[] points = mesh.Points; // The mesh's vertices
            int[] indicies = mesh.TriangleIndices; // The mesh's triangle indicies

            List<Edge> edges = new List<Edge>();

            // for every two triangle indicies
            for (int i = 0; i < indicies.Length; i++)
            {
                // if point a != point b (meaning there is an edge)
                if (points[indicies*] != points[indicies[i + 1]])*

{
// Create a new edge with the corresponding points
// and add it to edge list
Edge edge = new Edge(points[indicies*], points[indicies[i + 1]]);*
edges.Add(edge);
}

}
}
}

public class Edge
{
public Point A;
public Point B;

public Edge(Point a, Point b)
{
A = a;
B = b;
}

// Creates an object that represents
// a line from A to B (an edge)
}
With the edges, knowing that you only want the edges which dont go diagonally into the mesh, you can do a basic check with the points of each edge to check that the x or y of both points in the edge are the same, meaning it isn’t slanted, but rather straight, either on the x-axis or y-axis. For example:
private void GetStraightEdges(List edges)
{
List straightEdges = new List();

foreach (Edge edge in edges)
{
if (edge.A.X == edge.B.X ||
edge.A.Y == edge.B.Y)
{
// edge is straight and not diagonal
straightEdges.Add(edge);
}
else
{
// edge is diagonal and can be discarded
}
}
}
Finally, you wish to only find the red points on each straight edge, so you can simply create a new point array containing those points (as you already have the right edges for the job)
private List GetPoints(List straightEdges)
{
List Points = new List();

foreach (Edge edge in straightEdges)
{
Points.Add(edge.A);
Points.Add(edge.B);
}

return Points;
}
And this method returns the list of red points in your diagram from that mesh. You can do whatever you want with that list of points, like circling them, or allowing them to be edited, im guessing. You do need the original collection of vertices and triangle indicies from the original mesh to do this though, which Unity provides for each mesh you create. Hopefully this helps @Hellojeska
Full Code:
public class MainClass
{
private void GetEdges()
{
Point[] points = mesh.Points; // The mesh’s vertices
int[] indicies = mesh.TriangleIndices; // The mesh’s triangle indicies

List edges = new List();

// for every two triangle indicies
for (int i = 0; i < indicies.Length; i++)
{
// if point a != point b (meaning there is an edge)
if (points[indicies*] != points[indicies[i + 1]])*
{
// Create a new edge with the corresponding points
// and add it to edge list
Edge edge = new Edge(points[indicies*], points[indicies[i + 1]]);*
edges.Add(edge);
}
}

GetStraightEdges(edges);
}

private void GetStraightEdges(List edges)
{
List straightEdges = new List();

foreach (Edge edge in edges)
{
if (edge.A.X == edge.B.X ||
edge.A.Y == edge.B.Y)
{
// edge is straight and not diagonal
straightEdges.Add(edge);
}
else
{
// edge is diagonal and can be discarded
}
}

List redPoints = GetPoints(straightEdges);
}

private List GetPoints(List straightEdges)
{
List Points = new List();

foreach (Edge edge in straightEdges)
{
Points.Add(edge.A);
Points.Add(edge.B);
}

return Points;
}
}

public class Edge
{
public Point A;
public Point B;

public Edge(Point a, Point b)
{
A = a;
B = b;
}

// Creates an object that represents
// a line from A to B (an edge)
}