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::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > Class Template Reference

#include <LightExplicitDigitalSurface.h>

Collaboration diagram for DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >:
Collaboration graph
[legend]

Data Structures

class  Tracker
struct  VertexMap

Public Types

typedef
LightExplicitDigitalSurface
< TKSpace, TSurfelPredicate > 
Self
typedef TKSpace KSpace
typedef KSpace::SCell Surfel
typedef KSpace::Size Size
typedef TSurfelPredicate SurfelPredicate
typedef SurfelAdjacency
< KSpace::dimension > 
Adjacency
typedef KSpace::Cell Cell
typedef KSpace::SCell SCell
typedef KSpace::CellSet CellSet
typedef KSpace::SCellSet SCellSet
typedef Surfel Vertex
typedef SCellSet VertexSet
typedef BreadthFirstVisitor< SelfSelfVisitor
typedef
SelfVisitor::VertexConstIterator 
SurfelConstIterator
typedef KSpace::Space Space
typedef KSpace::Point Point
typedef Tracker DigitalSurfaceTracker

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CSurfelPredicate< SurfelPredicate >))
 ~LightExplicitDigitalSurface ()
 LightExplicitDigitalSurface (const LightExplicitDigitalSurface &other)
 LightExplicitDigitalSurface (const KSpace &aKSpace, const SurfelPredicate &aSP, const Adjacency &adj, const Surfel &s)
const AdjacencysurfelAdjacency () const
AdjacencysurfelAdjacency ()
const SurfelPredicatesurfelPredicate () const
const Surfelsurfel () const
void setSurfel (const Surfel &aSurfel)
const KSpacespace () const
bool isInside (const Surfel &s) const
SurfelConstIterator begin () const
SurfelConstIterator end () const
Size nbSurfels () const
bool empty () const
DigitalSurfaceTrackernewTracker (const Surfel &s) const
Connectedness connectedness () const
Size degree (const Vertex &v) const
template<typename OutputIterator >
void writeNeighbors (OutputIterator &it, const Vertex &v) const
template<typename OutputIterator , typename VertexPredicate >
void writeNeighbors (OutputIterator &it, const Vertex &v, const VertexPredicate &pred) const
Size bestCapacity () const
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

LightExplicitDigitalSurfaceoperator= (const LightExplicitDigitalSurface &other)

Private Attributes

const KSpacemyKSpace
const SurfelPredicatemySurfelPredicate
Adjacency mySurfelAdjacency
Surfel mySurfel
Tracker myTracker

Detailed Description

template<typename TKSpace, typename TSurfelPredicate>
class DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >

Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels. The shape is determined by a predicate telling whether a given surfel belongs or not to the shape boundary. The whole boundary is not precomputed nor stored. You may use an iterator to visit it.

Description of template class 'LightExplicitDigitalSurface'

It is also a model of CUndirectedSimpleLocalGraph, so as to be able to visit itself with a BreadthFirstVisitor. The "Light" or lazyness is implemented this way.

Template Parameters:
TKSpacea model of CCellularGridSpaceND: the type chosen for the cellular grid space.
TSurfelPredicatea model of CSurfelPredicate: this functor defines the digital surface as a characteristic function returning true iff the surfel belongs to it.

Definition at line 78 of file LightExplicitDigitalSurface.h.


Member Typedef Documentation

template<typename TKSpace, typename TSurfelPredicate>
typedef SurfelAdjacency<KSpace::dimension> DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Adjacency

Definition at line 177 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::Cell DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Cell

Definition at line 178 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::CellSet DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::CellSet

Definition at line 180 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef Tracker DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::DigitalSurfaceTracker

Definition at line 197 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef TKSpace DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::KSpace

Model of cellular grid space.

Definition at line 164 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::Point DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Point

Definition at line 196 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::SCell DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SCell

Definition at line 179 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::SCellSet DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SCellSet

Definition at line 181 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef LightExplicitDigitalSurface<TKSpace,TSurfelPredicate> DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Self

Definition at line 162 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef BreadthFirstVisitor< Self > DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SelfVisitor

Definition at line 193 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::Size DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Size

Type for sizes (unsigned integral type).

Definition at line 168 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::Space DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Space

Definition at line 195 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef KSpace::SCell DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Surfel

Type for surfels.

Definition at line 166 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef SelfVisitor::VertexConstIterator DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SurfelConstIterator

Definition at line 194 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef TSurfelPredicate DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SurfelPredicate

Definition at line 170 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef Surfel DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Vertex

