From e893bc94d34a40e712b36fda5f5d065a4d864c98 Mon Sep 17 00:00:00 2001 From: "m.overtheil" Date: Thu, 4 Dec 2014 11:46:10 +0100 Subject: [PATCH] Check worst dist before make_pair --- .../include/CGAL/Orthogonal_k_neighbor_search.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h index 625525c9a37..fbd076f9900 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h @@ -99,7 +99,9 @@ private: FT new_rd = this->distance_instance.new_distance(rd,dst,new_off,new_cut_dim); dists[new_cut_dim]=new_off; if (this->branch(new_rd)) + { compute_nearest_neighbors_orthogonally(otherChild, new_rd,dists); + } dists[new_cut_dim]=dst; } else @@ -108,6 +110,8 @@ private: typename Tree::Leaf_node_const_handle node = static_cast(N); this->number_of_leaf_nodes_visited++; + FT worst_dist = this->queue.top().second; + bool full = this->queue.full(); if (node->size() > 0) { for (typename Base::Point_d_iterator it=node->begin(); it != node->end(); it++) @@ -115,6 +119,7 @@ private: this->number_of_items_visited++; FT distance_to_query_object= this->distance_instance.transformed_distance(this->query_object,**it); + if(!full || distance_to_query_object < worst_dist) this->queue.insert(std::make_pair(*it,distance_to_query_object)); } } @@ -160,6 +165,8 @@ private: typename Tree::Leaf_node_const_handle node = static_cast(N); this->number_of_leaf_nodes_visited++; + FT worst_dist = this->queue.top().second; + bool full = this->queue.full(); if (node->size() > 0) { for (typename Base::Point_d_iterator it=node->begin(); it != node->end(); it++) @@ -167,6 +174,7 @@ private: this->number_of_items_visited++; FT distance_to_query_object= this->distance_instance.transformed_distance(this->query_object,**it); + if(!full || distance_to_query_object < worst_dist) this->queue.insert(std::make_pair(*it,distance_to_query_object)); } }