BresenhamLineIterator class
An iterator to iterate over pixels along a straight line.
Contents
The iterator is created giving two points: a start and and end point.
The iterator can be incremented until it reaches past the end point. When it does, the
iterator will become invalid. An invalid iterator will test false. The IsAtEnd method
can be used instead to test for this condition. It is also possible to compare two iterators
for equality (i.e. to compare against an end iterator).
Dereferencing the iterator yields the offset to the current pixel.
Satisfies all the requirements for a mutable ForwardIterator.
Constructors, destructors, assignment and conversion operators
- BresenhamLineIterator() defaulted
- Default constructor yields an invalid iterator that cannot be dereferenced, and is equivalent to an end iterator
- BresenhamLineIterator(dip::IntegerArray strides, dip::UnsignedArray start, dip::UnsignedArray const& end)
- To construct a useful iterator, provide image strides, and coordinates of the start and end pixels
- BresenhamLineIterator(dip::IntegerArray strides, dip::FloatArray stepSize, dip::UnsignedArray start, dip::uint length)
- To construct a useful iterator, provide image strides, a step size, a start position, and a length
Aliases
- using iterator_category = std::forward_iterator_tag
- Iterator category
- using pointer = dip::BresenhamLineIterator::value_type const*
- The type of a pointer an offset
- using reference = dip::BresenhamLineIterator::value_type const&
- The type of a reference to an offset
- using value_type = dip::sint
- The type of an offset
Functions
- auto Coordinates() const -> dip::UnsignedArray const&
- Return the current coordinates in the image
- auto IsAtEnd() const -> bool
- Test to see if the iterator reached past the last pixel
- auto Length() const -> dip::uint
- Return the number of pixels left on the line after the current one
- auto Offset() const -> dip::sint
- Return the current offset
- void swap(dip::BresenhamLineIterator& other) noexcept
- Swap
Operators
- auto operator bool() const -> bool explicit
- Test to see if the iterator is still pointing at a pixel
- auto operator!=(dip::BresenhamLineIterator const& other) const -> bool
- Inequality comparison (is unequal if coordinates are not identical)
- auto operator*() const -> dip::sint
- Dereference
- auto operator++() -> dip::BresenhamLineIterator&
- Pre-increment
- auto operator++(int ) -> dip::BresenhamLineIterator
- Post-increment
- auto operator==(dip::BresenhamLineIterator const& other) const -> bool
- Equality comparison (is equal if coordinates are identical)
Variables
- static dip::dfloat const delta = 1.0-epsilon constexpr
- A distance of almost one pixel.
- static dip::dfloat const epsilon = 1e-5 constexpr
- Tolerance used to avoid errors caused by rounding.
Alias documentation
using iterator_category = std::forward_iterator_tag
Iterator category
using value_type = dip::sint
The type of an offset
using reference = dip::BresenhamLineIterator::value_type const&
The type of a reference to an offset
using pointer = dip::BresenhamLineIterator::value_type const*
The type of a pointer an offset
Function documentation
BresenhamLineIterator( ) defaulted
Default constructor yields an invalid iterator that cannot be dereferenced, and is equivalent to an end iterator
BresenhamLineIterator( dip::IntegerArray strides, dip::UnsignedArray start, dip::UnsignedArray const& end)
To construct a useful iterator, provide image strides, and coordinates of the start and end pixels
BresenhamLineIterator( dip::IntegerArray strides, dip::FloatArray stepSize, dip::UnsignedArray start, dip::uint length)
To construct a useful iterator, provide image strides, a step size, a start position, and a length
void swap( dip::BresenhamLineIterator& other) noexcept
Swap
bool IsAtEnd( ) const
Test to see if the iterator reached past the last pixel
dip::UnsignedArray const& Coordinates( ) const
Return the current coordinates in the image
dip::BresenhamLineIterator& operator++( )
Pre-increment
dip::BresenhamLineIterator operator++( int )
Post-increment
bool operator==( dip::BresenhamLineIterator const& other) const
Equality comparison (is equal if coordinates are identical)
bool operator!=( dip::BresenhamLineIterator const& other) const
Inequality comparison (is unequal if coordinates are not identical)
bool operator bool( ) const explicit
Test to see if the iterator is still pointing at a pixel
Variable documentation
static dip::dfloat const epsilon = 1e-5 constexpr
Tolerance used to avoid errors caused by rounding.
static dip::dfloat const delta = 1.0-epsilon constexpr
A distance of almost one pixel.