diff --git a/Generator/benchmark/Generator/CMakeLists.txt b/Generator/benchmark/Generator/CMakeLists.txt new file mode 100644 index 00000000000..22b7ea11e27 --- /dev/null +++ b/Generator/benchmark/Generator/CMakeLists.txt @@ -0,0 +1,33 @@ +# Created by the script cgal_create_cmake_script +# This is the CMake script for compiling a CGAL application. + + +project( Generator_example ) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5) + +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + +if ( COMMAND cmake_policy ) + cmake_policy( SET CMP0003 NEW ) +endif() + +find_package(CGAL QUIET COMPONENTS Core ) + +if ( CGAL_FOUND ) + + include( ${CGAL_USE_FILE} ) + + include( CGAL_CreateSingleSourceCGALProgram ) + + include_directories (BEFORE ../../include) + + create_single_source_cgal_program( "random_grid.cpp" ) + create_single_source_cgal_program( "random_disc_2.cpp" ) + +else() + + message(STATUS "This program requires the CGAL library, and will not be compiled.") + +endif() + diff --git a/Generator/benchmark/Generator/random_disc_2.cpp b/Generator/benchmark/Generator/random_disc_2.cpp new file mode 100755 index 00000000000..9730693d790 --- /dev/null +++ b/Generator/benchmark/Generator/random_disc_2.cpp @@ -0,0 +1,68 @@ + +#include +namespace po = boost::program_options; + +#include +#include +#include +#include +#include +#include + +using namespace CGAL; + +typedef Simple_cartesian K; +typedef K::Point_2 Point; +typedef Creator_uniform_2 Creator; + + +void +disk(int N, double radius) +{ + std::cout.precision(12); + CGAL::Random_points_in_disc_2 rng(radius); + std::cout << N << std::endl; + for(double i = 0; i < N; i++){ + std::cout << *rng << std::endl; + ++rng; + } +} + +int main(int argc, char* argv[]) +{ + int N= 10; + double radius = 1; + try { + + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "Generator of perturbed points in a disk") + ("N", po::value(), "generate N points") + ("radius", po::value(), "radius of the disc") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + if (vm.count("N")) { + N = vm["N"].as(); + } + + if (vm.count("radius")) { + radius = vm["radius"].as(); + } + } + catch(std::exception& e) { + std::cerr << "error: " << e.what() << "\n"; + return 1; + } + + disk(N, radius); + return 0; +} diff --git a/Generator/benchmark/Generator/random_grid.cpp b/Generator/benchmark/Generator/random_grid.cpp new file mode 100644 index 00000000000..0b80e73405a --- /dev/null +++ b/Generator/benchmark/Generator/random_grid.cpp @@ -0,0 +1,69 @@ + +#include +namespace po = boost::program_options; + +#include +#include +#include +#include +#include +#include + +using namespace CGAL; + +typedef Simple_cartesian K; +typedef K::Point_2 Point; +typedef Creator_uniform_2 Creator; + + +void +grid(int N, double eps) +{ + CGAL::Random rng; + std::cout << N*N << std::endl; + for(double i = 0; i < N; i++){ + for(double j = 0; j < N; j++){ + std::cout << i + rng.get_double(-eps,eps) << " " + << j + rng.get_double(-eps,eps) << "\n"; + } + } +} + +int main(int argc, char* argv[]) +{ + int N= 10; + double eps = 0; + try { + + po::options_description desc("Allowed options"); + desc.add_options() + ("help", "Generator of perturbed points on a grid") + ("N", po::value(), "generate a grid with N x N points") + ("eps", po::value(), "perturb x and y of points by eps") + ; + + po::variables_map vm; + po::store(po::parse_command_line(argc, argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + std::cout << desc << "\n"; + return 1; + } + + if (vm.count("N")) { + N = vm["N"].as(); + } + + if (vm.count("eps")) { + eps = vm["eps"].as(); + } + } + catch(std::exception& e) { + std::cerr << "error: " << e.what() << "\n"; + return 1; + } + + grid(N,eps); + return 0; +} diff --git a/Generator/dont_submit b/Generator/dont_submit index add565083f2..b30fda9b996 100644 --- a/Generator/dont_submit +++ b/Generator/dont_submit @@ -1 +1,2 @@ qt3 +benchmark