mirror of https://github.com/CGAL/cgal
Merge pull request #6287 from afabri/Spatial_searching-Incremental_Manhattan_fix-GF
Spatial_searching: Fix incremental search with Manhattan distance
This commit is contained in:
commit
f01b30de0d
|
|
@ -17,6 +17,7 @@
|
|||
#include <CGAL/license/Spatial_searching.h>
|
||||
|
||||
#include <CGAL/disable_warnings.h>
|
||||
#include <CGAL/Kd_tree.h>
|
||||
#include <CGAL/Kd_tree_node.h>
|
||||
#include <CGAL/Kd_tree_rectangle.h>
|
||||
#include <CGAL/Euclidean_distance.h>
|
||||
|
|
@ -342,7 +343,8 @@ namespace CGAL {
|
|||
|
||||
typename SearchTraits::Construct_cartesian_const_iterator_d construct_it =
|
||||
m_tree.traits().construct_cartesian_const_iterator_d_object();
|
||||
m_dim = static_cast<int>(std::distance(construct_it(q), construct_it(q, 0)));
|
||||
const Point_d& p = *m_tree.begin();
|
||||
m_dim = static_cast<int>(std::distance(construct_it(p), construct_it(p, 0)));
|
||||
|
||||
multiplication_factor= distance.transformed_distance(FT(1)+Eps);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
#include <iostream>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Manhattan_distance_iso_box_point.h>
|
||||
#include <CGAL/Search_traits_2.h>
|
||||
#include <CGAL/Incremental_neighbor_search.h>
|
||||
|
||||
|
||||
using K = CGAL::Exact_predicates_inexact_constructions_kernel;
|
||||
using Point = K::Point_2;
|
||||
using TreeTraits = CGAL::Search_traits_2<K>;
|
||||
using Splitter = CGAL::Sliding_midpoint<TreeTraits>;
|
||||
using Distance = CGAL::Manhattan_distance_iso_box_point<TreeTraits>;
|
||||
|
||||
using IncrNN = CGAL::Incremental_neighbor_search<TreeTraits, Distance>;
|
||||
using Tree = IncrNN::Tree;
|
||||
|
||||
int main() {
|
||||
|
||||
Tree tree;
|
||||
tree.insert({1,1});
|
||||
tree.insert({2,2});
|
||||
|
||||
Point pQuery(0, 0);
|
||||
|
||||
IncrNN nn(tree, {pQuery, pQuery});
|
||||
|
||||
for (IncrNN::iterator it = nn.begin(); it != nn.end(); ++it) {
|
||||
std::cout << it->first << " dist: " << it->second << std::endl;;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue