MIRA
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GeneralBresenhamLineIterator< D, T, Drive, Res > Class Template Reference

This more general iterator basically follows the design of BresenhamLineIterator, but works on an arbitrary-dimensional line and handles real-valued start and end positions. More...

#include <geometry/Bresenham.h>

Inheritance diagram for GeneralBresenhamLineIterator< D, T, Drive, Res >:
Inheritance graph
[legend]

Classes

struct  Axis
 Add the type-dependent start and end value to the axis data struct. More...
 

Public Member Functions

 GeneralBresenhamLineIterator (Point< T, D > start=Point< T, D >(), Point< T, D > end=Point< T, D >())
 Creates a new bresenham iterator that iterates over a line starting at point start and ending in end. More...
 
void init (Point< T, D > start=Point< T, D >(), Point< T, D > end=Point< T, D >())
 Set a new start and end, reset iterator. More...
 
bool hasNext () const
 Returns true, if there are more points/pixels to go. More...
 
const GeneralBresenhamLineIteratoroperator++ ()
 Advances the iterator to the next point/pixel. More...
 
Point< int, D > pos () const
 Returns the current position (in all dimensions). More...
 
const Axisaxis (uint32 d) const
 Returns axis structure for a specified dimension. More...
 
int drivingAxis () const
 Returns dimension index of the driving axis. More...
 

Protected Member Functions

void checkForDrivingAxis (int index, const int64_t &dist, int64_t &maxd)
 
void step (AxisBase &axis, const AxisBase &drive)
 

Protected Attributes

Axis mAxes [D]
 the axes variables More...
 
int mDrivingAxis
 driving axis dimension index More...
 

Detailed Description

template<int D, typename T = float, int Drive = -1, int Res = 1000>
class mira::GeneralBresenhamLineIterator< D, T, Drive, Res >

This more general iterator basically follows the design of BresenhamLineIterator, but works on an arbitrary-dimensional line and handles real-valued start and end positions.

Template Parameters
DThe dimension of the space the line is defined in.
TThe numerical type of the start/end point values (default: float).
DriveThe (dimension index of the) driving axis. The iterator hits each point/pixel between start and end on the driving axis exactly once. For a dense line, the driving axis must be the longest axis. This longest axis will be determined as the driving axis automatically if Drive is set < 0 (the default). Guaranteeing the longest axis as driving axis also enables some (compile-time) optimization for the iteration, so use with Drive=-1 is encouraged.
ResResolution (default = 1000). Real-valued increments are translated to integer values (to allow for integer-arithmetic calculations) by multiplying with Res.

for details: http://www.idav.ucdavis.edu/education/GraphicsNotes/Bresenhams-Algorithm/Bresenhams-Algorithm.html

See also
Geometry

Constructor & Destructor Documentation

◆ GeneralBresenhamLineIterator()

GeneralBresenhamLineIterator ( Point< T, D >  start = Point<T, D>(),
Point< T, D >  end = Point<T, D>() 
)
inline

Creates a new bresenham iterator that iterates over a line starting at point start and ending in end.

Parameters
[in]startthe D-dimensional real-valued start point
[in]endthe D-dimensional real-valued end point

Member Function Documentation

◆ init()

void init ( Point< T, D >  start = Point<T, D>(),
Point< T, D >  end = Point<T, D>() 
)
inline

Set a new start and end, reset iterator.

Parameters
[in]startthe D-dimensional real-valued start point
[in]endthe D-dimensional real-valued end point

◆ hasNext()

bool hasNext ( ) const
inline

Returns true, if there are more points/pixels to go.

◆ operator++()

const GeneralBresenhamLineIterator< D, T, Drive, Res > & operator++ ( )
inline

Advances the iterator to the next point/pixel.

◆ pos()

Point< int, D > pos ( ) const
inline

Returns the current position (in all dimensions).

This method is just for convenience and is slow (as it creates the returned point variable from the internal axes variables). If you care about performance, query the position for each dimension using axis().

◆ axis()

const Axis& axis ( uint32  d) const
inline

Returns axis structure for a specified dimension.

Parameters
[in]ddimension, must be < D.

◆ checkForDrivingAxis()

void checkForDrivingAxis ( int  index,
const int64_t &  dist,
int64_t &  maxd 
)
inlineprotectedinherited

◆ step()

void step ( AxisBase axis,
const AxisBase drive 
)
inlineprotectedinherited

◆ drivingAxis()

int drivingAxis ( ) const
inlineinherited

Returns dimension index of the driving axis.

Member Data Documentation

◆ mAxes

Axis mAxes[D]
protected

the axes variables

◆ mDrivingAxis

int mDrivingAxis
protectedinherited

driving axis dimension index


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