mirror of https://github.com/CGAL/cgal
Completely revised version. build function replaced by creator
function objects. Three creators for 3D points added. Segment generator replaced by examples based on Join_input_iterator. Points on segment also as iterator.
This commit is contained in:
parent
cf4600e1fc
commit
5150958da3
|
|
@ -11,10 +11,11 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/random_selection.h>
|
||||
#include <CGAL/IO/Window_stream.h> /* only for visualization used */
|
||||
#include <CGAL/IO/Window_stream.h> /* only used for visualization */
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Creator_uniform_2<double,Point> Creator;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -23,11 +24,11 @@ int main()
|
|||
points.reserve(1000);
|
||||
|
||||
/* Create 600 points within a disc of radius 150. */
|
||||
CGAL_Random_points_in_disc_2<Point> g( 150.0);
|
||||
CGAL_Random_points_in_disc_2<Point,Creator> g( 150.0);
|
||||
CGAL_copy_n( g, 600, back_inserter( points));
|
||||
|
||||
/* Create 200 points from a 15 x 15 grid. */
|
||||
CGAL_points_on_square_grid_2( 500.0, 200, back_inserter(points),(Point*)0);
|
||||
CGAL_points_on_square_grid_2( 250.0, 200, back_inserter(points),Creator());
|
||||
|
||||
/* Select 100 points randomly and append them at the end of */
|
||||
/* the current vector of points. */
|
||||
|
|
|
|||
|
|
@ -8,21 +8,13 @@
|
|||
#include <algo.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Point_2.h>
|
||||
|
||||
typedef CGAL_Cartesian<int> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
|
||||
/* Provide your own CGAL_build_point function. */
|
||||
inline
|
||||
Point& CGAL_build_point( double x, double y, Point& p) {
|
||||
p = Point( int(x), int(y));
|
||||
return p;
|
||||
}
|
||||
|
||||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/IO/Window_stream.h> /* only for visualization used */
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Creator_uniform_2<double,Point> Creator;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -33,7 +25,7 @@ int main()
|
|||
/* Create 250 points from a 16 x 16 grid. Note that the double */
|
||||
/* arithmetic _is_ sufficient to produce exact integer grid points. */
|
||||
/* The distance between neighbors is 34 pixel = 510 / 15. */
|
||||
CGAL_points_on_square_grid_2( 510.0, 250, back_inserter(points),(Point*)0);
|
||||
CGAL_points_on_square_grid_2( 255.0, 250, back_inserter(points),Creator());
|
||||
|
||||
/* Lower, left corner. */
|
||||
assert( points[0].x() == -255);
|
||||
|
|
@ -44,7 +36,7 @@ int main()
|
|||
assert( points[249].y() == 255);
|
||||
|
||||
/* Create 250 points within a disc of radius 150. */
|
||||
CGAL_Random_points_in_disc_2<Point> g( 150.0);
|
||||
CGAL_Random_points_in_disc_2<Point,Creator> g( 150.0);
|
||||
CGAL_copy_n( g, 250, back_inserter( points));
|
||||
|
||||
/* Check that we have really created 500 points. */
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@
|
|||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/random_selection.h>
|
||||
#include <CGAL/IO/Window_stream.h> /* only for visualization used */
|
||||
#include <CGAL/IO/Window_stream.h> /* only used for visualization */
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Creator_uniform_2<double,Point> Creator;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -23,11 +24,11 @@ int main()
|
|||
points.reserve(1000);
|
||||
|
||||
/* Create 600 points within a disc of radius 150. */
|
||||
CGAL_Random_points_in_disc_2<Point> g( 150.0);
|
||||
CGAL_Random_points_in_disc_2<Point,Creator> g( 150.0);
|
||||
CGAL_copy_n( g, 600, back_inserter( points));
|
||||
|
||||
/* Create 200 points from a 15 x 15 grid. */
|
||||
CGAL_points_on_square_grid_2( 500.0, 200, back_inserter(points),(Point*)0);
|
||||
CGAL_points_on_square_grid_2( 250.0, 200, back_inserter(points),Creator());
|
||||
|
||||
/* Select 100 points randomly and append them at the end of */
|
||||
/* the current vector of points. */
|
||||
|
|
|
|||
|
|
@ -8,21 +8,13 @@
|
|||
#include <algo.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Point_2.h>
|
||||
|
||||
typedef CGAL_Cartesian<int> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
|
||||
/* Provide your own CGAL_build_point function. */
|
||||
inline
|
||||
Point& CGAL_build_point( double x, double y, Point& p) {
|
||||
p = Point( int(x), int(y));
|
||||
return p;
|
||||
}
|
||||
|
||||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/copy_n.h>
|
||||
#include <CGAL/IO/Window_stream.h> /* only for visualization used */
|
||||
|
||||
typedef CGAL_Cartesian<double> R;
|
||||
typedef CGAL_Point_2<R> Point;
|
||||
typedef CGAL_Creator_uniform_2<double,Point> Creator;
|
||||
|
||||
int main()
|
||||
{
|
||||
|
|
@ -33,7 +25,7 @@ int main()
|
|||
/* Create 250 points from a 16 x 16 grid. Note that the double */
|
||||
/* arithmetic _is_ sufficient to produce exact integer grid points. */
|
||||
/* The distance between neighbors is 34 pixel = 510 / 15. */
|
||||
CGAL_points_on_square_grid_2( 510.0, 250, back_inserter(points),(Point*)0);
|
||||
CGAL_points_on_square_grid_2( 255.0, 250, back_inserter(points),Creator());
|
||||
|
||||
/* Lower, left corner. */
|
||||
assert( points[0].x() == -255);
|
||||
|
|
@ -44,7 +36,7 @@ int main()
|
|||
assert( points[249].y() == 255);
|
||||
|
||||
/* Create 250 points within a disc of radius 150. */
|
||||
CGAL_Random_points_in_disc_2<Point> g( 150.0);
|
||||
CGAL_Random_points_in_disc_2<Point,Creator> g( 150.0);
|
||||
CGAL_copy_n( g, 250, back_inserter( points));
|
||||
|
||||
/* Check that we have really created 500 points. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue