mirror of https://github.com/CGAL/cgal
1. "Snap_rounding_traits_2.h" "Snap_rounding_kd_2.h" "Kd_tree.h" "snap_rounding_data.cpp", Changed the File header signature to match the templated signatures.
2. Made the required changes in the concepts i.e. in "Snap_rounding_2/doc/Snap_rounding_2/Concepts/SnapRoundingTraits_2.h" 3. Added documentation for the reserve() method of Kd_tree 4. Deleted the un maintained olk kd_tree package
This commit is contained in:
parent
0e14493632
commit
1c355ef42a
|
|
@ -41,6 +41,11 @@ Models the concept `SRTraits_2::IsoRectangle_2`
|
||||||
*/
|
*/
|
||||||
typedef unspecified_type Iso_rectangle_2;
|
typedef unspecified_type Iso_rectangle_2;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Models the concept `SearchTraits::Cartesian_const_iterator_2`
|
||||||
|
*/
|
||||||
|
typedef unspecified_type Cartesian_const_iterator_2;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \name Functor Types
|
/// \name Functor Types
|
||||||
|
|
@ -93,6 +98,21 @@ Models the concept `SRTraits_2::MinkowskiSumWithPixel_2`.
|
||||||
*/
|
*/
|
||||||
typedef unspecified_type Minkowski_sum_with_pixel_2;
|
typedef unspecified_type Minkowski_sum_with_pixel_2;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Models the concept `ArrTraits::ConstructMinVertex_2`.
|
||||||
|
*/
|
||||||
|
typedef unspecified_type Construct_min_vertex_2;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Models the concept `ArrTraits::ConstructMaxVertex_2`.
|
||||||
|
*/
|
||||||
|
typedef unspecified_type Construct_max_vertex_2;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Models the concept `SearchTraits::Construct_cartesian_const_iterator_2`.
|
||||||
|
*/
|
||||||
|
typedef unspecified_type Construct_cartesian_const_iterator_2;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// \name Accessing Functor Objects
|
/// \name Accessing Functor Objects
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
// Copyright (c) 1999
|
// Copyright 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
|
||||||
// Utrecht University (The Netherlands),
|
// All rights reserved.
|
||||||
// ETH Zurich (Switzerland),
|
|
||||||
// INRIA Sophia-Antipolis (France),
|
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
|
||||||
// and Tel-Aviv University (Israel). All rights reserved.
|
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
// This file is part of CGAL (www.cgal.org).
|
||||||
// modify it under the terms of the GNU Lesser General Public License as
|
// You can redistribute it and/or modify it under the terms of the GNU
|
||||||
// published by the Free Software Foundation; either version 3 of the License,
|
// General Public License as published by the Free Software Foundation,
|
||||||
// or (at your option) any later version.
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
//
|
//
|
||||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// author(s) : Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// author(s) : Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
// Copyright (c) 1999
|
// Copyright (c) 2001 Tel-Aviv University (Israel).
|
||||||
// Utrecht University (The Netherlands),
|
// 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
|
||||||
// ETH Zurich (Switzerland),
|
// All rights reserved.
|
||||||
// INRIA Sophia-Antipolis (France),
|
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
|
||||||
// and Tel-Aviv University (Israel). All rights reserved.
|
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
// This file is part of CGAL (www.cgal.org).
|
||||||
// modify it under the terms of the GNU Lesser General Public License as
|
// You can redistribute it and/or modify it under the terms of the GNU
|
||||||
// published by the Free Software Foundation; either version 3 of the License,
|
// General Public License as published by the Free Software Foundation,
|
||||||
// or (at your option) any later version.
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
//
|
//
|
||||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
@ -17,7 +17,8 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// author(s) : Eli Packer <elip@post.tau.ac.il>, Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// author(s) : Eli Packer <elip@post.tau.ac.il>,
|
||||||
|
// Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
#ifndef CGAL_SNAP_ROUNDING_KD_2_H
|
#ifndef CGAL_SNAP_ROUNDING_KD_2_H
|
||||||
#define CGAL_SNAP_ROUNDING_KD_2_H
|
#define CGAL_SNAP_ROUNDING_KD_2_H
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,24 @@
|
||||||
// Copyright (c) 1999
|
// Copyright (c) 2001 Tel-Aviv University (Israel).
|
||||||
// Utrecht University (The Netherlands),
|
// 2009,2014 Max-Planck-Institute Saarbruecken (Germany).
|
||||||
// ETH Zurich (Switzerland),
|
// All rights reserved.
|
||||||
// INRIA Sophia-Antipolis (France),
|
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
|
||||||
// and Tel-Aviv University (Israel). All rights reserved.
|
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
// This file is part of CGAL (www.cgal.org).
|
||||||
// modify it under the terms of the GNU Lesser General Public License as
|
// You can redistribute it and/or modify it under the terms of the GNU
|
||||||
// published by the Free Software Foundation; either version 3 of the License,
|
// General Public License as published by the Free Software Foundation,
|
||||||
// or (at your option) any later version.
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
//
|
//
|
||||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
|
//
|
||||||
//
|
//
|
||||||
//
|
// author(s) : Eli Packer <elip@post.tau.ac.il>,
|
||||||
// author(s) : Eli Packer <elip@post.tau.ac.il>, Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
#ifndef CGAL_SNAP_ROUNDING_2_TRAITS_H
|
#ifndef CGAL_SNAP_ROUNDING_2_TRAITS_H
|
||||||
#define CGAL_SNAP_ROUNDING_2_TRAITS_H
|
#define CGAL_SNAP_ROUNDING_2_TRAITS_H
|
||||||
|
|
@ -201,7 +202,6 @@ public:
|
||||||
return k.construct_iso_rectangle_2_object();
|
return k.construct_iso_rectangle_2_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace CGAL
|
} //namespace CGAL
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,12 @@ The value type of the `InputIterator` must be `Point_d`.
|
||||||
*/
|
*/
|
||||||
template <class InputIterator> void insert(InputIterator first, InputIterator beyond);
|
template <class InputIterator> void insert(InputIterator first, InputIterator beyond);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Reserve the memory for the 'Points' vector to the 'size'
|
||||||
|
*/
|
||||||
|
void reserve(size_t size);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reports the points that are approximately contained by `q`.
|
Reports the points that are approximately contained by `q`.
|
||||||
The types `FuzzyQueryItem::Point_d` and `Point_d` must be equivalent.
|
The types `FuzzyQueryItem::Point_d` and `Point_d` must be equivalent.
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,23 @@
|
||||||
// Copyright (c) 1999
|
// Copyright (c) 2002,2011 Utrecht University (The Netherlands).
|
||||||
// Utrecht University (The Netherlands),
|
// 2009,2014 Max-Planck-Institute Saarbruecken (Germany)
|
||||||
// ETH Zurich (Switzerland),
|
// All rights reserved.
|
||||||
// INRIA Sophia-Antipolis (France),
|
|
||||||
// Max-Planck-Institute Saarbruecken (Germany),
|
|
||||||
// and Tel-Aviv University (Israel). All rights reserved.
|
|
||||||
//
|
//
|
||||||
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
|
// This file is part of CGAL (www.cgal.org).
|
||||||
// modify it under the terms of the GNU Lesser General Public License as
|
// You can redistribute it and/or modify it under the terms of the GNU
|
||||||
// published by the Free Software Foundation; either version 3 of the License,
|
// General Public License as published by the Free Software Foundation,
|
||||||
// or (at your option) any later version.
|
// either version 3 of the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Licensees holding a valid commercial license may use this file in
|
||||||
|
// accordance with the commercial license agreement provided with the software.
|
||||||
//
|
//
|
||||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
//
|
//
|
||||||
// $URL$
|
// $URL$
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// Author(s) : Hans Tangelder (<hanst@cs.uu.nl>), Waqar Khan <wkhan@mpi-inf.mpg.de>
|
// Author(s) : Hans Tangelder (<hanst@cs.uu.nl>),
|
||||||
|
// : Waqar Khan <wkhan@mpi-inf.mpg.de>
|
||||||
|
|
||||||
#ifndef CGAL_KD_TREE_H
|
#ifndef CGAL_KD_TREE_H
|
||||||
#define CGAL_KD_TREE_H
|
#define CGAL_KD_TREE_H
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
examples
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
3
|
|
||||||
3
|
|
||||||
7
|
|
||||||
7
|
|
||||||
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
// Copyright (c) 1997 Tel-Aviv University (Israel).
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This file is part of an example program for CGAL. This example
|
|
||||||
// program may be used, distributed and modified without limitation.
|
|
||||||
//
|
|
||||||
|
|
||||||
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
|
||||||
* example1.C -
|
|
||||||
* Simple example the CGAL KD-tree module.
|
|
||||||
*
|
|
||||||
* Written by Sariel Har-Peled
|
|
||||||
* Iddo Hanniel
|
|
||||||
\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <CGAL/kdtree_d.h>
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<double> K;
|
|
||||||
typedef K::Point_2 point;
|
|
||||||
typedef CGAL::Kdtree_interface_2d<point> kd_interface;
|
|
||||||
typedef CGAL::Kdtree_d<kd_interface> kd_tree;
|
|
||||||
typedef kd_tree::Box box;
|
|
||||||
typedef std::list<point> points_list;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
CGAL::Kdtree_d<kd_interface> tree(2);
|
|
||||||
points_list l, res;
|
|
||||||
|
|
||||||
std::srand( (unsigned)time(NULL) );
|
|
||||||
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
point p(i,j);
|
|
||||||
l.push_front(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
// building the tree
|
|
||||||
tree.build( l );
|
|
||||||
|
|
||||||
// checking validity
|
|
||||||
if ( ! tree.is_valid() )
|
|
||||||
tree.dump();
|
|
||||||
assert( tree.is_valid() );
|
|
||||||
|
|
||||||
// Defining and searching the box r
|
|
||||||
double lx,ly,rx,ry;
|
|
||||||
std::cout << "Define your query square.\nEnter left x coordinate: " ;
|
|
||||||
std::cin >> lx ;
|
|
||||||
std::cout << "Enter left y coordinate: ";
|
|
||||||
std::cin >> ly;
|
|
||||||
std::cout << "Enter right x coordinate: " ;
|
|
||||||
std::cin >> rx ;
|
|
||||||
std::cout << "Enter right y coordinate: ";
|
|
||||||
std::cin >> ry;
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
box r(point(lx,ly), point(rx,ry) ,2);
|
|
||||||
|
|
||||||
tree.search( std::back_inserter( res ), r );
|
|
||||||
|
|
||||||
std::cout << "Listing of the points in the square: \n" ;
|
|
||||||
std::copy (res.begin(),res.end(),std::ostream_iterator<point>(std::cout," \n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
tree.delete_all();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
// Copyright (c) 1997 Tel-Aviv University (Israel).
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This file is part of an example program for CGAL. This example
|
|
||||||
// program may be used, distributed and modified without limitation.
|
|
||||||
//
|
|
||||||
|
|
||||||
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
|
||||||
* example2.C -
|
|
||||||
* Simple example the CGAL KD-tree module.
|
|
||||||
*
|
|
||||||
* Written by Sariel Har-Peled
|
|
||||||
* Iddo Hanniel
|
|
||||||
\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <CGAL/kdtree_d.h>
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<double> K;
|
|
||||||
typedef K::Point_3 point;
|
|
||||||
typedef CGAL::Kdtree_interface_3d<point> kd_interface;
|
|
||||||
typedef CGAL::Kdtree_d<kd_interface> kd_tree;
|
|
||||||
typedef kd_tree::Box box;
|
|
||||||
typedef std::list<point> points_list;
|
|
||||||
|
|
||||||
//RANDOM FUNCTIONS
|
|
||||||
// dblRand - a random number between 0..1
|
|
||||||
#ifndef RAND_MAX
|
|
||||||
#define RAND_MAX 0x7fffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline double dblRand( void )
|
|
||||||
{
|
|
||||||
return (double)std::rand() / (double)RAND_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void random_points( int num, points_list &l )
|
|
||||||
{
|
|
||||||
double x,y,z;
|
|
||||||
|
|
||||||
for (int j = 0; j < num; j++)
|
|
||||||
{
|
|
||||||
x = dblRand()*10 ;
|
|
||||||
y = dblRand()*10 ;
|
|
||||||
z = dblRand()*10 ;
|
|
||||||
point p(x,y,z);
|
|
||||||
l.push_front(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
CGAL::Kdtree_d<kd_interface> tree(3);
|
|
||||||
|
|
||||||
std::srand( (unsigned)time(NULL) );
|
|
||||||
|
|
||||||
std::cout << "Choosing randomly 30 points in the cube (0,0,0)-(10,10,10)\n" ;
|
|
||||||
|
|
||||||
points_list l , res;
|
|
||||||
random_points( 30, l);
|
|
||||||
|
|
||||||
std::cout << "Listing of random points:\n" ;
|
|
||||||
std::copy (l.begin(),l.end(),std::ostream_iterator<point>(std::cout,"\n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
// Building the tree for the random points
|
|
||||||
tree.build( l );
|
|
||||||
|
|
||||||
// Checking validity
|
|
||||||
if ( ! tree.is_valid() )
|
|
||||||
tree.dump();
|
|
||||||
assert( tree.is_valid() );
|
|
||||||
|
|
||||||
// Searching the box r
|
|
||||||
box r(point(2,2,2), point(7,7,7) ,3);
|
|
||||||
tree.search( std::back_inserter( res ), r );
|
|
||||||
|
|
||||||
std::cout << "Listing of the points in the box (2,2,2)-(7,7,7) : \n" ;
|
|
||||||
std::copy (res.begin(),res.end(),std::ostream_iterator<point>(std::cout,"\n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
tree.delete_all();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
// Copyright (c) 1997 Tel-Aviv University (Israel).
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This file is part of an example program for CGAL. This example
|
|
||||||
// program may be used, distributed and modified without limitation.
|
|
||||||
//
|
|
||||||
|
|
||||||
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
|
||||||
* example3.C -
|
|
||||||
* Simple example the CGAL KD-tree module.
|
|
||||||
* Example with user defined point_d.
|
|
||||||
*
|
|
||||||
* Written by Sariel Har-Peled
|
|
||||||
* Iddo Hanniel
|
|
||||||
\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <CGAL/kdtree_d.h>
|
|
||||||
|
|
||||||
template <int DIM>
|
|
||||||
class Point_float_d
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
double vec[ DIM ];
|
|
||||||
|
|
||||||
public:
|
|
||||||
Point_float_d()
|
|
||||||
{
|
|
||||||
for ( int ind = 0; ind < DIM; ind++ )
|
|
||||||
vec[ ind ] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int dimension() const
|
|
||||||
{
|
|
||||||
return DIM;
|
|
||||||
}
|
|
||||||
|
|
||||||
//not essential by specification but needed for initializing a general d-point
|
|
||||||
void set_coord(int k, double x)
|
|
||||||
{
|
|
||||||
assert( 0 <= k && k < DIM );
|
|
||||||
vec[ k ] = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
double & operator[](int k)
|
|
||||||
{
|
|
||||||
assert( 0 <= k && k < DIM );
|
|
||||||
return vec[ k ];
|
|
||||||
}
|
|
||||||
|
|
||||||
double operator[](int k) const
|
|
||||||
{
|
|
||||||
assert( 0 <= k && k < DIM );
|
|
||||||
return vec[ k ];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// not essential by specification but nice to have
|
|
||||||
template <int DIM>
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Point_float_d<DIM> &p)
|
|
||||||
{
|
|
||||||
std::cout << "(";
|
|
||||||
for(int i = 0; i < DIM; i++)
|
|
||||||
{
|
|
||||||
std::cout << p[i] ;
|
|
||||||
if (i < p.dimension() - 1) std::cout << ", ";
|
|
||||||
}
|
|
||||||
std::cout << ")";
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef Point_float_d<4> point;
|
|
||||||
typedef CGAL::Kdtree_interface<point> kd_interface;
|
|
||||||
typedef CGAL::Kdtree_d<kd_interface> kd_tree;
|
|
||||||
typedef kd_tree::Box box;
|
|
||||||
typedef std::list<point> points_list;
|
|
||||||
|
|
||||||
//RANDOM FUNCTIONS
|
|
||||||
// dblRand - a random number between 0..1
|
|
||||||
#ifndef RAND_MAX
|
|
||||||
#define RAND_MAX 0x7fffffff
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline double dblRand( void )
|
|
||||||
{
|
|
||||||
return (double)std::rand() / (double)RAND_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
void random_points( int num, points_list &l, int DIM)
|
|
||||||
{
|
|
||||||
double x;
|
|
||||||
|
|
||||||
for (int j = 0; j < num; j++)
|
|
||||||
{
|
|
||||||
point p;
|
|
||||||
for (int i=0; i<DIM; i++)
|
|
||||||
{
|
|
||||||
x = dblRand()*10 ;
|
|
||||||
p.set_coord(i,x);
|
|
||||||
}
|
|
||||||
l.push_front(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
CGAL::Kdtree_d<kd_interface> tree(3);
|
|
||||||
|
|
||||||
std::srand( (unsigned)time(NULL) );
|
|
||||||
|
|
||||||
std::cout << "Choosing randomly 30 points in the cube (0,0,0)-(10,10,10)\n" ;
|
|
||||||
|
|
||||||
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<point>(std::cout,"\n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
// Building the tree for the random points
|
|
||||||
tree.build( l );
|
|
||||||
|
|
||||||
// Checking validity
|
|
||||||
if ( ! tree.is_valid() )
|
|
||||||
tree.dump();
|
|
||||||
assert( tree.is_valid() );
|
|
||||||
|
|
||||||
// Searching the box r
|
|
||||||
point p,q;
|
|
||||||
for (int k=0;k<4;k++)
|
|
||||||
{
|
|
||||||
p.set_coord(k,2);
|
|
||||||
q.set_coord(k,8);
|
|
||||||
}
|
|
||||||
|
|
||||||
box r(p, q, 4);
|
|
||||||
tree.search( std::back_inserter( res ), r );
|
|
||||||
|
|
||||||
std::cout << "Listing of the points in the box (2,2,2,2)-(8,8,8,8) : \n" ;
|
|
||||||
std::copy (res.begin(),res.end(),
|
|
||||||
std::ostream_iterator<point>(std::cout,"\n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
tree.delete_all();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
@ -1,86 +0,0 @@
|
||||||
// Copyright (c) 1997 Tel-Aviv University (Israel).
|
|
||||||
// All rights reserved.
|
|
||||||
//
|
|
||||||
// This file is part of an example program for CGAL. This example
|
|
||||||
// program may be used, distributed and modified without limitation.
|
|
||||||
//
|
|
||||||
|
|
||||||
/*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
|
|
||||||
* example2.C - bench mark
|
|
||||||
* Simple example the CGAL KD-tree module.
|
|
||||||
*
|
|
||||||
* Written by Sariel Har-Peled
|
|
||||||
* Iddo Hanniel
|
|
||||||
\*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*/
|
|
||||||
|
|
||||||
#include <CGAL/Cartesian.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iterator>
|
|
||||||
#include <ctime>
|
|
||||||
#include <cassert>
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
#include <CGAL/kdtree_d.h>
|
|
||||||
#include <CGAL/Timer.h>
|
|
||||||
#include <CGAL/Random.h>
|
|
||||||
|
|
||||||
typedef CGAL::Cartesian<double> K;
|
|
||||||
typedef K::Point_3 Point;
|
|
||||||
typedef CGAL::Kdtree_interface_3d<Point> kd_interface;
|
|
||||||
typedef CGAL::Kdtree_d<kd_interface> kd_tree;
|
|
||||||
typedef kd_tree::Box box;
|
|
||||||
typedef std::list<Point> points_list;
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
CGAL::Kdtree_d<kd_interface> tree(3);
|
|
||||||
CGAL::Timer t;
|
|
||||||
const int dim=3;
|
|
||||||
|
|
||||||
// const int data_point_number=1000000;
|
|
||||||
const int data_point_number=10000;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef std::list<Point> point_list;
|
|
||||||
point_list data_points,res;
|
|
||||||
|
|
||||||
// get data points
|
|
||||||
|
|
||||||
// add random points of dimension dim to data_points
|
|
||||||
CGAL::Random Rnd;
|
|
||||||
// std::cout << "started tstrandom()" << std::endl;
|
|
||||||
for (int i1=0; i1<data_point_number; i1++) {
|
|
||||||
double v[dim];
|
|
||||||
for (int i2=0; i2<dim; i2++) v[i2]=Rnd.get_double(-1.0,1.0);
|
|
||||||
Point Random_point(v[0],v[1],v[2]);
|
|
||||||
data_points.push_front(Random_point);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
t.reset();t.start();
|
|
||||||
tree.build(data_points);
|
|
||||||
t.stop();
|
|
||||||
std::cout << "building time =" << t.time() << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
// Searching the box r
|
|
||||||
t.reset();t.start();
|
|
||||||
box r(Point(0.2,0.2,0.2), Point(0.7,0.7,0.7) ,3);
|
|
||||||
tree.search( std::back_inserter( res ), r );
|
|
||||||
t.stop();
|
|
||||||
std::cout << "searching time=" << t.time() << std::endl;
|
|
||||||
|
|
||||||
|
|
||||||
std::cout << "Number of the points in the box (0.2,0.2,0.2)-(0.7,0.7,0.7) = " <<
|
|
||||||
res.size();
|
|
||||||
// std::copy (res.begin(),res.end(),std::ostream_iterator<point>(std::cout,"\n") );
|
|
||||||
std::cout << std::endl;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1 +0,0 @@
|
||||||
Tel-Aviv University (Israel).
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
The KD-tree implementation .
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
GPL (v3 or later)
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
CGAL KD-tree impelementation
|
|
||||||
----------------------------
|
|
||||||
|
|
||||||
The following contains the CGAL KD-tree implementation. The examples/kdtrees/
|
|
||||||
directory contains three simple examples for the use of kd-trees in 2D, 3D
|
|
||||||
(using points from the Cgal kernel) and 4D (using user-defined points).
|
|
||||||
|
|
||||||
The source is under include/CGAL/kdtree_d.h, and it can be used
|
|
||||||
independently from the rest of CGAL.
|
|
||||||
|
|
||||||
-----------------------------------------------------------------------
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
cgal-develop
|
|
||||||
Loading…
Reference in New Issue