CGAL 5.1 - Geometric Object Generators
Generator/random_degenerate_point_set.cpp
#include <CGAL/Simple_cartesian.h>
#include <cassert>
#include <vector>
#include <algorithm>
#include <CGAL/point_generators_2.h>
#include <CGAL/algorithm.h>
#include <CGAL/random_selection.h>
using namespace CGAL;
typedef R::Point_2 Point;
typedef std::vector<Point> Vector;
int main() {
// Create test point set. Prepare a vector for 1000 points.
Vector points;
points.reserve(1000);
// Create 600 points within a disc of radius 150.
std::copy_n( g, 600, std::back_inserter(points));
// Create 200 points from a 15 x 15 grid.
points_on_square_grid_2( 250.0, 200, std::back_inserter(points),Creator());
// Select 100 points randomly and append them at the end of
// the current vector of points.
random_selection( points.begin(), points.end(), 100,
std::back_inserter(points));
// Create 100 points that are collinear to two randomly chosen
// points and append them to the current vector of points.
random_collinear_points_2( points.begin(), points.end(), 100,
std::back_inserter( points));
// Check that we have really created 1000 points.
assert( points.size() == 1000);
// Use a random permutation to hide the creation history
// of the point set.
CGAL::cpp98::random_shuffle( points.begin(), points.end());
// Check range of values.
for ( Vector::iterator i = points.begin(); i != points.end(); i++){
assert( i->x() <= 251);
assert( i->x() >= -251);
assert( i->y() <= 251);
assert( i->y() >= -251);
}
return 0;
}
CGAL::Random_points_in_disc_2
The class Random_points_in_disc_2 is an input iterator creating points uniformly distributed in an op...
Definition: point_generators_2.h:158
CGAL::random_selection
OutputIterator random_selection(RandomAccessIterator first, RandomAccessIterator last, Size n, OutputIterator result, Random &rnd=get_default_random())
chooses n items at random from a random access iterator range which is useful to produce degenerate i...
CGAL::points_on_square_grid_2
OutputIterator points_on_square_grid_2(double a, std::size_t n, OutputIterator o, Creator creator=Creator_uniform_2< Kernel_traits< P >::Kernel::RT, P >)
generates a given number of points on a square grid whose size is determined by the number of points ...
CGAL::Creator_uniform_2
CGAL
CGAL::cpp98::random_shuffle
void random_shuffle(RandomAccessIterator begin, RandomAccessIterator end, RandomGenerator &random)
CGAL::random_collinear_points_2
OutputIterator random_collinear_points_2(RandomAccessIterator first, RandomAccessIterator last, std::size_t n, OutputIterator first2, Random &rnd=get_default_random(), Creator creator=Creator_uniform_2< Kernel_traits< P >::Kernel::RT, P >)
randomly chooses two points from the range [first,last), creates a random third point on the segment ...
copy_n
OutputIterator copy_n(InputIterator first, Size n, OutputIterator result)
CGAL::Simple_cartesian