Template Class CDynamicGrid3D
Defined in File CDynamicGrid3D.h
Class Documentation
-
template<class T, class coord_t = double>
class CDynamicGrid3D A 3D rectangular grid of dynamic size which stores any kind of data at each voxel.
- Template Parameters:
T – The type of each voxel in the grid.
Direct and range-based access to data
-
inline const grid_data_t &data() const
-
inline const_iterator begin() const
-
inline const_iterator end() const
Public Types
-
using iterator = typename grid_data_t::iterator
-
using const_iterator = typename grid_data_t::const_iterator
Public Functions
-
inline CDynamicGrid3D(coord_t x_min = -1.0, coord_t x_max = 1.0, coord_t y_min = -1.0, coord_t y_max = +1.0, coord_t z_min = -1.0, coord_t z_max = 1.0, coord_t resolution_xy = 0.5, coord_t resolution_z = 0.5)
Constructor
-
inline virtual void resize(coord_t new_x_min, coord_t new_x_max, coord_t new_y_min, coord_t new_y_max, coord_t new_z_min, coord_t new_z_max, const T &defaultValueNewCells, coord_t additionalMarginMeters = 2)
Changes the size of the grid, maintaining previous contents.
See also
-
inline virtual void setSize(const coord_t x_min, const coord_t x_max, const coord_t y_min, const coord_t y_max, const coord_t z_min, const coord_t z_max, const coord_t resolution_xy, const coord_t resolution_z_ = -1.0, const T *fill_value = nullptr)
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 inresolution_xy
-
inline virtual void clear()
Erase the contents of all the cells, setting them to their default values (default ctor).
-
inline bool isOutOfBounds(const int cx, const int cy, const int cz) const
-
inline 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).
See also
x2idx(), y2idx(), z2idx()
-
inline T *cellByPos(coord_t x, coord_t y, coord_t z)
Returns a pointer to the contents of a voxel given by its coordinates, or nullptr if it is out of the map extensions.
-
inline const T *cellByPos(coord_t x, coord_t y, coord_t z) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline T &cellRefByPos(coord_t x, coord_t y, coord_t z)
Like cellByPos() but returns a reference
- Throws:
std::out_of_range – if out of grid limits.
-
inline const T &cellRefByPos(coord_t x, coord_t y, coord_t z) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline 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.
-
inline const T *cellByIndex(size_t cidx) const
Returns a pointer to the contents of a voxel given by its absolute voxel index, or nullptr if it is out of range.
-
inline T *cellByIndex(size_t cidx)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
inline size_t getSizeX() const
-
inline size_t getSizeY() const
-
inline size_t getSizeZ() const
-
inline size_t getVoxelCount() const
-
inline coord_t idx2x(int cx) const
Transform a voxel index into a coordinate value of the voxel central point
Public Static Attributes
-
static const size_t INVALID_VOXEL_IDX = size_t(-1)
Protected Functions