Ponca  eff04be8be0ed1ccd36b694a34ae55d988e046fb
Point Cloud Analysis library
Loading...
Searching...
No Matches
Ponca::StaticKdTreeBase< Traits > Class Template Reference

Customizable static base class for KdTree datastructure implementations. More...

#include <kdTree.h>

+ Inheritance diagram for Ponca::StaticKdTreeBase< Traits >:
+ Collaboration diagram for Ponca::StaticKdTreeBase< Traits >:

Classes

struct  Buffers
 Internal structure storing all the buffers used by the KdTree. More...
 

Public Types

using DataPoint = typename Traits::DataPoint
 DataPoint given by user via Traits

 
using IndexType = typename Traits::IndexType
 Type used to index points into the PointContainer

 
using LeafSizeType = typename Traits::LeafSizeType
 Type used to store the size of leaf nodes

 
using PointContainer = typename Traits::PointContainer
 Container for DataPoint used inside the KdTree

 
using IndexContainer = typename Traits::IndexContainer
 Container for indices used inside the KdTree

 
using NodeIndexType = typename Traits::NodeIndexType
 Type used to index nodes into the NodeContainer

 
using NodeType = typename Traits::NodeType
 Type of nodes used inside the KdTree

 
using NodeContainer = typename Traits::NodeContainer
 Container for nodes used inside the KdTree

 
using Scalar = typename DataPoint::Scalar
 Scalar given by user via DataPoint

 
using VectorType = typename DataPoint::VectorType
 VectorType given by user via DataPoint

 
using AabbType = typename NodeType::AabbType
 Bounding box type given by user via NodeType

 

Public Member Functions

 StaticKdTreeBase (Buffers &buf)
 Constructor that allows the use of prebuilt KdTree containers.
 
NodeIndexType nodeCount () const
 Get the number of nodes in the KdTree.
 
IndexType sampleCount () const
 Get the number of indices.
 
IndexType pointCount () const
 Get the number of points.
 
NodeIndexType leafCount () const
 Get the number of leafs in the KdTree.
 
PointContainerpoints ()
 Get the internal point container.
 
const PointContainerpoints () const
 Get the internal point container.
 
const NodeContainernodes () const
 Get the internal node container.
 
const IndexContainersamples () const
 Get the internal indice container.
 
const Buffersbuffers () const
 Get access to the internal buffer, for instance to prepare GPU binding.
 
LeafSizeType minCellSize () const
 Read leaf min size.
 
void setMinCellSize (LeafSizeType min_cell_size)
 Write leaf min size.
 
IndexType pointFromSample (IndexType sample_index) const
 Return the point index associated with the specified sample index.
 
DataPointpointDataFromSample (IndexType sample_index)
 Return the DataPoint associated with the specified sample index.
 
const DataPointpointDataFromSample (IndexType sample_index) const
 Return the DataPoint associated with the specified sample index.
 
KdTreeKNearestPointQuery< Traits > kNearestNeighbors (const VectorType &point, IndexType k) const
 Computes a Query object to iterate over the k-nearest neighbors of a point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeKNearestIndexQuery< Traits > kNearestNeighbors (IndexType index, IndexType k) const
 Computes a Query object to iterate over the k-nearest neighbors of a point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeKNearestPointQuery< Traits > kNearestNeighborsQuery () const
 Convenience function that provides an empty k-nearest neighbors Query object.
 
KdTreeKNearestIndexQuery< Traits > kNearestNeighborsIndexQuery () const
 Convenience function that provides an empty k-nearest neighbors Query object.
 
KdTreeNearestPointQuery< Traits > nearestNeighbor (const VectorType &point) const
 Computes a Query object that contains the nearest point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeNearestIndexQuery< Traits > nearestNeighbor (IndexType index) const
 Computes a Query object that contains the nearest point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeNearestIndexQuery< Traits > nearestNeighborQuery () const
 Convenience function that provides an empty nearest neighbor Query object.
 
KdTreeNearestIndexQuery< Traits > nearestNeighborIndexQuery () const
 Convenience function that provides an empty nearest neighbor Query object.
 
