diff --git a/Generator/include/CGAL/convex_random_polygon_in_disc.h b/Generator/include/CGAL/convex_random_polygon_in_disc.h index 1d10629fec5..ad0c5679e98 100644 --- a/Generator/include/CGAL/convex_random_polygon_in_disc.h +++ b/Generator/include/CGAL/convex_random_polygon_in_disc.h @@ -1,4 +1,4 @@ -// Copyright (c) 1997 +// Copyright (c) 2014 // Utrecht University (The Netherlands), // ETH Zurich (Switzerland), // INRIA Sophia-Antipolis (France), @@ -28,7 +28,11 @@ #include #include #include + +#ifndef Q_MOC_RUN #include +#endif + #include #include #include @@ -89,7 +93,8 @@ namespace CGAL{ template void Cyclic_increment_iterator(typename std::list

::iterator & it,std::list

& l){ ++it; - if (it==l.end()) { + if (it==l.end()) + { it=l.begin(); } @@ -102,7 +107,8 @@ namespace CGAL{ Left_turn left_turn = ch_traits.left_turn_2_object(); typename std::list

::iterator pmin=l.begin(); for (typename std::list

::iterator it=l.begin(); it!=l.end(); ++it) { - if ((*pmin).x()>(*it).x()) { + if ((*pmin).x()>(*it).x()) + { pmin=it; } }//*pmin is the extremal point on the left @@ -142,24 +148,25 @@ namespace CGAL{ } //namespace CGAL::internal - using namespace internal; ////////////////////////////////////////////////////////////////////////////// - template - void convex_random_polygon(long n, double radius, std::list

& l,GEN & gen, bool fast=true ){ + template + void convex_random_polygon(size_t n, typename Kernel_traits

::Kernel::FT radius, std::list

& l,GEN & gen, bool fast=true ){ + CGAL_precondition( n >= 3); typedef typename Kernel_traits

::Kernel K; - long simulated_points=0; - long generated_points=0; + typedef typename Kernel_traits

::Kernel::FT FT; + size_t simulated_points=0; + size_t generated_points=0; do { //Initialisation - long init=std::min(( long)100,n-simulated_points); - generate_points_annulus(init,-CGAL_PI, CGAL_PI,0,radius,l,gen); + size_t init=std::min( (size_t)100,n-simulated_points ); + internal::generate_points_annulus(init,-CGAL_PI, CGAL_PI,0,radius,l,gen); simulated_points+=init; generated_points+=init; - Graham_without_sort_2(l,K()); + internal::Graham_without_sort_2(l,K()); } while ((bounded_side_2(l.begin(),l.end(),P (0,0),K())!=ON_BOUNDED_SIDE)&&(simulated_points::iterator it=l.begin(); typename std::list

::iterator it2=++it; - for(;it!=l.end();++it,Cyclic_increment_iterator(it2,l)){ //computation of annulus + for(;it!=l.end();++it,internal::Cyclic_increment_iterator(it2,l)){ //computation of annulus typename K::Segment_2 s(*it,*it2); - double temp=std::sqrt(to_double(squared_distance(s,zero))); - if (small_radius>temp) small_radius=temp; + FT temp=squared_distance(s,zero); + if (squared_small_radius>temp) squared_small_radius=temp; } - }//smallradius=small radius of the annulus + }//squared_small_radius=squared small radius of the annulus - double p_disc=((small_radius*small_radius)/(double)(radius*radius)); - long nb; - // double T=n/std::pow(log(simulated_points),2); + FT p_disc=squared_small_radius/squared_radius; + size_t nb; if (simulated_points< T){nb=std::min(simulated_points,n-simulated_points);} else {nb=std::min(T,n-simulated_points); } boost::random::binomial_distribution dbin(nb,p_disc); @@ -211,12 +218,12 @@ namespace CGAL{ std::list

m; m.clear(); - generate_points_annulus(nb-k_disc,-CGAL_PI, CGAL_PI,small_radius,radius,m,gen); - l.merge(m,compare_points_angle

()); + internal::generate_points_annulus(nb-k_disc,-CGAL_PI, CGAL_PI,std::sqrt(to_double(squared_small_radius)),to_double(radius),m,gen); + l.merge(m,internal::compare_points_angle

()); generated_points+=nb-k_disc; simulated_points+=nb-k_disc; m.clear(); - Graham_without_sort_2(l,K()); + internal::Graham_without_sort_2(l,K()); } } diff --git a/GraphicsView/demo/Generator/Generator_2.cpp b/GraphicsView/demo/Generator/Generator_2.cpp index ab568480244..676dd9d230e 100644 --- a/GraphicsView/demo/Generator/Generator_2.cpp +++ b/GraphicsView/demo/Generator/Generator_2.cpp @@ -5,12 +5,8 @@ #include #include #include - -// Boost -#ifndef Q_MOC_RUN #include -#endif // Qt headers #include