Let's take Figure 34.2 of the user manual. f1 contains two holes. When parsing the holes using f1->holes_begin() and f1->holes_end(), how can I get the list of the faces inside each hole? For example, from the hole "f3+f4", how can I get the list (f3, f4)?
Of course, I could iterate over all the halfedges bounding the hole and access the face it bounds on its interior side using the twin() to get the opposite halfedge, and then face() to get the face that the opposite halfedge bounds, then remove duplicates, but I'm wondering if there is a simpler solution.
Thanks!
You need to iterate over the ccbs. For example, the code in
draw_arrangement_2.hdoes it; see an explanation below. Observe that the face member functionsholes_begin()andholes_end()are the same asinner_ccbs_begin()andinner_ccbs_end(). (The latter come from the base classArrangement_on_syrface_2.)We maintain a Boolean flag for each face called
m_visitedthat indicates whether we visited the face. In the code this is done via anstd:unordered_map. You can also extend the face record with a Boolean flag for instance.We start with the unbounded faces (see
add_faces()) and descend down to their holes. For each facefwe calladd_face(f); in this function we traverse the face inner ccbs and outer ccbs. For each ccbcwe calladd_ccb(c). For a ccbcwe traverse the halfedges ofc; for each halfedgehwe visit the facefincident to the twin ofh. If we visitedfwe discard it; otherwise, we mark it as visited and recurse to processfby callingadd_face(f).Notice that in the drawing function we process the ccbs such that we draw the regions bounded by the outer ccb of the faces in the opposite order of containment; see the call to
draw_region().