Ponca  2cfe00173bb12dda99e12b2b48a0e1f683bc5cdd
Point Cloud Analysis library
Loading...
Searching...
No Matches
Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType > Class Template Reference

The node type used by default by the kd-tree. More...

#include <kdTreeTraits.h>

Inheritance diagram for Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >:
Collaboration diagram for Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >:

Public Types

enum  : std::size_t { MAX_COUNT = std::size_t(2) << InnerType::INDEX_BITS }
using AabbType = Eigen::AlignedBox<Scalar, DataPoint::Dim>
 The type used to store node bounding boxes.

Public Member Functions

constexpr KdTreeCustomizableNode (KdTreeCustomizableNode &&n)
constexpr KdTreeCustomizableNode & operator= (KdTreeCustomizableNode &&n)
constexpr KdTreeCustomizableNode (const KdTreeCustomizableNode &n)
constexpr KdTreeCustomizableNode & operator= (const KdTreeCustomizableNode &n)
bool is_leaf () const
void set_is_leaf (bool is_leaf)
void configure_range (Index start, Index size, const AabbType &aabb)
 Configures the range of the node in the sample index array of the kd-tree.
void configure_inner (Scalar split_value, Index first_child_id, Index split_dim)
 Configures the inner node information.
Index leaf_start () const
 The start index of the range of the leaf node in the sample index array.
LeafSize leaf_size () const
 The size of the range of the leaf node in the sample index array.
Scalar inner_split_value () const
 The position of the AABB split of the inner node.
int inner_split_dim () const
 Which axis the split of the AABB of the inner node was done on.
Index inner_first_child_id () const
 The index of the first child of the node in the node array of the kd-tree.

Protected Member Functions

LeafType & getAsLeaf ()
InnerType & getAsInner ()
const LeafType & getAsLeaf () const
const InnerType & getAsInner () const

Detailed Description

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
class Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >

The node type used by default by the kd-tree.

It is possible to modify the Inner and Leaf node types by inheritance. For instance, to add a Bounding box to inner nodes, define a custom inner node type:

template <typename NodeIndex, typename Scalar, int DIM, typename _AabbType = Eigen::AlignedBox<Scalar, DIM>>
struct MyKdTreeInnerNode : public Ponca::KdTreeDefaultInnerNode<NodeIndex, Scalar, DIM>
{
using AabbType = _AabbType;
AabbType m_aabb{};
};

Define a custom node type to use it, and expose custom data (inner/leaf node are not exposed directly):

template <typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index>
struct MyKdTreeNode
: Ponca::KdTreeCustomizableNode<Index, NodeIndex, DataPoint, LeafSize,
MyKdTreeInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>>
{
using Base =
Ponca::KdTreeCustomizableNode<Index, NodeIndex, DataPoint, LeafSize,
MyKdTreeInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>>;
using AabbType = typename Base::AabbType;
void configure_range(Index start, Index size, const AabbType& aabb)
{
Base::configure_range(start, size, aabb);
if (!Base::is_leaf())
{
Base::getAsInner().m_aabb = aabb;
}
}
[[nodiscard]] inline std::optional<AabbType> getAabb() const
{
if (!Base::is_leaf())
return Base::getAsInner().m_aabb;
else
return std::optional<AabbType>();
}
};

To use in the KdTree, define a type using the custom node:

The added attribute can be accessed

auto bbox = kdtree.nodes()[0].getAabb();
if (bbox)
{
std::cout << "Root bounding box is as follows: \n"
<< " Center: " << bbox->center() << " Diagonal: " << bbox->diagonal() << std::endl;
}

Definition at line 109 of file kdTreeTraits.h.

Member Typedef Documentation

◆ AabbType

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
using Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::AabbType = Eigen::AlignedBox<Scalar, DataPoint::Dim>

The type used to store node bounding boxes.

Must provide diagonal(), and center() functions, all returning a DataPoint::VectorType.

Definition at line 132 of file kdTreeTraits.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
anonymous enum : std::size_t
Enumerator
MAX_COUNT 

The maximum number of nodes that a kd-tree can have when using this node type.

Definition at line 117 of file kdTreeTraits.h.

