#include #include #include #include #include #include #ifdef CGAL_USE_GMP #include typedef CGAL::Gmpz RT; #else // NOTE: the choice of double here for a number type may cause problems // for degenerate point sets #include typedef double RT; #endif #include #include typedef CGAL::Simple_cartesian K; typedef K::Point_2 Point_2; typedef std::list Container; typedef CGAL::Polygon_2 Polygon_2; typedef CGAL::Creator_uniform_2 Creator; typedef CGAL::Random_points_in_square_2 Point_generator; const double RADIUS = 100; const int MAX_POLY_SIZE = 100; int main() { Polygon_2 polygon; std::list point_set; CGAL::Random rand; std::cerr << "Seed = " << rand.get_seed() << std::endl; int size = rand.get_int(4, MAX_POLY_SIZE); // copy size points from the generator, eliminating duplicates, so the // polygon will have <= size vertices CGAL::copy_n_unique(Point_generator(RADIUS), size, std::back_inserter(point_set)); std::ostream_iterator< Point_2 > out( std::cout, " " ); std::cout << "From the following " << point_set.size() << " points " << std::endl; std::copy(point_set.begin(), point_set.end(), out); std::cout << std::endl; CGAL::random_polygon_2(point_set.size(), std::back_inserter(polygon), point_set.begin()); std::cout << "The following simple polygon was made: " << std::endl; std::cout << polygon << std::endl; return 0; }