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::UmbrellaComputer< TDigitalSurfaceTracker > Class Template Reference

#include <UmbrellaComputer.h>

Inheritance diagram for DGtal::UmbrellaComputer< TDigitalSurfaceTracker >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::UmbrellaComputer< TDigitalSurfaceTracker >:
Collaboration graph
[legend]

Data Structures

struct  State

Public Types

typedef TDigitalSurfaceTracker DigitalSurfaceTracker
typedef
DigitalSurfaceTracker::DigitalSurfaceContainer 
DigitalSurfaceContainer
typedef
DigitalSurfaceContainer::KSpace 
KSpace
typedef
DigitalSurfaceContainer::Surfel 
Surfel
typedef
DigitalSurfaceContainer::Size 
Size
typedef KSpace::SCell SCell

Public Member Functions

 ~UmbrellaComputer ()
 UmbrellaComputer ()
 UmbrellaComputer (const UmbrellaComputer &other)
UmbrellaComputeroperator= (const UmbrellaComputer &other)
void init (const DigitalSurfaceTracker &tracker, Dimension k, bool epsilon, Dimension j)
void setState (const State &aState)
void getState (State &aState) const
const Statestate () const
const KSpacespace () const
const Surfelsurfel () const
SCell separator () const
SCell pivot () const
Dimension orthDir () const
Dimension trackDir () const
bool trackOrientation () const
Dimension separatorDir () const
bool separatorOrientation () const
unsigned int next ()
unsigned int previous ()
bool adjacent ()
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

 BOOST_CONCEPT_ASSERT ((CDigitalSurfaceTracker< TDigitalSurfaceTracker >))

Private Attributes

DigitalSurfaceTrackermyTracker
State myState

Detailed Description

template<typename TDigitalSurfaceTracker>
class DGtal::UmbrellaComputer< TDigitalSurfaceTracker >

Aim: Useful for computing umbrellas on 'DigitalSurface's, ie set of n-1 cells around a n-3 cell.

Description of class 'DigitalSurfaceUmbrellaComputer'

The current surfel (n-1 cell), or face, is denoted by s. The n-3 cell is called the pivot and denoted by +p. It is always a positive cell. There is also a current n-2 cell, called the separator and denoted by t, which is in the boundary of s and whose boundary contains +p.

Two directions specifies the separator and the pivot, the track direction j and the separator direction k. Moreover an orientation \( \epsilon=\pm 1 \) specifies one which side is the separator wrt the face. We have \( t = \Delta^{\epsilon}_k s, +p = \Delta^{\mu}_{j} t, \) where \( \mu \) is the direct orientation of t along j.

Turning around the pivot means moving the face and the separator once (in the track direction), such that the pivot is the same (ie +p), the track and separator directions being updated. Repeating this process a sufficient number of times brings the umbrella back in its original position, except in the case when the DigitalSurface has a boundary touching the pivot.

Uses delegation with DigitalSurfaceTracker.

Essentially a backport from ImaGene.

Template Parameters:
TDigitalSurfaceTrackerthe type of the domain in which shapes are created.

Definition at line 87 of file UmbrellaComputer.h.


Member Typedef Documentation

template<typename TDigitalSurfaceTracker>
typedef DigitalSurfaceTracker::DigitalSurfaceContainer DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::DigitalSurfaceContainer

Definition at line 95 of file UmbrellaComputer.h.

template<typename TDigitalSurfaceTracker>
typedef TDigitalSurfaceTracker DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::DigitalSurfaceTracker

Definition at line 94 of file UmbrellaComputer.h.

template<typename TDigitalSurfaceTracker>
typedef DigitalSurfaceContainer::KSpace DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::KSpace

Definition at line 96 of file UmbrellaComputer.h.

template<typename TDigitalSurfaceTracker>
typedef KSpace::SCell DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::SCell

Definition at line 99 of file UmbrellaComputer.h.

template<typename TDigitalSurfaceTracker>
typedef DigitalSurfaceContainer::Size DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::Size

Definition at line 98 of file UmbrellaComputer.h.

template<typename TDigitalSurfaceTracker>
typedef DigitalSurfaceContainer::Surfel DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::Surfel

Definition at line 97 of file UmbrellaComputer.h.


Constructor & Destructor Documentation

template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::~UmbrellaComputer ( )
inline

Destructor.

Definition at line 44 of file UmbrellaComputer.ih.

{
if ( myTracker != 0 ) delete myTracker;
}
template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::UmbrellaComputer ( )
inline

Constructor. The object is not valid.

Definition at line 51 of file UmbrellaComputer.ih.

