dip::BresenhamLineIterator class

An iterator to iterate over pixels along a straight line.

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

Functions

void swap(dip::BresenhamLineIterator& other) noexcept
Swap
auto IsAtEnd() const -> bool
Test to see if the iterator reached past the last pixel
auto Coordinates() const -> dip::UnsignedArray const&
Return the current coordinates in the image
auto Offset() const -> dip::sint
Return the current offset
auto Length() const -> dip::uint
Return the number of pixels left on the line after the current one

Operators

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)
auto operator!=(dip::BresenhamLineIterator const& other) const -> bool
Inequality comparison (is unequal if coordinates are not identical)
auto operator bool() const -> bool explicit
Test to see if the iterator is still pointing at a pixel

Variables

static dip::dfloat const epsilon constexpr
Tolerance used to avoid errors caused by rounding.
static dip::dfloat const delta constexpr
A distance of almost one pixel.