#include <string>
#include <boost/lexical_cast.hpp>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_extended_dcel.h>
#include <CGAL/Arr_overlay_2.h>
#include <CGAL/Arr_default_overlay_traits.h>
struct Overlay_label
{
std::string operator() (char c, int i) const
{
return boost::lexical_cast<std::string>(c) +
boost::lexical_cast<std::string>(i);
}
};
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Segment_2 Segment_2;
typedef Traits_2::Ray_2 Ray_2;
typedef Traits_2::Line_2 Line_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curves_2;
ArrangementB_2,
ArrangementRes_2,
Overlay_label> Overlay_traits;
int main ()
{
ArrangementA_2 arr1;
insert (arr1, Line_2 (Point_2(0, 0), Point_2(1, 1)));
insert (arr1, Line_2 (Point_2(0, 0), Point_2(1, -1)));
CGAL_assertion (arr1.number_of_vertices() == 1);
ArrangementA_2::Halfedge_around_vertex_circulator first, curr;
char clabel = 'A';
curr = first = arr1.vertices_begin()->incident_halfedges();
do {
curr->face()->set_data (clabel);
++clabel;
++curr;
} while (curr != first);
std::cout << "Done with arr1." << std::endl;
ArrangementB_2 arr2;
insert (arr2, Segment_2 (Point_2(-4, -4), Point_2(4, -4)));
insert (arr2, Segment_2 (Point_2(4, -4), Point_2(4, 4)));
insert (arr2, Segment_2 (Point_2(4, 4), Point_2(-4, 4)));
insert (arr2, Segment_2 (Point_2(-4, 4), Point_2(-4, -4)));
CGAL_assertion (arr2.number_of_faces() == 2);
ArrangementB_2::Face_iterator fit;
for (fit = arr2.faces_begin(); fit != arr2.faces_end(); ++fit)
fit->set_data ((fit == arr2.unbounded_face()) ? 1 : 2);
std::cout << "Done with arr2." << std::endl;
ArrangementRes_2 overlay_arr;
Overlay_traits overlay_traits;
overlay (arr1, arr2, overlay_arr, overlay_traits);
ArrangementRes_2::Face_iterator res_fit;
std::cout << "The overlay faces are: ";
for (res_fit = overlay_arr.faces_begin();
res_fit != overlay_arr.faces_end(); ++res_fit)
{
std::cout << res_fit->data() << " ("
<< (res_fit->is_unbounded() ? "unbounded" : "bounded")
<< ")." << std::endl;
}
return 0;
}