#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <list>
#include <cstdlib>
#include <cmath>
typedef Traits_2::Polygon_2 Polygon_2;
typedef Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
Polygon_2 construct_polygon (const Circle_2& circle)
{
Traits_2 traits;
Curve_2 curve (circle);
std::list<CGAL::Object> objects;
traits.make_x_monotone_2_object() (curve, std::back_inserter(objects));
CGAL_assertion (objects.size() == 2);
Polygon_2 pgn;
X_monotone_curve_2 arc;
std::list<CGAL::Object>::iterator iter;
for (iter = objects.begin(); iter != objects.end(); ++iter) {
CGAL::assign (arc, *iter);
pgn.push_back (arc);
}
return pgn;
}
int main (int argc, char* argv[])
{
unsigned int n_circles = 8;
if (argc > 1) n_circles = std::atoi(argv[1]);
const double pi = std::atan(1.0) * 4;
const double n_circles_reciep = 1.0 / n_circles;
const double radius = 1;
const double frac = 2 * pi * n_circles_reciep;
std::list<Polygon_2> circles;
unsigned int k;
for (k = 0; k < n_circles; k++) {
const double angle = frac * k;
const double x = radius * std::sin(angle);
const double y = radius * std::cos(angle);
Point_2 center = Point_2(x, y);
Circle_2 circle(center, radius);
circles.push_back (construct_polygon (circle));
}
std::list<Polygon_with_holes_2> res;
std::copy (res.begin(), res.end(),
std::ostream_iterator<Polygon_with_holes_2>(std::cout, "\n"));
std::cout << std::endl;
return 0;
}