OpenWalnut  1.5.0dev
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
WFiberPointsIterator Class Reference

An iterator for iterating the points of a fiber. More...

#include <WDataSetFibers.h>

+ Collaboration diagram for WFiberPointsIterator:

Public Member Functions

 WFiberPointsIterator ()
 Default contructor. More...
 
 WFiberPointsIterator (WDataSetFibers const *fibers, std::size_t fbIdx, std::size_t idx, bool reverse=false)
 Constructor. More...
 
 WFiberPointsIterator (WFiberPointsIterator const &iter)
 Copy constructor. More...
 
 ~WFiberPointsIterator ()
 Destructor. More...
 
WFiberPointsIteratoroperator= (WFiberPointsIterator const &iter)
 Copy operator. More...
 
WFiberPointsIteratoroperator++ ()
 Increment operator. More...
 
WFiberPointsIteratoroperator-- ()
 Decrement operator. More...
 
WFiberPointsIterator operator++ (int)
 Increment operator. More...
 
WFiberPointsIterator operator-- (int)
 Decrement operator. More...
 
WFiberPointsIterator operator+ (size_t n)
 Plus operator. More...
 
WFiberPointsIterator operator- (size_t n)
 Minus operator. More...
 
bool operator== (WFiberPointsIterator const &rhs) const
 Compare to another point iterator. More...
 
bool operator!= (WFiberPointsIterator const &rhs) const
 Compare to another point iterator. More...
 
WIteratorRangeUnpacker< WFiberPointsIteratoroperator, (WFiberPointsIterator &other)
 Creates a temporary object that is used to unpack an iterator range to two iterators. More...
 
 operator bool () const
 Converts to a bool that indicates whether the current iterator is valid, i.e. More...
 
WPosition operator* () const
 Returns the coordinates of the point currently pointed to. More...
 
double getParameter (double def=0.0, size_t parameterIndex=0) const
 Returns the parameter specified in the vertex parameter array of the dataset. More...
 
WPosition getTangent () const
 The tangent of the point. More...
 
WColor getColor () const
 Return the color of the point. More...
 
WColor getColor (std::size_t idx) const
 Return the color of the point. More...
 
WColor getColor (std::string name) const
 Return the color of the point. More...
 
WColor getColor (const std::shared_ptr< WDataSetFibers::ColorScheme > scheme) const
 Return the color of the point. More...
 

Protected Member Functions

std::size_t getBaseIndex () const
 Calculates the index of this point in the dataset arrays. More...
 

Private Attributes

WDataSetFibers const * m_fibers
 The pointer to the fibers. More...
 
std::size_t m_fiberIndex
 The index of the fiber. More...
 
std::size_t m_index
 The index of the current point. More...
 
bool m_reverse
 Whether to iterate backwards. More...
 

Detailed Description

An iterator for iterating the points of a fiber.

Allows for both forward and backward iteration of points.

There are two ways to use the iterator. First:

for( WFiberPointsIterator pi = some_fiber_iterator.points().begin();
pi != some_fiber_iterator.points().end(); ++pi )
{
...
}
An iterator for iterating the points of a fiber.

Second:

for( ( pi, pe ) = some_fiber_iterator.points(); pi != pe; ++pi )
{
...
}

Dereferencing the iterator provides the 3D position of the point. Other information can be gained via the various member functions.

You can check whether an iterator points to a valid point of a fiber by:

if( iterator )
{
...
}

Definition at line 911 of file WDataSetFibers.h.

Constructor & Destructor Documentation

◆ WFiberPointsIterator() [1/3]

WFiberPointsIterator::WFiberPointsIterator ( )

Default contructor.

Creates an invalid iterator.

Definition at line 655 of file WDataSetFibers.cpp.

Referenced by operator+(), and operator-().

+ Here is the caller graph for this function:

◆ WFiberPointsIterator() [2/3]

WFiberPointsIterator::WFiberPointsIterator ( WDataSetFibers const *  fibers,
std::size_t  fbIdx,
std::size_t  idx,
bool  reverse = false 
)

Constructor.

Creates an iterator pointing to a certain point of a fiber.

Parameters
fibersThe pointer to the fiber data.
fbIdxThe index of the fiber in the fiber dataset.
idxThe index of the point of the current fiber.
reverseWhether to iterate backwards.

Definition at line 663 of file WDataSetFibers.cpp.

