DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Attributes | Private Attributes
DGtal::Projector< S > Struct Template Reference

#include <BasicPointFunctors.h>

Inheritance diagram for DGtal::Projector< S >:
Inheritance graph
[legend]

Public Types

typedef S Space
typedef Space::Dimension Dimension
typedef Space::Integer Integer
typedef Space::Point Point

Public Member Functions

 Projector (const Integer &aDefaultInteger=NumberTraits< Integer >::zero())
template<typename TIterator >
void init (const TIterator &itb, const TIterator &ite)
template<typename TInputPoint >
Point operator() (const TInputPoint &aPoint) const

Static Public Attributes

static const Dimension dimension = Space::dimension

Private Attributes

boost::array< Dimension,
dimension
myDims
Integer myDefaultInteger

Detailed Description

template<typename S = SpaceND< 2, DGtal::int32_t >>
struct DGtal::Projector< S >

Aim: Functor that maps a point P of dimension i to a point Q of dimension j. The member myDims is an array containing the coordinates - (0, 1, ..., j-1) by default - that are copied from P to Q.

Description of template class 'Projector'

Ex: for i = 3 and j = 2, the first two coordinates (numbered 0 and 1) are copied so that point (x,y,z) is is mapped to point (x,y).

All kth coordinates (0 < k < j) that are greater than i, are set to a value given at construction (0 by defaut).

Ex: for i = 2 and j = 3, the first two coordinates (numbered 0 and 1) are copied so that point (x,y) is is mapped to point (x,y,0).

Instead of using the default order, you can define your own orthonormal basis as shown below:

PointVector<2,int> p(3,1,5):
Projector<SpaceND<2,int> > proj;
proj( p ) //== (3,1)
...
//v (2, 0): selection of the 2nd and 0th basis vectors
proj.init(v.begin(), v.end());
proj( p ) //== (5,3)
Template Parameters:
Stype for the space where must lie the projected point

Definition at line 97 of file BasicPointFunctors.h.


Member Typedef Documentation

template<typename S = SpaceND< 2, DGtal::int32_t >>
typedef Space::Dimension DGtal::Projector< S >::Dimension

Definition at line 100 of file BasicPointFunctors.h.

template<typename S = SpaceND< 2, DGtal::int32_t >>
typedef Space::Integer DGtal::Projector< S >::Integer

Definition at line 102 of file BasicPointFunctors.h.

template<typename S = SpaceND< 2, DGtal::int32_t >>
typedef Space::Point DGtal::Projector< S >::Point

Definition at line 103 of file BasicPointFunctors.h.

template<typename S = SpaceND< 2, DGtal::int32_t >>
typedef S DGtal::Projector< S >::Space

Definition at line 99 of file BasicPointFunctors.h.


Constructor & Destructor Documentation

template<typename S >
DGtal::Projector< S >::Projector ( const Integer aDefaultInteger = NumberTraits<Integer>::zero())
inline

Default constructor

Definition at line 38 of file BasicPointFunctors.ih.

References DGtal::Projector< S >::dimension, and DGtal::Projector< S >::myDims.

: myDims(), myDefaultInteger(aDefaultInteger)
{ //default projection
Dimension k = 0;
for ( ; k < dimension; ++k)
{
myDims[k] = k;
}
}

Member Function Documentation

template<typename S >
template<typename TIterator >
void DGtal::Projector< S >::init ( const TIterator &  itb,
const TIterator &  ite 
)
inline

Initialization of the array of relevant dimensions

Parameters:
itbbegin iterator on dimensions.
iteend iterator on dimensions.

Definition at line 52 of file BasicPointFunctors.ih.

{
BOOST_STATIC_ASSERT ((boost::is_same< Dimension,
typename std::iterator_traits<TIterator>::value_type >::value));
TIterator it = itb;
Dimension k = 0;
for ( ; ( (k < dimension)&&(it != ite) ); ++it, ++k)
{
myDims[k] = *it;
}
for ( ; k < dimension; ++k)
{
}
}
template<typename S >
template<typename TInputPoint >
DGtal::Projector< S >::Point DGtal::Projector< S >::operator() ( const TInputPoint &  aPoint) const
inline

Main operator

Parameters:
aPointany point.
Returns:
the projected point.

Definition at line 73 of file BasicPointFunctors.ih.

{
BOOST_STATIC_ASSERT ((boost::is_same< typename TInputPoint::Coordinate,
Integer >::value));
Point res;
#ifdef CPP11_ARRAY
typename std::array<Dimension,dimension>::const_iterator it = myDims.begin();
typename std::array<Dimension,dimension>::const_iterator itEnd = myDims.end();
#else
typename boost::array<Dimension,dimension>::const_iterator it = myDims.begin();
typename boost::array<Dimension,dimension>::const_iterator itEnd = myDims.end();
#endif
Dimension k = 0;
for ( ; it != itEnd; ++it, ++k)
{
Dimension l = *it;
if (l < TInputPoint::dimension)
res[k] = aPoint.at(l);
else
res[k] = myDefaultInteger;
}
return res;
}

Field Documentation

template<typename S = SpaceND< 2, DGtal::int32_t >>
const Dimension DGtal::Projector< S >::dimension = Space::dimension
static

Definition at line 101 of file BasicPointFunctors.h.

Referenced by DGtal::Projector< S >::Projector().

template<typename S = SpaceND< 2, DGtal::int32_t >>
Integer DGtal::Projector< S >::myDefaultInteger
private

Default integer set to coordinates of the projected point not in the input point

Definition at line 140 of file BasicPointFunctors.h.

template<typename S = SpaceND< 2, DGtal::int32_t >>
boost::array<Dimension,dimension> DGtal::Projector< S >::myDims
private

Array storing the coordinates that are copied from the input point to its projection (order matters)

Definition at line 134 of file BasicPointFunctors.h.

Referenced by DGtal::Projector< S >::Projector().


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