MRPT  1.9.9
mrpt::containers::CDynamicGrid3D< T > Class Template Reference

Detailed Description

template<class T>
class mrpt::containers::CDynamicGrid3D< T >

A 3D rectangular grid of dynamic size which stores any kind of data at each voxel.

Template Parameters
TThe type of each voxel in the grid.

Definition at line 25 of file CDynamicGrid3D.h.

#include <mrpt/containers/CDynamicGrid3D.h>

Inheritance diagram for mrpt::containers::CDynamicGrid3D< T >:
Inheritance graph

Public Member Functions

 CDynamicGrid3D (double x_min=-1.0, double x_max=1.0, double y_min=-1.0, double y_max=+1.0, double z_min=-1.0, double z_max=1.0, double resolution_xy=0.5, double resolution_z=0.5)
 Constructor. More...
 
virtual void resize (double new_x_min, double new_x_max, double new_y_min, double new_y_max, double new_z_min, double new_z_max, const T &defaultValueNewCells, double additionalMarginMeters=2.0)
 Changes the size of the grid, maintaining previous contents. More...
 
virtual void setSize (const double x_min, const double x_max, const double y_min, const double y_max, const double z_min, const double z_max, const double resolution_xy, const double resolution_z_=-1.0, const T *fill_value=nullptr)
 Changes the size of the grid, ERASING all previous contents. More...
 
virtual void clear ()
 Erase the contents of all the cells, setting them to their default values (default ctor). More...
 
void fill (const T &value)
 Fills all the cells with the same value. More...
 
size_t cellAbsIndexFromCXCYCZ (const int cx, const int cy, const int cz) const
 Gets the absolute index of a voxel in the linear container m_map[] from its cx,cy,cz indices, or -1 if out of map bounds (in any dimension). More...
 
T * cellByPos (double x, double y, double z)
 Returns a pointer to the contents of a voxel given by its coordinates, or nullptr if it is out of the map extensions. More...
 
const T * cellByPos (double x, double y, double z) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
T * cellByIndex (unsigned int cx, unsigned int cy, unsigned int cz)
 Returns a pointer to the contents of a voxel given by its voxel indexes, or nullptr if it is out of the map extensions. More...
 
const T * cellByIndex (unsigned int cx, unsigned int cy, unsigned int cz) const
 Returns a pointer to the contents of a voxel given by its voxel indexes, or nullptr if it is out of the map extensions. More...
 
size_t getSizeX () const
 
size_t getSizeY () const
 
size_t getSizeZ () const
 
size_t getVoxelCount () const
 
double getXMin () const
 
double getXMax () const
 
double getYMin () const
 
double getYMax () const
 
double getZMin () const
 
double getZMax () const
 
double getResolutionXY () const
 
double getResolutionZ () const
 
int x2idx (double x) const
 Transform a coordinate values into voxel indexes. More...
 
int y2idx (double y) const
 
int z2idx (double z) const
 
double idx2x (int cx) const
 Transform a voxel index into a coordinate value of the voxel central point. More...
 
double idx2y (int cy) const
 
double idx2z (int cz) const
 

Static Public Attributes

static const size_t INVALID_VOXEL_IDX = size_t(-1)
 

Protected Member Functions

std::vector< T > & m_map_castaway_const () const
 Used only from logically const method that really need to modify the object. More...
 
template<class ARCHIVE >
void dyngridcommon_writeToStream (ARCHIVE &out) const
 Serialization of all parameters, except the contents of each voxel (responsability of the derived class) More...
 
template<class ARCHIVE >
void dyngridcommon_readFromStream (ARCHIVE &in)
 Serialization of all parameters, except the contents of each voxel (responsability of the derived class) More...
 

Protected Attributes

std::vector< T > m_map
 The cells. More...
 
double m_x_min
 
double m_x_max
 
double m_y_min
 
double m_y_max
 
double m_z_min
 
double m_z_max
 
