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

Super container used in leaves of the VoxelOctree. Mix between a fixed size 3D array (like in ArraySuperContainer) and a dynamic array. Useful for little density of sub-containers. More...

#include <SparseSuperContainer.hpp>

Public Types

using Container = T_Container
 
using VoxelData = typename Container::VoxelData
 
using VoxelContainer = typename Container::VoxelContainer
 
using iterator = supercontainer_iterator< SparseSuperContainer< Container, T_InternalContainer > >
 

Public Member Functions

 SparseSuperContainer ()=default
 Default constructor. More...
 
 SparseSuperContainer (SparseSuperContainer const &other)=default
 Default Copy constructor. More...
 
 SparseSuperContainer (SparseSuperContainer &&other)=default
 Default move constructor. More...
 
 ~SparseSuperContainer ()=default
 Default destructor. More...
 
void init (VoxelNode< SparseSuperContainer< Container, T_InternalContainer >> const &)
 Initialization method, do nothing. More...
 
uint32_t getNbVoxel () const
 Returns number of voxels. More...
 
template<typename Iterator >
VoxelDatafindVoxel (Iterator &it)
 Find voxel. More...
 
template<typename Iterator >
VoxelData const * findVoxel (Iterator &it) const
 Find voxel. More...
 
bool hasContainer (uint8_t x) const
 Check if there is sub-container. More...
 
bool hasContainer (uint8_t x, uint8_t y) const
 Check if there is sub-container. More...
 
bool hasContainer (uint8_t x, uint8_t y, uint8_t z) const
 Check if there is sub-container. More...
 
ContainerfindContainer (uint8_t x, uint8_t y, uint8_t z)
 Find sub-container. More...
 
Container const * findContainer (uint8_t x, uint8_t y, uint8_t z) const
 Find sub-container. 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 , typename... Args>
bool removeVoxel (Iterator const &it, Args &&... args)
 Remove an existing voxel. More...
 
void serialize (std::string &str) const
 Serialize the structure. More...
 
size_t unserialize (char const *str, size_t size)
 Unserialize str inside this. 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(typename T_Container::VoxelContainer const &)> const &predicate) const
 

Static Public Attributes

static const uint32_t NB_CONTAINERS = 8
 
static const uint32_t CONTAINER_MASK = NB_CONTAINERS - 1
 
static const uint32_t NB_VOXELS = NB_CONTAINERS * Container::NB_VOXELS
 
static const uint32_t COORD_MASK = ~(NB_VOXELS - 1)
 
static const uint32_t VOXEL_MASK = Container::VOXEL_MASK
 
static const uint32_t NB_SUPERCONTAINER = 1 + Container::NB_SUPERCONTAINER
 
static const uint32_t SUPERCONTAINER_ID = NB_SUPERCONTAINER - 1
 

Private Attributes

SparseIDArray< std::unique_ptr< Container >, NB_CONTAINERS, T_InternalContainer > _sparseArray
 
uint32_t _nbVoxels = 0
 Number of voxels. More...
 

Detailed Description

template<class T_Container, template< class... > class T_InternalContainer = std::vector>
class voxomap::SparseSuperContainer< T_Container, T_InternalContainer >

Super container used in leaves of the VoxelOctree. Mix between a fixed size 3D array (like in ArraySuperContainer) and a dynamic array. Useful for little density of sub-containers.

The container uses 3 arrays:

  • A dynamic vector that contains the super/voxel sub-containers
  • A fixed size array (like ArraySuperContainer) that contains the sub-container id inside the above vector, 0 if there is no sub-container
  • A dynamic vector that contains the unused sub-container inside the first vector. Due to performance issue, the removed sub-container pointer are not removed from the first vector.

Definition at line 41 of file SparseSuperContainer.hpp.

Member Typedef Documentation

◆ Container

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
using voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::Container = T_Container

Definition at line 43 of file SparseSuperContainer.hpp.

◆ VoxelData

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
using voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::VoxelData = typename Container::VoxelData

Definition at line 44 of file SparseSuperContainer.hpp.

◆ VoxelContainer

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
using voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::VoxelContainer = typename Container::VoxelContainer

Definition at line 45 of file SparseSuperContainer.hpp.

◆ iterator

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
using voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::iterator = supercontainer_iterator<SparseSuperContainer<Container, T_InternalContainer> >

Definition at line 46 of file SparseSuperContainer.hpp.

Constructor & Destructor Documentation

