Get border edges of mesh - in winding order

后端 未结 3 1423
心在旅途
心在旅途 2021-02-12 22:04

I have a triangulated mesh. Assume it looks like an bumpy surface. I want to be able to find all edges that fall on the surrounding border of the mesh. (forget about inner verti

3条回答
  •  清酒与你
    2021-02-12 23:01

    Boundary edges are only referenced by a single triangle in the mesh, so to find them you need to scan through all triangles in the mesh and take the edges with a single reference count. You can do this efficiently (in O(N)) by making use of a hash table.

    To convert the edge set to an ordered polygon loop you can use a traversal method:

    1. Pick any unvisited edge segment [v_start,v_next] and add these vertices to the polygon loop.
    2. Find the unvisited edge segment [v_i,v_j] that has either v_i = v_next or v_j = v_next and add the other vertex (the one not equal to v_next) to the polygon loop. Reset v_next as this newly added vertex, mark the edge as visited and continue from 2.
    3. Traversal is done when we get back to v_start.

    The traversal will give a polygon loop that could have either clock-wise or counter-clock-wise ordering. A consistent ordering can be established by considering the signed area of the polygon. If the traversal results in the wrong orientation you simply need to reverse the order of the polygon loop vertices.

提交回复
热议问题