◆ WFiberPointsIterator() [3/3]

WFiberPointsIterator::WFiberPointsIterator ( WFiberPointsIterator const &  iter)

Copy constructor.

Parameters
iterThe iterator to copy from.

Definition at line 671 of file WDataSetFibers.cpp.

◆ ~WFiberPointsIterator()

WFiberPointsIterator::~WFiberPointsIterator ( )

Destructor.

Definition at line 679 of file WDataSetFibers.cpp.

Member Function Documentation

◆ getBaseIndex()

std::size_t WFiberPointsIterator::getBaseIndex ( ) const
protected

Calculates the index of this point in the dataset arrays.

But be aware that this index works vertex-wise. This mens, getting the y coordinate of the vertex in the dataset vertex array, use 3 * getBaseIndex() + 1. This depends on the type of array you like to query.

Note
this function properly handles the case when walking in reverse direction.
Returns
the base index, vertex-wise.

Definition at line 734 of file WDataSetFibers.cpp.

References WDataSetFibers::getLengthOfLine(), WDataSetFibers::getStartIndex(), m_fiberIndex, m_fibers, m_index, and m_reverse.

Referenced by getColor(), and getParameter().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor() [1/4]

WColor WFiberPointsIterator::getColor ( ) const

Return the color of the point.

Returns
the color.

Definition at line 835 of file WDataSetFibers.cpp.

References WDataSetFibers::getColorScheme(), and m_fibers.

Referenced by getColor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColor() [2/4]

WColor WFiberPointsIterator::getColor ( const std::shared_ptr< WDataSetFibers::ColorScheme scheme) const

Return the color of the point.

Parameters
schemethe colorscheme to use.
Exceptions
WDHNoSuchDataSetif the colorscheme does not exist.
Returns
the color.

Definition at line 799 of file WDataSetFibers.cpp.

References getBaseIndex(), WDataSetFibers::ColorScheme::GRAY, WDataSetFibers::ColorScheme::RGB, and WDataSetFibers::ColorScheme::RGBA.

+ Here is the call graph for this function:

◆ getColor() [3/4]

WColor WFiberPointsIterator::getColor ( std::size_t  idx) const

Return the color of the point.

Parameters
idxthe index of the colorscheme to use.
Exceptions
WDHNoSuchDataSetif the colorscheme does not exist.
Returns
the color.

Definition at line 840 of file WDataSetFibers.cpp.

References getColor(), WDataSetFibers::getColorScheme(), and m_fibers.

+ Here is the call graph for this function:

◆ getColor() [4/4]

WColor WFiberPointsIterator::getColor ( std::string  name) const

Return the color of the point.

Parameters
namethe name of the colorscheme to use.
Exceptions
WDHNoSuchDataSetif the colorscheme does not exist.
Returns
the color.

Definition at line 845 of file WDataSetFibers.cpp.

References getColor(), WDataSetFibers::getColorScheme(), and m_fibers.

+ Here is the call graph for this function:

◆ getParameter()

double WFiberPointsIterator::getParameter ( double  def = 0.0,
size_t  parameterIndex = 0 
) const

Returns the parameter specified in the vertex parameter array of the dataset.

If no such array was set, the specified default will be returned.

Parameters
defthe default value which will be returned if no vertex parameter array was defined.
parameterIndexthe parameter to get.
Returns
the value or the specified default

Definition at line 782 of file WDataSetFibers.cpp.

References getBaseIndex(), WDataSetFibers::getVertexParameters(), and m_fibers.

+ Here is the call graph for this function:

◆ getTangent()

WPosition WFiberPointsIterator::getTangent ( ) const

The tangent of the point.

Returns
the tangent

Definition at line 792 of file WDataSetFibers.cpp.

References WDataSetFibers::getLengthOfLine(), WDataSetFibers::getTangent(), m_fiberIndex, m_fibers, m_index, and m_reverse.

+ Here is the call graph for this function:

◆ operator bool()

WFiberPointsIterator::operator bool ( ) const

Converts to a bool that indicates whether the current iterator is valid, i.e.

it points to a valid point and it is safe to dereference or use functions such as getTangent().

Definition at line 777 of file WDataSetFibers.cpp.

◆ operator!=()

bool WFiberPointsIterator::operator!= ( WFiberPointsIterator const &  rhs) const

Compare to another point iterator.

Parameters
rhsThe second point iterator.
Returns
false, iff the two iterators point to the same point of the same fiber.

