Main MRPT website > C++ reference for MRPT 1.5.6
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 20 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=NULL)
 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 NULL 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 NULL 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 NULL 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

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 24 of file CDynamicGrid3D.h.

Member Function Documentation

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 185 of file CDynamicGrid3D.h.

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

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 NULL if it is out of the map extensions.

Definition at line 211 of file CDynamicGrid3D.h.

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 NULL if it is out of the map extensions.

Definition at line 220 of file CDynamicGrid3D.h.

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 NULL if it is out of the map extensions.

Definition at line 195 of file CDynamicGrid3D.h.

Referenced by TEST().

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 202 of file CDynamicGrid3D.h.

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 170 of file CDynamicGrid3D.h.

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

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 266 of file CDynamicGrid3D.h.

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 260 of file CDynamicGrid3D.h.

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

Fills all the cells with the same value.

Definition at line 177 of file CDynamicGrid3D.h.

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

Definition at line 239 of file CDynamicGrid3D.h.

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

Definition at line 240 of file CDynamicGrid3D.h.

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

Definition at line 227 of file CDynamicGrid3D.h.

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

Definition at line 228 of file CDynamicGrid3D.h.

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

Definition at line 229 of file CDynamicGrid3D.h.

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

Definition at line 230 of file CDynamicGrid3D.h.

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

Definition at line 233 of file CDynamicGrid3D.h.

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

Definition at line 232 of file CDynamicGrid3D.h.

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

Definition at line 235 of file CDynamicGrid3D.h.

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

Definition at line 234 of file CDynamicGrid3D.h.

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

Definition at line 237 of file CDynamicGrid3D.h.

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

Definition at line 236 of file CDynamicGrid3D.h.

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 248 of file CDynamicGrid3D.h.

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

Definition at line 249 of file CDynamicGrid3D.h.

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

Definition at line 250 of file CDynamicGrid3D.h.

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 255 of file CDynamicGrid3D.h.

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 33 of file CDynamicGrid3D.h.

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 = NULL 
)
inlinevirtual

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

If fill_value is left as NULL, 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 NULL, 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 135 of file CDynamicGrid3D.h.

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

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

Transform a coordinate values into voxel indexes.

Definition at line 243 of file CDynamicGrid3D.h.

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

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

Member Data Documentation

template<class T>
const size_t mrpt::utils::CDynamicGrid3D< T >::INVALID_VOXEL_IDX = size_t(-1)
static
template<class T>
std::vector<T> mrpt::utils::CDynamicGrid3D< T >::m_map
mutableprotected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_resolution_xy
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_resolution_z
protected
template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_x
protected
template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_x_times_y
protected
template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_y
protected
template<class T>
size_t mrpt::utils::CDynamicGrid3D< T >::m_size_z
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_x_max
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_x_min
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_y_max
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_y_min
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_z_max
protected
template<class T>
double mrpt::utils::CDynamicGrid3D< T >::m_z_min
protected



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018