double m_resolution_xy
 
double m_resolution_z
 
size_t m_size_x
 
size_t m_size_y
 
size_t m_size_z
 
size_t m_size_x_times_y
 

Constructor & Destructor Documentation

◆ CDynamicGrid3D()

template<class T >
mrpt::containers::CDynamicGrid3D< T >::CDynamicGrid3D ( double  x_min = -1.0,
double  x_max = 1.0,
double  y_min = -1.0,
double  y_max = +1.0,
double  z_min = -1.0,
double  z_max = 1.0,
double  resolution_xy = 0.5,
double  resolution_z = 0.5 
)
inline

Constructor.

Definition at line 29 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::setSize().

Member Function Documentation

◆ cellAbsIndexFromCXCYCZ()

template<class T >
size_t mrpt::containers::CDynamicGrid3D< T >::cellAbsIndexFromCXCYCZ ( const int  cx,
const int  cy,
const int  cz 
) const
inline

◆ cellByIndex() [1/2]

template<class T >
T* mrpt::containers::CDynamicGrid3D< T >::cellByIndex ( unsigned int  cx,
unsigned int  cy,
unsigned int  cz 
)
inline

Returns a pointer to the contents of a voxel given by its voxel indexes, or nullptr if it is out of the map extensions.

Definition at line 264 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::cellAbsIndexFromCXCYCZ(), mrpt::containers::CDynamicGrid3D< T >::INVALID_VOXEL_IDX, and mrpt::containers::CDynamicGrid3D< T >::m_map.

◆ cellByIndex() [2/2]

template<class T >
const T* mrpt::containers::CDynamicGrid3D< T >::cellByIndex ( unsigned int  cx,
unsigned int  cy,
unsigned int  cz 
) const
inline

Returns a pointer to the contents of a voxel given by its voxel indexes, or nullptr if it is out of the map extensions.

Definition at line 274 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::cellAbsIndexFromCXCYCZ(), mrpt::containers::CDynamicGrid3D< T >::INVALID_VOXEL_IDX, and mrpt::containers::CDynamicGrid3D< T >::m_map.

◆ cellByPos() [1/2]

template<class T >
T* mrpt::containers::CDynamicGrid3D< T >::cellByPos ( double  x,
double  y,
double  z 
)
inline

◆ cellByPos() [2/2]

template<class T >
const T* mrpt::containers::CDynamicGrid3D< T >::cellByPos ( double  x,
double  y,
double  z 
) const
inline

◆ clear()

template<class T >
virtual void mrpt::containers::CDynamicGrid3D< T >::clear ( )
inlinevirtual

◆ dyngridcommon_readFromStream()

◆ dyngridcommon_writeToStream()

◆ fill()

template<class T >
void mrpt::containers::CDynamicGrid3D< T >::fill ( const T &  value)
inline

Fills all the cells with the same value.

Definition at line 218 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_map.

◆ getResolutionXY()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getResolutionXY ( ) const
inline

◆ getResolutionZ()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getResolutionZ ( ) const
inline

◆ getSizeX()

template<class T >
size_t mrpt::containers::CDynamicGrid3D< T >::getSizeX ( ) const
inline

Definition at line 282 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_size_x.

◆ getSizeY()

template<class T >
size_t mrpt::containers::CDynamicGrid3D< T >::getSizeY ( ) const
inline

Definition at line 283 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_size_y.

◆ getSizeZ()

template<class T >
size_t mrpt::containers::CDynamicGrid3D< T >::getSizeZ ( ) const
inline

Definition at line 284 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_size_z.

◆ getVoxelCount()

template<class T >
size_t mrpt::containers::CDynamicGrid3D< T >::getVoxelCount ( ) const
inline

◆ getXMax()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getXMax ( ) const
inline

Definition at line 287 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_x_max.

◆ getXMin()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getXMin ( ) const
inline

Definition at line 286 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_x_min.

◆ getYMax()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getYMax ( ) const
inline

Definition at line 289 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_y_max.

◆ getYMin()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getYMin ( ) const
inline

Definition at line 288 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_y_min.

◆ getZMax()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getZMax ( ) const
inline

Definition at line 291 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_z_max.

◆ getZMin()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::getZMin ( ) const
inline

Definition at line 290 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_z_min.

◆ idx2x()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::idx2x ( int  cx) const
inline

Transform a voxel index into a coordinate value of the voxel central point.

Definition at line 310 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_resolution_xy, and mrpt::containers::CDynamicGrid3D< T >::m_x_min.

◆ idx2y()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::idx2y ( int  cy) const
inline

◆ idx2z()

template<class T >
double mrpt::containers::CDynamicGrid3D< T >::idx2z ( int  cz) const
inline

◆ m_map_castaway_const()

template<class T >
std::vector<T>& mrpt::containers::CDynamicGrid3D< T >::m_map_castaway_const ( ) const
inlineprotected

Used only from logically const method that really need to modify the object.

Definition at line 318 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_map.

◆ resize()

◆ setSize()

template<class T >
virtual void mrpt::containers::CDynamicGrid3D< T >::setSize ( const double  x_min,
const double  x_max,
const double  y_min,
const double  y_max,
const double  z_min,
const double  z_max,
const double  resolution_xy,
const double  resolution_z_ = -1.0,
const T *  fill_value = nullptr 
)
inlinevirtual

Changes the size of the grid, ERASING all previous contents.

If fill_value is left as nullptr, the contents of cells may be undefined (some will remain with their old values, the new ones will have the default voxel value, but the location of old values may change wrt their old places). If fill_value is not nullptr, it is assured that all cells will have a copy of that value after resizing. If resolution_z<0, the same resolution will be used for all dimensions x,y,z as given in resolution_xy

See also
resize, fill

Definition at line 170 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_map, mrpt::containers::CDynamicGrid3D< T >::m_resolution_xy, mrpt::containers::CDynamicGrid3D< T >::m_resolution_z, mrpt::containers::CDynamicGrid3D< T >::m_size_x, mrpt::containers::CDynamicGrid3D< T >::m_size_x_times_y, mrpt::containers::CDynamicGrid3D< T >::m_size_y, mrpt::containers::CDynamicGrid3D< T >::m_size_z, mrpt::containers::CDynamicGrid3D< T >::m_x_max, mrpt::containers::CDynamicGrid3D< T >::m_x_min, mrpt::containers::CDynamicGrid3D< T >::m_y_max, mrpt::containers::CDynamicGrid3D< T >::m_y_min, mrpt::containers::CDynamicGrid3D< T >::m_z_max, mrpt::containers::CDynamicGrid3D< T >::m_z_min, and mrpt::round().

Referenced by mrpt::containers::CDynamicGrid3D< T >::CDynamicGrid3D().

◆ x2idx()

template<class T >
int mrpt::containers::CDynamicGrid3D< T >::x2idx ( double  x) const
inline

Transform a coordinate values into voxel indexes.

Definition at line 295 of file CDynamicGrid3D.h.

References mrpt::containers::CDynamicGrid3D< T >::m_resolution_xy, and mrpt::containers::CDynamicGrid3D< T >::m_x_min.

Referenced by mrpt::containers::CDynamicGrid3D< T >::cellByPos().

◆ y2idx()

◆ z2idx()

Member Data Documentation

◆ INVALID_VOXEL_IDX

◆ m_map

◆ m_resolution_xy

◆ m_resolution_z

◆ m_size_x

◆ m_size_x_times_y

◆ m_size_y

◆ m_size_z

◆ m_x_max

◆ m_x_min

◆ m_y_max

◆ m_y_min

◆ m_z_max

◆ m_z_min




Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 814d80880 Fri Aug 24 01:51:28 2018 +0200 at mar 26 may 2026 12:30:59 CEST