// ============================================================================ // // Copyright (c) 2000 The GALIA Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------------- // // release : $CGAL_Revision $ // release_date : $CGAL_Date $ // // file : test/Generator/random_poly_test.C // package : $CGAL_Package: Generator 2.12 (28 Jul 1999) $ // revision : $Id$ // revision_date : $Date$ // author(s) : Susan Hert // // coordinator : ETH Zurich (Bernd Gaertner ) // // Random Simple Polygons: Test Program // ============================================================================ #define CGAL_DONT_SHUFFLE_IN_RANDOM_POLYGON_2 #include #include #include #include #include #include #include #include #include #include template void test_fold() { // (-5, -7) is on [(-9, 5); (-2, -16)] std::array input {typename K::Point_2{-5,-7},{7,-85},{-9,5},{-2,-16}}; int i = 0; do { std::cout << "permutation #" << i++ << std::endl; for(const auto& pt : input) std::cout << " (" << pt << ")"; std::cout << std::endl; CGAL::Polygon_2 polygon; CGAL::random_polygon_2(input.size(), std::back_inserter(polygon), input.begin()); if (! polygon.is_simple()) { std::cerr << "ERROR: polygon is not simple." << std::endl; assert(false); } } while(std::next_permutation(input.begin(), input.end())); } template void test_random() { typedef CGAL::Point_2< K > 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; Polygon_2 polygon; int n = 50; // create a polygon CGAL::random_polygon_2(n, std::back_inserter(polygon), Point_generator(0.5)); // make sure it is simple if (! polygon.is_simple()) { std::cerr << "ERROR: polygon is not simple." << std::endl; assert(false); } } int main() { typedef CGAL::Simple_cartesian CK; typedef CGAL::Homogeneous HK; test_random(); test_random(); test_fold(); test_fold(); std::cout << "Done!" << std::endl; return EXIT_SUCCESS; }