40 #ifndef GEOGRAM_POINTS_NN_SEARCH
41 #define GEOGRAM_POINTS_NN_SEARCH
131 const double* query_point,
133 double* neighbors_sq_dist
161 const double* query_point,
163 double* neighbors_sq_dist,
184 double* neighbors_sq_dist
194 const double* query_point
198 get_nearest_neighbors(1, query_point, &result, &sq_dist);
226 return points_ + i * stride_;
263 const double* points_;
291 #define geo_register_NearestNeighborSearch_creator(type, name) \
292 geo_register_creator(GEO::NearestNeighborSearchFactory, type, name)
#define geo_assert(x)
Verifies that a condition is met.
#define geo_debug_assert(x)
Verifies that a condition is met.
Base class for reference-counted objects.
Factory for types with one constructor argument.
Abstract interface for nearest neighbor search algorithms.
~NearestNeighborSearch() override
NearestNeighborSearch destructor.
NearestNeighborSearch(coord_index_t dimension)
Constructs a NearestNeighborSearch.
const double * point_ptr(index_t i) const
Gets a point by its index.
coord_index_t dimension() const
Gets the dimension of the points.
virtual bool stride_supported() const
Tests whether the stride variant of set_points() is supported.
virtual void get_nearest_neighbors(index_t nb_neighbors, const double *query_point, index_t *neighbors, double *neighbors_sq_dist) const =0
Finds the nearest neighbors of a point given by coordinates.
SmartPointer< NearestNeighborSearch > NearestNeighborSearch_var
A smart pointer that contains a NearestNeighborSearch object.
static NearestNeighborSearch * create(coord_index_t dimension, const std::string &name="default")
Creates a new search algorithm.
Factory1< NearestNeighborSearch, coord_index_t > NearestNeighborSearchFactory
NearestNeighborSearch Factory.
virtual void set_exact(bool x)
Search can be exact or approximate. Approximate search may be faster.
bool exact() const
Search can be exact or approximate. Approximate search may be faster.
index_t nb_points() const
Gets the number of points.
virtual void get_nearest_neighbors(index_t nb_neighbors, const double *query_point, index_t *neighbors, double *neighbors_sq_dist, KeepInitialValues dummy) const
Finds the nearest neighbors of a point given by coordinates. Uses input neighbors and squared distanc...
virtual void get_nearest_neighbors(index_t nb_neighbors, index_t query_point, index_t *neighbors, double *neighbors_sq_dist) const
Finds the nearest neighbors of a point given by its index.
virtual void set_points(index_t nb_points, const double *points, index_t stride)
Sets the points and create the search data structure.
index_t get_nearest_neighbor(const double *query_point) const
Nearest neighbor search.
virtual void set_points(index_t nb_points, const double *points)
Sets the points and create the search data structure.
A smart pointer with reference-counted copy semantics.
Base class of reference-counted objects, to be used with smart pointers.
Generic factory mechanism.
Common include file, providing basic definitions. Should be included before anything else by all head...
Global Vorpaline namespace.
geo_signed_index_t signed_index_t
The type for storing and manipulating indices differences.
geo_index_t index_t
The type for storing and manipulating indices.
geo_coord_index_t coord_index_t
The type for storing coordinate indices, and iterating on the coordinates of a point.
Types and functions for numbers manipulation.
Pointers with automatic reference counting.
A structure to discriminate between the two versions of get_nearest_neighbors()