diff --git a/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt b/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt index 7a6fb3f3157..0320c4dd67d 100644 --- a/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt +++ b/Spatial_searching/doc/Spatial_searching/Spatial_searching.txt @@ -498,8 +498,8 @@ distances are used instead of the Euclidean distance itself. \section Spatial_searchingImplementationHistory Implementation History -The initial implementation of this package by Hans Tangelder and -Andreas Fabri was optimized in speed and memory consumption by Markus +The initial implementation of this package was done by Hans Tangelder and +Andreas Fabri. It was optimized in speed and memory consumption by Markus Overtheil during an internship at GeometryFactory in 2014. */ diff --git a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h index c255250c7f8..0fe9226b186 100644 --- a/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h +++ b/Spatial_searching/include/CGAL/Orthogonal_k_neighbor_search.h @@ -34,9 +34,11 @@ class Orthogonal_k_neighbor_search: public internal::K_neighbor_search dists; public: typedef typename Base::FT FT; + Orthogonal_k_neighbor_search(const Tree& tree, const typename Base::Query_item& q, unsigned int k=1, FT Eps=FT(0.0), bool Search_nearest=true, const Distance& d=Distance(),bool sorted=true) : Base(q,k,Eps,Search_nearest,d) @@ -47,18 +49,19 @@ public: query_object_it = construct_it(this->query_object); int dim = static_cast(std::distance(query_object_it, construct_it(this->query_object,0))); - std::vector dists(dim); + + dists.resize(dim); for(int i=0;isearch_nearest){ distance_to_root = this->distance_instance.min_distance_to_rectangle(q, tree.bounding_box(),dists); - compute_nearest_neighbors_orthogonally(tree.root(), distance_to_root,dists); + compute_nearest_neighbors_orthogonally(tree.root(), distance_to_root); } else { distance_to_root = this->distance_instance.max_distance_to_rectangle(q, tree.bounding_box(),dists); - compute_furthest_neighbors_orthogonally(tree.root(), distance_to_root,dists); + compute_furthest_neighbors_orthogonally(tree.root(), distance_to_root); } @@ -69,7 +72,7 @@ public: } private: - void compute_nearest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd,std::vector& dists) + void compute_nearest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd) { if (!(N->is_leaf())) { @@ -94,13 +97,13 @@ private: bestChild = node->upper(); otherChild = node->lower(); } - compute_nearest_neighbors_orthogonally(bestChild, rd,dists); + compute_nearest_neighbors_orthogonally(bestChild, rd); FT dst=dists[new_cut_dim]; FT new_rd = this->distance_instance.new_distance(rd,dst,new_off,new_cut_dim); dists[new_cut_dim]=new_off; if (this->branch_nearest(new_rd)) { - compute_nearest_neighbors_orthogonally(otherChild, new_rd,dists); + compute_nearest_neighbors_orthogonally(otherChild, new_rd); } dists[new_cut_dim]=dst; } @@ -127,7 +130,7 @@ private: } } - void compute_furthest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd,std::vector& dists) + void compute_furthest_neighbors_orthogonally(typename Base::Node_const_handle N, FT rd) { if (!(N->is_leaf())) { @@ -152,12 +155,12 @@ private: bestChild = node->lower(); otherChild = node->upper(); } - compute_furthest_neighbors_orthogonally(bestChild, rd,dists); + compute_furthest_neighbors_orthogonally(bestChild,rd); FT dst=dists[new_cut_dim]; FT new_rd = this->distance_instance.new_distance(rd,dst,new_off,new_cut_dim); dists[new_cut_dim]=new_off; if (this->branch_furthest(new_rd)) - compute_furthest_neighbors_orthogonally(otherChild, new_rd,dists); + compute_furthest_neighbors_orthogonally(otherChild, new_rd); dists[new_cut_dim]=dst; } else