Go to the documentation of this file.
32 double x_min = -1.0,
double x_max = 1.0,
double y_min = -1.0,
33 double y_max = +1.0,
double z_min = -1.0,
double z_max = 1.0,
34 double resolution_xy = 0.5,
double resolution_z = 0.5)
38 x_min, x_max, y_min, y_max, z_min, z_max, resolution_xy,
46 double new_x_min,
double new_x_max,
double new_y_min,
double new_y_max,
47 double new_z_min,
double new_z_max,
const T& defaultValueNewCells,
48 double additionalMarginMeters = 2.0)
64 if (additionalMarginMeters > 0)
67 new_x_min = floor(new_x_min - additionalMarginMeters);
69 new_x_max = ceil(new_x_max + additionalMarginMeters);
71 new_y_min = floor(new_y_min - additionalMarginMeters);
73 new_y_max = ceil(new_y_max + additionalMarginMeters);
75 new_z_min = floor(new_z_min - additionalMarginMeters);
77 new_z_max = ceil(new_z_max + additionalMarginMeters);
115 size_t new_size_x_times_y = new_size_x * new_size_y;
118 typename std::vector<T> new_map;
120 new_size_x * new_size_y * new_size_z, defaultValueNewCells);
133 (new_map.begin() + extra_x_izq +
134 (
y + extra_y_arr) * new_size_x +
135 (
z + extra_z_top) * new_size_x_times_y);
173 const double x_min,
const double x_max,
const double y_min,
174 const double y_max,
const double z_min,
const double z_max,
175 const double resolution_xy,
const double resolution_z_ = -1.0,
176 const T* fill_value =
nullptr)
178 const double resolution_z =
179 resolution_z_ > 0.0 ? resolution_z_ : resolution_xy;
188 x_min + resolution_xy *
round((x_max - x_min) / resolution_xy);
190 y_min + resolution_xy *
round((y_max - y_min) / resolution_xy);
191 m_z_max = z_min + resolution_z *
round((z_max - z_min) / resolution_z);
223 it !=
m_map.end(); ++it)
233 const int cx,
const int cy,
const int cz)
const
235 if (cx < 0 || cx >=
static_cast<int>(
m_size_x))
237 if (cy < 0 || cy >=
static_cast<int>(
m_size_y))
239 if (cz < 0 || cz >=
static_cast<int>(
m_size_z))
266 inline T*
cellByIndex(
unsigned int cx,
unsigned int cy,
unsigned int cz)
277 unsigned int cx,
unsigned int cy,
unsigned int cz)
const
326 template <
class ARCHIVE>
331 out << static_cast<uint32_t>(
m_size_x)
337 template <
class ARCHIVE>
344 in >> nX >> nY >> nZ;
348 m_map.resize(nX * nY * nZ);
void dyngridcommon_writeToStream(ARCHIVE &out) const
Serialization of all parameters, except the contents of each voxel (responsability of the derived cla...
int z2idx(double z) const
double idx2x(int cx) const
Transform a voxel index into a coordinate value of the voxel central point.
void fill(const T &value)
Fills all the cells with the same value.
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.
void dyngridcommon_readFromStream(ARCHIVE &in)
Serialization of all parameters, except the contents of each voxel (responsability of the derived cla...
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 o...
A 3D rectangular grid of dynamic size which stores any kind of data at each voxel.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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.
static const size_t INVALID_VOXEL_IDX
std::vector< T > & m_map_castaway_const() const
Used only from logically const method that really need to modify the object.
int round(const T value)
Returns the closer integer (int) to x.
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...
double getResolutionZ() const
virtual void clear()
Erase the contents of all the cells, setting them to their default values (default ctor).
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,...
size_t getVoxelCount() const
double idx2z(int cz) const
double idx2y(int cy) const
GLsizei const GLfloat * value
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.
std::vector< T > m_map
The cells.
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 t...
int x2idx(double x) const
Transform a coordinate values into voxel indexes.
double getResolutionXY() const
int y2idx(double y) const
unsigned __int32 uint32_t
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 t...
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |