2

I am working on a project that requires a triangle soup be converted to an actual structured mesh in order to apply operations to the mesh. The mesh object is a half-edge type structure with the following items:

Vertex { vec3 position, int edge /* any half edge leaving the vertex */}
HalfEdge {int vertex, int pair}
Triangle {int vertex[3], int normal[3]}
BoundaryEdge {int vertex, int pair, int next, int prev}

Where everything is referred to by an index into an array of those items. I have gotten to the point where I have all the interior edges connected, and all the edges and boundary edge pairs set, the problem I have is how to set the next and prev indices for the boundary edge loops (i.e., how to find these loops from a list of unconnected boundary edges).

If the loops were all simple, it would be easy; however, the meshes I am working with can have boundary 'junctions', that is, multiple boundary loops that share a vertex. This makes it so that there are points in creating the boundary loops where the algorithm has to decide which of multiple possible edges are the correct next edge in to loop. If the wrong edge is chosen, it can make it impossible to iterate over all edges incident to a vertex.

What I have so far is that every time such a junction is encountered, the code basically looks at all possible assignments for the next and prev indices for the half-edges leaving and entering the vertex, respectively, and finds the first assignment that makes it so that starting at any half-edge leaving a vertex, every other such half-edge (and only these edges) can be visited by using edge.pair.next to get to the next such half-edge. Currently, the solution is not overly efficient (I don't think) and I don't even know if it is correct or not, and the same problem also exists for adding triangles that are adjacent to 1 or fewer triangles.

What I was wondering if, a.) is my solution actually going to work, and b.) Is there another more commonly known / used solution to find these edge loops that I've not been able to find yet?

Katniir
  • 41
  • 6
  • Your data structure does not look as standard [half-edge](https://en.wikipedia.org/wiki/Doubly_connected_edge_list). For example, why do you distinguish HalfEdge and BoundaryEdge? – Fedor Oct 18 '22 at 12:27

1 Answers1

0

I've met the similar problem. My case is that several regions(represented as a set of triangles) intersect at a vertex/vertices and they are boundaries. The goal is to find the boundary of each regions. I found that using one-ring neighborhood(that is, edge.pair.next) is hard and inefficient.

What I did is that for each region, I go thought all the triangles and look for boundary edges. Whenever I find a boundary edge, I record the starting_vertex and ending_vertex into a hashmap(map[starting_vertex]=ending_vertex, map[ending_vertex]=starting_vertex). After you walk though all the triangles in this region, you start with a boundary vertex and use the hashmap to construct the boundary.

If there a hole on the triangulation boundary, the above method will fail since the triangulation is not a manifold. The work around: 1. If there is holes in the original surface, try to use interpolation to fill the holes. 2. If there is no holes in the original surface but the resulting triangulation has one, then the problem is caused by the poor code that generate the triangulation. So you may want to change the algorithm that generates the triangulation.

iefgnoix
  • 71
  • 2
  • 10
  • What you're doing is similar to what I was doing, and it works up to a point. The problem with this method is that it tends to fall apart when you have a mesh with holes or other nasty things that create the situation where you have multiple boundary edges entering and leaving the same vertex. When this happens, if your mesh requires certain properties which are dependent on the boundary edge loop structure, then the problem becomes which edge is the correct edge for a particular boundary loop. So for simple cases, yes, it works, but for more complex things, not so easy. – Katniir Jul 24 '15 at 16:48
  • You are absolutely correct. My method won't work for the mesh with holes, especially for the mesh with holes on the boundary in which case the code falls into infinite loop. Here is the work around: 1. If there is holes in the original surface, try to use interpolation to fill the holes. It works in my case since my case does not require to keep the topology. 2. If there is no holes in the original surface but the resulting triangulation has one, then the problem is caused by the poor code that generate the triangulation. So you may want to change the algorithm that generates the triangulation – iefgnoix Jul 25 '15 at 17:44
  • When there is holes on the boundary, then the mesh is not manifold. It itself is a hard topic even in the academia. – iefgnoix Jul 25 '15 at 17:51