EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Public Member Functions | List of all members
EBGeometry::PointCloud::KBest< T > Class Template Reference

The k nearest points seen so far, kept sorted in a caller-supplied buffer. More...

#include <EBGeometry_PointCloud.hpp>

Public Member Functions

 KBest (Hit< T > *a_out, const std::size_t a_k, const uint32_t a_exclude=InvalidIndex) noexcept
 Start an empty set.
 
void insert (const T a_distanceSquared, const uint32_t a_index) noexcept
 Offer one candidate.
 
T bound () const noexcept
 The squared distance a candidate must beat to be inserted.
 
std::size_t found () const noexcept
 Number of candidates held, at most k.
 

Detailed Description

template<class T>
class EBGeometry::PointCloud::KBest< T >

The k nearest points seen so far, kept sorted in a caller-supplied buffer.

The search structures feed every candidate point to insert(), and prune with bound(). The buffer holds the found() best candidates in ascending order of distance; ties keep the candidate inserted first. A candidate is inserted at most once per query by every caller, so no de-duplication is done. Callable on the host and on a device, and allocates nothing.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ KBest()

template<class T >
EBGeometry::PointCloud::KBest< T >::KBest ( Hit< T > *  a_out,
const std::size_t  a_k,
const uint32_t  a_exclude = InvalidIndex 
)
inlinenoexcept

Start an empty set.

Parameters
[out]a_outBuffer of at least a_k Hits. Its first found() entries hold the result.
[in]a_kNumber of neighbors wanted. Must be > 0.
[in]a_excludeCloud index never to report (a self-query's own point), or InvalidIndex.

Member Function Documentation

◆ bound()

template<class T >
T EBGeometry::PointCloud::KBest< T >::bound ( ) const
inlinenoexcept

The squared distance a candidate must beat to be inserted.

Math::Limits<T>::max() until k candidates are held, then the k-th smallest distance. A search may skip any region at least this far from the query.

Returns
The pruning bound.

◆ found()

template<class T >
std::size_t EBGeometry::PointCloud::KBest< T >::found ( ) const
inlinenoexcept

Number of candidates held, at most k.

Returns
The count.

◆ insert()

template<class T >
void EBGeometry::PointCloud::KBest< T >::insert ( const T  a_distanceSquared,
const uint32_t  a_index 
)
inlinenoexcept

Offer one candidate.

Rejected if it is the excluded point or no closer than bound(); otherwise inserted in order, dropping the farthest candidate once k are held.

Parameters
[in]a_distanceSquaredSquared distance from the query to the candidate.
[in]a_indexCloud index of the candidate.

The documentation for this class was generated from the following file: