Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
mrpt::utils::CDynamicGrid3D< T > Class Template Reference

Detailed Description

template<class T>
class mrpt::utils::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 28 of file CDynamicGrid3D.h.

#include <mrpt/utils/CDynamicGrid3D.h>

Inheritance diagram for mrpt::utils::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
 
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...
 
void dyngridcommon_writeToStream (mrpt::utils::CStream &out) const
 Serialization of all parameters, except the contents of each voxel (responsability of the derived class) More...
 
void dyngridcommon_readFromStream (mrpt::utils::CStream &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::utils::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 32 of file CDynamicGrid3D.h.

Member Function Documentation

◆ cellAbsIndexFromCXCYCZ()

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

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).

See also
x2idx(), y2idx(), z2idx()

Definition at line 233 of file CDynamicGrid3D.h.

Referenced by mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::cellByIndex(), and mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::cellByPos().

Here is the caller graph for this function:

◆ cellByIndex() [1/2]

template<class T>
T* mrpt::utils::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 267 of file CDynamicGrid3D.h.

◆ cellByIndex() [2/2]

template<class T>
const T* mrpt::utils::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 277 of file CDynamicGrid3D.h.

◆ cellByPos() [1/2]

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

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

Definition at line 248 of file CDynamicGrid3D.h.

Referenced by TEST().

Here is the caller graph for this function:

◆ cellByPos() [2/2]

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

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 256 of file CDynamicGrid3D.h.

◆ clear()

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

Erase the contents of all the cells, setting them to their default values (default ctor).

Reimplemented in mrpt::maps::CRandomFieldGridMap3D.

Definition at line 213 of file CDynamicGrid3D.h.

Referenced by mrpt::maps::CRandomFieldGridMap3D::clear().

Here is the caller graph for this function:

◆ dyngridcommon_readFromStream()

template<class T>
void mrpt::utils::CDynamicGrid3D< T >::dyngridcommon_readFromStream ( mrpt::utils::CStream in)
inlineprotected

Serialization of all parameters, except the contents of each voxel (responsability of the derived class)

Definition at line 337 of file CDynamicGrid3D.h.

◆ dyngridcommon_writeToStream()

template<class T>
void mrpt::utils::CDynamicGrid3D< T >::dyngridcommon_writeToStream ( mrpt::utils::CStream out) const
inlineprotected

Serialization of all parameters, except the contents of each voxel (responsability of the derived class)

Definition at line 327 of file CDynamicGrid3D.h.

◆ fill()

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

Fills all the cells with the same value.

Definition at line 221 of file CDynamicGrid3D.h.

◆ getResolutionXY()

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

Definition at line 295 of file CDynamicGrid3D.h.

◆ getResolutionZ()

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

Definition at line 296 of file CDynamicGrid3D.h.

◆ getSizeX()

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

Definition at line 285 of file CDynamicGrid3D.h.

◆ getSizeY()

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

Definition at line 286 of file CDynamicGrid3D.h.

◆ getSizeZ()

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

Definition at line 287 of file CDynamicGrid3D.h.

◆ getVoxelCount()

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

Definition at line 288 of file CDynamicGrid3D.h.

◆ getXMax()

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

Definition at line 290 of file CDynamicGrid3D.h.

◆ getXMin()

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

Definition at line 289 of file CDynamicGrid3D.h.

◆ getYMax()

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

Definition at line 292 of file CDynamicGrid3D.h.

◆ getYMin()

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

Definition at line 291 of file CDynamicGrid3D.h.

◆ getZMax()

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

Definition at line 294 of file CDynamicGrid3D.h.

◆ getZMin()

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

Definition at line 293 of file CDynamicGrid3D.h.

◆ idx2x()

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

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

Definition at line 313 of file CDynamicGrid3D.h.

◆ idx2y()

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

Definition at line 314 of file CDynamicGrid3D.h.

◆ idx2z()

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

Definition at line 315 of file CDynamicGrid3D.h.

◆ m_map_castaway_const()

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

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

Definition at line 321 of file CDynamicGrid3D.h.

◆ resize()

template<class T>
virtual void mrpt::utils::CDynamicGrid3D< T >::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 
)
inlinevirtual

Changes the size of the grid, maintaining previous contents.

See also
setSize

Definition at line 46 of file CDynamicGrid3D.h.

◆ setSize()

template<class T>
virtual void mrpt::utils::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 173 of file CDynamicGrid3D.h.

Referenced by mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::CDynamicGrid3D().

Here is the caller graph for this function:

◆ x2idx()

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

Transform a coordinate values into voxel indexes.

Definition at line 298 of file CDynamicGrid3D.h.

Referenced by mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::cellByPos().

Here is the caller graph for this function:

◆ y2idx()

template<class T>
int mrpt::utils::CDynamicGrid3D< T >::y2idx ( double  y) const
inline

Definition at line 302 of file CDynamicGrid3D.h.

Referenced by mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::cellByPos().

Here is the caller graph for this function:

◆ z2idx()

template<class T>
int mrpt::utils::CDynamicGrid3D< T >::z2idx ( double  z) const
inline

Definition at line 306 of file CDynamicGrid3D.h.

Referenced by mrpt::utils::CDynamicGrid3D< TRandomFieldVoxel >::cellByPos().

Here is the caller graph for this function:

Member Data Documentation

◆ INVALID_VOXEL_IDX

template<class T>
const size_t mrpt::utils::CDynamicGrid3D< T >::INVALID_VOXEL_IDX = size_t(-1)
static

◆ m_map

template<class T>
std::vector<T> mrpt::utils::CDynamicGrid3D< T >::m_map
mutableprotected

◆ m_resolution_xy

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_resolution_xy
protected

◆ m_resolution_z

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_resolution_z
protected

◆ m_size_x

template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_x
protected

◆ m_size_x_times_y

template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_x_times_y
protected

◆ m_size_y

template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_y
protected

◆ m_size_z

template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_z
protected

◆ m_x_max

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_x_max
protected

◆ m_x_min

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_x_min
protected

◆ m_y_max

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_y_max
protected

◆ m_y_min

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_y_min
protected

◆ m_z_max

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_z_max
protected

◆ m_z_min

template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_z_min
protected



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019