I have made a start at looking at a mesh that represents a shape that is cut out of plywood to see how you would determine the edges as defined by @gladiator-media. This turns out to be more of a problem than I though it would.
Why?
The task is to
which I take to mean without reference to the original construction data and to only use the vertex data contained by the mesh.
Making the assumption that the edges are perpendicular to th xz plane then the normal for each edge will have y = 0 and so will the triangular factes that make up the edges. This can be used to determine all the facets that belong to one of the edges.
All facets on a particular edge will have the same normal. The reverse is not true. As you can see for the image below there are three edges (black) where the facets making up the edges will all have the same normal.

Facets belonging to a particular edge will be adjacent to each other. So how you find adjacent facets that share the same normals? Since, because of the nature of the project, the edges and top and bottom all appear flat the mesh must be a flat shaded mesh. This means the facets do not share vertex indices which would be one way to find adjacency. What this means is that you have to check vertex positions. Two facets will be adjacent when two vertices in one facet share positions with two vertices in the other facet.
WARNING the following has only been tested with one mesh created using ExtrudePolygon
, more testing with meshes (of the correct form) of unknow construction is necessary.
Click on an edge (vertical side) to swap its color.
In the above PG the function getEdgesData(mesh)
will return an object with the following properties
edges - an array of an array of triangular facet indices, eg edge[i] = [facet_index0, facet_index1];
the number of edges is given by edges.length;
faceToEdge - maps a triangular facet index to the edge it belongs to
edgeToEdge - maps an edge to the two adjoing edges, eg edgeToEdge[edge] = [adjoing0, adjoining1];
Hopefully it will satisfy
With more work the following should be possible