Search code examples
c++c++14cgal

Obtain the vertices of each bounded face in an arrangement in CGAL


I have a set of points in the primal which I convert to a dual (a set of lines). I want to print the vertices involved in each bounded face of the arrangement.

I am trying to modify the code from http://www.cs.tau.ac.il/~efif/doc_output2/Arrangement_on_surface_2/#title36

I am adding the relavent code snipped below.

  std::vector<Point> points;
  read_objects<Point>(filename, std::back_inserter(points));
  std::list<X_monotone_curve> dual_lines;
  for (const auto& p : points) std::cout << p.x() << " " << p.y() << std::endl;
  for (const auto& p : points) dual_lines.push_back(Line(p.x(), -1, -p.y()));
  Arrangement arr;
  insert(arr, dual_lines.begin(), dual_lines.end());
  for (auto face_iter = arr.faces_begin(); face_iter != arr.faces_end(); ++face_iter) {
    // Please suggest how to iterate over the vertices of bounded face
  }

I feel I am missing something from the Face iterator. The iterator I obtain when I go over gdb is class CGAL::I_Filtered_iterator.

Can you help me with the iterator code?


Solution

  • Something like the following:

    void process_ccb(Ccb_halfedge_const_circulator circ) {
      auto curr = circ;
      do {
        // Do something with curr
      } while (++curr != circ);
    }
    
    void your_function() {
      // ...
      for (auto face_iter = arr.faces_begin(); face_iter != arr.faces_end(); ++face_iter) {
        for (auto it = face_iter->inner_ccbs_begin(); it != face->inner_ccbs_end(); ++it)
          process_ccb(*it);
    
        for (auto it = face_iter->outer_ccbs_begin(); it != face->outer_ccbs_end(); ++it)
          process_ccb(*it);
      }
    }