3#include <Eigen/Geometry>
19 using FlatIndex = std::size_t;
21 using GridIndex = Eigen::Vector3i;
103 const Eigen::Vector3f& origin = Eigen::Vector3f::Zero(),
109 const Eigen::Vector3f& origin = Eigen::Vector3f::Zero(),
114 const Eigen::Vector3f& voxelSize,
115 const Eigen::Vector3f& origin = Eigen::Vector3f::Zero(),
120 const Eigen::Vector3f& voxelSize,
121 const Eigen::Vector3f& origin = Eigen::Vector3f::Zero(),
146 std::size_t
getFlatIndex(
const Eigen::Vector3i& indices)
const;
148 std::size_t
getFlatIndex(
const Eigen::Vector3f& point,
bool local =
false)
const;
154 Eigen::Vector3i
getGridIndex(
const Eigen::Vector3f& point,
bool local =
false)
const;
164 Eigen::Vector3f
getVoxelCenter(
int x,
int y,
int z,
bool local =
false)
const;
166 Eigen::Vector3f
getVoxelCenter(
const Eigen::Vector3i& indices,
bool local =
false)
const;
176 void setOrigin(
const Eigen::Vector3f& value);
198 void setCenter(
const Eigen::Vector3f& center);
204 Eigen::Matrix4f
getPose()
const;
208 void setPose(
const Eigen::Matrix4f& pose);
228 bool isInside(
const Eigen::Vector3i& indices)
const;
230 bool isInside(
const Eigen::Vector3f& point,
bool local =
false)
const;
247 Eigen::Vector3f halfGridSize()
const;
249 Eigen::Vector3f getOriginToGridCenter(
bool local)
const;
253 Eigen::Vector3i _gridSize = Eigen::Vector3i::Zero();
255 Eigen::Vector3f _voxelSize = Eigen::Vector3f::Ones();
259 Eigen::Vector3f _origin = Eigen::Vector3f::Zero();
266 static const Eigen::IOFormat _iofVector;
268 static const Eigen::IOFormat _iofTimes;
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.
Eigen::Vector3f getOrigin() const
Get the grid origin in the world frame (center of voxel [0 0 0]).
bool operator!=(const VoxelGridStructure &rhs) const
Eigen::Matrix32f getLocalBoundingBox() const
Get the local axis aligned bounding box of the grid (minimal/maximal values in columns).
std::size_t getFlatIndex(int x, int y, int z) const
Get the flat index for the given grid indices.
void setVoxelSize(float voxelSize)
Set the voxel size for cubic voxels.
Eigen::Vector3f getVoxelCenter(std::size_t index, bool local=false) const
Get the center of the voxel with the given indices.
Eigen::Vector3f getCenter() const
Get the geometric center of the grid the world frame (which differs from the origin for even grid siz...
void setOrientation(const Eigen::Quaternionf &value)
Set the grid orienation in the world frame.
Eigen::Matrix32f getLocalBoundingBoxOfCenters() const
Get the local axis aligned bounding box of the voxel centers (minimal/maximal values in columns).
void setOrigin(const Eigen::Vector3f &value)
Set the grid origin the world frame (center of voxel [0 0 0]).
Eigen::Vector3i getGridSize() const
Get the grid size.
Eigen::Vector3i getGridIndex(size_t index) const
Get the voxel indices of the voxel with the given index.
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...
Eigen::Vector3f getVoxelSize() const
Get the voxel size.
Eigen::Vector3f getExtent() const
Get extent of the grid along each axis (encompassing the whole voxels).
bool operator==(const VoxelGridStructure &rhs) const
Indicates whether rhs is equal to *this.
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...
VoxelGridStructure()
Construct an empty grid structure (0 voxels with size 1.0).
bool isInside(const Eigen::Vector3i &indices) const
Indicate whether the given point is inside the voxel.
void checkIsInside(const Eigen::Vector3i &indices) const
Assert that the given indices are valid grid indices.
void setPose(const Eigen::Matrix4f &pose)
Get the grid pose in the world frame.
friend std::ostream & operator<<(std::ostream &os, const VoxelGridStructure &grid)
Stream a human-readable description of the grid's structure.
Eigen::Vector3f getExtentOfCenters() const
Get extent of the grid along each axis (encompassing only voxel centers).
Eigen::Matrix4f getPose() const
Get the grid pose in the world frame.
void setGridSize(int gridSize)
Set the grid size for a cubic grid.
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::Quaternionf getOrientation() const
Get the grid orienation in the world frame.
Quaternion< float, 0 > Quaternionf
Matrix< float, 3, 2 > Matrix32f
A 3x2 matrix.
This file offers overloads of toIce() and fromIce() functions for STL container types.