NuriKit v0.1.0b2
Loading...
Searching...
No Matches
nuri::OCTree Class Reference

An octree implementation for 3D point clouds. More...

#include <nuri/core/geometry.h>

Public Types

using Points = ConstRef<Matrix3Xd>

Public Member Functions

 OCTree ()=default
 OCTree (Points pts, int bucket_size=32)
void rebuild (Points pts, int bucket_size=-1)
void find_neighbors_kd (const Vector3d &pt, int k, std::vector< int > &idxs, std::vector< double > &distsq, double cutoff=-1) const
void find_neighbors_d (const Vector3d &pt, double cutoff, std::vector< int > &idxs, std::vector< double > &distsq) const
void find_neighbors_tree (const OCTree &oct, double cutoff, std::vector< int > &self, std::vector< int > &other) const
std::vector< std::vector< int > > find_neighbors_tree (const OCTree &oct, double cutoff) const
void find_neighbors_self (double cutoff, std::vector< int > &left, std::vector< int > &right) const
const Matrix3Xd & pts () const
const Vector3d & max () const
const Vector3d & len () const
void notify_transform (const Vector3d &new_max, const Vector3d &new_len)
 Notify the octree that the point set has been transformed by scaling and/or translation.
const std::vector< internal::OCTreeNode > & nodes () const
int size () const
int root () const
int bucket_size () const
const ArrayXi & idxs () const
const internal::OCTreeNode & node (int i) const
const internal::OCTreeNode & operator[] (int idx) const

Detailed Description

An octree implementation for 3D point clouds.

The octree partitions 3D space into axis-aligned boxes recursively, allowing efficient spatial queries such as nearest neighbor search.

This implementation is designed for static point clouds. To update the point set, one must rebuild(const MatrixLike &) the octree.

One notable exception is that if the points are only scaled uniformly in each axis and/or translated in any order, the octree can still be used without rebuilding, due to the axis-aligned nature of the octree. Note that, however, it is the user's responsibility to ensure that the points are "correctly" transformed separately from the octree; otherwise, the behavior is undefined.

Member Typedef Documentation

◆ Points

using nuri::OCTree::Points = ConstRef<Matrix3Xd>

Constructor & Destructor Documentation

◆ OCTree() [1/2]

nuri::OCTree::OCTree ( )
default

◆ OCTree() [2/2]

nuri::OCTree::OCTree ( Points pts,
int bucket_size = 32 )
inlineexplicit

Member Function Documentation

◆ bucket_size()

int nuri::OCTree::bucket_size ( ) const
inline

◆ find_neighbors_d()

void nuri::OCTree::find_neighbors_d ( const Vector3d & pt,
double cutoff,
std::vector< int > & idxs,
std::vector< double > & distsq ) const

◆ find_neighbors_kd()

void nuri::OCTree::find_neighbors_kd ( const Vector3d & pt,
int k,
std::vector< int > & idxs,
std::vector< double > & distsq,
double cutoff = -1 ) const

◆ find_neighbors_self()

void nuri::OCTree::find_neighbors_self ( double cutoff,
std::vector< int > & left,
std::vector< int > & right ) const

◆ find_neighbors_tree() [1/2]

std::vector< std::vector< int > > nuri::OCTree::find_neighbors_tree ( const OCTree & oct,
double cutoff ) const

◆ find_neighbors_tree() [2/2]

void nuri::OCTree::find_neighbors_tree ( const OCTree & oct,
double cutoff,
std::vector< int > & self,
std::vector< int > & other ) const

◆ idxs()

const ArrayXi & nuri::OCTree::idxs ( ) const
inline

◆ len()

const Vector3d & nuri::OCTree::len ( ) const
inline

◆ max()

const Vector3d & nuri::OCTree::max ( ) const
inline

◆ node()

const internal::OCTreeNode & nuri::OCTree::node ( int i) const
inline

◆ nodes()

const std::vector< internal::OCTreeNode > & nuri::OCTree::nodes ( ) const
inline

◆ notify_transform()

void nuri::OCTree::notify_transform ( const Vector3d & new_max,
const Vector3d & new_len )

Notify the octree that the point set has been transformed by scaling and/or translation.

Parameters
new_maxThe new maximum corner of the bounding box.
new_lenThe new length of the bounding box in each axis.
Warning
It is the user's responsibility to ensure that the points are "correctly" transformed separately from the octree; otherwise, the behavior is undefined.

◆ operator[]()

const internal::OCTreeNode & nuri::OCTree::operator[] ( int idx) const
inline

◆ pts()

const Matrix3Xd & nuri::OCTree::pts ( ) const
inline

◆ rebuild()

void nuri::OCTree::rebuild ( Points pts,
int bucket_size = -1 )
inline

◆ root()

int nuri::OCTree::root ( ) const
inline

◆ size()

int nuri::OCTree::size ( ) const
inline

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