Constructor & Destructor Documentation

◆ KdTreeCustomizableNode() [1/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::KdTreeCustomizableNode ( KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType > && n)
inlineconstexpr

Definition at line 136 of file kdTreeTraits.h.

◆ KdTreeCustomizableNode() [2/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::KdTreeCustomizableNode ( const KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType > & n)
inlineconstexpr

Definition at line 166 of file kdTreeTraits.h.

◆ ~KdTreeCustomizableNode()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::~KdTreeCustomizableNode ( )
inline

Definition at line 196 of file kdTreeTraits.h.

Member Function Documentation

◆ configure_inner()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
void Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::configure_inner ( Scalar split_value,
Index first_child_id,
Index split_dim )
inline

Configures the inner node information.

See also
the inner node accessors for a more detailed explanation of each argument.

Called after set_is_leaf and configure_range during kd-tree construction.

Definition at line 231 of file kdTreeTraits.h.

◆ configure_range()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
void Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::configure_range ( Index start,
Index size,
const AabbType & aabb )
inline

Configures the range of the node in the sample index array of the kd-tree.

See also
the leaf node accessors for a more detailed explanation of each argument.
Note
The AABB is not required by the implementation, so nodes don't have to make it available.

Called after set_is_leaf during kd-tree construction.

Definition at line 213 of file kdTreeTraits.h.

◆ getAsInner() [1/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
InnerType & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::getAsInner ( )
inlinenodiscardprotected

Definition at line 273 of file kdTreeTraits.h.

◆ getAsInner() [2/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
const InnerType & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::getAsInner ( ) const
inlinenodiscardprotected

Definition at line 275 of file kdTreeTraits.h.

◆ getAsLeaf() [1/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
LeafType & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::getAsLeaf ( )
inlinenodiscardprotected

Definition at line 272 of file kdTreeTraits.h.

◆ getAsLeaf() [2/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
const LeafType & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::getAsLeaf ( ) const
inlinenodiscardprotected

Definition at line 274 of file kdTreeTraits.h.

◆ inner_first_child_id()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Index Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::inner_first_child_id ( ) const
inlinenodiscard

The index of the first child of the node in the node array of the kd-tree.

Note
The second child is stored directly after the first in the array (i.e. first_child_id + 1).

Definition at line 269 of file kdTreeTraits.h.

◆ inner_split_dim()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
int Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::inner_split_dim ( ) const
inlinenodiscard

Which axis the split of the AABB of the inner node was done on.

Definition at line 260 of file kdTreeTraits.h.

◆ inner_split_value()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Scalar Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::inner_split_value ( ) const
inlinenodiscard

The position of the AABB split of the inner node.

Definition at line 255 of file kdTreeTraits.h.

◆ is_leaf()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
bool Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::is_leaf ( ) const
inlinenodiscard

Definition at line 198 of file kdTreeTraits.h.

◆ leaf_size()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
LeafSize Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::leaf_size ( ) const
inlinenodiscard

The size of the range of the leaf node in the sample index array.

Definition at line 250 of file kdTreeTraits.h.

◆ leaf_start()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
Index Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::leaf_start ( ) const
inlinenodiscard

The start index of the range of the leaf node in the sample index array.

Definition at line 245 of file kdTreeTraits.h.

◆ operator=() [1/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
KdTreeCustomizableNode & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::operator= ( const KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType > & n)
inlineconstexpr

Definition at line 178 of file kdTreeTraits.h.

◆ operator=() [2/2]

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
KdTreeCustomizableNode & Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::operator= ( KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType > && n)
inlineconstexpr

Definition at line 148 of file kdTreeTraits.h.

◆ set_is_leaf()

template<typename Index, typename NodeIndex, typename DataPoint, typename LeafSize = Index, typename _InnerNodeType = KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>, typename _LeafNodeType = KdTreeDefaultLeafNode<Index, LeafSize>>
void Ponca::KdTreeCustomizableNode< Index, NodeIndex, DataPoint, LeafSize, _InnerNodeType, _LeafNodeType >::set_is_leaf ( bool is_leaf)
inline

Definition at line 199 of file kdTreeTraits.h.