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

Node optimized for voxel. More...

#include <VoxelNode.hpp>

Classes

struct  NeighborAreaCache
 Use by the method findRelativeVoxel to improve performance. More...
 

Public Types

using Container = T_Container
 
using VoxelData = typename T_Container::VoxelData
 
using iterator = typename T_Container::iterator
 
using P_Node = Node< VoxelNode< T_Container > >
 

Public Member Functions

 VoxelNode (int x, int y, int z, int size)
 Constructs VoxelNode with its properties. More...
 
 VoxelNode (VoxelNode const &other)
 Copy constructor. More...
 
virtual ~VoxelNode ()=default
 Default destructor. More...
 
iterator begin ()
 Returns an iterator to the first voxel of the node. More...
 
iterator end ()
 Returns an iterator to the voxel folowing the last voxel of the node. More...
 
unsigned int getNbVoxel () const
 Returns the number of voxels. More...
 
bool hasVoxel () const
 Returns true if node has voxel. More...
 
T_ContainergetVoxelContainer ()
 Returns the voxel container. More...
 
T_Container const * getVoxelContainer () const
 Returns the voxel container. More...
 
std::shared_ptr< T_ContainergetSharedVoxelContainer ()
 Returns a shared pointer to the voxel container. More...
 
void setVoxelContainer (std::shared_ptr< T_Container > container)
 Sets the voxel container. More...
 
iterator findVoxel (int x, int y, int z)
 Search voxel. More...
 
bool findVoxel (iterator &it)
 Search voxel. More...
 
iterator findRelativeVoxel (int x, int y, int z) const
 Search voxel with position relative to the node position. More...
 
iterator findRelativeVoxel (NeighborAreaCache &neighbor_cache, int x, int y, int z) const
 Search voxel with position relative to the node position. Use cache structure for improve performance in case of lot of calls. More...
 
template<typename... Args>
bool addVoxel (iterator &it, Args &&... args)
 Add the voxel if not exist. More...
 
template<typename... Args>
bool updateVoxel (iterator &it, Args &&... args)
 Update the voxel if already exist. More...
 
template<typename... Args>
void putVoxel (iterator &it, Args &&... args)
 Add or update the voxel. More...
 
template<typename... Args>
bool removeVoxel (iterator const &it, Args &&... args)
 Remove an existing voxel. More...
 
void exploreVoxel (std::function< void(iterator const &)> const &predicate) const
 Browse all voxels and call predicate on each. More...
 
void exploreVoxelContainer (std::function< void(typename T_Container::VoxelContainer const &)> const &predicate) const
 Browse all voxel containers and call predicate on each. More...
 
void exploreVoxelNode (std::function< void(VoxelNode const &)> const &predicate) const
 Browse all voxel nodes and call predicate on each. More...
 
void exploreVoxelNode (std::function< void(VoxelNode &)> const &predicate)
 Browse all voxel containers and call predicate on each. More...
 
void exploreBoundingBox (BoundingBox< int > const &bounding_box, std::function< void(VoxelNode &)> const &in_predicate, std::function< void(VoxelNode &)> const &out_predicate)
 Browse all voxel containers. More...
 
void copyOnWrite ()
 Copy the voxel container if a modification occured (add/remove/update voxel) and the container is shared with another octree. More...
 
void merge (VoxelNode &node)
 Merge this with node Add existing voxel in node inside this but don't update voxel that already exists in this. More...
 
bool empty () const
 Returns true if there is no voxel. More...
 
void serialize (std::string &str) const
 Serialize the structure. More...
 
size_t unserialize (char const *str, size_t strsize)
 Unserialize str. More...
 

Static Public Member Functions

static int findContainerPosition (int src, int container_id)
 Method to find voxel container index inside its container. More...
 
static int findVoxelPosition (int src)
 Method to find voxel index inside its container. More...
 

Private Member Functions

uint32_t serializeNode (std::string &str) const
 Serialize node in str. More...
 

Private Attributes

std::shared_ptr< T_Container_container
 Voxel container. More...
 
friend T_Container
 

Detailed Description

template<class T_Container>
class voxomap::VoxelNode< T_Container >

Node optimized for voxel.

Examples
ArrayArea, Find Voxel, SidedArea, and SmartArea.

Definition at line 16 of file VoxelNode.hpp.

Member Typedef Documentation

◆ Container

template<class T_Container >
using voxomap::VoxelNode< T_Container >::Container = T_Container

Definition at line 24 of file VoxelNode.hpp.

◆ VoxelData

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

Definition at line 25 of file VoxelNode.hpp.

◆ iterator

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

Definition at line 26 of file VoxelNode.hpp.

◆ P_Node

template<class T_Container >
using voxomap::VoxelNode< T_Container >::P_Node = Node<VoxelNode<T_Container> >

Definition at line 27 of file VoxelNode.hpp.

Constructor & Destructor Documentation

◆ VoxelNode() [1/2]

template<class T_Container >
voxomap::VoxelNode< T_Container >::VoxelNode ( int  x,
int  y,
int  z,
int  size 
)

Constructs VoxelNode with its properties.

Parameters
xX coordinate
yY coordinate
zZ coordinate
sizeSize of the node

◆ VoxelNode() [2/2]

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

Copy constructor.

◆ ~VoxelNode()

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

Default destructor.

Member Function Documentation

◆ begin()

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

Returns an iterator to the first voxel of the node.

◆ end()

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

Returns an iterator to the voxel folowing the last voxel of the node.

◆ getNbVoxel()

