|
| 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.
|
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>>
{
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
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;
{
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.