DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Private Member Functions
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension > Class Template Reference

#include <MetricAdjacency.h>

Data Structures

struct  VertexMap

Public Types

typedef TSpace Space
typedef Space::Point Point
typedef MetricAdjacency< Space,
maxNorm1, dimension > 
Adjacency
typedef Space::Vector Vector
typedef Point Vertex
typedef Space::Size Size
typedef std::set< VertexVertexSet

Public Member Functions

 MetricAdjacency ()
 ~MetricAdjacency ()

Static Public Member Functions

static bool isAdjacentTo (const Point &p1, const Point &p2)
static bool isProperlyAdjacentTo (const Point &p1, const Point &p2)
static Size bestCapacity ()
static Size degree (const Vertex &v)
template<typename OutputIterator >
static void writeNeighbors (OutputIterator &it, const Vertex &v)
template<typename OutputIterator , typename VertexPredicate >
static void writeNeighbors (OutputIterator &it, const Vertex &v, const VertexPredicate &pred)
static void selfDisplay (std::ostream &out)
static bool isValid ()

Static Protected Member Functions

static Size computeCapacity ()

Private Member Functions

 BOOST_CONCEPT_ASSERT ((CSpace< TSpace >))
 MetricAdjacency (const MetricAdjacency &other)
MetricAdjacencyoperator= (const MetricAdjacency &other)

Detailed Description

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
class DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >

Aim: Describes digital adjacencies in digital spaces that are defined with the 1-norm and the infinity-norm.

Description of template class 'MetricAdjacency'

It induces the classical 4 and 8 adjacencies in 2D, the 6, 18 and 26 adjacencies in 3D, and the \( \omega \) and \( \alpha \) adjacencies in nD.

Model of CAdjacency.

Template Parameters:
TSpaceany digital space (see concept CSpace).
maxNorm1defines which points are adjacent. More precisely, two points are adjacent iff their norm-infinity is less or equal than 1 and if their norm-1 is less or equal than maxNorm1.
See also:
testAdjacency.cpp
Examples:
topology/3dBorderExtraction.cpp.

Definition at line 79 of file MetricAdjacency.h.


Member Typedef Documentation

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef MetricAdjacency<Space, maxNorm1, dimension> DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Adjacency

Definition at line 87 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef Space::Point DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Point

Definition at line 86 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef Space::Size DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Size

Definition at line 94 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef TSpace DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Space

Definition at line 85 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef Space::Vector DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Vector

Definition at line 90 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef Point DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Vertex

Definition at line 93 of file MetricAdjacency.h.

template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
typedef std::set<Vertex> DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::VertexSet

Definition at line 95 of file MetricAdjacency.h.


Constructor & Destructor Documentation

template<typename TSpace , Dimension maxNorm1, Dimension dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::MetricAdjacency ( )
inline

Constructor. Does nothing. Due to the symmetry and translation invariance of this digital topology, all methods are static.

Definition at line 58 of file MetricAdjacency.ih.

