diff --git a/Packages/kdtree/changes.txt b/Packages/kdtree/changes.txt index 308cc49799b..1e535a4909f 100644 --- a/Packages/kdtree/changes.txt +++ b/Packages/kdtree/changes.txt @@ -1,3 +1,5 @@ +2.2.16 Example code cleanups. + 2.2.15 Small corrections in documentation 2.2.13 Hans Tangelder adapted style of documentation by diff --git a/Packages/kdtree/examples/kdtrees/example1.C b/Packages/kdtree/examples/kdtrees/example1.C index 8d8c47fc5ab..4bc6a7668a5 100644 --- a/Packages/kdtree/examples/kdtrees/example1.C +++ b/Packages/kdtree/examples/kdtrees/example1.C @@ -6,38 +6,30 @@ * Iddo Hanniel \*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ -//might be needed when compiling with g++-2.7.2 -//#ifdef __GNUG__ -//#include -//#endif /* __GNUG__ */ -#include +#include #include #include #include - -#include -#include - #include -#include +#include -typedef CGAL::Point_2 > point; +typedef CGAL::Cartesian K; +typedef K::Point_2 point; typedef CGAL::Kdtree_interface_2d kd_interface; -typedef CGAL::Kdtree_d kd_tree; -typedef kd_tree::Box box; -typedef std::list points_list; +typedef CGAL::Kdtree_d kd_tree; +typedef kd_tree::Box box; +typedef std::list points_list; -int main() +int main() { - - CGAL::Kdtree_d tree(2); - points_list l , res; + CGAL::Kdtree_d tree(2); + points_list l, res; srand( (unsigned)time(NULL) ); - std::cout << "Insering evenly 81 points in the square (0,0)-(10,10) ...\n\n" ; + std::cout << "Insering evenly 81 points in the square (0,0)-(10,10) ...\n\n"; for (int i=1; i<10; i++) for (int j=1; j<10; j++) { @@ -48,13 +40,12 @@ int main() // building the tree for the random points tree.build( l ); - //checking validity + // checking validity if ( ! tree.is_valid() ) tree.dump(); assert( tree.is_valid() ); - - //defining and searching the box r + // Defining and searching the box r double lx,ly,rx,ry; std::cout << "Define your query square.\nEnter left x coordinate: " ; std::cin >> lx ; @@ -76,12 +67,5 @@ int main() tree.delete_all(); - - return 0; } - - - - - diff --git a/Packages/kdtree/examples/kdtrees/example2.C b/Packages/kdtree/examples/kdtrees/example2.C index d9575790681..2324527a967 100644 --- a/Packages/kdtree/examples/kdtrees/example2.C +++ b/Packages/kdtree/examples/kdtrees/example2.C @@ -6,44 +6,33 @@ * Iddo Hanniel \*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ -//might be needed when compiling with g++-2.7.2 -//#ifdef __GNUG__ -//#include -//#endif /* __GNUG__ */ -#include +#include + #include #include #include - -#include -#include - #include #include -typedef CGAL::Point_3 > point; +typedef CGAL::Cartesian K; +typedef K::Point_3 point; typedef CGAL::Kdtree_interface_3d kd_interface; -typedef CGAL::Kdtree_d kd_tree; -typedef kd_tree::Box box; -typedef std::list points_list; - - - - +typedef CGAL::Kdtree_d kd_tree; +typedef kd_tree::Box box; +typedef std::list points_list; //RANDOM FUNCTIONS // dblRand - a random number between 0..1 #ifndef RAND_MAX #define RAND_MAX 0x7fffffff -#endif // RAND_MAX +#endif -static inline double dblRand( void ) +inline double dblRand( void ) { - return (double)rand() / (double)RAND_MAX; + return (double)rand() / (double)RAND_MAX; } - void random_points( int num, points_list &l ) { double x,y,z; @@ -56,13 +45,10 @@ void random_points( int num, points_list &l ) point p(x,y,z); l.push_front(p); } - } - -int main() +int main() { - CGAL::Kdtree_d tree(3); srand( (unsigned)time(NULL) ); @@ -72,21 +58,19 @@ int main() points_list l , res; random_points( 30, l); - std::cout << "Listing of random points:\n" ; std::copy (l.begin(),l.end(),std::ostream_iterator(std::cout,"\n") ); std::cout << std::endl; - // building the tree for the random points + // Building the tree for the random points tree.build( l ); - //checking validity + // Checking validity if ( ! tree.is_valid() ) tree.dump(); assert( tree.is_valid() ); - - //searching the box r + // Searching the box r box r(point(2,2,2), point(7,7,7) ,3); tree.search( std::back_inserter( res ), r ); @@ -96,15 +80,5 @@ int main() tree.delete_all(); - - - return 0; + return 0; } - - - - - - - - diff --git a/Packages/kdtree/examples/kdtrees/example3.C b/Packages/kdtree/examples/kdtrees/example3.C index 382ca0ad190..da0e9c95d83 100644 --- a/Packages/kdtree/examples/kdtrees/example3.C +++ b/Packages/kdtree/examples/kdtrees/example3.C @@ -7,23 +7,14 @@ * Iddo Hanniel \*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/ -//might be needed when compiling with g++-2.7.2 -//#ifdef __GNUG__ -//#include -//#endif /* __GNUG__ */ -#include +#include + #include #include #include - -#include -#include - #include -#include - - +#include template class Point_float_d @@ -76,7 +67,6 @@ std::ostream &operator<<(std::ostream &os, const Point_float_d &p) std::cout << ")"; return os; } - typedef Point_float_d<4> point; typedef CGAL::Kdtree_interface kd_interface; @@ -84,19 +74,17 @@ typedef CGAL::Kdtree_d kd_tree; typedef kd_tree::Box box; typedef std::list points_list; - //RANDOM FUNCTIONS // dblRand - a random number between 0..1 #ifndef RAND_MAX #define RAND_MAX 0x7fffffff -#endif // RAND_MAX +#endif -static inline double dblRand( void ) +inline double dblRand( void ) { return (double)rand() / (double)RAND_MAX; } - void random_points( int num, points_list &l, int DIM) { double x; @@ -113,10 +101,8 @@ void random_points( int num, points_list &l, int DIM) } } - -int main() +int main() { - CGAL::Kdtree_d tree(3); srand( (unsigned)time(NULL) ); @@ -126,21 +112,19 @@ int main() points_list l , res; random_points( 30, l , 4); - std::cout << "Listing of random points:\n" ; std::copy (l.begin(),l.end(),std::ostream_iterator(std::cout,"\n") ); std::cout << std::endl; - // building the tree for the random points + // Building the tree for the random points tree.build( l ); - //checking validity + // Checking validity if ( ! tree.is_valid() ) tree.dump(); assert( tree.is_valid() ); - - //searching the box r + // Searching the box r point p,q; for (int k=0;k<4;k++) { @@ -157,16 +141,6 @@ int main() std::cout << std::endl; tree.delete_all(); - - - - return 0; + + return 0; } - - - - - - - -