KdTreeRangePointQuery< Traits > rangeNeighbors (const VectorType &point, Scalar r) const
 Computes a Query object to iterate over the neighbors that are inside a given radius. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeRangeIndexQuery< Traits > rangeNeighbors (IndexType index, Scalar r) const
 Computes a Query object to iterate over the neighbors that are inside a given radius. The returned object can be reset and reused with the () operator (using the same argument types as parameters).
 
KdTreeRangePointQuery< Traits > rangeNeighborsQuery () const
 Convenience function that provides an empty range neighbor Query object.
 
KdTreeRangeIndexQuery< Traits > rangeNeighborsIndexQuery () const
 KdTreeBase::rangeNeighborsQuery.
 
bool valid () const
 
void print (std::ostream &os, bool verbose=false) const
 

Static Public Attributes

static constexpr std::size_t MAX_NODE_COUNT = NodeType::MAX_COUNT
 The maximum number of nodes that the kd-tree can have.
 
static constexpr std::size_t MAX_POINT_COUNT = std::size_t(2) << sizeof(IndexType)*8
 The maximum number of points that can be stored in the kd-tree.
 
static constexpr int MAX_DEPTH = Traits::MAX_DEPTH
 The maximum depth of the kd-tree.
 
static constexpr bool SUPPORTS_SUBSAMPLING = false
 

Protected Attributes

Buffers m_bufs
 Buffers used to store the KdTree.
 
LeafSizeType m_min_cell_size {64}
 Minimal number of points per leaf.
 
NodeIndexType m_leaf_count {0}
 Number of leaves in the Kdtree (computed during construction)
 

Detailed Description

template<typename Traits>
class Ponca::StaticKdTreeBase< Traits >

Customizable static base class for KdTree datastructure implementations.

Note
This "Static" kdtree can be constructed using the Buffers structure, it only makes the Query functions available and doesn't define any build functionalities, (hence why it is static). This basic class can be used to make kdtree calls from inside a CUDA kernel.
See also
KdTreeBase to build a kdtree
rangeNeighbors, kNearestNeighbors, nearestNeighbor for the query calls
Template Parameters
TraitsTraits type providing the types and constants used by the kd-tree. Must have the same interface as the default traits type.
See also
KdTreeDefaultTraits for the trait interface documentation.

Definition at line 126 of file kdTree.h.

Member Typedef Documentation

◆ AabbType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::AabbType = typename NodeType::AabbType

Bounding box type given by user via NodeType

Definition at line 141 of file kdTree.h.

◆ DataPoint

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::DataPoint = typename Traits::DataPoint

DataPoint given by user via Traits

Definition at line 141 of file kdTree.h.

◆ IndexContainer

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::IndexContainer = typename Traits::IndexContainer

Container for indices used inside the KdTree

Definition at line 141 of file kdTree.h.

◆ IndexType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::IndexType = typename Traits::IndexType

Type used to index points into the PointContainer

Definition at line 141 of file kdTree.h.

◆ LeafSizeType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::LeafSizeType = typename Traits::LeafSizeType

Type used to store the size of leaf nodes

Definition at line 141 of file kdTree.h.

◆ NodeContainer

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::NodeContainer = typename Traits::NodeContainer

Container for nodes used inside the KdTree

Definition at line 141 of file kdTree.h.

◆ NodeIndexType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::NodeIndexType = typename Traits::NodeIndexType

Type used to index nodes into the NodeContainer

Definition at line 141 of file kdTree.h.

◆ NodeType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::NodeType = typename Traits::NodeType

Type of nodes used inside the KdTree

Definition at line 141 of file kdTree.h.

◆ PointContainer

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::PointContainer = typename Traits::PointContainer

Container for DataPoint used inside the KdTree

Definition at line 141 of file kdTree.h.

◆ Scalar

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::Scalar = typename DataPoint::Scalar

Scalar given by user via DataPoint

Definition at line 141 of file kdTree.h.

◆ VectorType

template<typename Traits >
using Ponca::StaticKdTreeBase< Traits >::VectorType = typename DataPoint::VectorType

VectorType given by user via DataPoint

Definition at line 141 of file kdTree.h.

Constructor & Destructor Documentation

◆ StaticKdTreeBase()

template<typename Traits >
Ponca::StaticKdTreeBase< Traits >::StaticKdTreeBase ( Buffers buf)
inline

