Go to the documentation of this file.
28 #include <Eigen/Geometry>
49 template <
typename _VoxelT>
73 const std::vector<VoxelGrid::VoxelT>& voxelData);
76 template <
typename OtherVoxelT>
373 bool isInside(
const Eigen::Vector3f& point,
bool local =
false)
const
407 typename std::vector<VoxelT>::iterator
begin()
412 typename std::vector<VoxelT>::const_iterator
begin()
const
417 typename std::vector<VoxelT>::const_iterator
cbegin()
const
423 typename std::vector<VoxelT>::iterator
end()
428 typename std::vector<VoxelT>::const_iterator
end()
const
433 typename std::vector<VoxelT>::const_iterator
cend()
const
440 template <
class VoxelType>
455 template <
typename VT>
459 template <
typename VT>
464 template <
typename VT>
466 const std::vector<VoxelGrid::VoxelT>& voxelData) :
476 template <
typename VT>
477 template <
typename OtherVoxelT>
483 template <
typename VT>
486 os <<
"VoxelGrid " << grid.
_struct;
std::vector< VoxelT >::const_iterator cbegin() const
Get an iterator to the first voxel.
Eigen::Vector3i getGridIndexMin() const
Get the minimal (along each axis) grid index.
void setVoxels(const std::vector< VoxelT > &voxels)
Set the voxels.
Eigen::Vector3i getGridIndexMax() const
Get the maximal (along each axis) grid index.
void setGridSizes(float gridSizes)
Set the grid size for a cubic grid. Resets the grid data.
std::vector< VoxelT >::iterator begin()
Get an iterator to the first voxel.
const VoxelT & getVoxel(int x, int y, int z) const
std::size_t getVoxelFlatIndex(int x, int y, int z) const
Get the flat index of the voxel with given grid index.
A 3D grid of voxels of type _VoxelT.
std::vector< VoxelT >::iterator end()
Get an iterator to the element following the last voxel.
void setCenterPose(const Eigen::Matrix4f &value)
Set the grid pose so that the grid center is the position of the given pose under the given orientati...
void reset(const VoxelT &value={})
Reset the voxel data by numVoxels() voxels with given value.
VoxelGrid()
Construct a voxel grid with 0 voxels of size 1.0.
Eigen::Vector3f getVoxelSizes() const
Get the voxel size.
std::size_t getFlatIndex(int x, int y, int z) const
Get the flat index for the given grid indices.
std::vector< VoxelT > _voxels
The voxel data.
Eigen::Vector3f getVoxelSize() const
Get the voxel size.
void setGridSize(int gridSize)
Set the grid size for a cubic grid.
Eigen::Matrix4f getPose() const
Get the grid pose in the world frame.
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
void setVoxelSizes(const Eigen::Vector3f &voxelSizes)
Set the voxel size. The grid data is not updated.
VoxelT & operator[](std::size_t index)
Get the voxel with given flat index.
void setGridSizes(const Eigen::Vector3i &gridSizes)
Set the grid size. This resets the grid data.
void resetStructure(const VoxelGridStructure &structure)
Set the voxel grid structure and reset voxel data.
void setPose(const Eigen::Matrix4f &pose)
Get the grid pose in the world frame.
VoxelT VoxelT
The voxel type.
std::ostream & operator<<(std::ostream &os, const VoxelGrid< VT > &grid)
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
std::size_t getVoxelFlatIndex(const Eigen::Vector3i &index) const
Get the flat index of the voxel with given grid index.
Eigen::Matrix4f getPose() const
Get the grid pose in the world frame.
void setCenter(const Eigen::Vector3f &value)
Set the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Eigen::Vector3f getExtentOfCenters() const
Get extent of the grid along each axis (encompassing only voxel centers).
Indicates that voxel data with an invalid number of voxels has been passed to a VoxelGrid.
std::vector< VoxelT >::const_iterator cend() const
Get an iterator to the element following the last voxel.
VoxelGridStructure getStructure() const
Get the voxel grid structure.
Eigen::Vector3f getExtent() const
Get extent of the grid along each axis (encompassing the whole voxels).
VoxelT & getVoxel(int x, int y, int z)
Get the voxel with the given grid index.
const VoxelT & getVoxel(std::size_t index) const
VoxelT & operator[](const Eigen::Vector3i &index)
Get the voxel with given grid index.
VoxelT & getVoxel(std::size_t index)
Get the voxel with the given index.
Eigen::Matrix32f getLocalBoundingBoxOfCenters() const
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
bool isInside(const Eigen::Vector3f &point, bool local=false) const
Indicate whether the given point is inside the voxel.
bool isInside(const Eigen::Vector3i &indices) const
Indicate whether the given point is inside the voxel.
std::size_t numVoxels() const
Get the number of voxels in the grid.
Geometric structure of a 3D voxel grid.
std::vector< VoxelT >::const_iterator end() const
Get an iterator to the element following the last voxel.
std::shared_ptr< Value > value()
Eigen::Vector3i getGridSize() const
Get the grid size.
Eigen::Vector3f getVoxelCenter(const Eigen::Vector3i &index, bool local=false) const
Get the center of the voxel with the given index.
std::vector< VoxelT >::const_iterator begin() const
Get an iterator to the first voxel.
void setCenter(const Eigen::Vector3f ¢er)
Set the geometric center of the grid the world frame (which differs from the origin for even grid siz...
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
Eigen::Matrix4f getCenterPose() const
Get the grid pose positioned at the grid center in the world frame.
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Eigen::Vector3i getVoxelGridIndex(size_t index) const
Get the grid index of the voxel with the given flat index.
VoxelT & getVoxel(const Eigen::Vector3f &point, bool local=false)
Get the voxel closest to the given point.
friend std::ostream & operator<<(std::ostream &os, const VoxelGrid< VoxelType > &grid)
Stream a human-readable description of the grid's structure.
Eigen::Vector3i getVoxelGridIndexMax() const
Get the maximal (along each axis) voxel grid index.
Eigen::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Eigen::Vector3i getVoxelGridIndex(const Eigen::Vector3f &point, bool local=false) const
Get the grid index of the voxel closest to point.
Eigen::Vector3f getExtents() const
Get extent of the grid along each axis (encompassing the whole voxels).
Eigen::Vector3f getVoxelCenter(std::size_t index, bool local=false) const
Get the center of the voxel with the given indices.
std::size_t getNumVoxels() const
Get the number of voxels in the grid.
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
Eigen::Vector3f getCenter() const
Get the geometric center of the grid the world frame (which differs from the origin for even grid siz...
MatrixXX< 4, 4, float > Matrix4f
const VoxelT & operator[](std::size_t index) const
std::size_t getNumVoxels() const
Get the number of voxels contained in the structure.
Eigen::Matrix4f getCenterPose() const
Get the grid pose positioned at the grid center in the world frame.
void setVoxelSize(float voxelSize)
Set the voxel size for cubic voxels.
const VoxelT & getVoxel(const Eigen::Vector3f &point, bool local=false) const
void checkIsInside(const Eigen::Vector3i &indices) const
Assert that the given indices are valid grid indices.
void setVoxelSizes(float voxelSize)
Set the voxel size of cubic voxels. The grid data is not updated.
const std::vector< VoxelT > & getVoxels() const
Get the voxels.
Eigen::Vector3i getGridSizes() const
Get the grid size.
Eigen::Vector3f getVoxelCenter(std::size_t index, bool local=false) const
Get the center of the voxel with the given index.
Eigen::Vector3f getCenter() const
Get the geometric center of the grid the world frame (which differs from the origin for even grid siz...
Eigen::Vector3f getVoxelCenter(int x, int y, int z, bool local=false) const
Get the center of the voxel with the given index.
bool isInside(const Eigen::Vector3i &index) const
Indicate whether the given point is inside the voxel.
const VoxelT & getVoxel(const Eigen::Vector3i &index) const
void setPose(const Eigen::Matrix4f &value)
Get the grid pose in the world frame.
voxelgrid::VoxelGrid< VoxelT > VoxelGrid
Eigen::Matrix32f getLocalBoundingBox() const
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
Eigen::Vector3f getExtentsOfCenters() const
Get extent of the grid along each axis (encompassing only voxel centers).
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
VoxelT & getVoxel(const Eigen::Vector3i &index)
Get the voxel with the given grid index.
Eigen::Vector3i getGridIndex(size_t index) const
Get the voxel indices of the voxel with the given index.
void checkIsInside(const Eigen::Vector3i &index) const
Assert that the given index is a valid grid index.
Eigen::Matrix32f getLocalBoundingBox() const
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
Eigen::Vector3i getVoxelGridIndexMin() const
Get the minimal (along each axis) voxel grid index.
VoxelGridStructure _struct
The geometric structure.
Eigen::Matrix32f getLocalBoundingBoxOfCenters() const
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
std::size_t getVoxelFlatIndex(const Eigen::Vector3f &point, bool local=false) const
Get the flat index of the voxel closest to point.
void setCenterPose(const Eigen::Matrix4f &pose)
Set the grid pose so that the grid center is the position of the given pose under the given orientati...
const VoxelT & operator[](const Eigen::Vector3i &index) const