VoxelGrid holds a dense 3D, axis-aligned set of data at a given resolution, where the data is supplied as a template parameter. More...
#include <voxel_grid.h>
Public Member Functions | |
T & | getCell (const Eigen::Vector3i &pos) |
const T & | getCell (const Eigen::Vector3i &pos) const |
T & | getCell (int x, int y, int z) |
Gives the value of the given location (x,y,z) in the discretized voxel grid space. More... | |
const T & | getCell (int x, int y, int z) const |
int | getNumCells (Dimension dim) const |
Gets the number of cells in the indicated dimension. More... | |
double | getOrigin (Dimension dim) const |
Gets the origin (miniumum point) of the indicated dimension. More... | |
double | getResolution () const |
Gets the resolution in arbitrary consistent units. More... | |
double | getResolution (Dimension dim) const |
deprecated. Use the version with no arguments. More... | |
double | getSize (Dimension dim) const |
Gets the size in arbitrary units of the indicated dimension. More... | |
void | gridToWorld (const Eigen::Vector3i &grid, Eigen::Vector3d &world) const |
void | gridToWorld (int x, int y, int z, double &world_x, double &world_y, double &world_z) const |
Converts grid coordinates to world coordinates. More... | |
bool | isCellValid (const Eigen::Vector3i &pos) const |
bool | isCellValid (Dimension dim, int cell) const |
Checks if the indicated index is valid along a particular dimension. More... | |
bool | isCellValid (int x, int y, int z) const |
Checks if the given cell in integer coordinates is within the voxel grid. More... | |
MOVEIT_DECLARE_PTR_MEMBER (VoxelGrid) | |
const T & | operator() (const Eigen::Vector3d &pos) const |
const T & | operator() (double x, double y, double z) const |
Operator that gets the value of the given location (x, y, z) given the discretization of the volume. The location represents a location in the original coordinate frame used to construct the voxel grid. More... | |
void | reset (const T &initial) |
Sets every cell in the voxel grid to the supplied data. More... | |
void | resize (double size_x, double size_y, double size_z, double resolution, double origin_x, double origin_y, double origin_z, T default_object) |
Resize the VoxelGrid. More... | |
void | setCell (const Eigen::Vector3i &pos, const T &obj) |
void | setCell (int x, int y, int z, const T &obj) |
Sets the value of the given location (x,y,z) in the discretized voxel grid space to supplied value. More... | |
VoxelGrid () | |
Default constructor for the VoxelGrid. More... | |
VoxelGrid (double size_x, double size_y, double size_z, double resolution, double origin_x, double origin_y, double origin_z, T default_object) | |
Constructor for the VoxelGrid. More... | |
bool | worldToGrid (const Eigen::Vector3d &world, Eigen::Vector3i &grid) const |
bool | worldToGrid (double world_x, double world_y, double world_z, int &x, int &y, int &z) const |
Converts from a world location to a set of integer indices. Does check whether or not the cell being returned is valid. The returned indices will be computed even if they are invalid. More... | |
virtual | ~VoxelGrid () |
Protected Member Functions | |
int | getCellFromLocation (Dimension dim, double loc) const |
Gets the cell number from the location. More... | |
double | getLocationFromCell (Dimension dim, int cell) const |
Gets the center of the cell in world coordinates along the given dimension. No validity check. More... | |
int | ref (int x, int y, int z) const |
Gets the 1D index into the array, with no validity check. More... | |
Protected Attributes | |
T * | data_ |
Storage for the full set of data elements. More... | |
T *** | data_ptrs_ |
3D array of pointers to the data elements More... | |
T | default_object_ |
The default object to return in case of out-of-bounds query. More... | |
int | num_cells_ [3] |
The number of cells in each dimension (in Dimension order) More... | |
int | num_cells_total_ |
The total number of voxels in the grid. More... | |
double | oo_resolution_ |
1.0/resolution_ More... | |
double | origin_ [3] |
The origin (minumum point) of each dimension in meters (in Dimension order) More... | |
double | origin_minus_ [3] |
origin - 0.5/resolution More... | |
double | resolution_ |
The resolution of each dimension in meters (in Dimension order) More... | |
double | size_ [3] |
The size of each dimension in meters (in Dimension order) More... | |
int | stride1_ |
The step to take when stepping between consecutive X members in the 1D array. More... | |
int | stride2_ |
The step to take when stepping between consecutive Y members given an X in the 1D array. More... | |
VoxelGrid holds a dense 3D, axis-aligned set of data at a given resolution, where the data is supplied as a template parameter.
Definition at line 93 of file voxel_grid.h.
distance_field::VoxelGrid< T >::VoxelGrid | ( | double | size_x, |
double | size_y, | ||
double | size_z, | ||
double | resolution, | ||
double | origin_x, | ||
double | origin_y, | ||
double | origin_z, | ||
T | default_object | ||
) |
Constructor for the VoxelGrid.
Constructs a dense representation of a 3D, axis-aligned volume at a given resolution. The volume can be represented in any consistent set of units, but for the sake of documentation we assume that the units are meters. The size of the the volume is given along each of the X, Y, and Z axes. The volume begins at the minimum point in each dimension, as specified by the origin parameters. The data structure will remain unintialized until the VoxelGrid::reset function is called.
[in] | size_x | Size of the X axis in meters |
[in] | size_y | Size of the Y axis in meters |
[in] | size_z | Size of the Z axis in meters |
[in] | resolution | Resolution of a single cell in meters |
[in] | origin_x | Minimum point along the X axis of the volume |
[in] | origin_y | Minimum point along the Y axis of the volume |
[in] | origin_z | Minimum point along the Z axis of the volume |
[in] | default_object | An object that will be returned for any future queries that are not valid |
Definition at line 374 of file voxel_grid.h.
|
virtual |
Definition at line 434 of file voxel_grid.h.
distance_field::VoxelGrid< T >::VoxelGrid |
Default constructor for the VoxelGrid.
This is only useful if resize() is called after construction to set the size and resolution of the VoxelGrid.
Definition at line 382 of file voxel_grid.h.
|
inline |
Definition at line 523 of file voxel_grid.h.
|
inline |
Definition at line 529 of file voxel_grid.h.
|
inline |
Gives the value of the given location (x,y,z) in the discretized voxel grid space.
The address here is in the discretized space of the voxel grid, where the cell indicated by the constructor arguments (origin_x, origin_y, origin_z) is cell (0,0,0), and the cell indicated by (origin_x+x_size, origin_y+y_size, origin_z+z_size) will be (size_x/resolution, size_y/resolution, size_z/resolution).
[in] | x | The X index of the desired cell |
[in] | y | The Y index of the desired cell |
[in] | z | The Z index of the desired cell |
Definition at line 511 of file voxel_grid.h.
|
inline |
Definition at line 517 of file voxel_grid.h.
|
inlineprotected |
Gets the cell number from the location.
Gets the cell number in a given dimension given a world value. No validity check.
[in] | dim | The dimension of the query |
[in] | loc | The world location along that dimension |
Definition at line 547 of file voxel_grid.h.
|
inlineprotected |
Gets the center of the cell in world coordinates along the given dimension. No validity check.
[in] | dim | The dimension of the query |
[in] | cell | The cell along the given dimension |
Definition at line 567 of file voxel_grid.h.
|
inline |
Gets the number of cells in the indicated dimension.
[in] | dim | The dimension for the query |
Definition at line 488 of file voxel_grid.h.
|
inline |
Gets the origin (miniumum point) of the indicated dimension.
[in] | dim | The dimension for the query |
Definition at line 482 of file voxel_grid.h.
|
inline |
Gets the resolution in arbitrary consistent units.
Definition at line 470 of file voxel_grid.h.
|
inline |
deprecated. Use the version with no arguments.
Definition at line 476 of file voxel_grid.h.
|
inline |
Gets the size in arbitrary units of the indicated dimension.
[in] | dim | The dimension for the query |
Definition at line 464 of file voxel_grid.h.
|
inline |
Definition at line 587 of file voxel_grid.h.
|
inline |
Converts grid coordinates to world coordinates.
Converts from an set of integer indices to a world location given the origin and resolution parameters. There is no check whether or not the cell or world locations lie within the represented region.
[in] | x | The integer X location |
[in] | y | The integer Y location |
[in] | z | The integer Z location |
[out] | world_x | The computed world X location |
[out] | world_y | The computed world X location |
[out] | world_z | The computed world X location |
Definition at line 579 of file voxel_grid.h.
|
inline |
Definition at line 446 of file voxel_grid.h.
|
inline |
Checks if the indicated index is valid along a particular dimension.
[in] | dim | The dimension for the query |
[in] | cell | The index along that dimension |
Definition at line 452 of file voxel_grid.h.
|
inline |
Checks if the given cell in integer coordinates is within the voxel grid.
[in] | x | The integer X location |
[in] | y | The integer Y location |
[in] | z | The integer Z location |
Definition at line 440 of file voxel_grid.h.
distance_field::VoxelGrid< T >::MOVEIT_DECLARE_PTR_MEMBER | ( | VoxelGrid< T > | ) |
|
inline |
Definition at line 505 of file voxel_grid.h.
|
inline |
Operator that gets the value of the given location (x, y, z) given the discretization of the volume. The location represents a location in the original coordinate frame used to construct the voxel grid.
[in] | x | X component of the desired location |
[in] | y | Y component of the desired location |
[in] | z | Z component of the desired location |
Definition at line 494 of file voxel_grid.h.
|
inlineprotected |
Gets the 1D index into the array, with no validity check.
[in] | x | The integer X location |
[in] | y | The integer Y location |
[in] | z | The integer Z location |
Definition at line 458 of file voxel_grid.h.
|
inline |
Sets every cell in the voxel grid to the supplied data.
[in] | initial | The template variable to which to set the data |
Definition at line 573 of file voxel_grid.h.
void distance_field::VoxelGrid< T >::resize | ( | double | size_x, |
double | size_y, | ||
double | size_z, | ||
double | resolution, | ||
double | origin_x, | ||
double | origin_y, | ||
double | origin_z, | ||
T | default_object | ||
) |
Resize the VoxelGrid.
This discards all the data in the voxel grid and reinitializes it with a new size and resolution. This is mainly useful if the size or resolution is not known until after the voxelgrid is constructed.
[in] | size_x | Size of the X axis in meters |
[in] | size_y | Size of the Y axis in meters |
[in] | size_z | Size of the Z axis in meters |
[in] | resolution | Resolution of a single cell in meters |
[in] | origin_x | Minimum point along the X axis of the volume |
[in] | origin_y | Minimum point along the Y axis of the volume |
[in] | origin_z | Minimum point along the Z axis of the volume |
Definition at line 399 of file voxel_grid.h.
|
inline |
Definition at line 541 of file voxel_grid.h.
|
inline |
Sets the value of the given location (x,y,z) in the discretized voxel grid space to supplied value.
The address here is in the discretized space of the voxel grid, where the cell indicated by the constructor arguments (origin_x, origin_y, origin_z) is cell (0,0,0), and the cell indicated by (origin_x+x_size, origin_y+y_size, origin_z+z_size) will be (size_x/resolution, size_y/resolution, size_z/resolution).
If the arguments do not indicate a valid cell, corruption and/or SEGFAULTS will occur.
[in] | x | The X index of the desired cell |
[in] | y | The Y index of the desired cell |
[in] | z | The Z index of the desired cell |
[out] | obj | The data to place into the given cell |
Definition at line 535 of file voxel_grid.h.
|
inline |
Definition at line 604 of file voxel_grid.h.
|
inline |
Converts from a world location to a set of integer indices. Does check whether or not the cell being returned is valid. The returned indices will be computed even if they are invalid.
[in] | world_x | The world X location |
[in] | world_y | The world Y location |
[in] | world_z | The world Z location |
[out] | x | The computed integer X location |
[out] | y | The computed integer X location |
[out] | z | The computed integer X location |
Definition at line 595 of file voxel_grid.h.
|
protected |
Storage for the full set of data elements.
Definition at line 321 of file voxel_grid.h.
|
protected |
3D array of pointers to the data elements
Definition at line 323 of file voxel_grid.h.
|
protected |
The default object to return in case of out-of-bounds query.
Definition at line 322 of file voxel_grid.h.
|
protected |
The number of cells in each dimension (in Dimension order)
Definition at line 329 of file voxel_grid.h.
|
protected |
The total number of voxels in the grid.
Definition at line 330 of file voxel_grid.h.
|
protected |
1.0/resolution_
Definition at line 326 of file voxel_grid.h.
|
protected |
The origin (minumum point) of each dimension in meters (in Dimension order)
Definition at line 327 of file voxel_grid.h.
|
protected |
origin - 0.5/resolution
Definition at line 328 of file voxel_grid.h.
|
protected |
The resolution of each dimension in meters (in Dimension order)
Definition at line 325 of file voxel_grid.h.
|
protected |
The size of each dimension in meters (in Dimension order)
Definition at line 324 of file voxel_grid.h.
|
protected |
The step to take when stepping between consecutive X members in the 1D array.
Definition at line 331 of file voxel_grid.h.
|
protected |
The step to take when stepping between consecutive Y members given an X in the 1D array.
Definition at line 332 of file voxel_grid.h.