Add generators for benchmark data sets

This commit is contained in:
Andreas Fabri 2010-11-22 12:45:29 +00:00
parent 76fca27990
commit cc155db930
4 changed files with 171 additions and 0 deletions

View File

@ -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()

View File

@ -0,0 +1,68 @@
#include <boost/program_options.hpp>
namespace po = boost::program_options;
#include <CGAL/Simple_cartesian.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/point_generators_2.h>
#include <CGAL/algorithm.h>
using namespace CGAL;
typedef Simple_cartesian<double> K;
typedef K::Point_2 Point;
typedef Creator_uniform_2<int,Point> Creator;
void
disk(int N, double radius)
{
std::cout.precision(12);
CGAL::Random_points_in_disc_2<Point> 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<int>(), "generate N points")
("radius", po::value<double>(), "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<int>();
}
if (vm.count("radius")) {
radius = vm["radius"].as<double>();
}
}
catch(std::exception& e) {
std::cerr << "error: " << e.what() << "\n";
return 1;
}
disk(N, radius);
return 0;
}

View File

@ -0,0 +1,69 @@
#include <boost/program_options.hpp>
namespace po = boost::program_options;
#include <CGAL/Simple_cartesian.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/point_generators_2.h>
#include <CGAL/algorithm.h>
using namespace CGAL;
typedef Simple_cartesian<int> K;
typedef K::Point_2 Point;
typedef Creator_uniform_2<int,Point> 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<int>(), "generate a grid with N x N points")
("eps", po::value<double>(), "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<int>();
}
if (vm.count("eps")) {
eps = vm["eps"].as<double>();
}
}
catch(std::exception& e) {
std::cerr << "error: " << e.what() << "\n";
return 1;
}
grid(N,eps);
return 0;
}

View File

@ -1 +1,2 @@
qt3
benchmark