|
|
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. | |
| Eigen::Vector3f | getCenter () const |
| Get the geometric center of the grid the world frame (which differs from the origin for even grid sizes). | |
| Eigen::Matrix4f | getCenterPose () const |
| Get the grid pose positioned at the grid center in the world frame. | |
| Eigen::Vector3f | getExtent () const |
| Get extent of the grid along each axis (encompassing the whole voxels). | |
| Eigen::Vector3f | getExtentOfCenters () const |
| Get extent of the grid along each axis (encompassing only voxel centers). | |
| 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. | |
| std::size_t | getFlatIndex (const Eigen::Vector3i &indices) const |
| Get the flat index for the given grid indices. | |
| std::size_t | getFlatIndex (int x, int y, int z) const |
| Get the flat index for the given grid indices. | |
| Eigen::Vector3i | getGridIndex (const Eigen::Vector3f &point, bool local=false) const |
| Get the indices of the voxel closest to point. | |
| Eigen::Vector3i | getGridIndex (size_t index) const |
| Get the voxel indices of the voxel with the given index. | |
| Eigen::Vector3i | getGridIndexMax () const |
| Get the maximal (along each axis) grid index. | |
| Eigen::Vector3i | getGridIndexMin () const |
| Get the minimal (along each axis) grid index. | |
| Eigen::Vector3i | getGridSize () const |
| Get the grid size. | |
| Eigen::Matrix32f | getLocalBoundingBox () const |
| Get the local axis aligned bounding box of the grid (minimal/maximal values in columns). | |
| Eigen::Matrix32f | getLocalBoundingBoxOfCenters () const |
| Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns). | |
| std::size_t | getNumVoxels () const |
| Get the number of voxels contained in the structure. | |
| Eigen::Quaternionf | getOrientation () const |
| Get the grid orienation in the world frame. | |
| Eigen::Vector3f | getOrigin () const |
| Get the grid origin in the world frame (center of voxel [0 0 0]). | |
| Eigen::Matrix4f | getPose () const |
| Get the grid pose in the world frame. | |
| Eigen::Vector3f | getVoxelCenter (const Eigen::Vector3i &indices, bool local=false) const |
| Get the center of the voxel with the given indices. | |
| Eigen::Vector3f | getVoxelCenter (int x, int y, int z, bool local=false) const |
| Get the center of the voxel with the given indices. | |
| Eigen::Vector3f | getVoxelCenter (std::size_t index, bool local=false) const |
| Get the center of the voxel with the given indices. | |
| Eigen::Vector3f | getVoxelSize () const |
| Get the voxel size. | |
| 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. | |
| bool | operator!= (const VoxelGridStructure &rhs) const |
| bool | operator== (const VoxelGridStructure &rhs) const |
Indicates whether rhs is equal to *this. | |
| 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). | |
| 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. | |
| void | setGridSize (const Eigen::Vector3i &gridSize) |
| Set the grid size. | |
| void | setGridSize (int gridSize) |
| Set the grid size for a cubic grid. | |
| void | setOrientation (const Eigen::Quaternionf &value) |
| Set the grid orienation in the world frame. | |
| void | setOrigin (const Eigen::Vector3f &value) |
| Set the grid origin the world frame (center of voxel [0 0 0]). | |
| void | setPose (const Eigen::Matrix4f &pose) |
| Get the grid pose in the world frame. | |
| void | setVoxelSize (const Eigen::Vector3f &voxelSize) |
| Set the voxel size. | |
| void | setVoxelSize (float voxelSize) |
| Set the voxel size for cubic voxels. | |
| VoxelGridStructure () | |
| Construct an empty grid structure (0 voxels with size 1.0). | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const VoxelGridStructure &grid) |
| Stream a human-readable description of the grid's structure. | |
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.
Construct an empty grid structure (0 voxels with size 1.0).
| 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.
| 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.
| 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.
| 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.
| void checkIsInside | ( | const Eigen::Vector3i & | indices | ) | const |
Assert that the given indices are valid grid indices.
| Eigen::Vector3f getCenter | ( | ) | const |
Get the geometric center of the grid the world frame (which differs from the origin for even grid sizes).
| Eigen::Matrix4f getCenterPose | ( | ) | const |
Get the grid pose positioned at the grid center in the world frame.
| Eigen::Vector3f getExtent | ( | ) | const |
Get extent of the grid along each axis (encompassing the whole voxels).
| Eigen::Vector3f getExtentOfCenters | ( | ) | const |
Get extent of the grid along each axis (encompassing only voxel centers).
| 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.
| std::size_t getFlatIndex | ( | const Eigen::Vector3i & | indices | ) | const |
Get the flat index for the given grid indices.
| std::size_t getFlatIndex | ( | int | x, |
| int | y, | ||
| int | z ) const |
Get the flat index for the given grid indices.
| 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. |
| Eigen::Vector3i getGridIndex | ( | size_t | index | ) | const |
Get the voxel indices of the voxel with the given index.
| Eigen::Vector3i getGridIndexMax | ( | ) | const |
Get the maximal (along each axis) grid index.
| Eigen::Vector3i getGridIndexMin | ( | ) | const |
Get the minimal (along each axis) grid index.
| Eigen::Vector3i getGridSize | ( | ) | const |
Get the grid size.
| Eigen::Matrix32f getLocalBoundingBox | ( | ) | const |
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
| Eigen::Matrix32f getLocalBoundingBoxOfCenters | ( | ) | const |
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
| std::size_t getNumVoxels | ( | ) | const |
Get the number of voxels contained in the structure.
| Eigen::Quaternionf getOrientation | ( | ) | const |
Get the grid orienation in the world frame.
| 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.
| Eigen::Matrix4f getPose | ( | ) | const |
Get the grid pose in the world frame.
Note that this differs from the geometric center for even grid sizes.
| Eigen::Vector3f getVoxelCenter | ( | const Eigen::Vector3i & | indices, |
| bool | local = false ) const |
Get the center of the voxel with the given indices.
| Eigen::Vector3f getVoxelCenter | ( | int | x, |
| int | y, | ||
| int | z, | ||
| bool | local = false ) const |
Get the center of the voxel with the given indices.
| Eigen::Vector3f getVoxelCenter | ( | std::size_t | index, |
| bool | local = false ) const |
Get the center of the voxel with the given indices.
| Eigen::Vector3f getVoxelSize | ( | ) | const |
Get the voxel size.
| 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.
| bool operator!= | ( | const VoxelGridStructure & | rhs | ) | const |
| bool operator== | ( | const VoxelGridStructure & | rhs | ) | const |
Indicates whether rhs is equal to *this.
Uses v.isApprox() to compare voxel size, origin and orientation.
| 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().| 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.
| void setGridSize | ( | const Eigen::Vector3i & | gridSize | ) |
Set the grid size.
| void setGridSize | ( | int | gridSize | ) |
Set the grid size for a cubic grid.
| void setOrientation | ( | const Eigen::Quaternionf & | value | ) |
Set the grid orienation in the world frame.
| 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.
| 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.
| void setVoxelSize | ( | const Eigen::Vector3f & | voxelSize | ) |
Set the voxel size.
| void setVoxelSize | ( | float | voxelSize | ) |
Set the voxel size for cubic voxels.
|
friend |
Stream a human-readable description of the grid's structure.