DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields | Private Types | Private Member Functions
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect > Class Template Reference

#include <FMMPointFunctors.h>

Public Types

typedef TMap Map
typedef Map::mapped_type Value
typedef TKSpace KSpace
typedef KSpace::Point Point
typedef KSpace::Cell Cell

Public Member Functions

 L2FirstOrderLocalDistanceFromCells (const KSpace &aK, Map &aMap)
 L2FirstOrderLocalDistanceFromCells (const L2FirstOrderLocalDistanceFromCells &other)
L2FirstOrderLocalDistanceFromCellsoperator= (const L2FirstOrderLocalDistanceFromCells &other)
 ~L2FirstOrderLocalDistanceFromCells ()
Value operator() (const Point &aPoint)
void selfDisplay (std::ostream &out) const

Data Fields

const KSpacemyKSpace
MapmyMap

Private Types

typedef std::vector< ValueValues

Private Member Functions

Value compute (Values &aValueList) const

Detailed Description

template<typename TKSpace, typename TMap, bool isIndirect = false>
class DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >

Aim: Class for the computation of the Euclidean distance at some point p, from the available distance values in the neighborhood of p. Contrary to L2FirstOrderLocalDistance, the distance values are not available from the points adjacent to p but instead from the (d-1)-cells lying between p and these points.

Description of template class 'L2FirstOrderLocalDistanceFromCells'

Note:
The stored values are expected to be the distance of the interface to the points directly incident to the cells and must be between 0 and 1.
Template Parameters:
TKSpacea model of cellular grid
TMapa model of associative container used for the mapping cells-value
isIndirecta bool equal to 'false' if the tested points are expected to be directly incident to the cells (default) and 'true' otherwise
See also:
initFromBelsRange FMM

Definition at line 584 of file FMMPointFunctors.h.


Member Typedef Documentation

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef KSpace::Cell DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Cell

Definition at line 598 of file FMMPointFunctors.h.

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef TKSpace DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::KSpace

cellular grid

Definition at line 596 of file FMMPointFunctors.h.

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef TMap DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Map

map

Definition at line 592 of file FMMPointFunctors.h.

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef KSpace::Point DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Point

Definition at line 597 of file FMMPointFunctors.h.

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef Map::mapped_type DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Value

Definition at line 593 of file FMMPointFunctors.h.

template<typename TKSpace, typename TMap, bool isIndirect = false>
typedef std::vector<Value> DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Values
private

Definition at line 602 of file FMMPointFunctors.h.


Constructor & Destructor Documentation

template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::L2FirstOrderLocalDistanceFromCells ( const KSpace aK,
Map aMap 
)
inline

Constructor from a space and a map. NB: only pointers are stored

Parameters:
aMapany distance map

Definition at line 755 of file FMMPointFunctors.ih.

: myKSpace(&aK), myMap(&aMap)
{
}
template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::L2FirstOrderLocalDistanceFromCells ( const L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 764 of file FMMPointFunctors.ih.

: myKSpace(other.myKSpace), myMap(other.myMap)
{
}
template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::~L2FirstOrderLocalDistanceFromCells ( )
inline

Destructor. Does nothing.

Definition at line 790 of file FMMPointFunctors.ih.

{
}

Member Function Documentation

template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Value DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::compute ( Values aValueList) const
inlineprivate

Returns an approximation of the Euclidean distance at some point, knowing the distance of its adjacent cells contained in aValueList

Parameters:
aValueListthe distance of (some of) the neighbors
Returns:
the computed distance.

Definition at line 871 of file FMMPointFunctors.ih.

{
ASSERT(aValueList.size() > 0);
if ( aValueList.size() == 1 )
{
return aValueList.back();
}
else
{ //resolution
double a = 0;
for (typename Values::iterator it = aValueList.begin();
it != aValueList.end(); ++it)
{
Value d = *it;
a += ( 1.0 / static_cast<double>( d*d ) );
}
return static_cast<Value>( std::sqrt(a) / a );
}
}
template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::Value DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::operator() ( const Point aPoint)
inline

Euclidean distance computation at aPoint , from the available distance values of the adjacent cells.

Parameters:
aPointthe point for which the distance is computed
Returns:
the distance value at aPoint.

for the direct orientation

for the indirect orientation

Definition at line 799 of file FMMPointFunctors.ih.

{
//distance values
Values v;
v.reserve(Point::dimension);
Cell spel = myKSpace->uSpel( aPoint );
for ( typename KSpace::DirIterator q = myKSpace->uDirs( spel );
(q != 0); ++q )
{ //for each dimension
const DGtal::Dimension dir = *q;
Cell surfel1 = myKSpace->uIncident( spel, dir, true );
ASSERT( myKSpace->uDim( surfel1 ) == (KSpace::dimension - 1) );
Cell surfel2 = myKSpace->uIncident( spel, dir, false );
ASSERT( myKSpace->uDim( surfel2 ) == (KSpace::dimension - 1) );
//neighboring values
Value d = 0;
typename Map::iterator it1 = myMap->find( surfel1 );
typename Map::iterator it2 = myMap->find( surfel2 );
bool flag1 = ( it1 != myMap->end() );
bool flag2 = ( it2 != myMap->end() );
if ( flag1 || flag2 )
{
if ( flag1 && flag2 )
{ //take the minimal value
ASSERT( (it1->second >= 0)&&(it1->second <= 1) );
ASSERT( (it2->second >= 0)&&(it2->second <= 1) );
if (it1->second < it2->second)
d = ValueBetween0And1<isIndirect>
::get( it1->second );
else
d = ValueBetween0And1<isIndirect>
::get( it2->second );
} else
{
if (flag1)
{
ASSERT( (it1->second >= 0)&&(it1->second <= 1) );
d = ValueBetween0And1<isIndirect>
::get( it1->second );
}
if (flag2)
{
ASSERT( (it2->second >= 0)&&(it2->second <= 1) );
d = ValueBetween0And1<isIndirect>
::get( it2->second );
}
}
if (d == 0) return 0;
v.push_back(d);
}
} //end for each dimension
//computation of the new value
return this->compute(v);
}
template<typename TKSpace , typename TMap , bool isIndirect>
DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect > & DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::operator= ( const L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect > &  other)
inline

Assignment.

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

Definition at line 775 of file FMMPointFunctors.ih.

References DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::myKSpace, and DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::myMap.

{
if( this != &other)
{
myMap = other.myMap;
myKSpace = other.myKSpace;
}
return *this;
}
template<typename TKSpace , typename TMap , bool isIndirect>
void DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::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 899 of file FMMPointFunctors.ih.

{
out << "L2";
}

Field Documentation

template<typename TKSpace, typename TMap, bool isIndirect = false>
const KSpace* DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::myKSpace

Aliasing pointer on the underlying cellular grid.

Definition at line 607 of file FMMPointFunctors.h.

Referenced by DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::operator=().

template<typename TKSpace, typename TMap, bool isIndirect = false>
Map* DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::myMap

Aliasing pointer on the underlying mapping.

Definition at line 609 of file FMMPointFunctors.h.

Referenced by DGtal::L2FirstOrderLocalDistanceFromCells< TKSpace, TMap, isIndirect >::operator=().


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