Definition at line 767 of file WDataSetFibers.cpp.

References operator==().

+ Here is the call graph for this function:

◆ operator*()

WPosition WFiberPointsIterator::operator* ( ) const

Returns the coordinates of the point currently pointed to.

Returns
The current coordinates.

Definition at line 748 of file WDataSetFibers.cpp.

References WDataSetFibers::getLengthOfLine(), WDataSetFibers::getPosition(), m_fiberIndex, m_fibers, m_index, and m_reverse.

+ Here is the call graph for this function:

◆ operator+()

WFiberPointsIterator WFiberPointsIterator::operator+ ( size_t  n)

Plus operator.

Increments the iterator

Parameters
ntimes.
Returns
The iterator on the new place.

Definition at line 724 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, m_reverse, and WFiberPointsIterator().

+ Here is the call graph for this function:

◆ operator++() [1/2]

WFiberPointsIterator & WFiberPointsIterator::operator++ ( )

Increment operator.

Makes the iterator point to the next point.

Returns
The incremented iterator.

Definition at line 698 of file WDataSetFibers.cpp.

References m_index.

◆ operator++() [2/2]

WFiberPointsIterator WFiberPointsIterator::operator++ ( int  )

Increment operator.

Makes the iterator point to the next point.

Returns
The iterator before incrementing.

Definition at line 704 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, and m_reverse.

◆ operator,()

WIteratorRangeUnpacker< WFiberPointsIterator > WFiberPointsIterator::operator, ( WFiberPointsIterator other)

Creates a temporary object that is used to unpack an iterator range to two iterators.

The first of these target iterators is *this, the second is the parameter of the operator.

Parameters
otherThe iterator to assign the end iterator of the range to.
Returns
The unpacker to assign a range to.

Definition at line 772 of file WDataSetFibers.cpp.

◆ operator-()

WFiberPointsIterator WFiberPointsIterator::operator- ( size_t  n)

Minus operator.

Decrements the iterator

Parameters
ntimes.
Returns
The iterator on the new place.

Definition at line 729 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, m_reverse, and WFiberPointsIterator().

+ Here is the call graph for this function:

◆ operator--() [1/2]

WFiberPointsIterator & WFiberPointsIterator::operator-- ( )

Decrement operator.

Makes the iterator point to the previous point. 3

Returns
The decremented iterator.

Definition at line 711 of file WDataSetFibers.cpp.

References m_index.

◆ operator--() [2/2]

WFiberPointsIterator WFiberPointsIterator::operator-- ( int  )

Decrement operator.

Makes the iterator point to the previous point.

Returns
The iterator before decrementing.

Definition at line 717 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, and m_reverse.

◆ operator=()

WFiberPointsIterator & WFiberPointsIterator::operator= ( WFiberPointsIterator const &  iter)

Copy operator.

Parameters
iterThe iterator to copy from.
Returns
*this

Definition at line 683 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, and m_reverse.

◆ operator==()

bool WFiberPointsIterator::operator== ( WFiberPointsIterator const &  rhs) const

Compare to another point iterator.

Parameters
rhsThe second point iterator.
Returns
true, iff the two iterators point to the same point of the same fiber.

Definition at line 757 of file WDataSetFibers.cpp.

References m_fiberIndex, m_fibers, m_index, m_reverse, and wlog::warn().

Referenced by operator!=().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_fiberIndex

std::size_t WFiberPointsIterator::m_fiberIndex
private

The index of the fiber.

Definition at line 1106 of file WDataSetFibers.h.

Referenced by getBaseIndex(), getTangent(), operator*(), operator+(), operator++(), operator-(), operator--(), operator=(), and operator==().

◆ m_fibers

WDataSetFibers const* WFiberPointsIterator::m_fibers
private

◆ m_index

std::size_t WFiberPointsIterator::m_index
private

The index of the current point.

Definition at line 1109 of file WDataSetFibers.h.

Referenced by getBaseIndex(), getTangent(), operator*(), operator+(), operator++(), operator-(), operator--(), operator=(), and operator==().

◆ m_reverse

bool WFiberPointsIterator::m_reverse
private

Whether to iterate backwards.

Definition at line 1112 of file WDataSetFibers.h.

Referenced by getBaseIndex(), getTangent(), operator*(), operator+(), operator++(), operator-(), operator--(), operator=(), and operator==().


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