Constructor that allows the use of prebuilt KdTree containers.

Each internal values of a KdTree can be extracted using `KdTreeBasebuffers()`

Note
This constructor can be used to avoid the convertion and building process, which is useful to transfer directly the KdTree to the device in CUDA.
Parameters
bufInternal buffers of the KdTree

Definition at line 191 of file kdTree.h.

Member Function Documentation

◆ buffers()

template<typename Traits >
const Buffers & Ponca::StaticKdTreeBase< Traits >::buffers ( ) const
inline

Get access to the internal buffer, for instance to prepare GPU binding.

Definition at line 244 of file kdTree.h.

◆ kNearestNeighbors() [1/2]

template<typename Traits >
KdTreeKNearestPointQuery< Traits > Ponca::StaticKdTreeBase< Traits >::kNearestNeighbors ( const VectorType point,
IndexType  k 
) const
inline

Computes a Query object to iterate over the k-nearest neighbors of a point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
pointPoint from where the query is evaluated
kNumber of neighbors returned
Returns
The KdTreeKNearestIndexQuery mutable object to iterate over the search results.
See also
KdTreeKNearestQueryBase

Definition at line 298 of file kdTree.h.

◆ kNearestNeighbors() [2/2]

template<typename Traits >
KdTreeKNearestIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::kNearestNeighbors ( IndexType  index,
IndexType  k 
) const
inline

Computes a Query object to iterate over the k-nearest neighbors of a point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
indexIndex of the point from where the query is evaluated
kNumber of neighbors returned
Returns
The KdTreeKNearestIndexQuery mutable object to iterate over the search results.
See also
KdTreeKNearestQueryBase

Definition at line 308 of file kdTree.h.

◆ kNearestNeighborsIndexQuery()

template<typename Traits >
KdTreeKNearestIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::kNearestNeighborsIndexQuery ( ) const
inline

Convenience function that provides an empty k-nearest neighbors Query object.

The returned object can call for a k-nearest neighbors search using the operator (), which takes a k and an index as parameters.

Same as KdTreeBase::kNearestNeighbors (0, 0)

Returns
The empty KdTreeKNearestIndexQuery mutable object to iterate over the search results.
See also
KdTreeKNearestQueryBase

Definition at line 334 of file kdTree.h.

◆ kNearestNeighborsQuery()

template<typename Traits >
KdTreeKNearestPointQuery< Traits > Ponca::StaticKdTreeBase< Traits >::kNearestNeighborsQuery ( ) const
inline

Convenience function that provides an empty k-nearest neighbors Query object.

The returned object can call for a k-nearest neighbors search using the operator (), which takes a k and a position as parameters.

Same as KdTreeBase::kNearestNeighbors (0, VectorType::Zero())

Returns
The empty KdTreeKNearestPointQuery mutable object to iterate over the search results.
See also
KdTreeKNearestQueryBase

Definition at line 321 of file kdTree.h.

◆ leafCount()

template<typename Traits >
NodeIndexType Ponca::StaticKdTreeBase< Traits >::leafCount ( ) const
inline

Get the number of leafs in the KdTree.

Definition at line 214 of file kdTree.h.

◆ minCellSize()

template<typename Traits >
LeafSizeType Ponca::StaticKdTreeBase< Traits >::minCellSize ( ) const
inline

Read leaf min size.

Definition at line 252 of file kdTree.h.

◆ nearestNeighbor() [1/2]

template<typename Traits >
KdTreeNearestPointQuery< Traits > Ponca::StaticKdTreeBase< Traits >::nearestNeighbor ( const VectorType point) const
inline

Computes a Query object that contains the nearest point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
pointPoint from where the query is evaluated
Returns
The KdTreeNearestPointQuery mutable object that contains the search result.
See also
KdTreeNearestQueryBase

Definition at line 346 of file kdTree.h.

◆ nearestNeighbor() [2/2]

template<typename Traits >
KdTreeNearestIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::nearestNeighbor ( IndexType  index) const
inline

Computes a Query object that contains the nearest point. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
indexIndex of the point from where the query is evaluated
Returns
The KdTreeKNearestIndexQuery mutable object that contains the search result.
See also
KdTreeNearestQueryBase

Definition at line 356 of file kdTree.h.

◆ nearestNeighborIndexQuery()

