Ok so let's say we have a portion of a mesh that looks somewhat like this:
A triangle fan with one of the triangles removed. If that triangles was not removed, we could get all the edges adjacent to that vertex this way:
std::vector<GraphEdgePtr> GraphVertex::GetVertexEdges()
{
std::vector<GraphEdgePtr> edges;
auto current_edge = edge;
do
{
edges.push_back(current_edge);
current_edge = current_edge->pair->next;
} while(current_edge != edges[0]);
return edges;
}
However, if the triangle is removed, the above will segfault. One could create an additional loop that iterates backwards from the starting edge in the case the first loop finds a null pointer.
However that is a bit inelegant in my opinion. Is there a way to do it in a single loop? Using a stack or a queue or some sort for example?