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::LightImplicitDigitalSurface< TKSpace, TPointPredicate > Class Template Reference

#include <LightImplicitDigitalSurface.h>

Collaboration diagram for DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >:
Collaboration graph
[legend]

Data Structures

class  Tracker
struct  VertexMap

Public Types

typedef
LightImplicitDigitalSurface
< TKSpace, TPointPredicate > 
Self
typedef TKSpace KSpace
typedef KSpace::SCell Surfel
typedef KSpace::Size Size
typedef TPointPredicate PointPredicate
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 ((CPointPredicate< PointPredicate >))
 ~LightImplicitDigitalSurface ()
 LightImplicitDigitalSurface (const LightImplicitDigitalSurface &other)
 LightImplicitDigitalSurface (const KSpace &aKSpace, const PointPredicate &aPP, const Adjacency &adj, const Surfel &s)
const AdjacencysurfelAdjacency () const
AdjacencysurfelAdjacency ()
const PointPredicatepointPredicate () const
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

LightImplicitDigitalSurfaceoperator= (const LightImplicitDigitalSurface &other)

Private Attributes

const KSpacemyKSpace
const PointPredicatemyPointPredicate
Adjacency mySurfelAdjacency
Surfel mySurfel
Tracker myTracker

Detailed Description

template<typename TKSpace, typename TPointPredicate>
class DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >

Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an implicitly define shape. The whole boundary is not precomputed nor stored. You may use an iterator to visit it.

Description of template class 'LightImplicitDigitalSurface'

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.
TPointPredicatea model of CPointPredicate: this functor defines the inside of a shape on points where it is true.

Definition at line 76 of file LightImplicitDigitalSurface.h.


Member Typedef Documentation

template<typename TKSpace, typename TPointPredicate>
typedef SurfelAdjacency<KSpace::dimension> DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Adjacency

Definition at line 175 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::Cell DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Cell

Definition at line 176 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::CellSet DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::CellSet

Definition at line 178 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef Tracker DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::DigitalSurfaceTracker

Definition at line 195 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef TKSpace DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::KSpace

Model of cellular grid space.

Definition at line 162 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::Point DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Point

Definition at line 194 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef TPointPredicate DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::PointPredicate

Definition at line 168 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::SCell DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::SCell

Definition at line 177 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::SCellSet DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::SCellSet

Definition at line 179 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef LightImplicitDigitalSurface<TKSpace,TPointPredicate> DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Self

Definition at line 160 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef BreadthFirstVisitor< Self > DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::SelfVisitor

Definition at line 191 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::Size DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Size

Type for sizes (unsigned integral type).

Definition at line 166 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::Space DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Space

Definition at line 193 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef KSpace::SCell DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Surfel

Type for surfels.

Definition at line 164 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef SelfVisitor::VertexConstIterator DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::SurfelConstIterator

Definition at line 192 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef Surfel DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Vertex

Definition at line 183 of file LightImplicitDigitalSurface.h.

template<typename TKSpace, typename TPointPredicate>
typedef SCellSet DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::VertexSet

Definition at line 184 of file LightImplicitDigitalSurface.h.


Constructor & Destructor Documentation

template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::~LightImplicitDigitalSurface ( )
inline

Destructor.

Definition at line 124 of file LightImplicitDigitalSurface.ih.

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

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 131 of file LightImplicitDigitalSurface.ih.

template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::LightImplicitDigitalSurface ( const KSpace aKSpace,
const PointPredicate aPP,
const Adjacency adj,
const Surfel s 
)
inline

Constructor from digital set.

Parameters:
aKSpacea cellular grid space (referenced).
aPPa point predicate defining implicitly 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 143 of file LightImplicitDigitalSurface.ih.

: myKSpace( aKSpace ), myPointPredicate( aPP ), mySurfelAdjacency( adj ),
mySurfel( s ), myTracker( *this, s )
{
}

Member Function Documentation

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

Definition at line 214 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::mySurfel.

Referenced by DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::nbSurfels().

{
SelfVisitor* ptrVisitor = new SelfVisitor( *this, mySurfel );
ASSERT( ptrVisitor != 0 );
return SurfelConstIterator( ptrVisitor );
}
template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Size DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 337 of file LightImplicitDigitalSurface.ih.