Definition at line 185 of file LightExplicitDigitalSurface.h.

template<typename TKSpace, typename TSurfelPredicate>
typedef SCellSet DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::VertexSet

Definition at line 186 of file LightExplicitDigitalSurface.h.


Constructor & Destructor Documentation

template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::~LightExplicitDigitalSurface ( )
inline

Destructor.

Definition at line 125 of file LightExplicitDigitalSurface.ih.

{
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::LightExplicitDigitalSurface ( const LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 132 of file LightExplicitDigitalSurface.ih.

template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::LightExplicitDigitalSurface ( const KSpace aKSpace,
const SurfelPredicate aSP,
const Adjacency adj,
const Surfel s 
)
inline

Constructor from digital set.

Parameters:
aKSpacea cellular grid space (referenced).
aSPa surfel predicate defining the shape (referenced).
adjthe surfel adjacency (for instance Adjacency( true ) is interior to exterior adjacency ).
sany surfel of aKSpace such that aPP is true in the interior and false in the exterior.

Definition at line 144 of file LightExplicitDigitalSurface.ih.

: myKSpace( aKSpace ), mySurfelPredicate( aSP ), mySurfelAdjacency( adj ),
mySurfel( s ), myTracker( *this, s )
{
}

Member Function Documentation

template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SurfelConstIterator DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::begin ( ) const
inline
Returns:
an iterator pointing on the first surfel of the digital surface (unspecified order).

Definition at line 223 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::mySurfel.

Referenced by DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::nbSurfels().

{
SelfVisitor* ptrVisitor = new SelfVisitor( *this, mySurfel );
ASSERT( ptrVisitor != 0 );
return SurfelConstIterator( ptrVisitor );
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Size DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::bestCapacity ( ) const
inline

Should return a reasonable estimation of the number of neighbors for all vertices. For instance a planar triangulation should return 6-8, a quad-mesh should return 4, digital surface is 2*(K::dimension-1).

Returns:
2*(K::dimension-1)

Definition at line 346 of file LightExplicitDigitalSurface.ih.

{
return KSpace::dimension * 2 - 2;
}
template<typename TKSpace, typename TSurfelPredicate>
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::BOOST_CONCEPT_ASSERT ( (CSurfelPredicate< SurfelPredicate >)  )
template<typename TKSpace , typename TSurfelPredicate >
DGtal::Connectedness DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::connectedness ( ) const
inline
Returns:
the connectedness of this surface. By construction CONNECTED.

Definition at line 269 of file LightExplicitDigitalSurface.ih.

References DGtal::CONNECTED.

{
return CONNECTED;
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Size DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::degree ( const Vertex v) const
inline
Parameters:
vany vertex of this graph
Returns:
the number of neighbors of this Vertex/Surfel.

Definition at line 280 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::adjacent(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::move(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::myTracker, and DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::space().

{
Size d = 0;
Vertex s;
for ( typename KSpace::DirIterator q = space().sDirs( v );
q != 0; ++q )
{
if ( myTracker.adjacent( s, *q, true ) )
++d;
if ( myTracker.adjacent( s, *q, false ) )
++d;
}
return d;
}
template<typename TKSpace , typename TSurfelPredicate >
bool DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::empty ( ) const
inline
Returns:
'true' is the surface has no surfels, 'false' otherwise. NB: O(1) operation.

Definition at line 252 of file LightExplicitDigitalSurface.ih.

{
return false;
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SurfelConstIterator DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::end ( ) const
inline
Returns:
an iterator after the last surfel of the digital surface (unspecified order).

Definition at line 233 of file LightExplicitDigitalSurface.ih.

Referenced by DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::nbSurfels().

{
return SurfelConstIterator( 0 );
}
template<typename TKSpace , typename TSurfelPredicate >
bool DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::isInside ( const Surfel s) const
inline
Parameters:
sany surfel of the space.
Returns:
'true' if s belongs to this digital surface.

Definition at line 215 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfelPredicate().

Referenced by DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::move().

{
return surfelPredicate()( s );
}
template<typename TKSpace , typename TSurfelPredicate >
bool DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 376 of file LightExplicitDigitalSurface.ih.

{
return true;
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Size DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::nbSurfels ( ) const
inline
Returns:
the number of surfels of this digital surface. NB: O(N) computational complexity where N is the number of surfels.

Definition at line 241 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::begin(), and DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::end().

{
Size nb = 0;
for ( SurfelConstIterator it = begin(), it_end = end(); it != it_end; ++it )
++nb;
return nb;
}
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::DigitalSurfaceTracker * DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::newTracker ( const Surfel s) const
inline
Parameters:
sany surfel of the space.
Precondition:
'isInside( s )'
Returns:
a dyn. alloc. pointer on a tracker positionned at s.

Definition at line 261 of file LightExplicitDigitalSurface.ih.

{
return new Tracker( *this, s );
}
template<typename TKSpace, typename TSurfelPredicate>
LightExplicitDigitalSurface& DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::operator= ( const LightExplicitDigitalSurface< TKSpace, TSurfelPredicate > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TKSpace , typename TSurfelPredicate >
void DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::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 364 of file LightExplicitDigitalSurface.ih.

{
out << "[LightExplicitDigitalSurface]";
}
template<typename TKSpace , typename TSurfelPredicate >
void DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::setSurfel ( const Surfel aSurfel)
inline
template<typename TKSpace , typename TSurfelPredicate >
const DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::KSpace & DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::space ( ) const
inline
template<typename TKSpace , typename TSurfelPredicate >
const DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Surfel & DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfel ( ) const
inline
template<typename TKSpace , typename TSurfelPredicate >
const DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Adjacency & DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfelAdjacency ( ) const
inline
template<typename TKSpace , typename TSurfelPredicate >
DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Adjacency & DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfelAdjacency ( )
inline
template<typename TKSpace , typename TSurfelPredicate >
const DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::SurfelPredicate & DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfelPredicate ( ) const
inline
template<typename TKSpace , typename TSurfelPredicate >
template<typename OutputIterator >
void DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::writeNeighbors ( OutputIterator &  it,
const Vertex v 
) const
inline

Writes the neighbors of [v] in the output iterator [it]. Neighbors are given in no specific order.

Template Parameters:
OutputIteratorthe type for the output iterator (e.g. back_insert_iterator<std::vector<Vertex> >).
Parameters:
[in,out]itany output iterator on Vertex (*it++ should be allowed), which specifies where neighbors are written.
[in]vany vertex of this graph

Definition at line 301 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::adjacent(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::move(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::myTracker, and DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::space().

{
Vertex s;
for ( typename KSpace::DirIterator q = space().sDirs( v );
q != 0; ++q )
{
if ( myTracker.adjacent( s, *q, true ) )
*it++ = s;
if ( myTracker.adjacent( s, *q, false ) )
*it++ = s;
}
}
template<typename TKSpace , typename TSurfelPredicate >
template<typename OutputIterator , typename VertexPredicate >
void DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::writeNeighbors ( OutputIterator &  it,
const Vertex v,
const VertexPredicate &  pred 
) const
inline

Writes the neighbors of [v], verifying the predicate [pred] in the output iterator [it]. Neighbors are given in no specific order.

Template Parameters:
OutputIteratorthe type for the output iterator (e.g. back_insert_iterator<std::vector<Vertex> >).
VertexPredicateany type of predicate taking a Vertex as input.
Parameters:
[in,out]itany output iterator on Vertex (*it++ should be allowed), which specifies where neighbors are written.
[in]vany vertex of this graph
[in]predthe predicate for selecting neighbors.

Definition at line 321 of file LightExplicitDigitalSurface.ih.

References DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::adjacent(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::BOOST_CONCEPT_ASSERT(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::Tracker::move(), DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::myTracker, and DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::space().

{
Vertex s;
for ( typename KSpace::DirIterator q = space().sDirs( v );
q != 0; ++q )
{
if ( myTracker.adjacent( s, *q, true ) )
{
if ( pred( s ) ) *it++ = s;
}
if ( myTracker.adjacent( s, *q, false ) )
{
if ( pred( s ) ) *it++ = s;
}
}
}

Field Documentation

template<typename TKSpace, typename TSurfelPredicate>
const KSpace& DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::myKSpace
private
template<typename TKSpace, typename TSurfelPredicate>
Surfel DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::mySurfel
private
template<typename TKSpace, typename TSurfelPredicate>
Adjacency DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::mySurfelAdjacency
private

the surfel adjacency used to determine neighbors.

Definition at line 361 of file LightExplicitDigitalSurface.h.

Referenced by DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::surfelAdjacency().

template<typename TKSpace, typename TSurfelPredicate>
const SurfelPredicate& DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::mySurfelPredicate
private
template<typename TKSpace, typename TSurfelPredicate>
Tracker DGtal::LightExplicitDigitalSurface< TKSpace, TSurfelPredicate >::myTracker
mutableprivate

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