Voxomap
A C++11 voxel container.
voxomap::ArrayContainer< T_Voxel > Struct Template Reference

Voxel container used in leaves of the VoxelOctree. Based on a fixed size 3D array, useful for high density of voxels. More...

#include <ArrayContainer.hpp>

Public Types

using VoxelData = T_Voxel
 
using VoxelContainer = ArrayContainer< T_Voxel >
 
using iterator = container_iterator< ArrayContainer< T_Voxel > >
 

Public Member Functions

 ArrayContainer ()
 Default constructor. More...
 
 ArrayContainer (ArrayContainer const &other)
 Copy constructor. More...
 
 ArrayContainer (ArrayContainer &&other)=default
 Default move constructor. More...
 
void init (VoxelNode< ArrayContainer< VoxelData >> const &)
 Initialization method, do nothing. More...
 
uint16_t getNbVoxel () const
 Returns number of voxels. More...
 
bool hasVoxel (uint8_t x) const
 Check if there is voxel inside. More...
 
bool hasVoxel (uint8_t x, uint8_t y) const
 Check if there is voxel inside. More...
 
bool hasVoxel (uint8_t x, uint8_t y, uint8_t z) const
 Check if voxel exist. More...
 
VoxelDatafindVoxel (uint8_t x, uint8_t y, uint8_t z)
 Find voxel. More...
 
VoxelData const * findVoxel (uint8_t x, uint8_t y, uint8_t z) const
 Find voxel. More...
 
template<typename Iterator >
VoxelDatafindVoxel (Iterator &it)
 Find voxel. More...
 
template<typename Iterator >
VoxelData const * findVoxel (Iterator &it) const
 Find voxel. More...
 
template<typename Iterator , typename... Args>
bool addVoxel (Iterator &it, Args &&... args)
 Add a voxel, don't update an existing voxel. More...
 
template<typename Iterator , typename... Args>
bool updateVoxel (Iterator &it, Args &&... args)
 Update an existing voxel, don't create a new one. More...
 
template<typename Iterator , typename... Args>
void putVoxel (Iterator &it, Args &&... args)
 Add or update a voxel. More...
 
template<typename Iterator >
bool removeVoxel (Iterator const &it, VoxelData *voxel=nullptr)
 Remove an existing voxel. More...
 
template<typename Iterator >
void exploreVoxel (Iterator &it, std::function< void(Iterator const &)> const &predicate) const
 Go through all voxels of the container and call the predicate for each. More...
 
void exploreVoxelContainer (std::function< void(ArrayContainer const &)> const &predicate) const
 
void serialize (std::string &str) const
 Serialize the structure. More...
 
size_t unserialize (char const *str, size_t size)
 Unserialize str inside this. More...
 

Public Attributes

uint16_t nbVoxels = 0
 Number of voxels. More...
 
union {
   VoxelData   area [NB_VOXELS][NB_VOXELS][NB_VOXELS]
 Array of voxels. More...
 
   char   _
 Compiler hack to avoid the call of the default constructor of each VoxelData of area. More...
 
}; 
 

Static Public Attributes

static const uint32_t NB_VOXELS = 8
 
static const uint32_t COORD_MASK = ~(NB_VOXELS - 1)
 
static const uint32_t VOXEL_MASK = NB_VOXELS - 1
 
static const uint32_t NB_SUPERCONTAINER = 0
 

Private Member Functions

template<typename T >
std::enable_if< std::is_trivially_constructible< T >::value >::type copy (T const &other)
 Method use to copy data when voxel is trivially constructible. More...
 
template<typename T >
std::enable_if<!std::is_trivially_constructible< T >::value >::type copy (T const &other)
 Method use to copy data when voxel is not trivially constructible. More...
 

Static Private Attributes

static const VoxelData _emptyArea [NB_VOXELS][NB_VOXELS][NB_VOXELS]
 

Detailed Description

template<class T_Voxel>
struct voxomap::ArrayContainer< T_Voxel >

Voxel container used in leaves of the VoxelOctree. Based on a fixed size 3D array, useful for high density of voxels.

  • Advantage:
    • Good global performances
  • Disadvantage:
    • Big memory footprint (RAM and serialized), same footprint with 1 or 512 voxels.

Definition at line 28 of file ArrayContainer.hpp.

Member Typedef Documentation

◆ VoxelData

