|
Geometric structure of a 3D voxel grid. More...
#include <VisionX/libraries/VoxelGridCore/VoxelGridStructure.h>
Public Member Functions | |
void | checkIsInside (const Eigen::Vector3i &indices) const |
Assert that the given indices are valid grid indices. More... | |
Eigen::Vector3f | getCenter () const |
Get the geometric center of the grid the world frame (which differs from the origin for even grid sizes). More... | |
Eigen::Matrix4f | getCenterPose () const |
Get the grid pose positioned at the grid center in the world frame. More... | |
Eigen::Vector3f | getExtent () const |
Get extent of the grid along each axis (encompassing the whole voxels). More... | |
Eigen::Vector3f | getExtentOfCenters () const |
Get extent of the grid along each axis (encompassing only voxel centers). More... | |
std::size_t | getFlatIndex (const Eigen::Vector3f &point, bool local=false) const |
Get the flat index into the grid data of the voxel closest to point. More... | |
std::size_t | getFlatIndex (const Eigen::Vector3i &indices) const |
Get the flat index for the given grid indices. More... | |
std::size_t | getFlatIndex (int x, int y, int z) const |
Get the flat index for the given grid indices. More... | |
Eigen::Vector3i | getGridIndex (const Eigen::Vector3f &point, bool local=false) const |
Get the indices of the voxel closest to point. More... | |
Eigen::Vector3i | getGridIndex (size_t index) const |
Get the voxel indices of the voxel with the given index. More... | |
Eigen::Vector3i | getGridIndexMax () const |
Get the maximal (along each axis) grid index. More... | |
Eigen::Vector3i | getGridIndexMin () const |
Get the minimal (along each axis) grid index. More... | |
Eigen::Vector3i | getGridSize () const |
Get the grid size. More... | |
Eigen::Matrix32f | getLocalBoundingBox () const |
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns). More... | |
Eigen::Matrix32f | getLocalBoundingBoxOfCenters () const |
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns). More... | |
std::size_t | getNumVoxels () const |
Get the number of voxels contained in the structure. More... | |
Eigen::Quaternionf | getOrientation () const |
Get the grid orienation in the world frame. More... | |
Eigen::Vector3f | getOrigin () const |
Get the grid origin in the world frame (center of voxel [0 0 0]). More... | |
Eigen::Matrix4f | getPose () const |
Get the grid pose in the world frame. More... | |
Eigen::Vector3f | getVoxelCenter (const Eigen::Vector3i &indices, bool local=false) const |
Get the center of the voxel with the given indices. More... | |
Eigen::Vector3f | getVoxelCenter (int x, int y, int z, bool local=false) const |
Get the center of the voxel with the given indices. More... | |
Eigen::Vector3f | getVoxelCenter (std::size_t index, bool local=false) const |
Get the center of the voxel with the given indices. More... | |
Eigen::Vector3f | getVoxelSize () const |
Get the voxel size. More... | |
bool | isInside (const Eigen::Vector3f &point, bool local=false) const |
Indicate whether the given point is inside the voxel. More... | |
bool | isInside (const Eigen::Vector3i &indices) const |
Indicate whether the given point is inside the voxel. More... | |
bool | operator!= (const VoxelGridStructure &rhs) const |
bool | operator== (const VoxelGridStructure &rhs) const |
Indicates whether rhs is equal to *this . More... | |
void | setCenter (const Eigen::Vector3f ¢er) |
Set the geometric center of the grid the world frame (which differs from the origin for even grid sizes). More... | |
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 orientation. More... | |
void | setGridSize (const Eigen::Vector3i &gridSize) |
Set the grid size. More... | |
void | setGridSize (int gridSize) |
Set the grid size for a cubic grid. More... | |
void | setOrientation (const Eigen::Quaternionf &value) |
Set the grid orienation in the world frame. More... | |
void | setOrigin (const Eigen::Vector3f &value) |
Set the grid origin the world frame (center of voxel [0 0 0]). More... | |
void | setPose (const Eigen::Matrix4f &pose) |
Get the grid pose in the world frame. More... | |
void | setVoxelSize (const Eigen::Vector3f &voxelSize) |
Set the voxel size. More... | |
void | setVoxelSize (float voxelSize) |
Set the voxel size for cubic voxels. More... | |
VoxelGridStructure () | |
Construct an empty grid structure (0 voxels with size 1.0). More... | |
VoxelGridStructure (const Eigen::Vector3i &gridSize, const Eigen::Vector3f &voxelSize, const Eigen::Vector3f &origin=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity()) | |
Construct a voxel grid structure. More... | |
VoxelGridStructure (const Eigen::Vector3i &gridSize, float voxelSize, const Eigen::Vector3f &origin=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity()) | |
Construct a voxel grid structure with cubic voxels. More... | |
VoxelGridStructure (int gridSize, const Eigen::Vector3f &voxelSize, const Eigen::Vector3f &origin=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity()) | |
Construct a voxel grid structure with cubic grid. More... | |
VoxelGridStructure (int gridSize, float voxelSize, const Eigen::Vector3f &origin=Eigen::Vector3f::Zero(), const Eigen::Quaternionf &orientation=Eigen::Quaternionf::Identity()) | |
Construct a voxel grid structure with cubic voxels and cubic grid. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const VoxelGridStructure &grid) |
Stream a human-readable description of the grid's structure. More... | |
Geometric structure of a 3D voxel grid.
The grid structure is defined by the voxel size(s) and grid size(s). The voxel size (R^3) is the extent of a single voxel along each axis (x, y, z). (Cubic voxels have constant extent along all axes). The grid size (N^3) is the number of voxels along each axis. (Cubic grids have constant number of voxels along all axes.)
In addition, the voxel grid can have a pose, i.e. position and orientation.
The total number of voxels to be contained in a structure is the product of the grid size coefficients.
To indicate a voxel, one can use either of:
A grid index specifies the voxel index along each axis. A flat index specifies a voxel's running index (from 0 to #voxels - 1).
Each coefficient of a grid index is in the range [ - gridSize/2, gridSize/2 )
More precisely, it is in the set { - floor(gridSize/2), ..., 0, ..., ceil(gridSize/2) - 1 }
In other words,
For example (along one axis):
| Grid Size | Valid grid indices | +--------—+-----------------------—+ | 3 | { -1, 0, 1 } | | 4 | { -2, -1, 0, 1 } | | 5 | { -2, -1, 0, 1, 2 } |
Note that grid indices are centered around zero and can be negative. A flat index is always non-negative.
The grid origin coincides with the center of voxel (0 0 0) and can be chosen freely upon construction. It differs from the grid center in axes with even grid size.
Definition at line 96 of file VoxelGridStructure.h.
Construct an empty grid structure (0 voxels with size 1.0).
Definition at line 31 of file VoxelGridStructure.cpp.
VoxelGridStructure | ( | int | gridSize, |
float | voxelSize, | ||
const Eigen::Vector3f & | origin = Eigen::Vector3f::Zero() , |
||
const Eigen::Quaternionf & | orientation = Eigen::Quaternionf::Identity() |
||
) |
Construct a voxel grid structure with cubic voxels and cubic grid.
Definition at line 34 of file VoxelGridStructure.cpp.
VoxelGridStructure | ( | const Eigen::Vector3i & | gridSize, |
float | voxelSize, | ||
const Eigen::Vector3f & | origin = Eigen::Vector3f::Zero() , |
||
const Eigen::Quaternionf & | orientation = Eigen::Quaternionf::Identity() |
||
) |
Construct a voxel grid structure with cubic voxels.
Definition at line 42 of file VoxelGridStructure.cpp.
VoxelGridStructure | ( | int | gridSize, |
const Eigen::Vector3f & | voxelSize, | ||
const Eigen::Vector3f & | origin = Eigen::Vector3f::Zero() , |
||
const Eigen::Quaternionf & | orientation = Eigen::Quaternionf::Identity() |
||
) |
Construct a voxel grid structure with cubic grid.
Definition at line 48 of file VoxelGridStructure.cpp.
VoxelGridStructure | ( | const Eigen::Vector3i & | gridSize, |
const Eigen::Vector3f & | voxelSize, | ||
const Eigen::Vector3f & | origin = Eigen::Vector3f::Zero() , |
||
const Eigen::Quaternionf & | orientation = Eigen::Quaternionf::Identity() |
||
) |
Construct a voxel grid structure.
Definition at line 54 of file VoxelGridStructure.cpp.
void checkIsInside | ( | const Eigen::Vector3i & | indices | ) | const |
Assert that the given indices are valid grid indices.
Definition at line 300 of file VoxelGridStructure.cpp.
Eigen::Vector3f getCenter | ( | ) | const |
Get the geometric center of the grid the world frame (which differs from the origin for even grid sizes).
Definition at line 222 of file VoxelGridStructure.cpp.
Eigen::Matrix4f getCenterPose | ( | ) | const |
Get the grid pose positioned at the grid center in the world frame.
Definition at line 243 of file VoxelGridStructure.cpp.
Eigen::Vector3f getExtent | ( | ) | const |
Get extent of the grid along each axis (encompassing the whole voxels).
Definition at line 254 of file VoxelGridStructure.cpp.
Eigen::Vector3f getExtentOfCenters | ( | ) | const |
Get extent of the grid along each axis (encompassing only voxel centers).
Definition at line 259 of file VoxelGridStructure.cpp.
std::size_t getFlatIndex | ( | const Eigen::Vector3f & | point, |
bool | local = false |
||
) | const |
Get the flat index into the grid data of the voxel closest to point.
Definition at line 122 of file VoxelGridStructure.cpp.
std::size_t getFlatIndex | ( | const Eigen::Vector3i & | indices | ) | const |
Get the flat index for the given grid indices.
Definition at line 107 of file VoxelGridStructure.cpp.
std::size_t getFlatIndex | ( | int | x, |
int | y, | ||
int | z | ||
) | const |
Get the flat index for the given grid indices.
Definition at line 102 of file VoxelGridStructure.cpp.
Eigen::Vector3i getGridIndex | ( | const Eigen::Vector3f & | point, |
bool | local = false |
||
) | const |
Get the indices of the voxel closest to point.
local | If false (default), the point is transformed to local coordinate system. |
Definition at line 141 of file VoxelGridStructure.cpp.
Eigen::Vector3i getGridIndex | ( | size_t | index | ) | const |
Get the voxel indices of the voxel with the given index.
Definition at line 127 of file VoxelGridStructure.cpp.
Eigen::Vector3i getGridIndexMax | ( | ) | const |
Get the maximal (along each axis) grid index.
Definition at line 168 of file VoxelGridStructure.cpp.
Eigen::Vector3i getGridIndexMin | ( | ) | const |
Get the minimal (along each axis) grid index.
Definition at line 159 of file VoxelGridStructure.cpp.
Eigen::Vector3i getGridSize | ( | ) | const |
Get the grid size.
Definition at line 67 of file VoxelGridStructure.cpp.
Eigen::Matrix32f getLocalBoundingBox | ( | ) | const |
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
Definition at line 264 of file VoxelGridStructure.cpp.
Eigen::Matrix32f getLocalBoundingBoxOfCenters | ( | ) | const |
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
Definition at line 272 of file VoxelGridStructure.cpp.
std::size_t getNumVoxels | ( | ) | const |
Get the number of voxels contained in the structure.
Definition at line 97 of file VoxelGridStructure.cpp.
Eigen::Quaternionf getOrientation | ( | ) | const |
Get the grid orienation in the world frame.
Definition at line 212 of file VoxelGridStructure.cpp.
Eigen::Vector3f getOrigin | ( | ) | const |
Get the grid origin in the world frame (center of voxel [0 0 0]).
Note that this differs from the geometric center for even grid sizes.
Definition at line 202 of file VoxelGridStructure.cpp.
Eigen::Matrix4f getPose | ( | ) | const |
Get the grid pose in the world frame.
Note that this differs from the geometric center for even grid sizes.
Definition at line 232 of file VoxelGridStructure.cpp.
Eigen::Vector3f getVoxelCenter | ( | const Eigen::Vector3i & | indices, |
bool | local = false |
||
) | const |
Get the center of the voxel with the given indices.
Definition at line 188 of file VoxelGridStructure.cpp.
Eigen::Vector3f getVoxelCenter | ( | int | x, |
int | y, | ||
int | z, | ||
bool | local = false |
||
) | const |
Get the center of the voxel with the given indices.
Definition at line 183 of file VoxelGridStructure.cpp.
Eigen::Vector3f getVoxelCenter | ( | std::size_t | index, |
bool | local = false |
||
) | const |
Get the center of the voxel with the given indices.
Definition at line 178 of file VoxelGridStructure.cpp.
Eigen::Vector3f getVoxelSize | ( | ) | const |
Get the voxel size.
Definition at line 82 of file VoxelGridStructure.cpp.
bool isInside | ( | const Eigen::Vector3f & | point, |
bool | local = false |
||
) | const |
Indicate whether the given point is inside the voxel.
Definition at line 295 of file VoxelGridStructure.cpp.
bool isInside | ( | const Eigen::Vector3i & | indices | ) | const |
Indicate whether the given point is inside the voxel.
Definition at line 280 of file VoxelGridStructure.cpp.
bool operator!= | ( | const VoxelGridStructure & | rhs | ) | const |
Definition at line 317 of file VoxelGridStructure.cpp.
bool operator== | ( | const VoxelGridStructure & | rhs | ) | const |
Indicates whether rhs
is equal to *this
.
Uses v.isApprox()
to compare voxel size, origin and orientation.
Definition at line 309 of file VoxelGridStructure.cpp.
void setCenter | ( | const Eigen::Vector3f & | center | ) |
Set the geometric center of the grid the world frame (which differs from the origin for even grid sizes).
setGridCenterPose()
.Definition at line 227 of file VoxelGridStructure.cpp.
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 orientation.
Definition at line 248 of file VoxelGridStructure.cpp.
void setGridSize | ( | const Eigen::Vector3i & | gridSize | ) |
Set the grid size.
Definition at line 77 of file VoxelGridStructure.cpp.
void setGridSize | ( | int | gridSize | ) |
Set the grid size for a cubic grid.
Definition at line 72 of file VoxelGridStructure.cpp.
void setOrientation | ( | const Eigen::Quaternionf & | value | ) |
Set the grid orienation in the world frame.
Definition at line 217 of file VoxelGridStructure.cpp.
void setOrigin | ( | const Eigen::Vector3f & | value | ) |
Set the grid origin the world frame (center of voxel [0 0 0]).
Note that this differs from the geometric center for even grid sizes.
Definition at line 207 of file VoxelGridStructure.cpp.
void setPose | ( | const Eigen::Matrix4f & | pose | ) |
Get the grid pose in the world frame.
Note that this differs from the geometric center for even grid sizes.
Definition at line 237 of file VoxelGridStructure.cpp.
void setVoxelSize | ( | const Eigen::Vector3f & | voxelSize | ) |
Set the voxel size.
Definition at line 92 of file VoxelGridStructure.cpp.
void setVoxelSize | ( | float | voxelSize | ) |
Set the voxel size for cubic voxels.
Definition at line 87 of file VoxelGridStructure.cpp.
|
friend |
Stream a human-readable description of the grid's structure.
Definition at line 341 of file VoxelGridStructure.cpp.