<p>Observe that you can construct another graph by connecting the centroids of faces with centroids of adjacent faces. This is known as the dual. The edges of the graph between the centroids can be represented as the twin relation between halfedges. Then you can use something like Depth First Search to visit all the faces:</p>
<pre><code>function visit(f)
   mark f as visited
   for(edge e in f) 
       if(!e-&gt;twin-&gt;face-&gt;visited) 
           faces.append(e-&gt;twin-&gt;face) 
           visit(f) 
</code></pre>

CC BY-SA 4.0
2021-07-02T09:19:19.227Z
2021-07-02T09:19:19.227Z
Reynolds
<p>I need to, starting from one face, iterate over the rest of the faces until I reach the first facet. For this I can use twin, start, end or other info of halfedges, faces, vertex. That is, I need to switch to another face at each iteration until I go through all the faces.</p>
<p>Please, help</p>

<pathtracing><computational-geometry><polygon><edge-detection>
HalfEdge: How to get list of all faces from one face
JoungCPPser
# HalfEdge: How to get list of all faces from one face

(Asked by: username_0 on 2021-07-02)

I need to, starting from one face, iterate over the rest of the faces until I reach the first facet. For this I can use twin, start, end or other info of halfedges, faces, vertex. That is, I need to switch to another face at each iteration until I go through all the faces.

Please, help

**Tags:** pathtracing, computational-geometry, polygon, edge-detection


---

## 1 answers

### Answer by username_1 on 2021-07-02. Score: 1

Observe that you can construct another graph by connecting the centroids of faces with centroids of adjacent faces. This is known as the dual. The edges of the graph between the centroids can be represented as the twin relation between halfedges. Then you can use something like Depth First Search to visit all the faces:

```
function visit(f)
   mark f as visited
   for(edge e in f) 
       if(!e->twin->face->visited) 
           faces.append(e->twin->face) 
           visit(f) 

```


---