template<class T_Container >
unsigned int voxomap::VoxelNode< T_Container >::getNbVoxel ( ) const

Returns the number of voxels.

◆ hasVoxel()

template<class T_Container >
bool voxomap::VoxelNode< T_Container >::hasVoxel ( ) const

Returns true if node has voxel.

◆ getVoxelContainer() [1/2]

template<class T_Container >
T_Container* voxomap::VoxelNode< T_Container >::getVoxelContainer ( )

Returns the voxel container.

◆ getVoxelContainer() [2/2]

template<class T_Container >
T_Container const* voxomap::VoxelNode< T_Container >::getVoxelContainer ( ) const

Returns the voxel container.

◆ getSharedVoxelContainer()

template<class T_Container >
std::shared_ptr<T_Container> voxomap::VoxelNode< T_Container >::getSharedVoxelContainer ( )

Returns a shared pointer to the voxel container.

◆ setVoxelContainer()

template<class T_Container >
void voxomap::VoxelNode< T_Container >::setVoxelContainer ( std::shared_ptr< T_Container container)

Sets the voxel container.

◆ findVoxel() [1/2]

template<class T_Container >
iterator voxomap::VoxelNode< T_Container >::findVoxel ( int  x,
int  y,
int  z 
)

Search voxel.

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

◆ findVoxel() [2/2]

template<class T_Container >
bool voxomap::VoxelNode< T_Container >::findVoxel ( iterator it)

Search voxel.

Parameters
itIterator with the voxel position
Returns
True if a voxel was found, it was updated

◆ findRelativeVoxel() [1/2]

template<class T_Container >
iterator voxomap::VoxelNode< T_Container >::findRelativeVoxel ( int  x,
int  y,
int  z 
) const

Search voxel with position relative to the node position.

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

◆ findRelativeVoxel() [2/2]

template<class T_Container >
iterator voxomap::VoxelNode< T_Container >::findRelativeVoxel ( NeighborAreaCache neighbor_cache,
int  x,
int  y,
int  z 
) const

Search voxel with position relative to the node position. Use cache structure for improve performance in case of lot of calls.

Parameters
neighbor_cacheCache structure
xX coordinate
yY coordinate
zZ coordinate
Returns
iterator on the found voxel

◆ addVoxel()

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

Add the voxel if not exist.

Parameters
itIterator that contain coordinates
argsArguments forward to VoxelData constructor
Returns
True if a voxel was added

◆ updateVoxel()

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

Update the voxel if already exist.

Parameters
itIterator that contain coordinates
argsArguments forward to VoxelData constructor
Returns
True if a voxel was updated

◆ putVoxel()

template<class T_Container >
template<typename... Args>
void voxomap::VoxelNode< T_Container >::putVoxel ( iterator it,
Args &&...  args 
)

Add or update the voxel.

Parameters
itIterator that contain coordinates
argsArguments forward to VoxelData constructor

◆ removeVoxel()

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

Remove an existing voxel.

Parameters
itIterator that contain coordinates
argsArguments forward to VoxelData constructor
Returns
True if success

◆ exploreVoxel()

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

Browse all voxels and call predicate on each.

Parameters
predicateFunction called for each voxel

◆ exploreVoxelContainer()

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

Browse all voxel containers and call predicate on each.

Parameters
predicateFunction called for each voxel container

◆ exploreVoxelNode() [1/2]

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

Browse all voxel nodes and call predicate on each.

Parameters
predicateFunction called for each voxel node

◆ exploreVoxelNode() [2/2]

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

Browse all voxel containers and call predicate on each.

Parameters
predicateFunction called for each voxel area

◆ exploreBoundingBox()

template<class T_Container >
void voxomap::VoxelNode< 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

◆ copyOnWrite()

template<class T_Container >
void voxomap::VoxelNode< T_Container >::copyOnWrite ( )

Copy the voxel container if a modification occured (add/remove/update voxel) and the container is shared with another octree.

◆ merge()

template<class T_Container >
void voxomap::VoxelNode< T_Container >::merge ( VoxelNode< T_Container > &  node)

Merge this with node Add existing voxel in node inside this but don't update voxel that already exists in this.

◆ empty()

template<class T_Container >
bool voxomap::VoxelNode< T_Container >::empty ( ) const

Returns true if there is no voxel.

◆ serialize()

template<class T_Container >
void voxomap::VoxelNode< 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::VoxelNode< 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

◆ serializeNode()

template<class T_Container >
uint32_t voxomap::VoxelNode< T_Container >::serializeNode ( std::string &  str) const
private

Serialize node in str.

◆ findContainerPosition()

template<class T_Container >
static int voxomap::VoxelNode< T_Container >::findContainerPosition ( int  src,
int  container_id 
)
static

Method to find voxel container index inside its container.

Parameters
srcCoordinate (x, y or z)
container_idId of the container
Returns
The index

◆ findVoxelPosition()

template<class T_Container >
static int voxomap::VoxelNode< T_Container >::findVoxelPosition ( int  src)
static

Method to find voxel index inside its container.

Parameters
srcCoordinate (x, y or z)
Returns
The index

Member Data Documentation

◆ _container

template<class T_Container >
std::shared_ptr<T_Container> voxomap::VoxelNode< T_Container >::_container
private

Voxel container.

Definition at line 222 of file VoxelNode.hpp.

◆ T_Container

template<class T_Container >
friend voxomap::VoxelNode< T_Container >::T_Container
private

Definition at line 223 of file VoxelNode.hpp.


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