Voxomap
A C++11 voxel container.
voxomap::VoxelOctree< T_Container > Class Template Reference

Octree optimized for voxel. More...

#include <VoxelOctree.hpp>

Public Types

using VoxelData = typename T_Container::VoxelData
 
using iterator = typename T_Container::iterator
 

Public Member Functions

 VoxelOctree ()
 Default constructor. More...
 
 VoxelOctree (VoxelOctree< T_Container > const &other)
 Copy constructor. More...
 
 VoxelOctree (VoxelOctree< T_Container > &&other)
 Move constructor. More...
 
virtual ~VoxelOctree ()=default
 Default destructor. More...
 
VoxelOctreeoperator= (VoxelOctree< T_Container > const &other)
 Assignement operator. More...
 
VoxelOctreeoperator= (VoxelOctree< T_Container > &&other)
 Move assignement operator. More...
 
VoxelNode< T_Container > * push (VoxelNode< T_Container > &node) override
 Pushes node into the octree. More...
 
std::unique_ptr< VoxelNode< T_Container > > pop (VoxelNode< T_Container > &node) override
 Removes node from the octree. More...
 
void clear () override
 Clear the octree Removes all nodes and all elements. More...
 
template<typename T >
iterator findVoxel (T x, T y, T z)
 Returns a voxel iterator. More...
 
template<typename T >
VoxelNode< T_Container > * findVoxelNode (T x, T y, T z) const
 Returns a node, can be NULL. More...
 
template<typename T , typename... Args>
std::pair< iterator, bool > addVoxel (T x, T y, T z, Args &&... args)
 Add the voxel if not exist. More...
 
template<typename T , typename... Args>
iterator updateVoxel (T x, T y, T z, Args &&... args)
 Update the voxel if already exist. More...
 
template<typename... Args>
iterator updateVoxel (iterator it, Args &&... args)
 Update the voxel if already exist. More...
 
template<typename T , typename... Args>
iterator putVoxel (T x, T y, T z, Args &&... args)
 Add or update the voxel. More...
 
template<typename T , typename... Args>
bool removeVoxel (T x, T y, T z, Args &&... args)
 Removes a voxel. More...
 
template<typename... Args>
bool removeVoxel (iterator it, Args &&... args)
 Removes a voxel. More...
 
unsigned int getContainerSize () const
 Returns the size of containers. More...
 
void removeOfCache (VoxelNode< T_Container > const &node)
 Calcul the bounding box. More...
 
void exploreVoxel (std::function< void(iterator const &)> const &predicate) const
 Browse all voxels. More...
 
void exploreVoxelContainer (std::function< void(typename T_Container::VoxelContainer const &)> const &predicate) const
 Browse all voxel containers. More...
 
void exploreVoxelNode (std::function< void(VoxelNode< T_Container > const &)> const &predicate) const
 Browse all voxel nodes. More...
 
void exploreBoundingBox (BoundingBox< int > const &bounding_box, std::function< void(VoxelNode< T_Container > &)> const &in_predicate, std::function< void(VoxelNode< T_Container > &)> const &out_predicate)
 Browse all voxel containers. More...
 
unsigned int getNbVoxels () const
 Get the number of voxels. More...
 
void setNbVoxels (unsigned int nbVoxels)
 Set the number of voxels. More...
 
iterator begin ()
 Returns an iterator to the first voxel of the octree. More...
 
iterator end ()
 Returns an iterator to the element folowing the last voxel of the octree. More...
 
void serialize (std::string &str) const
 Serialize the structure. More...
 
size_t unserialize (char const *str, size_t strsize)
 Unserialize str. More...
 

Protected Member Functions

VoxelNode< T_Container > * pushContainerNode (int x, int y, int z)
 Adds the leaf node that contain the voxel container. More...
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, VoxelNode< T_Container > * >::type pushContainerNode (T x, T y, T z)
 Adds the leaf node that contain the voxel container. More...
 

Protected Attributes

VoxelNode< T_Container > * _nodeCache = nullptr
 Cache for improve performance. More...
 
unsigned int _nbVoxels = 0
 Number of voxels. More...
 

Private Member Functions

iterator _findVoxel (int x, int y, int z)
 Method to find voxel (for integer arguments) More...
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, iterator >::type _findVoxel (T x, T y, T z)
 Method to find voxel (for floating point arguments) More...
 
VoxelNode< T_Container > * _findVoxelNode (int x, int y, int z) const
 Method to find node that contain voxel (for integer arguments) More...
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, VoxelNode< T_Container > * >::type _findVoxelNode (T x, T y, T z) const
 Method to find node that contain voxel (for floating point arguments) More...
 

Detailed Description

template<class T_Container>
class voxomap::VoxelOctree< T_Container >

Octree optimized for voxel.

Examples
ArrayArea, Find Voxel, SidedArea, and SmartArea.

Definition at line 19 of file VoxelOctree.hpp.

Member Typedef Documentation

◆ VoxelData

template<class T_Container >
using voxomap::VoxelOctree< T_Container >::VoxelData = typename T_Container::VoxelData