◆ SparseSuperContainer() [1/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::SparseSuperContainer ( )
default

Default constructor.

◆ SparseSuperContainer() [2/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::SparseSuperContainer ( SparseSuperContainer< T_Container, T_InternalContainer > const &  other)
default

Default Copy constructor.

◆ SparseSuperContainer() [3/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::SparseSuperContainer ( SparseSuperContainer< T_Container, T_InternalContainer > &&  other)
default

Default move constructor.

◆ ~SparseSuperContainer()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::~SparseSuperContainer ( )
default

Default destructor.

Member Function Documentation

◆ init()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
void voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::init ( VoxelNode< SparseSuperContainer< Container, T_InternalContainer >> const &  )

Initialization method, do nothing.

Definition at line 77 of file SparseSuperContainer.hpp.

◆ getNbVoxel()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::getNbVoxel ( ) const

Returns number of voxels.

◆ findVoxel() [1/2]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator >
VoxelData* voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::findVoxel ( Iterator &  it)

Find voxel.

Parameters
itIterator containing voxel position information
Returns
The voxel if exists, otherwise nullptr

◆ findVoxel() [2/2]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator >
VoxelData const* voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::findVoxel ( Iterator &  it) const

Find voxel.

Parameters
itIterator containing voxel position information
Returns
The voxel if exists, otherwise nullptr

◆ hasContainer() [1/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::hasContainer ( uint8_t  x) const

Check if there is sub-container.

Parameters
xX index
Returns
True if there is sub-container

◆ hasContainer() [2/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::hasContainer ( uint8_t  x,
uint8_t  y 
) const

Check if there is sub-container.

Parameters
xX index
yY index
Returns
True if there is sub-container

◆ hasContainer() [3/3]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::hasContainer ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Check if there is sub-container.

Parameters
xX index
yY index
zZ index
Returns
True if there is sub-container

◆ findContainer() [1/2]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
Container* voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::findContainer ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)

Find sub-container.

Parameters
xX index
yY index
zZ index
Returns
Pointer on the sub-container if exists, otherwise nullptr

◆ findContainer() [2/2]

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
Container const* voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::findContainer ( uint8_t  x,
uint8_t  y,
uint8_t  z 
) const

Find sub-container.

Parameters
xX index
yY index
zZ index
Returns
Pointer on the sub-container if exists, otherwise nullptr

◆ addVoxel()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator , typename... Args>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::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_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator , typename... Args>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::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_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator , typename... Args>
void voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::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_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator , typename... Args>
bool voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::removeVoxel ( Iterator const &  it,
Args &&...  args 
)

Remove an existing voxel.

Parameters
itIterator that contains the informations
argsArguments to forward to removeVoxel method of the container
Returns
True if success

◆ serialize()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
void voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::serialize ( std::string &  str) const

Serialize the structure.

Parameters
strString use for save the serialization

◆ unserialize()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
size_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::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

◆ exploreVoxel()

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
template<typename Iterator >
void voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::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_Container , template< class... > class T_InternalContainer = std::vector>
void voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::exploreVoxelContainer ( std::function< void(typename T_Container::VoxelContainer const &)> const &  predicate) const

Member Data Documentation

◆ NB_CONTAINERS

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::NB_CONTAINERS = 8
static

Definition at line 48 of file SparseSuperContainer.hpp.

◆ CONTAINER_MASK

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::CONTAINER_MASK = NB_CONTAINERS - 1
static

Definition at line 49 of file SparseSuperContainer.hpp.

◆ NB_VOXELS

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::NB_VOXELS = NB_CONTAINERS * Container::NB_VOXELS
static

Definition at line 50 of file SparseSuperContainer.hpp.

◆ COORD_MASK

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::COORD_MASK = ~(NB_VOXELS - 1)
static

Definition at line 51 of file SparseSuperContainer.hpp.

◆ VOXEL_MASK

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::VOXEL_MASK = Container::VOXEL_MASK
static

Definition at line 52 of file SparseSuperContainer.hpp.

◆ NB_SUPERCONTAINER

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::NB_SUPERCONTAINER = 1 + Container::NB_SUPERCONTAINER
static

Definition at line 53 of file SparseSuperContainer.hpp.

◆ SUPERCONTAINER_ID

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
const uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::SUPERCONTAINER_ID = NB_SUPERCONTAINER - 1
static

Definition at line 54 of file SparseSuperContainer.hpp.

◆ _sparseArray

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
SparseIDArray<std::unique_ptr<Container>, NB_CONTAINERS, T_InternalContainer> voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::_sparseArray
private

Definition at line 191 of file SparseSuperContainer.hpp.

◆ _nbVoxels

template<class T_Container , template< class... > class T_InternalContainer = std::vector>
uint32_t voxomap::SparseSuperContainer< T_Container, T_InternalContainer >::_nbVoxels = 0
private

Number of voxels.

Definition at line 192 of file SparseSuperContainer.hpp.


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