: myTracker( 0 )
{
}
template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::UmbrellaComputer ( const UmbrellaComputer< TDigitalSurfaceTracker > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 59 of file UmbrellaComputer.ih.

References DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myState, and DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myTracker.

: myTracker( 0 )
{
if ( other.myTracker != 0 )
{
myTracker = new DigitalSurfaceTracker( *other.myTracker );
myState = other.myState;
}
}

Member Function Documentation

template<typename TDigitalSurfaceTracker >
bool DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::adjacent ( )
inline

Go the adjacent umbrella, ie the one which shares the same faces around the separator but whose pivot is symmetric around the separator.

Returns:
'true' if their was an adjacent umbrella, 'false' otherwise. (the umbrella is in the same state as before the call).

Definition at line 312 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
Dimension old_j = trackDir(); // uint old_j = m_track_dir;
if ( previous() == 0 ) return false;
bool mu = trackOrientation(); // m_space->sdirect( separator(), m_track_dir );
myState.k = myState.j; // m_separator_dir = m_track_dir;
myState.epsilon = mu; // m_separator_orientation = mu;
myState.j = old_j; // m_track_dir = old_j;
return true;
}
template<typename TDigitalSurfaceTracker>
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::BOOST_CONCEPT_ASSERT ( (CDigitalSurfaceTracker< TDigitalSurfaceTracker >)  )
private
template<typename TDigitalSurfaceTracker >
void DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::getState ( State aState) const
inline

Returns the state of the umbrella in the referenced object [state].

Parameters:
aState(returns) the current umbrella state describing the face, the separator and the pivot.

Definition at line 112 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
aState = myState;
}
template<typename TDigitalSurfaceTracker >
void DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::init ( const DigitalSurfaceTracker tracker,
Dimension  k,
bool  epsilon,
Dimension  j 
)

Initializes the umbrella with a 'DigitalSurfaceTracker'. Links the umbrella computer with a concrete surface and a surfel on it. Tells also where is the positive pivot to turn around.

Parameters:
trackera tracker on a digital surface with a valid 'current()' surfel. (cloned). Specifies the initial surfel.
kthe separator direction different from [j] and the orthogonal direction to the surfel.
epsilonthe orientation where to find the separator pointing at the pivot.
jthe track direction where the next surfel of the umbrella is.

Definition at line 94 of file UmbrellaComputer.ih.

{
if ( myTracker != 0 )
delete myTracker;
myTracker = new DigitalSurfaceTracker( tracker );
ASSERT( space().isSpaceClosed()
&& "[UmbrellaComputer] It is necessary to work with a closed cellular space since umbrellas use separators and pivots, which must exist for arbitrary surfels. Please build a closed KhalimskySpaceND for instance if you wish to work with faces in digital surfaces." );
myState.surfel = myTracker->current();
myState.k = k;
myState.epsilon = epsilon;
myState.j = j;
}
template<typename TDigitalSurfaceTracker >
bool DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 346 of file UmbrellaComputer.ih.

{
return true;
}
template<typename TDigitalSurfaceTracker >
unsigned int DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::next ( )
inline

Turns around the current pivot (positive turn).

Returns:
0 if the move was impossible (nothing is updated) otherwise returns the move code of the face.

Definition at line 222 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
// Delta^mu_t = +p
bool mu = trackOrientation(); // m_space->sdirect( separator(), j );
SCell sp;
unsigned int code = myTracker->adjacent( sp, j, mu );
if ( code != 0 )
{ // Then the face has a successor.
SCell s = myTracker->current();
myState.j = myState.k; // m_track_dir = m_separator_dir;
myTracker->move( sp );
if ( code != 2 ) // s and sp are not aligned.
{
bool track_direct_orientation
= space().sDirect( s, j );
bool nu = space().sDirect( sp, i );
myState.k = i; // m_separator_dir = i;
myState.epsilon = ( mu == track_direct_orientation ) ^ nu;
// m_separator_orientation = ( mu == track_direct_orientation ) ^ nu;
}
else
{
myState.k = j; //m_separator_dir = j;
myState.epsilon = ! mu; // m_separator_orientation = ! mu;
}
}
return code;
}
template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker > & DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::operator= ( const UmbrellaComputer< TDigitalSurfaceTracker > &  other)
inline

Assignment.

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

Definition at line 73 of file UmbrellaComputer.ih.

References DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myState, and DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myTracker.

{
if ( this != &other )
{
if ( myTracker != 0 )
{
delete myTracker;
myTracker = 0;
}
if ( other.myTracker != 0 )
{
myTracker = new DigitalSurfaceTracker( *other.myTracker );
myState = other.myState;
}
}
return *this;
}
template<typename TDigitalSurfaceTracker >
Dimension DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::orthDir ( ) const
inline
Returns:
the orthogonal direction to the current surfel.

Definition at line 179 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
return myTracker->orthDir();
}
template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::SCell DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::pivot ( ) const
inline
Returns:
the pivot n-3 cell (always positively orientated).