Definition at line 27 of file VoxelOctree.hpp.

◆ iterator

template<class T_Container >
using voxomap::VoxelOctree< T_Container >::iterator = typename T_Container::iterator

Definition at line 28 of file VoxelOctree.hpp.

Constructor & Destructor Documentation

◆ VoxelOctree() [1/3]

template<class T_Container >
voxomap::VoxelOctree< T_Container >::VoxelOctree ( )

Default constructor.

◆ VoxelOctree() [2/3]

template<class T_Container >
voxomap::VoxelOctree< T_Container >::VoxelOctree ( VoxelOctree< T_Container > const &  other)

Copy constructor.

◆ VoxelOctree() [3/3]

template<class T_Container >
voxomap::VoxelOctree< T_Container >::VoxelOctree ( VoxelOctree< T_Container > &&  other)

Move constructor.

◆ ~VoxelOctree()

template<class T_Container >
virtual voxomap::VoxelOctree< T_Container >::~VoxelOctree ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ operator=() [1/2]

template<class T_Container >
VoxelOctree& voxomap::VoxelOctree< T_Container >::operator= ( VoxelOctree< T_Container > const &  other)

Assignement operator.

◆ operator=() [2/2]

template<class T_Container >
VoxelOctree& voxomap::VoxelOctree< T_Container >::operator= ( VoxelOctree< T_Container > &&  other)

Move assignement operator.

◆ push()

template<class T_Container >
VoxelNode<T_Container>* voxomap::VoxelOctree< T_Container >::push ( VoxelNode< T_Container > &  node)
override

Pushes node into the octree.

Parameters
nodeNode to push
Returns
Pointer to the added node, can be different of node if it is already present in the octree

◆ pop()

template<class T_Container >
std::unique_ptr<VoxelNode<T_Container> > voxomap::VoxelOctree< T_Container >::pop ( VoxelNode< T_Container > &  node)
override

Removes node from the octree.

Parameters
nodeNode to remove
Returns
Pointer to the removed node

◆ clear()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::clear ( )
override

Clear the octree Removes all nodes and all elements.

◆ findVoxel()

template<class T_Container >
template<typename T >
iterator voxomap::VoxelOctree< T_Container >::findVoxel ( x,
y,
z 
)

Returns a voxel iterator.

Parameters
xX coordinate
yY coordinate
zZ coordinate
Returns
iterator

◆ findVoxelNode()

template<class T_Container >
template<typename T >
VoxelNode<T_Container>* voxomap::VoxelOctree< T_Container >::findVoxelNode ( x,
y,
z 
) const

Returns a node, can be NULL.

Parameters
xX coordinate
yY coordinate
zZ coordinate
Returns
The node which contain the voxel, can be NULL

◆ addVoxel()

template<class T_Container >
template<typename T , typename... Args>
std::pair<iterator, bool> voxomap::VoxelOctree< T_Container >::addVoxel ( x,
y,
z,
Args &&...  args 
)

Add the voxel if not exist.

Parameters
xX coordinate
yY coordinate
zZ coordinate
argsArguments forward to VoxelData constructor
Returns
Returns a pair consisting of an iterator to the inserted element, or the already-existing element if no insertion happened, and a bool denoting whether the insertion took place (true if insertion happened, false if it did not).

◆ updateVoxel() [1/2]

template<class T_Container >
template<typename T , typename... Args>
iterator voxomap::VoxelOctree< T_Container >::updateVoxel ( x,
y,
z,
Args &&...  args 
)

Update the voxel if already exist.

Parameters
xX coordinate
yY coordinate
zZ coordinate
argsArguments forward to VoxelData constructor
Returns
iterator

◆ updateVoxel() [2/2]

template<class T_Container >
template<typename... Args>
iterator voxomap::VoxelOctree< T_Container >::updateVoxel ( iterator  it,
Args &&...  args 
)

Update the voxel if already exist.

Parameters
itIterator of the voxel to remove
argsArguments forward to VoxelData constructor
Returns
iterator

◆ putVoxel()

template<class T_Container >
template<typename T , typename... Args>
iterator voxomap::VoxelOctree< T_Container >::putVoxel ( x,
y,
z,
Args &&...  args 
)

Add or update the voxel.

Parameters
xX coordinate
yY coordinate
zZ coordinate
argsArguments forward to VoxelData constructor
Returns
iterator

◆ removeVoxel() [1/2]

template<class T_Container >
template<typename T , typename... Args>
bool voxomap::VoxelOctree< T_Container >::removeVoxel ( x,
y,
z,
Args &&...  args 
)

Removes a voxel.

Parameters
xX coordinate
yY coordinate
zZ coordinate
argsArguments forward to removeVoxel area method
Returns
True if success

◆ removeVoxel() [2/2]

template<class T_Container >
template<typename... Args>
bool voxomap::VoxelOctree< T_Container >::removeVoxel ( iterator  it,
Args &&...  args 
)

Removes a voxel.

