#include <CGAL/Cartesian.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/Arr_observer.h>
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
{
private:
int n_faces;
public:
Face_index_observer (Arrangement_2& arr) :
n_faces (0)
{
CGAL_precondition (arr.is_empty());
arr.unbounded_face()->set_data (0);
n_faces++;
}
Face_handle new_face, bool )
{
new_face->set_data (n_faces);
n_faces++;
}
};
int main ()
{
Arrangement_2 arr;
Face_index_observer obs (arr);
Segment_2 s1 (Point_2(4, 1), Point_2(7, 6));
Segment_2 s2 (Point_2(1, 6), Point_2(7, 6));
Segment_2 s3 (Point_2(4, 1), Point_2(1, 6));
Segment_2 s4 (Point_2(1, 3), Point_2(7, 3));
Segment_2 s5 (Point_2(1, 3), Point_2(4, 8));
Segment_2 s6 (Point_2(4, 8), Point_2(7, 3));
Arrangement_2::Face_const_iterator fit;
Arrangement_2::Ccb_halfedge_const_circulator curr;
std::cout << arr.number_of_faces() << " faces:" << std::endl;
for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit) {
std::cout << "Face no. " << fit->data() << ": ";
if (fit->is_unbounded())
std::cout << "Unbounded." << std::endl;
else {
curr = fit->outer_ccb();
std::cout << curr->source()->point();
do {
std::cout << " --> " << curr->target()->point();
++curr;
} while (curr != fit->outer_ccb());
std::cout << std::endl;
}
}
return 0;
}