DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator Class Reference

#include <GreedySegmentation.h>

Public Types

typedef
GreedySegmentation::SegmentComputer 
SegmentComputer
typedef
SegmentComputer::ConstIterator 
ConstIterator

Public Member Functions

 SegmentComputerIterator (const GreedySegmentation< TSegmentComputer > *aSegmentation, const TSegmentComputer &aSegmentComputer, const bool &aFlag)
 SegmentComputerIterator (const SegmentComputerIterator &aOther)
SegmentComputerIteratoroperator= (const SegmentComputerIterator &aOther)
 ~SegmentComputerIterator ()
bool isValid () const
const SegmentComputeroperator* () const
SegmentComputer get () const
const SegmentComputeroperator-> () const
SegmentComputerIteratoroperator++ ()
void next ()
bool operator== (const SegmentComputerIterator &aOther) const
bool operator!= (const SegmentComputerIterator &aOther) const
bool intersectNext () const
bool intersectPrevious () const
const ConstIterator begin () const
const ConstIterator end () const

Private Member Functions

void longestSegment (const ConstIterator &it)
bool doesIntersectNext (const ConstIterator &it, const ConstIterator &itb, const ConstIterator &ite)
bool doesIntersectNext (const ConstIterator &it, const ConstIterator &itb, const ConstIterator &ite, IteratorType)
bool doesIntersectNext (const ConstIterator &it, const ConstIterator &itb, const ConstIterator &ite, CirculatorType)
bool doesIntersectNext (const ConstIterator &it)

Private Attributes

const GreedySegmentation
< TSegmentComputer > * 
myS
SegmentComputer mySegmentComputer
bool myFlagIsValid
bool myFlagIntersectNext
bool myFlagIntersectPrevious
bool myFlagIsLast

Friends

class GreedySegmentation< TSegmentComputer >

Detailed Description

template<typename TSegmentComputer>
class DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator

Aim: Specific iterator to visit all the segments of a greedy segmentation.

Description of template class 'SaturatedSegmentation::SegmentComputerIterator'

Definition at line 168 of file GreedySegmentation.h.


Member Typedef Documentation

template<typename TSegmentComputer>
typedef SegmentComputer::ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::ConstIterator

Definition at line 175 of file GreedySegmentation.h.

template<typename TSegmentComputer>
typedef GreedySegmentation::SegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputer

Definition at line 174 of file GreedySegmentation.h.


Constructor & Destructor Documentation

template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputerIterator ( const GreedySegmentation< TSegmentComputer > *  aSegmentation,
const TSegmentComputer &  aSegmentComputer,
const bool &  aFlag 
)
inline

Constructor.

Nb: complexity in O(n).

Parameters:
aSegmentationthe object that knows the range bounds
aSegmentComputeran online segment recognition algorithm
aFlag'true' to build a valid object, 'false' otherwise

Definition at line 160 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::longestSegment(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIntersectPrevious, DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIsValid, and DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myS.

: myS( s ),
mySegmentComputer( aSegmentComputer ),
myFlagIsValid( aIsValid ),
myFlagIsLast( false )
{
{
if ( isNotEmpty<ConstIterator>(myS->myStart, myS->myStop) )
{ //if at least one element
myFlagIntersectPrevious = doesIntersectNext( myS->myStart, myS->myBegin, myS->myEnd );
//computation of the longest segment from myS->myStart
this->longestSegment(myS->myStart);
}
else
{
myFlagIsValid = false;
}
}
}
template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputerIterator ( const SegmentComputerIterator aOther)
inline

Copy constructor.

Parameters:
otherthe iterator to clone.

Definition at line 194 of file GreedySegmentation.ih.

: myS( other.myS ),
mySegmentComputer( other.mySegmentComputer ),
myFlagIsValid( other.myFlagIsValid ),
myFlagIntersectNext( other.myFlagIntersectNext ),
myFlagIntersectPrevious( other.myFlagIntersectPrevious ) ,
myFlagIsLast( other.myFlagIsLast )
{
}
template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::~SegmentComputerIterator ( )
inline

Destructor. Does nothing.

Definition at line 226 of file GreedySegmentation.ih.

{
}

Member Function Documentation

template<typename TSegmentComputer >
const DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::begin ( ) const
inline
Returns:
begin iterator on the segment.

Definition at line 319 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
return mySegmentComputer.begin();
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext ( const ConstIterator it,
const ConstIterator itb,
const ConstIterator ite 
)
inlineprivate

Checks if the current segment intersects the next one.

Parameters:
itend of the current segment
itbbegin iterator of the underlying range
iteend iterator of the underlying range
Returns:
'true' if it != itb and it != ite and –it and it form a valid segment, false otherwise

Definition at line 48 of file GreedySegmentation.ih.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputerIterator().

{
typedef typename IteratorCirculatorTraits<typename SegmentComputer::ConstIterator>::Type Type;
return this->doesIntersectNext( it, itb, ite, Type() );
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext ( const ConstIterator it,
const ConstIterator itb,
const ConstIterator ite,
IteratorType   
)
inlineprivate

Definition at line 57 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
ConstIterator previousIt(it);
if ( (it != itb)&&(it != ite) )
{
--previousIt;
SegmentComputer tmpSegmentComputer=mySegmentComputer.getSelf();
tmpSegmentComputer.init(previousIt);
return tmpSegmentComputer.extendForward();
}
else
{
return false;
}
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext ( const ConstIterator it,
const ConstIterator itb,
const ConstIterator ite,
CirculatorType   
)
inlineprivate

Definition at line 77 of file GreedySegmentation.ih.

{
return this->doesIntersectNext(it);
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::doesIntersectNext ( const ConstIterator it)
inlineprivate

Checks if the current segment intersects the next one (if exists).

Parameters:
itend of the current segment
Returns:
'true' if –it and it form a valid segment, false otherwise

NB: no verification

Definition at line 86 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
ConstIterator previousIt(it); --previousIt;
SegmentComputer tmpSegmentComputer=mySegmentComputer.getSelf();
tmpSegmentComputer.init(previousIt);
return tmpSegmentComputer.extendForward();
}
template<typename TSegmentComputer >
const DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::ConstIterator DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::end ( ) const
inline
Returns:
end iterator on the segment.

Definition at line 327 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
return mySegmentComputer.end();
}
template<typename TSegmentComputer >
TSegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::get ( ) const
inline
Returns:
the current segment.

Definition at line 254 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::intersectNext ( ) const
inline
Returns:
TRUE if the current segment intersects the next one, FALSE otherwise.

Definition at line 301 of file GreedySegmentation.ih.

{
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::intersectPrevious ( ) const
inline
Returns:
TRUE if the current segment intersects the previous one, FALSE otherwise.

Definition at line 309 of file GreedySegmentation.ih.

template<typename TSegmentComputer>
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Definition at line 258 of file GreedySegmentation.h.

References DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIsValid.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator==().

{ return myFlagIsValid; }
template<typename TSegmentComputer >
void DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::longestSegment ( const ConstIterator it)
inlineprivate

Computes the longest possible segment from [it]

Parameters:
ita given iterator

Nb: complexity in O(n).

Definition at line 99 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputerIterator().

{
//while my segmentComputer can be extended
while ( (mySegmentComputer.end() != myS->myStop)
&&(mySegmentComputer.extendForward()) ) {}
//if the end is reached
if (mySegmentComputer.end() == myS->myStop) {
myFlagIsLast = true;
//last extension
if ( isNotEmpty<ConstIterator>(myS->myStop, myS->myEnd) ) {
if (myS->myMode == "Truncate+1") {
mySegmentComputer.extendForward();
}
if (myS->myMode == "DoNotTruncate") {
while ( (mySegmentComputer.extendForward())
&& (mySegmentComputer.end() != myS->myEnd) ) {}
}
}
} else {
//otherwise
}
}
template<typename TSegmentComputer >
void DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::next ( )
inline

Goes to the next segment (if possible).

Nb: complexity in O(n).

Definition at line 135 of file GreedySegmentation.ih.

References DGtal::longestSegment(), and DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
if (myFlagIsLast) { //if the segmentComputer has reached the end
myFlagIsValid = false;
} else { //otherwise
ConstIterator it( mySegmentComputer.end() );
this->longestSegment(it);
}
}
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator!= ( const SegmentComputerIterator aOther) const
inline

Inequality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions differs. (different front and back iterators)

Definition at line 290 of file GreedySegmentation.ih.

{
return !(*this == other);
}
template<typename TSegmentComputer >
const TSegmentComputer & DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator* ( ) const
inline
Returns:
a constant reference to the current segment

Definition at line 237 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
}
template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator & DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator++ ( )
inline

Pre-increment. Goes to the next segment (if possible).

Nb: complexity in O(n).

Definition at line 262 of file GreedySegmentation.ih.

{
this->next();
return *this;
}
template<typename TSegmentComputer >
const TSegmentComputer * DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator-> ( ) const
inline
Returns:
a constant pointer to the current segment

Definition at line 245 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
}
template<typename TSegmentComputer >
DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator & DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator= ( const SegmentComputerIterator aOther)
inline
template<typename TSegmentComputer >
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator== ( const SegmentComputerIterator aOther) const
inline

Equality operator.

Parameters:
aOtherthe iterator to compare with
Returns:
'true' if their current positions coincide. (same front and back iterators)

Definition at line 274 of file GreedySegmentation.ih.

References DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::isValid(), DGtal::GreedySegmentation< TSegmentComputer >::isValid(), DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::mySegmentComputer, and DGtal::GreedySegmentation< TSegmentComputer >::mySegmentComputer.

{
if ( isValid() )
return ( (other.isValid() ) &&
( mySegmentComputer.begin() == other.mySegmentComputer.begin() ) &&
( mySegmentComputer.end() == other.mySegmentComputer.end() ) );
else
return ( ! other.isValid() );
}

Friends And Related Function Documentation

template<typename TSegmentComputer>
friend class GreedySegmentation< TSegmentComputer >
friend

Definition at line 218 of file GreedySegmentation.h.


Field Documentation

template<typename TSegmentComputer>
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIntersectNext
private

A flag equal to TRUE if the current segment intersects the next one, FALSE otherwise (and FALSE if the current segment is the last one)

Definition at line 200 of file GreedySegmentation.h.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator=().

template<typename TSegmentComputer>
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIntersectPrevious
private

A flag equal to TRUE if the current segment intersects the previous one, FALSE otherwise (and FALSE if the current segment is the first one)

Definition at line 207 of file GreedySegmentation.h.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator=(), and DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::SegmentComputerIterator().

template<typename TSegmentComputer>
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIsLast
private

A flag equal to TRUE if *this has reached the end, FALSE otherwise

Definition at line 212 of file GreedySegmentation.h.

Referenced by DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::operator=().

template<typename TSegmentComputer>
bool DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myFlagIsValid
private
template<typename TSegmentComputer>
const GreedySegmentation<TSegmentComputer>* DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::myS
private
template<typename TSegmentComputer>
SegmentComputer DGtal::GreedySegmentation< TSegmentComputer >::SegmentComputerIterator::mySegmentComputer
private

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