diff --git a/Apollonius_graph_2/generators/gen_sites_in_0x1_box.cpp b/Apollonius_graph_2/generators/gen_sites_in_0x1_box.cpp new file mode 100644 index 00000000000..ec8268b8f0b --- /dev/null +++ b/Apollonius_graph_2/generators/gen_sites_in_0x1_box.cpp @@ -0,0 +1,52 @@ +#include +#include + +#include +#include +#include + +#include +#include + +typedef CGAL::Simple_cartesian K; +typedef CGAL::Apollonius_site_2 Site_2; + +int usage (int argc, char **argv) +{ + std::cerr << "usage: " << argv[0] + << " [seed]" << std::endl; + return 2; +} + + +int main (int argc, char **argv) +{ + int num, seed = 42; + double rmax; + + if (argc < 2) + return usage (argc, argv); + + { + std::istringstream is (argv[1]); + if (! (is >> num)) return usage (argc, argv); + } + { + std::istringstream is (argv[2]); + if (! (is >> rmax)) return usage (argc, argv); + } + if (argc > 3) { + std::istringstream is (argv[3]); + if (! (is >> seed)) return usage (argc, argv); + } + + CGAL::Random_sites_in_0x1_box g(rmax, seed); + + std::cout << std::setprecision(17); + + for (int i = 0; i < num; ++i) { + std::cout << *g << std::endl; + } + + return 0; +} diff --git a/Apollonius_graph_2/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h b/Apollonius_graph_2/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h new file mode 100644 index 00000000000..82c93820eba --- /dev/null +++ b/Apollonius_graph_2/generators/include/CGAL/Apollonius_graph_2/random_sites_in_0x1_box.h @@ -0,0 +1,37 @@ +#ifndef CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H +#define CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H 1 + +#include +#include + +CGAL_BEGIN_NAMESPACE + +template +class Random_sites_in_0x1_box +{ +public: + typedef Site Site_2; + typedef Site_2 result_type; + +private: + typedef typename Site_2::Point_2 Point_2; + +public: + Random_sites_in_0x1_box(double rmax = 0.125, int seed = 0) + : rmax_(rmax), random_(seed) {} + + Site_2 operator*() { + double x = random_.get_double(0, 1); + double y = random_.get_double(0, 1); + double w = random_.get_double(0, rmax_); + return Site_2(Point_2(x,y),w); + } + +private: + double rmax_; + Random random_; +}; + +CGAL_END_NAMESPACE + +#endif // CGAL_APOLLONIUS_GRAPH_2_RANDOM_SITES_IN_0X1_BOX_H