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
DGtal::GridCurve< TKSpace > Class Template Reference

#include <GridCurve.h>

Collaboration diagram for DGtal::GridCurve< TKSpace >:
Collaboration graph
[legend]

Public Types

typedef TKSpace KSpace
typedef KSpace::Point Point
typedef KSpace::Point Vector
typedef KSpace::SCell SCell
typedef std::vector< SCellStorage
typedef Storage::const_iterator const_iterator
typedef Storage::const_iterator ConstIterator
typedef
Storage::const_reverse_iterator 
const_reverse_iterator
typedef
Storage::const_reverse_iterator 
ConstReverseIterator
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
DefaultFunctor, SCell
SCellsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToPoint< KSpace >, Point
PointsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToMidPoint< KSpace >
, typename
KSpace::Space::RealPoint > 
MidPointsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToArrow< KSpace >
, std::pair< Point, Vector > > 
ArrowsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToInnerPoint< KSpace >
, Point
InnerPointsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToOuterPoint< KSpace >
, Point
OuterPointsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToIncidentPoints< KSpace >
, std::pair< Point, Point > > 
IncidentPointsRange
typedef ConstRangeAdapter
< typename
Storage::const_iterator,
SCellToCode< KSpace >, char > 
CodesRange

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CCellularGridSpaceND< KSpace >))
 ~GridCurve ()
 GridCurve (const KSpace &aKSpace)
 GridCurve ()
 GridCurve (const GridCurve &other)
GridCurveoperator= (const GridCurve &other)
std::string className () const
void selfDisplay (std::ostream &out) const
bool isValid () const
bool initFromVectorStream (std::istream &in)
void writeVectorToStream (std::ostream &out)
bool initFromVector (const std::vector< Point > &aVectorOfPoints)
bool initFromPointsVector (const std::vector< Point > &aVectorOfPoints)
template<typename TIterator >
bool initFromPointsRange (const TIterator &itb, const TIterator &ite)
bool initFromSCellsVector (const std::vector< SCell > &aVectorOfSCells)
template<typename TIterator >
bool initFromSCellsRange (const TIterator &itb, const TIterator &ite)
bool isClosed () const
bool isOpen () const
ConstIterator begin () const
ConstIterator end () const
ConstReverseIterator rbegin () const
ConstReverseIterator rend () const
SCell back () const
void push_back (const SCell &aSCell)
void pushBack (const SCell &aSCell)
Storage::size_type size () const
SCellsRange getSCellsRange () const
PointsRange getPointsRange () const
MidPointsRange getMidPointsRange () const
ArrowsRange getArrowsRange () const
InnerPointsRange getInnerPointsRange () const
OuterPointsRange getOuterPointsRange () const
IncidentPointsRange getIncidentPointsRange () const
GridCurve::CodesRange getCodesRange () const

Private Member Functions

SCell PointVectorTo1SCell (const Point &aPoint, const Vector &aVector)
bool isInside (const SCell &aSCell) const

Private Attributes

const KSpacemyKPtr
bool myFlagIsOwned
Storage mySCells

Detailed Description

template<typename TKSpace = KhalimskySpaceND<2>>
class DGtal::GridCurve< TKSpace >

Aim: describes, in a cellular space of dimension n, a closed of open sequence of signed d-cells (or d-scells), d being either equal to 1 or (n-1).

For instance, the topological boundary of a simply connected digital set is a closed sequence of 1-scells in 2d.

Template Parameters:
TKSpaceKhalimsky space, a model of CCellularGridSpaceND

Using the namespace Z2i, defined in StdDefs.h, you can instanciate a grid curve as follows:

//default construction
Curve c1;
//from a Khalimsky space
K2 ks; ks.init( lowerBound, upperBound, true );
Curve c2( ks );

This object provides several IO services. For instance, you can read a grid curve from a data file, which contains the (digital) coordinates of the 0-cells (pointels) in nd:

fstream inputStream;
inputStream.open (square.c_str(), ios::in);
c1.initFromVectorStream(inputStream);
inputStream.close();

Note that if the first and last 0-scells of the file have the same coordinates (i) or if only one of their coordinates differ by 1 (ii), then the grid curve is considered as closed, ie. scells directly incident to the last signed cell and indirectly incident to the first signed cell are the same.

