MIRA
Public Member Functions | List of all members
BresenhamLineIterator Class Reference

Implements an iterator that is able to iterate over a Bresenham line point by point using the prefix ++operator and –operator. More...

#include <geometry/Bresenham.h>

Public Member Functions

 BresenhamLineIterator (int x0, int y0, int x1, int y1, int xInc=1, int yInc=1)
 Creates a new bresenham iterator that iterates over a line starting at coordinate (x0,y0) and ending in (x1,y1). More...
 
bool hasNext () const
 Returns true, if there are more points/pixels to go. More...
 
const BresenhamLineIteratoroperator++ ()
 Advances the iterator to the next point/pixel. More...
 
const BresenhamLineIteratoroperator-- ()
 Moves iterator backward to the previous point/pixel. More...
 
int x () const
 Returns current x-coordinate. More...
 
int y () const
 Returns current y-coordinate. More...
 
bool isMajorX () const
 Returns true if the line mainly moves along the x-axis. More...
 
bool isMajorY () const
 Returns true if the line mainly moves along the y-axis. More...
 
int pos () const
 Returns the current position on the line. More...
 
int length () const
 Returns the length of the line in points/pixels. More...
 
BresenhamLineIterator orthogonal ()
 Creates a new bresenham line iterator that is orthogonal to this line and starts in the current point. More...
 

Detailed Description

Implements an iterator that is able to iterate over a Bresenham line point by point using the prefix ++operator and –operator.

This class is generic and operates on the point coordinates only without underlying data. It can be subclassed to implement a more specialized iterator that is able to iterate over concrete data structures like images etc. Such a subclassed iterator can be extended by a *operator and ->operator to allow direct access to the data for drawing and sampling lines e.g.

See also
Geometry

Constructor & Destructor Documentation

◆ BresenhamLineIterator()

BresenhamLineIterator ( int  x0,
int  y0,
int  x1,
int  y1,
int  xInc = 1,
int  yInc = 1 
)
inline

Creates a new bresenham iterator that iterates over a line starting at coordinate (x0,y0) and ending in (x1,y1).

Parameters
[in]x0the x start coordinate
[in]y0the y start coordinate
[in]x1the x end coordinate
[in]y1the y end coordinate
[in]xIncthe optional increment in x-direction (default = 1)
[in]yIncthe optional increment in y-direction (default = 1)

Member Function Documentation

◆ hasNext()

bool hasNext ( ) const
inline

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

◆ operator++()

const BresenhamLineIterator & operator++ ( )
inline

Advances the iterator to the next point/pixel.

◆ operator--()

const BresenhamLineIterator & operator-- ( )
inline

Moves iterator backward to the previous point/pixel.

◆ x()

int x ( ) const
inline

Returns current x-coordinate.

◆ y()

int y ( ) const
inline

Returns current y-coordinate.

◆ isMajorX()

bool isMajorX ( ) const
inline

Returns true if the line mainly moves along the x-axis.

◆ isMajorY()

bool isMajorY ( ) const
inline

Returns true if the line mainly moves along the y-axis.

◆ pos()

int pos ( ) const
inline

Returns the current position on the line.

◆ length()

int length ( ) const
inline

Returns the length of the line in points/pixels.

◆ orthogonal()

BresenhamLineIterator orthogonal ( )
inline

Creates a new bresenham line iterator that is orthogonal to this line and starts in the current point.


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