5 #ifndef _KSEARCHTREE_H_
6 #define _KSEARCHTREE_H_
12 #include <CGAL/basic.h>
13 #include <CGAL/Search_traits.h>
14 #include <CGAL/Orthogonal_k_neighbor_search.h>
51 {
return &(p.
vec[0]); }
54 {
return &(p.
vec[0])+3; }
64 double distx= p1.
vec[0]-p2.
vec[0];
65 double disty= p1.
vec[1]-p2.
vec[1];
66 double distz= p1.
vec[2]-p2.
vec[2];
67 return distx*distx+disty*disty+distz*distz;
70 template <
class TreeTraits>
72 const CGAL::Kd_tree_rectangle<TreeTraits>& b)
const
74 double distance(0.0), h = p.
vec[0];
75 if (h < b.min_coord(0)) distance += (b.min_coord(0)-h)*(b.min_coord(0)-h);
76 if (h > b.max_coord(0)) distance += (h-b.max_coord(0))*(h-b.max_coord(0));
78 if (h < b.min_coord(1)) distance += (b.min_coord(1)-h)*(b.min_coord(1)-h);
79 if (h > b.max_coord(1)) distance += (h-b.max_coord(1))*(h-b.min_coord(1));
81 if (h < b.min_coord(2)) distance += (b.min_coord(2)-h)*(b.min_coord(2)-h);
82 if (h > b.max_coord(2)) distance += (h-b.max_coord(2))*(h-b.max_coord(2));
86 template <
class TreeTraits>
88 const CGAL::Kd_tree_rectangle<TreeTraits>& b)
const
91 double d0 = (h >= (b.min_coord(0)+b.max_coord(0))/2.0) ?
92 (h-b.min_coord(0))*(h-b.min_coord(0)) : (b.max_coord(0)-h)*(b.max_coord(0)-h);
95 double d1 = (h >= (b.min_coord(1)+b.max_coord(1))/2.0) ?
96 (h-b.min_coord(1))*(h-b.min_coord(1)) : (b.max_coord(1)-h)*(b.max_coord(1)-h);
99 double d2 = (h >= (b.min_coord(2)+b.max_coord(2))/2.0) ?
100 (h-b.min_coord(2))*(h-b.min_coord(2)) : (b.max_coord(2)-h)*(b.max_coord(2)-h);
106 return dist + new_off*new_off - old_off*old_off;
137 typedef CGAL::Search_traits<double,
MyPoint,
const double*,
140 typedef K_neighbor_search::Tree
Tree;
const double * operator()(const MyPoint &p, int) const
Vector< double, 3 > Vec3D
const double * operator()(const MyPoint &p) const
Tangent sqrt(const Tangent &a)
CGAL::Orthogonal_k_neighbor_search< Traits > K_neighbor_search
double max_distance_to_rectangle(const MyPoint &p, const CGAL::Kd_tree_rectangle< TreeTraits > &b) const
void findNeighbors(const Vec3D &p, const int k, Array< int > &neighbors)
double transformed_distance(const MyPoint &p1, const MyPoint &p2) const
Vector< double, 3 > Vec3D
MyPoint(const MyPoint &o)
Array< Vec3D > Vec3DArray
double new_distance(double &dist, double old_off, double new_off, int) const
double inverse_of_transformed_distance(double d)
double min_distance_to_rectangle(const MyPoint &p, const CGAL::Kd_tree_rectangle< TreeTraits > &b) const
boost::shared_ptr< Tree > _tree
K_neighbor_search::Tree Tree
double transformed_distance(double d) const
MyPoint(const Vec3D &vec_, const int index_)
CGAL::Search_traits< double, MyPoint, const double *, Construct_coord_iterator > Traits
void insert(const Vec3D &v, const int n)