#include #include #include #include #include #include #include #include #include #include #define bench(METHOD,CONTAINER) \ {\ std::size_t previous=0;\ unsigned run=0;\ CGAL::Timer time;\ do{\ result.clear();\ time.start();\ METHOD( CONTAINER.begin(), CONTAINER.end(), std::back_inserter(result) );\ time.stop();\ if( previous!=0 && previous!=result.size()) std::cerr << "error got different result" << std::endl;\ previous=result.size();\ }while(++run Points; typedef CGAL::Creator_uniform_2 Creator; int main(int argc, char** argv) { unsigned nbpts=100000; unsigned repeat=0; unsigned seed=0; if (argc>1) nbpts=atoi(argv[1]); if (argc>2) repeat=atoi(argv[2]); if (argc>3) seed=atoi(argv[3]); Points points, result; CGAL::Random r(seed); CGAL::Random_points_in_disc_2 g( 150.0,r); std::copy_n( g, nbpts, std::back_inserter(points)); //the following code is for testing when there is only two extreme points, affine hull is 2D /* CGAL::Bbox_2 bbox=points.begin()->bbox(); for (Points::iterator it=points.begin();it!=points.end();++it) bbox=bbox+it->bbox(); points.push_back( Point_2(bbox.xmin()-1,bbox.ymin()-1) ); points.push_back( Point_2(bbox.xmax()+1,bbox.ymax()+1) ); */ //the following code is for testing when there is only three extreme points /* CGAL::Bbox_2 bbox=points.begin()->bbox(); for (Points::iterator it=points.begin();it!=points.end();++it) bbox=bbox+it->bbox(); points.push_back( Point_2(bbox.xmin()-1,bbox.ymin()-1) ); points.push_back( Point_2(bbox.xmax()+1,bbox.ymax()+1) ); points.push_back( Point_2(bbox.xmax(),bbox.ymax()+2) ); */ //the following code is for testing when there is only two extreme points, affine hull is 1D /* points.clear(); for (unsigned i=0;i pt_list; std::copy(points.begin(),points.end(),std::back_inserter(pt_list)); std::cout << "Using list" << std::endl; bench(CGAL::convex_hull_2,pt_list) } }