{
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::~MetricAdjacency ( )
inline

Destructor.

Definition at line 48 of file MetricAdjacency.ih.

{
}
template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::MetricAdjacency ( const MetricAdjacency< TSpace, maxNorm1, dimension > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

template<typename TSpace , Dimension maxNorm1, Dimension dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Size DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::bestCapacity ( )
inlinestatic
Returns:
maximum number of neighbors for this adjacency

Definition at line 116 of file MetricAdjacency.ih.

{
static Size myCapacity = computeCapacity();
return myCapacity;
}
template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::BOOST_CONCEPT_ASSERT ( (CSpace< TSpace >)  )
private
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Size DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::computeCapacity ( )
inlinestaticprotected

Definition at line 265 of file MetricAdjacency.ih.

{
Dimension result = 0;
for( Dimension m = dimension - 1; m > dimension - maxNorm1 - 1; m-- )
{
result += ( (dimension - m) << 1 ) * static_cast<Dimension>( boost::math::binomial_coefficient<float>(dimension, m) );
}
return result;
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::Size DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::degree ( const Vertex v)
inlinestatic
Parameters:
vany vertex
Returns:
the number of neighbors of this vertex

Definition at line 131 of file MetricAdjacency.ih.

{
return bestCapacity();
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
bool DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::isAdjacentTo ( const Point p1,
const Point p2 
)
inlinestatic
Parameters:
p1any point in this space.
p2any point in this space.
Returns:
'true' iff p1 is adjacent to p2 according to this adjacency relation.

Definition at line 77 of file MetricAdjacency.ih.

{
Vector v( p2 - p1 );
return ( v.normInfinity() <= 1 ) && ( v.norm1() <= maxNorm1 );
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
bool DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::isProperlyAdjacentTo ( const Point p1,
const Point p2 
)
inlinestatic
Parameters:
p1any point in this space.
p2any point in this space.
Returns:
'true' iff p1 is adjacent to p2 according to this adjacency relation and p1 != p2.

Definition at line 94 of file MetricAdjacency.ih.

{
Vector v( p2 - p1 );
if ( v.normInfinity() <= 1 )
{
typename Vector::UnsignedComponent n1 = v.norm1();
return ( n1 <= maxNorm1 ) && ( n1 != 0 );
}
return false;
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
bool DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::isValid ( )
inlinestatic

Checks the validity/consistency of the object.

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

Definition at line 238 of file MetricAdjacency.ih.

{
return true;
}
template<typename TSpace, Dimension maxNorm1, Dimension dimension = TSpace::dimension>
MetricAdjacency& DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::operator= ( const MetricAdjacency< TSpace, maxNorm1, dimension > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
void DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::selfDisplay ( std::ostream &  out)
inlinestatic

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 225 of file MetricAdjacency.ih.

{
out << "[MetricAdjacency Z" << Space::dimension
<< " n1<=" << maxNorm1 << " ]";
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
template<typename OutputIterator >
void DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::writeNeighbors ( OutputIterator &  it,
const Vertex v 
)
inlinestatic

Writes the neighbors of a vertex using an output iterator

Template Parameters:
OutputObjectIteratorthe type of an output iterator writing in a container of vertices.
Parameters:
itthe output iterator
vthe vertex whose neighbors will be writen

Writes the neighbors of a vertex using an output iterator

Template Parameters:
OutputObjectIteratorthe type of an output iterator writing in a container of vertices.
Parameters:
itthe output iterator
vthe vertex whose neighbors will be written

Definition at line 152 of file MetricAdjacency.ih.

{
Point p1( v );
for ( typename Point::Iterator iter = p1.begin(); iter != p1.end(); ++iter )
--(*iter);
Point p2( v );
for ( typename Point::Iterator iter = p2.begin(); iter != p2.end(); ++iter )
++(*iter);
typedef HyperRectDomain<Space> LocalDomain;
LocalDomain domain( p1, p2 );
for ( typename LocalDomain::ConstIterator iter = domain.begin();
iter != domain.end();
++iter )
{
Vector vect( v - *iter );
typename Vector::UnsignedComponent n1 = vect.norm1();
if ( ( n1 <= maxNorm1 ) && ( n1 != 0 ) )
*it++ = *iter;
}
}
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
template<typename OutputIterator , typename VertexPredicate >
void DGtal::MetricAdjacency< TSpace, maxNorm1, dimension >::writeNeighbors ( OutputIterator &  it,
const Vertex v,
const VertexPredicate &  pred 
)
static

Writes the neighbors of a vertex which satisfy a predicate using an output iterator

Template Parameters:
OutputObjectIteratorthe type of an output iterator writing in a container of vertices.
VertexPredicatethe type of the predicate
Parameters:
itthe output iterator
vthe vertex whose neighbors will be written
predthe predicate that must be satisfied

Definition at line 193 of file MetricAdjacency.ih.

{
Point p1( v );
for ( typename Point::Iterator iter = p1.begin(); iter != p1.end(); ++iter )
--(*iter);
Point p2( v );
for ( typename Point::Iterator iter = p2.begin(); iter != p2.end(); ++iter )
++(*iter);
typedef HyperRectDomain<Space> LocalDomain;
LocalDomain domain( p1, p2 );
for ( typename LocalDomain::ConstIterator iter = domain.begin();
iter != domain.end();
++iter )
{
Vector vect( v - *iter );
typename Vector::UnsignedComponent n1 = vect.norm1();
if ( ( n1 <= maxNorm1 ) && ( n1 != 0 ) && (pred(*iter)) )
*it++ = *iter;
}
}

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