Subject: CGAL users discussion list
List archive
- From: Flaminigo <>
- To:
- Subject: [cgal-discuss] about nearest_neighbor_searching
- Date: Tue, 10 Nov 2009 20:35:23 +0800
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=QGcj5TiNC40wZmJHbz5TcjZAHzUZkdcH8E3Hgk7y9o29jlO2TJwuMq/3HZWkdYAVeC pLVGN7yaCmbP9pZmsayvpgJLHuDthVhmqBAXv/D82fK3FF9g59Op0BBhLeLTFian827u 2aCZj+qP9RtPwQHvPDuWbjnnDe/d+BIIHZFNE=
Hi,
I am using CGAL nearest_neighbor_searching to find the nearest neighbor of a given point.
However, the search function only return the coordinates of the nearest point. If i want to mark the original point set for querying. What should I do? I want the search function not only return the coordinates, but also return the id of this point.
My code is similar to this example.
#include <CGAL/Simple_cartesian.h> #include <CGAL/point_generators_2.h> #include <CGAL/Orthogonal_k_neighbor_search.h> #include <CGAL/Search_traits_2.h> #include <list> #include <cmath> typedef CGAL::Simple_cartesian<double> K; typedef K::Point_2 Point_d; typedef CGAL::Search_traits_2<K> TreeTraits; typedef CGAL::Orthogonal_k_neighbor_search<TreeTraits> Neighbor_search; typedef Neighbor_search::Tree Tree; int main() { const unsigned int N = 1; std::list<Point_d> points; points.push_back(Point_d(0,0)); Tree tree(points.begin(), points.end()); Point_d query(0,0); // Initialize the search structure, and search all N points Neighbor_search search(tree, query, N); // report the N nearest neighbors and their distance // This should sort all N points by increasing distance from origin for(Neighbor_search::iterator it = search.begin(); it != search.end(); ++it){ std::cout << it->first << " "<< std::sqrt(it->second) << std::endl; } return 0; }
- [cgal-discuss] about nearest_neighbor_searching, Flaminigo, 11/10/2009
- Re: [cgal-discuss] about nearest_neighbor_searching, Bernhard Kornberger, 11/12/2009
- Re: [cgal-discuss] about nearest_neighbor_searching, Flaminigo, 11/13/2009
- Re: [cgal-discuss] about nearest_neighbor_searching, Bernhard Kornberger, 11/12/2009
Archive powered by MHonArc 2.6.16.