You can also build a grid curve from the contour of a digital set as follows:

vector<SCell> contour; //contour
SurfelAdjacency<K2::dimension> sAdj( true ); //adjacency
SetPredicate<DigitalSet> predicate( set ); //predicate (from the digital set)
//tracking and init grid curve
SCell s = Surfaces<KSpace>::findABel( ks, predicate, 1000 );
Surfaces<KSpace>::track2DBoundary( contour, ks, sAdj, predicate, s );
c2.initFromSCellsVector( contour );

To save a grid curve in a data file, GridCurve provides the special method writeVectorToStream():

ofstream outputStream("myGridCurve.dat");
if (outputStream.is_open())
c2.writeVectorToStream(outputStream);
outputStream.close();

The stream mechanism is used to display the true content of the grid curve:

trace.info() << c1 << std::endl;

In 2d, the grid curve can be drawn in a vector graphics file as follows:

Board2D aBoard;
aBoard.setUnit(Board2D::UCentimeter);
aBoard << c2;
aBoard.saveEPS( "myGridCurve.eps", Board2D::BoundingBox, 5000 );

See Board2D: a stream mechanism for displaying 2D digital objects to learn more about the 2d drawing mechanism used in DGtal.

Moreover, this object provides several ranges as nested types:

You can get an access to these eight ranges through the following methods:

Each range can be displayed in the standard output or can be drawn (except CodesRange) in a vector graphics file as shown in the following snippet:

Curve::IncidentPointsRange r = c1.getIncidentPointsRange();
trace.info() << r << endl;
aBoard << SetMode(aDomain.className(), "Grid") << aDomain;
aBoard << r;
aBoard.saveEPS( "MyIncidentPointsRange.eps", Board2D::BoundingBox, 5000 );

Moreover, each range has the following inner types:

And each range provides these (circular)iterator services:

You can use these services to iterate over the elements of a given range as follows:

trace.info() << "\t iterate over the range" << endl;
Range::ConstIterator it = r.begin();
Range::ConstIterator itEnd = r.end();
for ( ; it != itEnd; ++it)
{
trace.info() << *it;
}
trace.info() << endl;
trace.info() << "\t iterate over the range in the reverse way" << endl;
Range::ConstReverseIterator rit = r.rbegin();
Range::ConstReverseIterator ritEnd = r.rend();
for ( ; rit != ritEnd; ++rit)
{
trace.info() << *rit;
}
trace.info() << endl;
trace.info() << "\t iterate over the range in a circular way" << endl;
Range::ConstCirculator c = r.c();
//set the starting element wherever you want...
for (unsigned i = 0; i < 20; ++i) ++c;
//... and circulate
Range::ConstCirculator cend( c );
do
{
trace.info() << *c;
c++;
} while (c!=cend);
trace.info() << endl;
See also:
exampleGridCurve2d.cpp testGridCurve.cpp

Definition at line 170 of file GridCurve.h.


Member Typedef Documentation

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToArrow<KSpace>, std::pair<Point,Vector> > DGtal::GridCurve< TKSpace >::ArrowsRange

Definition at line 443 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToCode<KSpace>, char > DGtal::GridCurve< TKSpace >::CodesRange

Definition at line 489 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef Storage::const_iterator DGtal::GridCurve< TKSpace >::const_iterator

Definition at line 311 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef Storage::const_reverse_iterator DGtal::GridCurve< TKSpace >::const_reverse_iterator

Definition at line 313 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef Storage::const_iterator DGtal::GridCurve< TKSpace >::ConstIterator

Definition at line 312 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef Storage::const_reverse_iterator DGtal::GridCurve< TKSpace >::ConstReverseIterator

Definition at line 314 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToIncidentPoints<KSpace>, std::pair<Point, Point> > DGtal::GridCurve< TKSpace >::IncidentPointsRange

Definition at line 479 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToInnerPoint<KSpace>, Point > DGtal::GridCurve< TKSpace >::InnerPointsRange

Definition at line 455 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef TKSpace DGtal::GridCurve< TKSpace >::KSpace

Definition at line 174 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToMidPoint<KSpace>, typename KSpace::Space::RealPoint > DGtal::GridCurve< TKSpace >::MidPointsRange

Definition at line 431 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToOuterPoint<KSpace>, Point > DGtal::GridCurve< TKSpace >::OuterPointsRange

Definition at line 467 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef KSpace::Point DGtal::GridCurve< TKSpace >::Point

Definition at line 177 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, SCellToPoint<KSpace>, Point > DGtal::GridCurve< TKSpace >::PointsRange

Definition at line 419 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef KSpace::SCell DGtal::GridCurve< TKSpace >::SCell

Definition at line 180 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef ConstRangeAdapter< typename Storage::const_iterator, DefaultFunctor, SCell > DGtal::GridCurve< TKSpace >::SCellsRange

Definition at line 408 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef std::vector<SCell> DGtal::GridCurve< TKSpace >::Storage

Definition at line 181 of file GridCurve.h.

template<typename TKSpace = KhalimskySpaceND<2>>
typedef KSpace::Point DGtal::GridCurve< TKSpace >::Vector

Definition at line 178 of file GridCurve.h.


Constructor & Destructor Documentation

template<typename TKSpace >
DGtal::GridCurve< TKSpace >::~GridCurve ( )

Destructor.

Definition at line 44 of file GridCurve.ih.

{
delete myKPtr;
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::GridCurve ( const KSpace aKSpace)

Constructor.

Parameters:
aKSpacethe Khalimsky space where the grid curve lies.

Definition at line 57 of file GridCurve.ih.

: myKPtr( &aKSpace ), myFlagIsOwned( false )
{
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::GridCurve ( )

Default Constructor. (the underlying Khalimsky space is default constructed).

Definition at line 51 of file GridCurve.ih.

: myKPtr( new KSpace() ), myFlagIsOwned( true )
{
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::GridCurve ( const GridCurve< TKSpace > &  other)

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 63 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::myFlagIsOwned, and DGtal::GridCurve< TKSpace >::myKPtr.

: myFlagIsOwned( aOther.myFlagIsOwned ), mySCells( aOther.mySCells )
{
myKPtr = new KSpace( *aOther.myKPtr ); //owned copy
else
myKPtr = aOther.myKPtr; //copy of the alias
}

Member Function Documentation

template<typename TKSpace >
DGtal::GridCurve< TKSpace >::SCell DGtal::GridCurve< TKSpace >::back ( ) const
inline
Returns:
last scell

Definition at line 358 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::back().

Referenced by DGtal::GridCurve< TKSpace >::back().

{
return mySCells.back();
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::ConstIterator DGtal::GridCurve< TKSpace >::begin ( ) const
inline
Returns:
begin iterator on scells

Definition at line 326 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::begin().

Referenced by DGtal::GridCurve< TKSpace >::begin(), and DGtal::GridCurve< TKSpace >::isClosed().

{
return mySCells.begin();
}
template<typename TKSpace = KhalimskySpaceND<2>>
DGtal::GridCurve< TKSpace >::BOOST_CONCEPT_ASSERT ( (CCellularGridSpaceND< KSpace >)  )
template<typename TKSpace >
std::string DGtal::GridCurve< TKSpace >::className ( ) const
inline
Returns:
the style name used for drawing this object.

Definition at line 405 of file GridCurve.ih.

{
return "GridCurve";
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::ConstIterator DGtal::GridCurve< TKSpace >::end ( ) const
inline
Returns:
end iterator on scells

Definition at line 334 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::end().

Referenced by DGtal::GridCurve< TKSpace >::end().

{
return mySCells.end();
}
template<typename TKSpace = KhalimskySpaceND<2>>
ArrowsRange DGtal::GridCurve< TKSpace >::getArrowsRange ( ) const
inline
Returns:
an instance of ArrowsRange

Definition at line 448 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return ArrowsRange(mySCells.begin(), mySCells.end(), new SCellToArrow<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
GridCurve::CodesRange DGtal::GridCurve< TKSpace >::getCodesRange ( ) const
inline
Returns:
an instance of CodesRange

Definition at line 494 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return CodesRange( mySCells.begin(), mySCells.end(), new SCellToCode<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
IncidentPointsRange DGtal::GridCurve< TKSpace >::getIncidentPointsRange ( ) const
inline
Returns:
an instance of IncidentPointsRange

Definition at line 484 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return IncidentPointsRange(mySCells.begin(), mySCells.end(), new SCellToIncidentPoints<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
InnerPointsRange DGtal::GridCurve< TKSpace >::getInnerPointsRange ( ) const
inline
Returns:
an instance of ArrowsRange

Definition at line 460 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return InnerPointsRange(mySCells.begin(), mySCells.end(), new SCellToInnerPoint<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
MidPointsRange DGtal::GridCurve< TKSpace >::getMidPointsRange ( ) const
inline
Returns:
an instance of MidPointsRange

Definition at line 436 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return MidPointsRange(mySCells.begin(), mySCells.end(), new SCellToMidPoint<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
OuterPointsRange DGtal::GridCurve< TKSpace >::getOuterPointsRange ( ) const
inline
Returns:
an instance of OuterPointsRange

Definition at line 472 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return OuterPointsRange(mySCells.begin(), mySCells.end(), new SCellToOuterPoint<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
PointsRange DGtal::GridCurve< TKSpace >::getPointsRange ( ) const
inline
Returns:
an instance of PointsRange

Definition at line 424 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

{
return PointsRange(mySCells.begin(), mySCells.end(), new SCellToPoint<KSpace>(*myKPtr) );
}
template<typename TKSpace = KhalimskySpaceND<2>>
SCellsRange DGtal::GridCurve< TKSpace >::getSCellsRange ( ) const
inline
Returns:
an instance of SCellsRange

Definition at line 413 of file GridCurve.h.

References DGtal::GridCurve< TKSpace >::mySCells.

Referenced by DGtal::Display3DFactory::draw().

{
return SCellsRange(mySCells.begin(), mySCells.end(), new DefaultFunctor() );
}
template<typename TKSpace >
template<typename TIterator >
bool DGtal::GridCurve< TKSpace >::initFromPointsRange ( const TIterator &  itb,
const TIterator &  ite 
)
inline

Init from a range of points.

Parameters:
itbbegin iterator
iteend iterator

Definition at line 164 of file GridCurve.ih.

{
mySCells.clear();
TIterator i = itb;
TIterator j = itb;
++j;
for ( ; j != ite; ++i, ++j) {
Point p = *i;
Vector v = *j - p;
if (v.norm(Vector::L_1) != 1) { //disconnected !
throw ConnectivityException();
}
if ( ! isInside( s ) ) { //out of space !
throw InputException();
}
mySCells.push_back( s );
}
Point first = *itb;
Point last = *i;
Vector v(first - last);
if (v.norm(Vector::L_1) == 1) {
SCell s = PointVectorTo1SCell(last,v);
ASSERT( isInside( s ) ); //never out of space
mySCells.push_back( PointVectorTo1SCell(last,v) );
}
return true;
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::initFromPointsVector ( const std::vector< Point > &  aVectorOfPoints)
inline

Init from a STL vector of points.

Parameters:
aVectorOfPointsthe vector containing a sequence of grid points (digital coordinates).
See also:
initFromPointsRange

Definition at line 147 of file GridCurve.ih.

{
try {
return initFromPointsRange( aVectorOfPoints.begin(), aVectorOfPoints.end() );
} catch (DGtal::ConnectivityException& /*ce*/) {
throw ConnectivityException();
return false;
} catch (DGtal::InputException& /*ie*/) {
throw InputException();
return false;
}
}
template<typename TKSpace >
template<typename TIterator >
bool DGtal::GridCurve< TKSpace >::initFromSCellsRange ( const TIterator &  itb,
const TIterator &  ite 
)
inline

Init from a range of signed cells.

Parameters:
itbbegin iterator
iteend iterator

Definition at line 223 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::push_back().

{
mySCells.clear();
//first scell
TIterator it = itb;
if (it != ite)
{
SCell currentSCell = *it;
mySCells.push_back( currentSCell );
//other scells
for (++it; it != ite; ++it)
{
SCell expectedS( myKPtr->sDirectIncident( currentSCell, *myKPtr->sDirs( currentSCell ) ) );
currentSCell = *it;
SCell s( myKPtr->sIndirectIncident( currentSCell, *myKPtr->sDirs( currentSCell ) ) );
if ( myKPtr->sKCoords(s) != myKPtr->sKCoords(expectedS) )
{ //disconnected !
throw ConnectivityException();
}
if ( ! isInside( currentSCell ) )
{ //out of space !
throw InputException();
}
mySCells.push_back( currentSCell );
}
return true;
} else return false; //empty range
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::initFromSCellsVector ( const std::vector< SCell > &  aVectorOfSCells)
inline

Init from a STL vector of signed cells.

Parameters:
aVectorOfSCellsthe vector containing the sequence of signed cells.
See also:
initFromSCellsRange

Definition at line 206 of file GridCurve.ih.

{
try {
return initFromSCellsRange( aVectorOfSCells.begin(), aVectorOfSCells.end() );
} catch (DGtal::ConnectivityException& /*ce*/) {
throw ConnectivityException();
return false;
} catch (DGtal::InputException& /*ie*/) {
throw InputException();
return false;
}
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::initFromVector ( const std::vector< Point > &  aVectorOfPoints)
inline

Deprecated name, use initFromPointsVector instead Init.

Parameters:
aVectorOfPointsthe vector containing a sequence of grid points (digital coordinates).
See also:
initFromPointsRange

Definition at line 139 of file GridCurve.ih.

{
return initFromPointsVector( aVectorOfPoints );
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::initFromVectorStream ( std::istream &  in)
inline

Init.

Parameters:
inany input stream,

Definition at line 264 of file GridCurve.ih.

References DGtal::PointListReader< TPoint >::getPointsFromInputStream().

{
std::vector<Point> v = PointListReader<Point>
::getPointsFromInputStream(in);
if (v.size() == 0) throw IOException();
try {
} catch (DGtal::ConnectivityException& /*ce*/) {
throw ConnectivityException();
return false;
} catch (DGtal::InputException& /*ie*/) {
throw InputException();
return false;
}
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::isClosed ( ) const
inline

Checks whether the grid curve is open or closed. Signed cells directly incident to the last scell and indirectly incident to the first scell should be the same in case of a closed grid curve.

Returns:
'true' if grid curve is closed, 'false' otherwise

Definition at line 305 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::begin().

{
SCell first = *mySCells.begin();
SCell last = *mySCells.rbegin();
SCell nextLast( myKPtr->sDirectIncident( last , *myKPtr->sDirs( last ) ) );
SCell previousFirst( myKPtr->sIndirectIncident( first, *myKPtr->sDirs( first ) ) );
return ( myKPtr->sKCoords(nextLast) == myKPtr->sKCoords(previousFirst) );
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::isInside ( const SCell aSCell) const
inlineprivate
Parameters:
aSCellany signed cell
Returns:
'true' if aSCell is within the underlying Khalimsky space and 'false' otherwise

Definition at line 123 of file GridCurve.ih.

{
bool flag = true;
for (Dimension k = 0; ( (k < KSpace::dimension)&&(flag) ); ++k)
{
flag = myKPtr->sIsInside( aSCell, k );
}
return flag;
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::isOpen ( ) const
inline
Returns:
'true' if the grid curve is not closed, 'false' otherwise
See also:
isClosed

Definition at line 317 of file GridCurve.ih.

{
return (! isClosed() );
}
template<typename TKSpace >
bool DGtal::GridCurve< TKSpace >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 96 of file GridCurve.ih.

{
return ( (myKPtr != NULL)
&& ( mySCells.size() > 0 ) );
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace > & DGtal::GridCurve< TKSpace >::operator= ( const GridCurve< TKSpace > &  other)

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.

Definition at line 74 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::myFlagIsOwned, DGtal::GridCurve< TKSpace >::myKPtr, and DGtal::GridCurve< TKSpace >::mySCells.

{
if ( this != &aOther )
{
mySCells = aOther.mySCells;
//free old space
delete myKPtr;
//acquire new space
myFlagIsOwned = aOther.myFlagIsOwned;
myKPtr = new KSpace( *aOther.myKPtr ); //owned copy
else
myKPtr = aOther.myKPtr; //copy of the alias
}
return *this;
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::SCell DGtal::GridCurve< TKSpace >::PointVectorTo1SCell ( const Point aPoint,
const Vector aVector 
)
inlineprivate
Parameters:
aPointany point
aVectorany vector of L1 norm equal to 1
Returns:
the signed 1-cell associated to a pair point - shift vector (both in digital coordinates)

Definition at line 109 of file GridCurve.ih.

{
ASSERT( (aVector.norm(Vector::L_1) == 1) );
SCell pointel( myKPtr->sPointel(aPoint,myKPtr->NEG) );
typename KSpace::Space::Dimension d = 0;
while ( aVector[d] == 0 ) ++d;
return myKPtr->sIncident( pointel,d,(aVector[d]>0)?myKPtr->POS:myKPtr->NEG );
}
template<typename TKSpace >
void DGtal::GridCurve< TKSpace >::push_back ( const SCell aSCell)
inline

Back insertion of aSCell

Parameters:
aSCellany signed cell
See also:
pushBack NB: this alias is kept for STL compliance

Definition at line 366 of file GridCurve.ih.

Referenced by DGtal::GridCurve< TKSpace >::initFromSCellsRange(), and DGtal::GridCurve< TKSpace >::pushBack().

{
pushBack(aSCell);
}
template<typename TKSpace >
void DGtal::GridCurve< TKSpace >::pushBack ( const SCell aSCell)
inline

Back insertion of aSCell

Parameters:
aSCellany signed cell

Definition at line 374 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::push_back().

{
mySCells.push_back(aSCell);
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::ConstReverseIterator DGtal::GridCurve< TKSpace >::rbegin ( ) const
inline
Returns:
reverse begin iterator on scells

Definition at line 342 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::rbegin().

Referenced by DGtal::GridCurve< TKSpace >::rbegin().

{
return mySCells.rbegin();
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::ConstReverseIterator DGtal::GridCurve< TKSpace >::rend ( ) const
inline
Returns:
reverse end iterator on scells

Definition at line 350 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::rend().

Referenced by DGtal::GridCurve< TKSpace >::rend().

{
return mySCells.rend();
}
template<typename TKSpace >
void DGtal::GridCurve< TKSpace >::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 392 of file GridCurve.ih.

Referenced by DGtal::operator<<().

{
out << "[" << className() << "]" << std::endl;
for(unsigned int i=0; i< mySCells.size(); i++){
out << mySCells.at(i) << " ";
}
out << std::endl;
}
template<typename TKSpace >
DGtal::GridCurve< TKSpace >::Storage::size_type DGtal::GridCurve< TKSpace >::size ( ) const
inline
Returns:
number of scells

Definition at line 382 of file GridCurve.ih.

References DGtal::GridCurve< TKSpace >::size().

Referenced by DGtal::GridCurve< TKSpace >::size().

{
return mySCells.size();
}
template<typename TKSpace >
void DGtal::GridCurve< TKSpace >::writeVectorToStream ( std::ostream &  out)
inline

Outputs the grid curve to the stream out.

Parameters:
outany output stream,

Definition at line 286 of file GridCurve.ih.

References DGtal::ConstRangeAdapter< TIterator, TFunctor, TReturnType >::begin(), and DGtal::ConstRangeAdapter< TIterator, TFunctor, TReturnType >::end().

{
for (typename PointsRange::ConstIterator it = r.begin(), itEnd = r.end();
it != itEnd; ++it)
{
Point p = *it;
for (unsigned int k = 0; k < Point::dimension; ++k) {
out << p[k] << " ";
}
out << std::endl;
}
}

Field Documentation

template<typename TKSpace = KhalimskySpaceND<2>>
bool DGtal::GridCurve< TKSpace >::myFlagIsOwned
private

bool equal to 'true' if this owns the Khalimsky space but 'false' otherwise

Definition at line 370 of file GridCurve.h.

Referenced by DGtal::GridCurve< TKSpace >::GridCurve(), and DGtal::GridCurve< TKSpace >::operator=().

template<typename TKSpace = KhalimskySpaceND<2>>
const KSpace* DGtal::GridCurve< TKSpace >::myKPtr
private

Pointer on a Khalimsky space

Definition at line 365 of file GridCurve.h.

Referenced by DGtal::GridCurve< TKSpace >::GridCurve(), and DGtal::GridCurve< TKSpace >::operator=().

template<typename TKSpace = KhalimskySpaceND<2>>
Storage DGtal::GridCurve< TKSpace >::mySCells
private

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