CGAL::K_neighbor_search<Traits, GeneralDistance, Splitter, SpatialTree>

Definition

The class K_neighbor_search<Traits, GeneralDistance, Splitter, SpatialTree> implements approximate k-nearest and k-furthest neighbor searching using standard search on a tree using a general distance class. The tree may be built with extended or unextended nodes.

#include <CGAL/K_neighbor_search.h>

Parameters

Expects for the first template argument an implementation of the concept SearchTraits, for example CGAL::Cartesian_d<double>.

Expects for the second template argument a model of the concept GeneralDistance. If Traits is CGAL::Search_traits_adapter<Key,PointPropertyMap,BaseTraits> the default type is CGAL::Distance_for_point_adapter<Key,PointPropertyMap,CGAL::Euclidean_distance<Traits> >, and CGAL::Euclidean_distance<Traits> otherwise.

Expects for fourth template argument an implementation of the concept SpatialTree. The default type is CGAL::Kd_tree<Traits, Splitter, CGAL::Tag_false>. The template argument CGAL::Tag_false makes that the tree is built with unextended nodes.

Types

Traits::Point_d Point_d; Point type.

Traits::FT FT; Number type.

GeneralDistance Distance; Distance type.

std::pair<Point_d,FT> Point_with_transformed_distance; Pair of point and transformed distance.

K_neighbor_search<Traits, GeneralDistance, Splitter, SpatialTree>::iterator
Bidirectional iterator with value type Point_with_distance for enumerating approximate neighbors.

GeneralDistance::Query_item Query_item; Query item type.

SpatialTree Tree; The tree type.

Creation

K_neighbor_search<Traits, GeneralDistance, Splitter, SpatialTree> s (
Tree& tree,
Query_item q,
unsigned int k=1,
FT eps=FT(0.0),
bool search_nearest=true,
GeneralDistance d=GeneralDistance(),
bool sorted=true);
Constructor for searching approximately k neighbors of the query item q in the points stored in tree using distance class d and approximation factor eps. sorted indicates if the computed sequence of k-nearest neighbors needs to be sorted.

Operations

iterator s.begin () Returns an iterator to the approximate neighbors.

iterator s.end () Past-the-end iterator.

std::ostream& s.statistics ( std::ostream& s) Inserts statistics of the search process into the output stream s.

See Also

CGAL::Orthogonal_k_neighbor_search<Traits, OrthogonalDistance, Splitter, SpatialTree>.