PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
nsearch::TreeSearchResult< _DistanceType, _IndexType > Class Template Reference

To collect results of nanoflann tree search. Default result output of nanoflann search uses std::vector<std::pair<size_t, double>>. We prefer to get the index and distance in a separate list. More...

#include <nflannSetup.h>

Collaboration diagram for nsearch::TreeSearchResult< _DistanceType, _IndexType >:

Public Types

typedef _DistanceType DistanceType
 Distance type (double, float, etc)
 
typedef _IndexType IndexType
 Index type (int, size_t, etc)
 

Public Member Functions

 TreeSearchResult (DistanceType radius_, std::vector< IndexType > &indices, std::vector< DistanceType > &dists)
 Constructor.
 
void init ()
 Initialize the data (clear)
 
void clear ()
 Clear the data.
 
size_t size () const
 Get the size of currently stored (found so far) indices.
 
bool full () const
 Check (not implemented)
 
bool addPoint (DistanceType dist, IndexType index)
 Called during search to add an element matching the criteria.
 
DistanceType worstDist () const
 Return maximum distance for search.
 
std::pair< IndexType, DistanceTypeworst_item () const
 Find the worst result (furtherest neighbor) without copying or sorting Pre-conditions: size() > 0.
 

Data Fields

const DistanceType d_r
 Define search radius. Note this should be square of radius, where radius is a distance within which we are searching for points.
 
std::vector< IndexType > & d_indices
 Indices within the search radius.
 
std::vector< DistanceType > & d_dists
 Distance of points found within the search radius.
 

Detailed Description

template<typename _DistanceType, typename _IndexType = size_t>
class nsearch::TreeSearchResult< _DistanceType, _IndexType >

To collect results of nanoflann tree search. Default result output of nanoflann search uses std::vector<std::pair<size_t, double>>. We prefer to get the index and distance in a separate list.

Definition at line 86 of file nflannSetup.h.

Member Typedef Documentation

◆ DistanceType

template<typename _DistanceType , typename _IndexType = size_t>
typedef _DistanceType nsearch::TreeSearchResult< _DistanceType, _IndexType >::DistanceType

Distance type (double, float, etc)

Definition at line 89 of file nflannSetup.h.

◆ IndexType

template<typename _DistanceType , typename _IndexType = size_t>
typedef _IndexType nsearch::TreeSearchResult< _DistanceType, _IndexType >::IndexType

Index type (int, size_t, etc)

Definition at line 92 of file nflannSetup.h.

Constructor & Destructor Documentation

◆ TreeSearchResult()

template<typename _DistanceType , typename _IndexType = size_t>
nsearch::TreeSearchResult< _DistanceType, _IndexType >::TreeSearchResult ( DistanceType  radius_,
std::vector< IndexType > &  indices,
std::vector< DistanceType > &  dists 
)
inline

Constructor.

Parameters
radius_Search radius (square of radius)
indicesReference to index vector
distsReference to distance vector

Definition at line 112 of file nflannSetup.h.

115 : d_r(radius_), d_indices(indices), d_dists(dists) {
116 init();
117 }
const DistanceType d_r
Define search radius. Note this should be square of radius, where radius is a distance within which w...
Definition nflannSetup.h:97
std::vector< IndexType > & d_indices
Indices within the search radius.
void init()
Initialize the data (clear)
std::vector< DistanceType > & d_dists
Distance of points found within the search radius.

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::init().

Here is the call graph for this function:

Member Function Documentation

◆ addPoint()

template<typename _DistanceType , typename _IndexType = size_t>
bool nsearch::TreeSearchResult< _DistanceType, _IndexType >::addPoint ( DistanceType  dist,
IndexType  index 
)
inline

Called during search to add an element matching the criteria.

Parameters
distDistance of point from the search point
indexId of point
Returns
True True if continue the search further

Definition at line 152 of file nflannSetup.h.

152 {
153 if (dist < d_r) {
154 d_indices.push_back(index);
155 d_dists.push_back(dist);
156 }
157 return true;
158 }

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_dists, nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_indices, and nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_r.

◆ clear()

template<typename _DistanceType , typename _IndexType = size_t>
void nsearch::TreeSearchResult< _DistanceType, _IndexType >::clear ( )
inline

Clear the data.

Definition at line 127 of file nflannSetup.h.

127 {
128 d_indices.clear();
129 d_dists.clear();
130 }

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_dists, and nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_indices.

Referenced by nsearch::TreeSearchResult< _DistanceType, _IndexType >::init().

Here is the caller graph for this function:

◆ full()

template<typename _DistanceType , typename _IndexType = size_t>
bool nsearch::TreeSearchResult< _DistanceType, _IndexType >::full ( ) const
inline

Check (not implemented)

Returns
bool Status

Definition at line 143 of file nflannSetup.h.

143{ return true; }

◆ init()

template<typename _DistanceType , typename _IndexType = size_t>
void nsearch::TreeSearchResult< _DistanceType, _IndexType >::init ( )
inline

Initialize the data (clear)

Definition at line 122 of file nflannSetup.h.

122{ clear(); }
void clear()
Clear the data.

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::clear().

Referenced by nsearch::TreeSearchResult< _DistanceType, _IndexType >::TreeSearchResult().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

template<typename _DistanceType , typename _IndexType = size_t>
size_t nsearch::TreeSearchResult< _DistanceType, _IndexType >::size ( ) const
inline

Get the size of currently stored (found so far) indices.

Returns
size Size of indices data

Definition at line 137 of file nflannSetup.h.

137{ return d_indices.size(); }

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_indices.

◆ worst_item()

template<typename _DistanceType , typename _IndexType = size_t>
std::pair< IndexType, DistanceType > nsearch::TreeSearchResult< _DistanceType, _IndexType >::worst_item ( ) const
inline

Find the worst result (furtherest neighbor) without copying or sorting Pre-conditions: size() > 0.

Currently, we return pair(0, 0.)

Returns
Pair Pair of id and max distanced point

Definition at line 174 of file nflannSetup.h.

174 {
175 if (d_indices.empty())
176 throw std::runtime_error("Cannot invoke RadiusResultSet::worst_item() on "
177 "an empty list of results.");
178 return std::make_pair(0, 0.);
179 }

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_indices.

◆ worstDist()

template<typename _DistanceType , typename _IndexType = size_t>
DistanceType nsearch::TreeSearchResult< _DistanceType, _IndexType >::worstDist ( ) const
inline

Return maximum distance for search.

Returns
Radius Maximum distance for search

Definition at line 164 of file nflannSetup.h.

164{ return d_r; }

References nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_r.

Field Documentation

◆ d_dists

template<typename _DistanceType , typename _IndexType = size_t>
std::vector<DistanceType>& nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_dists

Distance of points found within the search radius.

Definition at line 103 of file nflannSetup.h.

Referenced by nsearch::TreeSearchResult< _DistanceType, _IndexType >::addPoint(), and nsearch::TreeSearchResult< _DistanceType, _IndexType >::clear().

◆ d_indices

template<typename _DistanceType , typename _IndexType = size_t>
std::vector<IndexType>& nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_indices

◆ d_r

template<typename _DistanceType , typename _IndexType = size_t>
const DistanceType nsearch::TreeSearchResult< _DistanceType, _IndexType >::d_r

Define search radius. Note this should be square of radius, where radius is a distance within which we are searching for points.

Definition at line 97 of file nflannSetup.h.

Referenced by nsearch::TreeSearchResult< _DistanceType, _IndexType >::addPoint(), and nsearch::TreeSearchResult< _DistanceType, _IndexType >::worstDist().


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