22 #ifndef _RL_PLAN_ORTHOGONAL_K_NEIGHBOR_SEARCH_H_
23 #define _RL_PLAN_ORTHOGONAL_K_NEIGHBOR_SEARCH_H_
25 #include <CGAL/internal/K_neighbor_search.h>
27 namespace rl {
namespace plan {
29 template <
class SearchTraits,
30 #if (CGAL_VERSION_NR > 1030801000)
31 class Distance= typename ::CGAL::internal::Spatial_searching_default_distance<SearchTraits>::type,
33 class Distance= ::CGAL::Euclidean_distance<SearchTraits>,
35 class Splitter= ::CGAL::Sliding_midpoint<SearchTraits> ,
36 class Tree= ::CGAL::Kd_tree<SearchTraits, Splitter, ::CGAL::Tag_true> >
38 typedef ::CGAL::internal::K_neighbor_search<SearchTraits,Distance,Splitter,Tree>
Base;
43 typedef typename Base::FT
FT;
45 #if (CGAL_VERSION_NR > 1030901000)
50 unsigned int k=1,
FT Eps=
FT(0.0),
bool Search_nearest=
true,
const Distance& d=Distance(),
bool sorted=
true)
51 :
Base(q,k,Eps,Search_nearest,d)
53 if (tree.empty())
return;
56 if (this->search_nearest)
57 distance_to_root = this->distance_instance.min_distance_to_rectangle(q, tree.bounding_box());
59 distance_to_root = this->distance_instance.max_distance_to_rectangle(q, tree.bounding_box());
62 #
if (CGAL_VERSION_NR > 1030801000)
63 typename SearchTraits::Construct_cartesian_const_iterator_d construct_it=tree.traits().construct_cartesian_const_iterator_d_object();
65 typename SearchTraits::Construct_cartesian_const_iterator_d construct_it;
71 if (sorted) this->queue.sort();
75 #if (CGAL_VERSION_NR > 1030901000)
83 this->number_of_internal_nodes_visited++;
84 int new_cut_dim=N->cutting_dimension();
86 FT low_off = this->distance_instance.min_distance_to_rectangle(
92 FT high_off = this->distance_instance.min_distance_to_rectangle(
98 if ( ((low_off < high_off) && (this->search_nearest)) ||
99 ((low_off >= high_off) && (!this->search_nearest)) )
102 if (this->search_nearest) {
103 new_rd = this->distance_instance.new_distance(rd,low_off,high_off,new_cut_dim);
106 new_rd = this->distance_instance.new_distance(rd,high_off,low_off,new_cut_dim);
108 if (this->branch(new_rd))
114 if (this->search_nearest) {
115 new_rd = this->distance_instance. new_distance(rd,high_off,low_off,new_cut_dim);
118 new_rd = this->distance_instance. new_distance(rd,low_off,high_off,new_cut_dim);
120 if (this->branch(new_rd))
127 this->number_of_leaf_nodes_visited++;
130 for (
typename Base::Point_d_iterator it=N->begin(); it != N->end(); it++)
132 this->number_of_items_visited++;
133 FT distance_to_query_object=
134 this->distance_instance.transformed_distance(this->query_object,**it);
135 this->queue.insert(::std::make_pair(*it,distance_to_query_object));
145 #endif // _RL_PLAN_ORTHOGONAL_K_NEIGHBOR_SEARCH_H_