template<typename Traits >
KdTreeNearestIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::nearestNeighborIndexQuery ( ) const
inline

Convenience function that provides an empty nearest neighbor Query object.

The returned object can call for a nearest neighbor search using the operator (), which takes an index as parameter.

Same as KdTreeBase::nearestNeighbor (0)

Returns
The KdTreeKNearestIndexQuery mutable object that contains the search result.
See also
KdTreeNearestQueryBase

Definition at line 384 of file kdTree.h.

◆ nearestNeighborQuery()

template<typename Traits >
KdTreeNearestIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::nearestNeighborQuery ( ) const
inline

Convenience function that provides an empty nearest neighbor Query object.

The returned object can call for a nearest neighbor search using the operator (), which takes a position as parameter.

Same as KdTreeBase::nearestNeighbor (VectorType::Zero())

Returns
The empty KdTreeNearestPointQuery mutable object that contains the search result.
See also
KdTreeNearestQueryBase

Definition at line 370 of file kdTree.h.

◆ nodeCount()

template<typename Traits >
NodeIndexType Ponca::StaticKdTreeBase< Traits >::nodeCount ( ) const
inline

Get the number of nodes in the KdTree.

Definition at line 196 of file kdTree.h.

◆ nodes()

template<typename Traits >
const NodeContainer & Ponca::StaticKdTreeBase< Traits >::nodes ( ) const
inline

Get the internal node container.

Definition at line 232 of file kdTree.h.

◆ pointCount()

template<typename Traits >
IndexType Ponca::StaticKdTreeBase< Traits >::pointCount ( ) const
inline

Get the number of points.

Definition at line 208 of file kdTree.h.

◆ pointDataFromSample() [1/2]

template<typename Traits >
DataPoint & Ponca::StaticKdTreeBase< Traits >::pointDataFromSample ( IndexType  sample_index)
inline

Return the DataPoint associated with the specified sample index.

Note
Convenience function, equivalent to point_data()[pointFromSample(sample_index)]

Definition at line 275 of file kdTree.h.

◆ pointDataFromSample() [2/2]

template<typename Traits >
const DataPoint & Ponca::StaticKdTreeBase< Traits >::pointDataFromSample ( IndexType  sample_index) const
inline

Return the DataPoint associated with the specified sample index.

Note
Convenience function, equivalent to point_data()[pointFromSample(sample_index)]

Definition at line 283 of file kdTree.h.

◆ pointFromSample()

template<typename Traits >
IndexType Ponca::StaticKdTreeBase< Traits >::pointFromSample ( IndexType  sample_index) const
inline

Return the point index associated with the specified sample index.

Definition at line 267 of file kdTree.h.

◆ points() [1/2]

template<typename Traits >
PointContainer & Ponca::StaticKdTreeBase< Traits >::points ( )
inline

Get the internal point container.

Definition at line 220 of file kdTree.h.

◆ points() [2/2]

template<typename Traits >
const PointContainer & Ponca::StaticKdTreeBase< Traits >::points ( ) const
inline

Get the internal point container.

Definition at line 226 of file kdTree.h.

◆ print()

template<typename Traits >
PONCA_MULTIARCH_HOST void StaticKdTreeBase::print ( std::ostream &  os,
bool  verbose = false 
) const
inline

Definition at line 72 of file kdTree.hpp.

◆ rangeNeighbors() [1/2]

template<typename Traits >
KdTreeRangePointQuery< Traits > Ponca::StaticKdTreeBase< Traits >::rangeNeighbors ( const VectorType point,
Scalar  r 
) const
inline

Computes a Query object to iterate over the neighbors that are inside a given radius. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
pointPoint from where the query is evaluated
rRadius around where to search the neighbors
Returns
The KdTreeRangePointQuery mutable object to iterate over the search results.
See also
KdTreeRangeQueryBase

Definition at line 397 of file kdTree.h.

◆ rangeNeighbors() [2/2]

template<typename Traits >
KdTreeRangeIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::rangeNeighbors ( IndexType  index,
Scalar  r 
) const
inline

Computes a Query object to iterate over the neighbors that are inside a given radius. The returned object can be reset and reused with the () operator (using the same argument types as parameters).

