VoxelLine Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ VoxelLine() [1/2]

VoxelLine ( )

Construct an empty voxel line.

Definition at line 12 of file VoxelLine.cpp.

◆ VoxelLine() [2/2]

VoxelLine ( const Eigen::Vector3i &  start,
const Eigen::Vector3i &  end,
bool  includeStart = true,
bool  includeEnd = true 
)

Construct a voxel line from start to end.

Parameters
startthe start voxel
endthe end voxel
includeStartif true, the start voxel is included in the result list
includeEndif 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.

Member Function Documentation

◆ finished()

bool finished ( ) const

Indicate whether there are more voxels on the line.

Definition at line 89 of file VoxelLine.cpp.

+ Here is the caller graph for this function:

◆ getLineVoxels()

std::vector< Eigen::Vector3i > getLineVoxels ( const Eigen::Vector3i &  start,
const Eigen::Vector3i &  end,
bool  includeStart = true,
bool  includeEnd = true 
)
static

Get the voxels indices of the line from start to end.

See also
VoxelLine::VoxelLine() (constructor)

Definition at line 108 of file VoxelLine.cpp.

+ Here is the call graph for this function:

◆ next()

Eigen::Vector3i next ( )

Get the next voxel.

Exceptions
<tt>std::logic_error</tt>if there are no more voxels (this->finished())

Definition at line 94 of file VoxelLine.cpp.

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: