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

#include <GreedyDecomposition.h>

Data Structures

class  SegmentIterator

Public Types

typedef TSegment Segment
typedef Segment::ConstIterator Iterator

Public Member Functions

 GreedyDecomposition ()
 GreedyDecomposition (const Iterator &aBegin, const Iterator &aEnd, const Segment &aSegment, const bool &aFlag)
void init (const Iterator &aBegin, const Iterator &aEnd, const Segment &aSegment, const bool &aFlag)
 ~GreedyDecomposition ()
GreedyDecomposition::SegmentIterator begin () const
GreedyDecomposition::SegmentIterator end () const
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

 GreedyDecomposition (const GreedyDecomposition &other)
GreedyDecompositionoperator= (const GreedyDecomposition &other)

Private Attributes

Iterator myBegin
Iterator myEnd
Segment mySegment
bool isClosed

Detailed Description

template<typename TSegment>
class DGtal::deprecated::GreedyDecomposition< TSegment >

Aim: Computes the greedy decomposition of a sequence into segments (the last element of a given segment is the first one one of the next segment).

 @warning This class is deprecated since GreedySegmentation has been created. 
 This class is used in @href testDecomposition.cpp @href DSSLengthEstimator.ih and @href displayContours.cpp, 
 but GreedySegmentation will be preferred in the future. 

 Description of template class 'GreedyDecomposition' <p>
 This class is a model of CDecomposition.

 This class is templated by 'TSegment', a model of CSegmentComputer
 that is able to manage the on-line recognition of a given class of 
 segments (4-connected DSS, 8-connected DSS, thick segment, etc.)
 'TSegment' must have an internal type 'ConstIterator' that is a means of 
 of accessing the sequence elements. 
 'TSegment' must have the methods init() and extendForward() taking as input
 a parameter of type 'Iterator'. The extend method must return a boolean
 equal to TRUE if the extension is possible and has been successfully
 performed and FALSE otherwise.

 In the short example below, a digital curve stored in a STL vector
 is decomposed into 8-connected DSSs whose parameters are sent to 
 the standard output.
 @code 

//types definition typedef PointVector<2,int> Point; typedef std::vector<Point> Sequence; typedef Sequence::const_iterator ConstIterator; typedef ArithmeticalDSS<ConstIterator,int,8> DSS; typedef GreedyDecomposition<DSS> Decomposition;

//sequence of input points Sequence curve; curve.push_back(Point(1,1)); curve.push_back(Point(2,1)); curve.push_back(Point(3,2)); curve.push_back(Point(4,2)); curve.push_back(Point(5,2)); curve.push_back(Point(6,2)); curve.push_back(Point(7,2)); curve.push_back(Point(8,1)); curve.push_back(Point(9,1));

//Segmentation DSS dssRecognition; Decomposition theDecomposition(curve.begin(), curve.end(), dssRecognition, false);

Decomposition::SegmentIterator i = theDecomposition.begin(); for ( ; i != theDecomposition.end(); ++i) { DSS currentSegment(*i); trace.info() << currentSegment << std::endl; //standard output }

If you want to get the DSSs decomposition of the digital curve when it is scanned in the reverse way, you can use the reverse iterator of the STL vector:

...
typedef Sequence::const_reverse_iterator ConstReverseIterator;
...
Decomposition theDecomposition(curve.rbegin(), curve.rend(), dssRecognition, false);
...

Definition at line 125 of file GreedyDecomposition.h.


Member Typedef Documentation

template<typename TSegment>
typedef Segment::ConstIterator DGtal::deprecated::GreedyDecomposition< TSegment >::Iterator

Definition at line 131 of file GreedyDecomposition.h.

template<typename TSegment>
typedef TSegment DGtal::deprecated::GreedyDecomposition< TSegment >::Segment

Definition at line 130 of file GreedyDecomposition.h.


Constructor & Destructor Documentation

template<typename TSegment>
DGtal::deprecated::GreedyDecomposition< TSegment >::GreedyDecomposition ( )
inline

Default constructor. Nb: not valid

Definition at line 321 of file GreedyDecomposition.h.

{};
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::GreedyDecomposition ( const Iterator aBegin,
const Iterator aEnd,
const Segment aSegment,
const bool &  aFlag 
)

Constructor. Nb: The digital curve is decompose as a closed one by default.

Parameters:
aBegin,beginiterator on a digital curve
aEnd,enditerator on a digital curve
aSegment,asegment computer
aFlaga boolean equal to TRUE to decompose the digital curve as a closed one, FALSE otherwise

Constructor.

Parameters:
aBegin,beginiterator on a digital curve
aEnd,enditerator on a digital curve

Definition at line 358 of file GreedyDecomposition.ih.

: myBegin(aBegin),
myEnd(aEnd),
mySegment(aSegment),
isClosed(aFlag)
{
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::~GreedyDecomposition ( )
inline

Destructor.

Definition at line 388 of file GreedyDecomposition.ih.

{
}
template<typename TSegment>
DGtal::deprecated::GreedyDecomposition< TSegment >::GreedyDecomposition ( const GreedyDecomposition< TSegment > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone.

Member Function Documentation

template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator DGtal::deprecated::GreedyDecomposition< TSegment >::begin ( ) const
inline

Iterator service.

Returns:
an iterator pointing on the first segment of a digital curve.

Iterator service.

Returns:
an iterator pointing on the first segment of the digital curve.

Definition at line 400 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::myBegin, and DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

Referenced by DGtal::DSSLengthEstimator< TConstIterator >::init().

{
return SegmentIterator(this, myBegin, mySegment);
}
template<typename TSegment >
DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator DGtal::deprecated::GreedyDecomposition< TSegment >::end ( ) const
inline

Iterator service.

Returns:
an iterator pointing after the last segment of a digital curve.

Iterator service.

Returns:
an iterator pointing after the last segment of the digital curve.

Definition at line 413 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::myEnd, and DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

Referenced by DGtal::DSSLengthEstimator< TConstIterator >::init().

{
return SegmentIterator(this, myEnd, mySegment);
}
template<typename TSegment >
void DGtal::deprecated::GreedyDecomposition< TSegment >::init ( const Iterator aBegin,
const Iterator aEnd,
const Segment aSegment,
const bool &  aFlag 
)
inline

Init. Nb: The digital curve is decompose as a closed one by default.

Parameters:
aBegin,beginiterator on a digital curve
aEnd,enditerator on a digital curve
aSegment,asegment computer
aFlaga boolean equal to TRUE to decompose the digital curve as a closed one, FALSE otherwise

Init.

Parameters:
aBegin,beginiterator on a digital curve
aEnd,enditerator on a digital curve

Definition at line 375 of file GreedyDecomposition.ih.

References DGtal::deprecated::GreedyDecomposition< TSegment >::isClosed, DGtal::deprecated::GreedyDecomposition< TSegment >::myBegin, DGtal::deprecated::GreedyDecomposition< TSegment >::myEnd, and DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment.

Referenced by DGtal::deprecated::GreedyDecomposition< TSegment >::SegmentIterator::doesIntersectNext().

{
myBegin = aBegin;
myEnd = aEnd;
mySegment = aSegment;
isClosed = aFlag;
}
template<typename TSegment >
bool DGtal::deprecated::GreedyDecomposition< TSegment >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 438 of file GreedyDecomposition.ih.

{
return true;
}
template<typename TSegment>
GreedyDecomposition& DGtal::deprecated::GreedyDecomposition< TSegment >::operator= ( const GreedyDecomposition< TSegment > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.
template<typename TSegment >
void DGtal::deprecated::GreedyDecomposition< TSegment >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 426 of file GreedyDecomposition.ih.

{
out << "[GreedyDecomposition]";
}

Field Documentation

template<typename TSegment>
bool DGtal::deprecated::GreedyDecomposition< TSegment >::isClosed
private
template<typename TSegment>
Iterator DGtal::deprecated::GreedyDecomposition< TSegment >::myBegin
private
template<typename TSegment>
Iterator DGtal::deprecated::GreedyDecomposition< TSegment >::myEnd
private
template<typename TSegment>
Segment DGtal::deprecated::GreedyDecomposition< TSegment >::mySegment
private

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