10#include "../../Common/Macro.h"
14#include <Eigen/Geometry>
18#ifndef PARSED_WITH_DOXYGEN
21 constexpr int clz(
unsigned int value)
23# if PONCA_HAS_BUILTIN_CLZ
24 return __builtin_clz(value);
31 unsigned int msb_mask = 1 << (
sizeof(
unsigned int) * 8 - 1);
33 for (; (value & msb_mask) == 0; value <<= 1, ++count)
42 template <
typename NodeIndex,
typename Scalar,
int DIM>
58 DIM_BITS =
sizeof(
unsigned int) * 8 - internal::clz((
unsigned int)
DIM),
62 using UIndex =
typename std::make_unsigned<NodeIndex>::type;
73 Scalar split_value{0};
75 UIndex split_dim : DIM_BITS;
78 template <
typename Index,
typename Size>
106 template <
typename Index,
typename NodeIndex,
typename DataPoint,
typename LeafSize = Index,
112 using Scalar =
typename DataPoint::Scalar;
132 using AabbType = Eigen::AlignedBox<Scalar, DataPoint::Dim>;
140 data.m_leaf = n.data.m_leaf;
144 data.m_inner = n.data.m_inner;
152 m_is_leaf = n.m_is_leaf;
155 data.m_leaf = n.data.m_leaf;
159 data.m_inner = n.data.m_inner;
166 PONCA_MULTIARCH
constexpr KdTreeCustomizableNode(
const KdTreeCustomizableNode& n) : m_is_leaf(n.m_is_leaf)
170 data.m_leaf = n.data.m_leaf;
174 data.m_inner = n.data.m_inner;
178 PONCA_MULTIARCH
constexpr KdTreeCustomizableNode& operator=(
const KdTreeCustomizableNode& n)
182 m_is_leaf = n.m_is_leaf;
185 data.m_leaf = n.data.m_leaf;
189 data.m_inner = n.data.m_inner;
196 PONCA_MULTIARCH_HOST ~KdTreeCustomizableNode() {}
198 PONCA_MULTIARCH [[nodiscard]]
bool is_leaf()
const {
return m_is_leaf; }
199 PONCA_MULTIARCH
void set_is_leaf(
bool is_leaf) { m_is_leaf = is_leaf; }
217 data.m_leaf.start = start;
231 PONCA_MULTIARCH
void configure_inner(Scalar split_value, Index first_child_id, Index split_dim)
235 data.m_inner.split_value = split_value;
236 data.m_inner.first_child_id = first_child_id;
237 data.m_inner.split_dim = split_dim;
272 PONCA_MULTIARCH [[
nodiscard]]
inline LeafType& getAsLeaf() {
return data.m_leaf; }
273 PONCA_MULTIARCH [[nodiscard]]
inline InnerType& getAsInner() {
return data.m_inner; }
274 PONCA_MULTIARCH [[nodiscard]]
inline const LeafType& getAsLeaf()
const {
return data.m_leaf; }
275 PONCA_MULTIARCH [[nodiscard]]
inline const InnerType& getAsInner()
const {
return data.m_inner; }
278 bool m_is_leaf{
true};
281 constexpr Data() : m_leaf() {}
290 template <
typename Index,
typename NodeIndex,
typename DataPo
int,
typename LeafSize = Index>
293 KdTreeDefaultInnerNode<NodeIndex, typename DataPoint::Scalar, DataPoint::Dim>,
294 KdTreeDefaultLeafNode<Index, LeafSize>>
309 template <
typename _DataPoint,
template <
typename ,
typename ,
typename ,
335 using PointContainer = std::vector<DataPoint>;
336 using IndexContainer = std::vector<IndexType>;
339 using NodeIndexType = std::size_t;
341 using NodeContainer = std::vector<NodeType>;
351 template <
typename _DataPoint,
template <
typename ,
typename ,
typename ,
381 using NodeIndexType = std::size_t;
Aggregator class used to declare specialized structures using CRTP.
The node type used by default by the kd-tree.
Scalar inner_split_value() const
The position of the AABB split of the inner node.
@ MAX_COUNT
The maximum number of nodes that a kd-tree can have when using this node type.
Index leaf_start() const
The start index of the range of the leaf node in the sample index array.
Eigen::AlignedBox< Scalar, DataPoint::Dim > AabbType
The type used to store node bounding boxes.
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.
int inner_split_dim() const
Which axis the split of the AABB of the inner node was done on.
LeafSize leaf_size() const
The size of the range of the leaf node in the sample index array.
Index inner_first_child_id() const
The index of the first child of the node in the node array of the kd-tree.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
@ INDEX_BITS
The bit width used to store the first child index.
The default traits type used by the kd-tree.
@ MAX_DEPTH
A compile-time constant specifying the maximum depth of the kd-tree.
Variant to the KdTree Traits type that uses pointers as internal storage instead of an STL-like conta...
@ MAX_DEPTH
A compile-time constant specifying the maximum depth of the kd-tree.