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:
-
TSpace | any digital space (see concept CSpace). |
maxNorm1 | defines 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.
template<typename TSpace , Dimension maxNorm1, Dimension dimension>
template<typename OutputIterator >
Writes the neighbors of a vertex using an output iterator
- Template Parameters:
-
OutputObjectIterator | the type of an output iterator writing in a container of vertices. |
- Parameters:
-
it | the output iterator |
v | the vertex whose neighbors will be writen |
Writes the neighbors of a vertex using an output iterator
- Template Parameters:
-
OutputObjectIterator | the type of an output iterator writing in a container of vertices. |
- Parameters:
-
it | the output iterator |
v | the vertex whose neighbors will be written |
Definition at line 152 of file MetricAdjacency.ih.
{
for ( typename Point::Iterator iter = p1.begin(); iter != p1.end(); ++iter )
--(*iter);
for ( typename Point::Iterator iter = p2.begin(); iter != p2.end(); ++iter )
++(*iter);
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:
-
OutputObjectIterator | the type of an output iterator writing in a container of vertices. |
VertexPredicate | the type of the predicate |
- Parameters:
-
it | the output iterator |
v | the vertex whose neighbors will be written |
pred | the predicate that must be satisfied |
Definition at line 193 of file MetricAdjacency.ih.
{
for ( typename Point::Iterator iter = p1.begin(); iter != p1.end(); ++iter )
--(*iter);
for ( typename Point::Iterator iter = p2.begin(); iter != p2.end(); ++iter )
++(*iter);
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;
}
}