class mrpt::maps::NearestNeighborsCapable
Overview
Virtual interface for maps having the capability of searching the closest neighbor(s) of a given query 2D or 3D point.
Note this is more generic than mrpt::math::KDTreeCapable since it does not assume the use of KD-trees, and it is also non templatized, so users can use dynamic casting to interact with maps in a generic way.
New in MRPT 2.11.3
#include <mrpt/maps/NearestNeighborsCapable.h> class NearestNeighborsCapable { public: // construction NearestNeighborsCapable(); // methods virtual bool nn_has_indices_or_ids() const = 0; virtual size_t nn_index_count() const = 0; virtual bool nn_single_search( const mrpt::math::TPoint3Df& query, mrpt::math::TPoint3Df& result, float& out_dist_sqr, uint64_t& resultIndexOrIDOrID ) const = 0; virtual bool nn_single_search( const mrpt::math::TPoint2Df& query, mrpt::math::TPoint2Df& result, float& out_dist_sqr, uint64_t& resultIndexOrIDOrID ) const = 0; virtual void nn_multiple_search( const mrpt::math::TPoint3Df& query, const size_t N, std::vector<mrpt::math::TPoint3Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs ) const = 0; virtual void nn_multiple_search( const mrpt::math::TPoint2Df& query, const size_t N, std::vector<mrpt::math::TPoint2Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs ) const = 0; virtual void nn_radius_search( const mrpt::math::TPoint3Df& query, const float search_radius_sqr, std::vector<mrpt::math::TPoint3Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs, size_t maxPoints = 0 ) const = 0; virtual void nn_radius_search( const mrpt::math::TPoint2Df& query, const float search_radius_sqr, std::vector<mrpt::math::TPoint2Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs, size_t maxPoints = 0 ) const = 0; }; // direct descendants template <typename voxel_node_t, typename occupancy_t = int8_t> class CVoxelMapOccupancyBase; class COccupancyGridMap2D; class COccupancyGridMap3D; class CPointsMap;
Methods
virtual bool nn_has_indices_or_ids() const = 0
Returns true if the rest of nn_* methods will populate the output indices values with 0-based contiguous indices.
Returns false if indices are actually sparse ID numbers without any expectation of they be contiguous or start near zero.
virtual size_t nn_index_count() const = 0
If nn_has_indices_or_ids() returns true, this must return the number of “points” (or whatever entity) the indices correspond to.
Otherwise, the return value should be ignored.
virtual bool nn_single_search( const mrpt::math::TPoint3Df& query, mrpt::math::TPoint3Df& result, float& out_dist_sqr, uint64_t& resultIndexOrIDOrID ) const = 0
Search for the closest 3D point to a given one.
Parameters:
query  | 
The query input point.  | 
result  | 
The found closest point.  | 
out_dist_sqr  | 
The square Euclidean distance between the query and the returned point.  | 
resultIndexOrID  | 
The index or ID of the result point in the map.  | 
Returns:
True if successful, false if no point was found.
virtual void nn_multiple_search( const mrpt::math::TPoint3Df& query, const size_t N, std::vector<mrpt::math::TPoint3Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs ) const = 0
Search for the N closest 3D points to a given one.
Parameters:
query  | 
The query input point.  | 
results  | 
The found closest points.  | 
out_dists_sqr  | 
The square Euclidean distances between the query and the returned point.  | 
resultIndicesOrIDs  | 
The indices or IDs of the result points.  | 
virtual void nn_radius_search( const mrpt::math::TPoint3Df& query, const float search_radius_sqr, std::vector<mrpt::math::TPoint3Df>& results, std::vector<float>& out_dists_sqr, std::vector<uint64_t>& resultIndicesOrIDs, size_t maxPoints = 0 ) const = 0
Radius search for closest 3D points to a given one.
Parameters:
query  | 
The query input point.  | 
search_radius_sqr  | 
The search radius, squared.  | 
results  | 
The found closest points.  | 
out_dists_sqr  | 
The square Euclidean distances between the query and the returned point.  | 
resultIndicesOrIDs  | 
The indices or IDs of the result points.  | 
maxPoints  | 
If !=0, the maximum number of neigbors to return.  |