|
A line of voxels, from start voxel to an end voxel. More...
#include <VisionX/libraries/VoxelGridCore/VoxelLine.h>
Public Member Functions | |
bool | finished () const |
Indicate whether there are more voxels on the line. More... | |
Eigen::Vector3i | next () |
Get the next voxel. More... | |
VoxelLine () | |
Construct an empty voxel line. More... | |
VoxelLine (const Eigen::Vector3i &start, const Eigen::Vector3i &end, bool includeStart=true, bool includeEnd=true) | |
Construct a voxel line from start to end. More... | |
Static Public Member Functions | |
static std::vector< Eigen::Vector3i > | getLineVoxels (const Eigen::Vector3i &start, const Eigen::Vector3i &end, bool includeStart=true, bool includeEnd=true) |
Get the voxels indices of the line from start to end. More... | |
A line of voxels, from start voxel to an end voxel.
Voxels are represented by their 3D integer index.
Usage:
(1) (a) Construct a VoxelLine line. (b) while !line.finished(), call line.next().
(2) Call VoxelLine::getLineVoxels() to get all voxels at once.
Uses Bresenham's algorithm for line drawing in 3D (i.e. drawing voxels).
Implementation based on: https://www.geeksforgeeks.org/bresenhams-algorithm-for-3-d-line-drawing/
Definition at line 27 of file VoxelLine.h.
VoxelLine | ( | ) |
Construct an empty voxel line.
Definition at line 12 of file VoxelLine.cpp.
VoxelLine | ( | const Eigen::Vector3i & | start, |
const Eigen::Vector3i & | end, | ||
bool | includeStart = true , |
||
bool | includeEnd = true |
||
) |
Construct a voxel line from start to end.
start | the start voxel |
end | the end voxel |
includeStart | if true, the start voxel is included in the result list |
includeEnd | if true, the end voxel is included in the result list |
If start
and end
are equal and any of includeStart
or includeEnd
is true, the point is included.
Definition at line 15 of file VoxelLine.cpp.
bool finished | ( | ) | const |
Indicate whether there are more voxels on the line.
Definition at line 89 of file VoxelLine.cpp.
|
static |
Get the voxels indices of the line from start to end.
VoxelLine::VoxelLine()
(constructor) Definition at line 108 of file VoxelLine.cpp.
Eigen::Vector3i next | ( | ) |
Get the next voxel.
<tt>std::logic_error</tt> | if there are no more voxels (this->finished() ) |
Definition at line 94 of file VoxelLine.cpp.