{
return KSpace::dimension * 2 - 2;
}
template<typename TKSpace, typename TPointPredicate>
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::BOOST_CONCEPT_ASSERT ( (CPointPredicate< PointPredicate >)  )
template<typename TKSpace , typename TPointPredicate >
DGtal::Connectedness DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::connectedness ( ) const
inline
Returns:
the connectedness of this surface. Either CONNECTED, DISCONNECTED, or UNKNOWN.

Definition at line 260 of file LightImplicitDigitalSurface.ih.

References DGtal::CONNECTED.

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

Definition at line 271 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::adjacent(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::move(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myTracker, and DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 TPointPredicate >
bool DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::empty ( ) const
inline
Returns:
'true' is the surface has no surfels, 'false' otherwise. NB: O(1) operation.

Definition at line 243 of file LightImplicitDigitalSurface.ih.

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

Definition at line 224 of file LightImplicitDigitalSurface.ih.

Referenced by DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::nbSurfels().

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

Definition at line 193 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myKSpace, and DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myPointPredicate.

Referenced by DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::move().

{
Dimension k = myKSpace.sOrthDir( s );
// checks if the surfel is on the space boundary.
if ( myKSpace.sIsMax( s, k ) || myKSpace.sIsMin( s, k ) )
return false;
// p1 must be in the set and p2 must not be in the set.
SCell spel1 = myKSpace.sDirectIncident( s, k );
Point p1 = myKSpace.sCoords( spel1 );
if ( myPointPredicate( p1 ) )
{
SCell spel2 = myKSpace.sIndirectIncident( s, k );
Point p2 = myKSpace.sCoords( spel2 );
return ! myPointPredicate( p2 );
}
return false;
}
template<typename TKSpace , typename TPointPredicate >
bool DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 367 of file LightImplicitDigitalSurface.ih.

{
return true;
}
template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Size DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 232 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::begin(), and DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::end().

{
Size nb = 0;
for ( SurfelConstIterator it = begin(), it_end = end(); it != it_end; ++it )
++nb;
return nb;
}
template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::DigitalSurfaceTracker * DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 252 of file LightImplicitDigitalSurface.ih.

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

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TKSpace , typename TPointPredicate >
const DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::PointPredicate & DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::pointPredicate ( ) const
inline
template<typename TKSpace , typename TPointPredicate >
void DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 355 of file LightImplicitDigitalSurface.ih.

{
out << "[LightImplicitDigitalSurface]";
}
template<typename TKSpace , typename TPointPredicate >
const DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::KSpace & DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::space ( ) const
inline
template<typename TKSpace , typename TPointPredicate >
const DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Adjacency & DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::surfelAdjacency ( ) const
inline
template<typename TKSpace , typename TPointPredicate >
DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Adjacency & DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::surfelAdjacency ( )
inline
template<typename TKSpace , typename TPointPredicate >
template<typename OutputIterator >
void DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 292 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::adjacent(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::move(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myTracker, and DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 TPointPredicate >
template<typename OutputIterator , typename VertexPredicate >
void DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 312 of file LightImplicitDigitalSurface.ih.

References DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::adjacent(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::BOOST_CONCEPT_ASSERT(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::Tracker::move(), DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myTracker, and DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::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 TPointPredicate>
const KSpace& DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myKSpace
private
template<typename TKSpace, typename TPointPredicate>
const PointPredicate& DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myPointPredicate
private
template<typename TKSpace, typename TPointPredicate>
Surfel DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::mySurfel
private

a surfel belonging to the surface.

Definition at line 358 of file LightImplicitDigitalSurface.h.

Referenced by DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::begin().

template<typename TKSpace, typename TPointPredicate>
Adjacency DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::mySurfelAdjacency
private

the surfel adjacency used to determine neighbors.

Definition at line 356 of file LightImplicitDigitalSurface.h.

Referenced by DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::surfelAdjacency().

template<typename TKSpace, typename TPointPredicate>
Tracker DGtal::LightImplicitDigitalSurface< TKSpace, TPointPredicate >::myTracker
mutableprivate

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