Definition at line 170 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
return space()->sDirectIncident( separator(), trackDir() );
}
template<typename TDigitalSurfaceTracker >
unsigned int DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::previous ( )
inline

Turns around the current pivot (negative turn).

Returns:
0 if the move was impossible (nothing is updated) otherwise returns the move code of the face.

Definition at line 259 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
// cerr << "[DGtal::UmbrellaComputer<TDigitalSurfaceTracker>::previous()] begin" << endl;
// cerr << "(f=" << face()
// << ",s=" << separator()
// << ",p=" << pivot()
// << ",i=" << m_tracker->orthDir()
// << ",j=" << trackDir()
// << ",k=" << separatorDir()
// << ",E=" << separatorOrientation()
// << ")";
// cerr << endl;
// Delta^mu_t = +p
bool mu = trackOrientation(); // m_space->sdirect( separator(), j );
SCell sp;
unsigned int code = myTracker->adjacent( sp, separatorDir(),
// Kn_sid sp = m_tracker->adjacent( m_separator_dir, m_separator_orientation );
// cerr << "(" << face() << "," << sp << ")";
if ( code != 0 )
{ // Then the face has a successor.
myTracker->move( sp );
myState.k = j;
myState.j = ( code != 2 )
? i // s and sp are not aligned.
: k; // s and sp are aligned.
}
// cerr << "(f=" << face()
// << ",s=" << separator()
// << ",p=" << pivot()
// << ",i=" << m_tracker->orthDir()
// << ",j=" << trackDir()
// << ",k=" << separatorDir()
// << ",E=" << separatorOrientation()
// << ")";
// cerr << endl;
// cerr << "[DGtal::UmbrellaComputer<TDigitalSurfaceTracker>::previous()] end" << endl;
return code;
}
template<typename TDigitalSurfaceTracker >
void DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::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 334 of file UmbrellaComputer.ih.

{
out << "[UmbrellaComputer]";
}
template<typename TDigitalSurfaceTracker >
DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::SCell DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::separator ( ) const
inline
Returns:
the separator n-2 cell.

Definition at line 159 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
return space().sIncident( surfel(),
}
template<typename TDigitalSurfaceTracker >
Dimension DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::separatorDir ( ) const
inline
Returns:
the separator direction.

Definition at line 204 of file UmbrellaComputer.ih.

{
return myState.k;
}
template<typename TDigitalSurfaceTracker >
bool DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::separatorOrientation ( ) const
inline
Returns:
the separator orientation.

Definition at line 212 of file UmbrellaComputer.ih.

{
return myState.epsilon;
}
template<typename TDigitalSurfaceTracker >
void DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::setState ( const State aState)
inline

Puts the umbrella in the state [state]. The umbrella must have been initialized with a 'DigitalSurfaceTracker' before and the state must be consistent with the tracker. In particular, the face of the state must lie on the same digital surface.

Parameters:
aStatea state describing the face, the separator and the pivot.

Definition at line 121 of file UmbrellaComputer.ih.

References DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::State::surfel.

{
ASSERT( myTracker != 0 );
myTracker->move( aState.surfel );
myState = aState;
}
template<typename TDigitalSurfaceTracker >
const DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::KSpace & DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::space ( ) const
inline

Accessor to the digital space.

Definition at line 139 of file UmbrellaComputer.ih.

References DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::space().

Referenced by DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::space().

{
return myTracker->surface().space();
}
template<typename TDigitalSurfaceTracker >
const DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::State & DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::state ( ) const
inline

Accessor to current state.

Definition at line 131 of file UmbrellaComputer.ih.

{
return myState;
}
template<typename TDigitalSurfaceTracker >
const DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::Surfel & DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::surfel ( ) const
inline
Returns:
the current surfel at which the umbrella is pointing.

Definition at line 149 of file UmbrellaComputer.ih.

{
ASSERT( myTracker != 0 );
ASSERT( myTracker->current() == myState.surfel );
return myState.surfel;
}
template<typename TDigitalSurfaceTracker >
Dimension DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::trackDir ( ) const
inline
Returns:
the track direction (j).

Definition at line 188 of file UmbrellaComputer.ih.

{
return myState.j;
}
template<typename TDigitalSurfaceTracker >
bool DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::trackOrientation ( ) const
inline
Returns:
the track orientation (mu).

Definition at line 196 of file UmbrellaComputer.ih.

{
return space().sDirect( separator(), trackDir() );
}

Field Documentation

template<typename TDigitalSurfaceTracker>
State DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myState
private
template<typename TDigitalSurfaceTracker>
DigitalSurfaceTracker* DGtal::UmbrellaComputer< TDigitalSurfaceTracker >::myTracker
private

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