template<class T_Voxel >
using voxomap::ArrayContainer< T_Voxel >::VoxelData = T_Voxel

Definition at line 32 of file ArrayContainer.hpp.

◆ VoxelContainer

template<class T_Voxel >
using voxomap::ArrayContainer< T_Voxel >::VoxelContainer = ArrayContainer<T_Voxel>

Definition at line 33 of file ArrayContainer.hpp.

◆ iterator

template<class T_Voxel >
using voxomap::ArrayContainer< T_Voxel >::iterator = container_iterator<ArrayContainer<T_Voxel> >

Definition at line 34 of file ArrayContainer.hpp.

Constructor & Destructor Documentation

◆ ArrayContainer() [1/3]

template<class T_Voxel >
voxomap::ArrayContainer< T_Voxel >::ArrayContainer ( )

Default constructor.

◆ ArrayContainer() [2/3]

template<class T_Voxel >
voxomap::ArrayContainer< T_Voxel >::ArrayContainer ( ArrayContainer< T_Voxel > const &  other)

Copy constructor.

◆ ArrayContainer() [3/3]

template<class T_Voxel >
voxomap::ArrayContainer< T_Voxel >::ArrayContainer ( ArrayContainer< T_Voxel > &&  other)
default

Default move constructor.

Member Function Documentation

◆ init()

template<class T_Voxel >
void voxomap::ArrayContainer< T_Voxel >::init ( VoxelNode< ArrayContainer< VoxelData >> const &  )

Initialization method, do nothing.

Definition at line 57 of file ArrayContainer.hpp.

◆ getNbVoxel()

template<class T_Voxel >
uint16_t voxomap::ArrayContainer< T_Voxel >::getNbVoxel ( ) const

Returns number of voxels.

◆ hasVoxel() [1/3]

template<class T_Voxel >
bool voxomap::ArrayContainer< T_Voxel >::hasVoxel ( uint8_t  x) const

Check if there is voxel inside.

Parameters
xX index
Returns
True if there is a voxel

◆ hasVoxel() [2/3]

template<class T_Voxel >
bool voxomap::ArrayContainer< T_Voxel >::hasVoxel ( uint8_t  x,
uint8_t  y 
) const

Check if there is voxel inside.

Parameters
xX index
yY index
Returns
True if there is a voxel

◆ hasVoxel() [3/3]

template<class T_Voxel >
bool voxomap::ArrayContainer< T_Voxel >::hasVoxel ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Check if voxel exist.

Parameters
xX index
yY index
zZ index
Returns
True if voxel exist

◆ findVoxel() [1/4]

template<class T_Voxel >
VoxelData* voxomap::ArrayContainer< T_Voxel >::findVoxel ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)

Find voxel.

Parameters
xX index
yY index
zZ index
Returns
The voxel if exists, otherwise nullptr

◆ findVoxel() [2/4]

template<class T_Voxel >
VoxelData const* voxomap::ArrayContainer< T_Voxel >::findVoxel ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Find voxel.

Parameters
xX index
yY index
zZ index
Returns
The voxel if exists, otherwise nullptr

◆ findVoxel() [3/4]

template<class T_Voxel >
template<typename Iterator >
VoxelData* voxomap::ArrayContainer< T_Voxel >::findVoxel ( Iterator &  it)

Find voxel.

Parameters
itThe iterator
Returns
The voxel if exists, otherwise nullptr

◆ findVoxel() [4/4]

template<class T_Voxel >
template<typename Iterator >
VoxelData const* voxomap::ArrayContainer< T_Voxel >::findVoxel ( Iterator &  it) const

Find voxel.

Parameters
itThe iterator
Returns
The voxel if exists, otherwise nullptr

◆ addVoxel()

template<class T_Voxel >
template<typename Iterator , typename... Args>
bool voxomap::ArrayContainer< T_Voxel >::addVoxel ( Iterator &  it,
Args &&...  args 
)

Add a voxel, don't update an existing voxel.

Parameters
itIterator that contains the informations
argsArguments to forward to voxel constructor
Returns
True if success and update it

◆ updateVoxel()

template<class T_Voxel >
template<typename Iterator , typename... Args>
bool voxomap::ArrayContainer< T_Voxel >::updateVoxel ( Iterator &  it,
Args &&...  args 
)

Update an existing voxel, don't create a new one.

Parameters
itIterator that contains the informations
argsArguments to forward to voxel constructor
Returns
True if success