Parameters
itIterator of the voxel to remove
argsArguments forward to removeVoxel area method
Returns
True if success

◆ getContainerSize()

template<class T_Container >
unsigned int voxomap::VoxelOctree< T_Container >::getContainerSize ( ) const

Returns the size of containers.

◆ removeOfCache()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::removeOfCache ( VoxelNode< T_Container > const &  node)

Calcul the bounding box.

◆ exploreVoxel()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::exploreVoxel ( std::function< void(iterator const &)> const &  predicate) const

Browse all voxels.

Parameters
predicateFunction called for each voxel

◆ exploreVoxelContainer()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::exploreVoxelContainer ( std::function< void(typename T_Container::VoxelContainer const &)> const &  predicate) const

Browse all voxel containers.

Parameters
predicateFunction called for each voxel container

◆ exploreVoxelNode()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::exploreVoxelNode ( std::function< void(VoxelNode< T_Container > const &)> const &  predicate) const

Browse all voxel nodes.

Parameters
predicateFunction called for each voxel node

◆ exploreBoundingBox()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::exploreBoundingBox ( BoundingBox< int > const &  bounding_box,
std::function< void(VoxelNode< T_Container > &)> const &  in_predicate,
std::function< void(VoxelNode< T_Container > &)> const &  out_predicate 
)

Browse all voxel containers.

Parameters
bounding_boxThe aligned axis bounding box
in_predicateFunction called for each voxel container inside the bounding box
out_predicateFunction called for each voxel container outside the bounding box

◆ getNbVoxels()

template<class T_Container >
unsigned int voxomap::VoxelOctree< T_Container >::getNbVoxels ( ) const

Get the number of voxels.

◆ setNbVoxels()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::setNbVoxels ( unsigned int  nbVoxels)

Set the number of voxels.

Parameters
nbVoxelsNumber of voxels

◆ begin()

template<class T_Container >
iterator voxomap::VoxelOctree< T_Container >::begin ( )

Returns an iterator to the first voxel of the octree.

◆ end()

template<class T_Container >
iterator voxomap::VoxelOctree< T_Container >::end ( )

Returns an iterator to the element folowing the last voxel of the octree.

◆ serialize()

template<class T_Container >
void voxomap::VoxelOctree< T_Container >::serialize ( std::string &  str) const

Serialize the structure.

Parameters
strString use for save the serialization

◆ unserialize()

template<class T_Container >
size_t voxomap::VoxelOctree< T_Container >::unserialize ( char const *  str,
size_t  strsize 
)

Unserialize str.

Parameters
strString that contains data
strsizeSize of the string
Returns
Number of bytes read inside str

◆ _findVoxel() [1/2]

template<class T_Container >
iterator voxomap::VoxelOctree< T_Container >::_findVoxel ( int  x,
int  y,
int  z 
)
private

Method to find voxel (for integer arguments)

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
iterator on the voxel

◆ _findVoxel() [2/2]

template<class T_Container >
template<typename T >
std::enable_if<std::is_floating_point<T>::value, iterator>::type voxomap::VoxelOctree< T_Container >::_findVoxel ( x,
y,
z 
)
private

Method to find voxel (for floating point arguments)

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
iterator on the voxel

◆ _findVoxelNode() [1/2]

template<class T_Container >
VoxelNode<T_Container>* voxomap::VoxelOctree< T_Container >::_findVoxelNode ( int  x,
int  y,
int  z 
) const
private

Method to find node that contain voxel (for integer arguments)

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
The found node

◆ _findVoxelNode() [2/2]

template<class T_Container >
template<typename T >
std::enable_if<std::is_floating_point<T>::value, VoxelNode<T_Container>*>::type voxomap::VoxelOctree< T_Container >::_findVoxelNode ( x,
y,
z 
) const
private

Method to find node that contain voxel (for floating point arguments)

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
The found node

◆ pushContainerNode() [1/2]

template<class T_Container >
VoxelNode<T_Container>* voxomap::VoxelOctree< T_Container >::pushContainerNode ( int  x,
int  y,
int  z 
)
protected

Adds the leaf node that contain the voxel container.

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
The added node

◆ pushContainerNode() [2/2]

template<class T_Container >
template<typename T >
std::enable_if<std::is_floating_point<T>::value, VoxelNode<T_Container>*>::type voxomap::VoxelOctree< T_Container >::pushContainerNode ( x,
y,
z 
)
protected

Adds the leaf node that contain the voxel container.

Parameters
xX coordinate of the voxel
yY coordinate of the voxel
zZ coordinate of the voxel
Returns
The added node

Member Data Documentation

◆ _nodeCache

template<class T_Container >
VoxelNode<T_Container>* voxomap::VoxelOctree< T_Container >::_nodeCache = nullptr
mutableprotected

Cache for improve performance.

Definition at line 273 of file VoxelOctree.hpp.

◆ _nbVoxels

template<class T_Container >
unsigned int voxomap::VoxelOctree< T_Container >::_nbVoxels = 0
protected

Number of voxels.

Definition at line 274 of file VoxelOctree.hpp.


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