Parameters
indexIndex of the point from where the query is evaluated
rRadius around where to search the neighbors
Returns
The KdTreeRangeIndexQuery mutable object to iterate over the search results.
See also
KdTreeRangeQueryBase

Definition at line 407 of file kdTree.h.

◆ rangeNeighborsIndexQuery()

template<typename Traits >
KdTreeRangeIndexQuery< Traits > Ponca::StaticKdTreeBase< Traits >::rangeNeighborsIndexQuery ( ) const
inline

KdTreeBase::rangeNeighborsQuery.

The returned object can call for a range neighbor search using the operator (), which takes an index as parameter.

Same as KdTreeBase::rangeNeighborsQuery (0, 0)

Returns
The empty KdTreeRangeIndexQuery mutable object to iterate over the search results.
See also
KdTreeRangeQueryBase

Definition at line 435 of file kdTree.h.

◆ rangeNeighborsQuery()

template<typename Traits >
KdTreeRangePointQuery< Traits > Ponca::StaticKdTreeBase< Traits >::rangeNeighborsQuery ( ) const
inline

Convenience function that provides an empty range neighbor Query object.

The returned object can call for a range neighbor search using the operator (), which takes a position as parameter.

Same as KdTreeBase::rangeNeighborsQuery (0, VectorType::Zero())

Returns
The empty KdTreeRangePointQuery mutable object to iterate over the search results.
See also
KdTreeRangeQueryBase

Definition at line 421 of file kdTree.h.

◆ sampleCount()

template<typename Traits >
IndexType Ponca::StaticKdTreeBase< Traits >::sampleCount ( ) const
inline

Get the number of indices.

Definition at line 202 of file kdTree.h.

◆ samples()

template<typename Traits >
const IndexContainer & Ponca::StaticKdTreeBase< Traits >::samples ( ) const
inline

Get the internal indice container.

Definition at line 238 of file kdTree.h.

◆ setMinCellSize()

template<typename Traits >
void Ponca::StaticKdTreeBase< Traits >::setMinCellSize ( LeafSizeType  min_cell_size)
inline

Write leaf min size.

Definition at line 258 of file kdTree.h.

◆ valid()

template<typename Traits >
PONCA_MULTIARCH_HOST bool StaticKdTreeBase::valid ( ) const
inline

Definition at line 19 of file kdTree.hpp.

Member Data Documentation

◆ m_bufs

template<typename Traits >
Buffers Ponca::StaticKdTreeBase< Traits >::m_bufs
protected

Buffers used to store the KdTree.

Definition at line 447 of file kdTree.h.

◆ m_leaf_count

template<typename Traits >
NodeIndexType Ponca::StaticKdTreeBase< Traits >::m_leaf_count {0}
protected

Number of leaves in the Kdtree (computed during construction)

Definition at line 449 of file kdTree.h.

◆ m_min_cell_size

template<typename Traits >
LeafSizeType Ponca::StaticKdTreeBase< Traits >::m_min_cell_size {64}
protected

Minimal number of points per leaf.

Definition at line 448 of file kdTree.h.

◆ MAX_DEPTH

template<typename Traits >
constexpr int Ponca::StaticKdTreeBase< Traits >::MAX_DEPTH = Traits::MAX_DEPTH
staticconstexpr

The maximum depth of the kd-tree.

Definition at line 170 of file kdTree.h.

◆ MAX_NODE_COUNT

template<typename Traits >
constexpr std::size_t Ponca::StaticKdTreeBase< Traits >::MAX_NODE_COUNT = NodeType::MAX_COUNT
staticconstexpr

The maximum number of nodes that the kd-tree can have.

Definition at line 165 of file kdTree.h.

◆ MAX_POINT_COUNT

template<typename Traits >
constexpr std::size_t Ponca::StaticKdTreeBase< Traits >::MAX_POINT_COUNT = std::size_t(2) << sizeof(IndexType)*8
staticconstexpr

The maximum number of points that can be stored in the kd-tree.

Definition at line 167 of file kdTree.h.

◆ SUPPORTS_SUBSAMPLING

template<typename Traits >
constexpr bool Ponca::StaticKdTreeBase< Traits >::SUPPORTS_SUBSAMPLING = false
staticconstexpr

Definition at line 172 of file kdTree.h.