◆ putVoxel()

template<class T_Voxel >
template<typename Iterator , typename... Args>
void voxomap::ArrayContainer< T_Voxel >::putVoxel ( Iterator &  it,
Args &&...  args 
)

Add or update a voxel.

Parameters
itIterator that contains the informations
argsArguments to forward to voxel constructor

◆ removeVoxel()

template<class T_Voxel >
template<typename Iterator >
bool voxomap::ArrayContainer< T_Voxel >::removeVoxel ( Iterator const &  it,
VoxelData voxel = nullptr 
)

Remove an existing voxel.

Parameters
itIterator that contains the informations
voxelPointer on a voxel structure, filled with the data of the removed voxel
Returns
True if success

◆ exploreVoxel()

template<class T_Voxel >
template<typename Iterator >
void voxomap::ArrayContainer< T_Voxel >::exploreVoxel ( Iterator &  it,
std::function< void(Iterator const &)> const &  predicate 
) const

Go through all voxels of the container and call the predicate for each.

Parameters
itBegin iterator
predicateFunction called for each voxel found

◆ exploreVoxelContainer()

template<class T_Voxel >
void voxomap::ArrayContainer< T_Voxel >::exploreVoxelContainer ( std::function< void(ArrayContainer< T_Voxel > const &)> const &  predicate) const

◆ serialize()

template<class T_Voxel >
void voxomap::ArrayContainer< T_Voxel >::serialize ( std::string &  str) const

Serialize the structure.

Parameters
strString use for save the serialization

◆ unserialize()

template<class T_Voxel >
size_t voxomap::ArrayContainer< T_Voxel >::unserialize ( char const *  str,
size_t  size 
)

Unserialize str inside this.

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

◆ copy() [1/2]

template<class T_Voxel >
template<typename T >
std::enable_if<std::is_trivially_constructible<T>::value>::type voxomap::ArrayContainer< T_Voxel >::copy ( T const &  other)
private

Method use to copy data when voxel is trivially constructible.

◆ copy() [2/2]

template<class T_Voxel >
template<typename T >
std::enable_if<!std::is_trivially_constructible<T>::value>::type voxomap::ArrayContainer< T_Voxel >::copy ( T const &  other)
private

Method use to copy data when voxel is not trivially constructible.

Member Data Documentation

◆ NB_VOXELS

template<class T_Voxel >
const uint32_t voxomap::ArrayContainer< T_Voxel >::NB_VOXELS = 8
static

Definition at line 36 of file ArrayContainer.hpp.

◆ COORD_MASK

template<class T_Voxel >
const uint32_t voxomap::ArrayContainer< T_Voxel >::COORD_MASK = ~(NB_VOXELS - 1)
static

Definition at line 37 of file ArrayContainer.hpp.

◆ VOXEL_MASK

template<class T_Voxel >
const uint32_t voxomap::ArrayContainer< T_Voxel >::VOXEL_MASK = NB_VOXELS - 1
static

Definition at line 38 of file ArrayContainer.hpp.

◆ NB_SUPERCONTAINER

template<class T_Voxel >
const uint32_t voxomap::ArrayContainer< T_Voxel >::NB_SUPERCONTAINER = 0
static

Definition at line 39 of file ArrayContainer.hpp.

◆ nbVoxels

template<class T_Voxel >
uint16_t voxomap::ArrayContainer< T_Voxel >::nbVoxels = 0

Number of voxels.

Definition at line 171 of file ArrayContainer.hpp.

◆ area

template<class T_Voxel >
VoxelData voxomap::ArrayContainer< T_Voxel >::area[NB_VOXELS][NB_VOXELS][NB_VOXELS]

Array of voxels.

Definition at line 173 of file ArrayContainer.hpp.

◆ _

template<class T_Voxel >
char voxomap::ArrayContainer< T_Voxel >::_

Compiler hack to avoid the call of the default constructor of each VoxelData of area.

Definition at line 174 of file ArrayContainer.hpp.

◆ @1

union { ... }

◆ _emptyArea

template<class T_Voxel >
const VoxelData voxomap::ArrayContainer< T_Voxel >::_emptyArea[NB_VOXELS][NB_VOXELS][NB_VOXELS]
staticprivate

Used for initialize ArrayContainer::area attribute without call constructor on each VoxelData of array

Definition at line 192 of file ArrayContainer.hpp.


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