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

#include <Lattice.h>

Inheritance diagram for DGtal::Lattice< TSpace >:
Inheritance graph
[legend]

Public Types

typedef TSpace Space
typedef TSpace::Integer Integer
typedef TSpace::Point Point
typedef TSpace::Dimension Dimension

Public Member Functions

 ~Lattice ()
 Lattice ()
 Lattice (const Lattice< Space > &other)
Lattice< Space > & operator= (const Lattice< Space > &other)
void init (Dimension aN, Dimension aM, double dh=1.0)
void clear ()
Dimension n () const
Dimension m () const
void setOrigin (const double *x)
void setVector (Dimension i, const double *v)
void immerse (const Integer *p, double *x) const
void immerse (const Point &p, double *x) const
void immerse (const Integer *p, float *x) const
void immerse (const Point &p, float *x) const
void selfDisplay (std::ostream &out) const
bool isValid () const

Static Public Member Functions

static void defaultZ2toZ3 (Lattice &l, const double *x0, double dh=1.0)
static void defaultZ3toZ3 (Lattice &l, const double *x0, double dh=1.0)

Private Member Functions

 BOOST_CONCEPT_ASSERT ((CSpace< TSpace >))

Private Attributes

unsigned int myN
unsigned int myM
double * myX0
double * myV

Detailed Description

template<typename TSpace>
class DGtal::Lattice< TSpace >

Aim: Represents an n-dimensional integer lattice in an m-dimensional real vector space.

Description of template class 'Lattice'

Parameters:
TSpacethe source digital space for the lattice.

Definition at line 62 of file Lattice.h.


Member Typedef Documentation

template<typename TSpace>
typedef TSpace::Dimension DGtal::Lattice< TSpace >::Dimension

Definition at line 72 of file Lattice.h.

template<typename TSpace>
typedef TSpace::Integer DGtal::Lattice< TSpace >::Integer

Definition at line 70 of file Lattice.h.

template<typename TSpace>
typedef TSpace::Point DGtal::Lattice< TSpace >::Point

Definition at line 71 of file Lattice.h.

template<typename TSpace>
typedef TSpace DGtal::Lattice< TSpace >::Space

Definition at line 69 of file Lattice.h.


Constructor & Destructor Documentation

template<typename TSpace >
DGtal::Lattice< TSpace >::~Lattice ( )
inline

Destructor.

Definition at line 98 of file Lattice.ih.

{
if ( myX0 != 0 ) delete[] myX0;
if ( myV != 0 ) delete[] myV;
}
template<typename TSpace >
DGtal::Lattice< TSpace >::Lattice ( )
inline

Constructor. Invalid.

Constructor.

Definition at line 110 of file Lattice.ih.

: myN( 0 ), myM( 0 ), myX0( 0 ), myV( 0 )
{
}
template<typename TSpace >
DGtal::Lattice< TSpace >::Lattice ( const Lattice< Space > &  other)

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 120 of file Lattice.ih.

References DGtal::Lattice< TSpace >::myM, DGtal::Lattice< TSpace >::myN, DGtal::Lattice< TSpace >::myV, and DGtal::Lattice< TSpace >::myX0.

: myN( other.myN ), myM( other.myM ), myX0( 0 ), myV( 0 )
{
if ( ( myN == 0 ) || ( myM == 0 ) ) return;
myX0 = new double[ myM ];
myV = new double[ myM * myN ];
for ( Dimension j = 0; j < myM; j++ )
myX0[ j ] = other.myX0[ j ];
for ( Dimension i = 0; i < myN; i++ )
{
for ( Dimension j = 0; j < myM; j++ )
myV[ m*i + j ] = other.myV[ m*i + j ];
}
}

Member Function Documentation

template<typename TSpace>
DGtal::Lattice< TSpace >::BOOST_CONCEPT_ASSERT ( (CSpace< TSpace >)  )
private
template<typename TSpace >
void DGtal::Lattice< TSpace >::clear ( )
inline

Resets the lattice.

Definition at line 211 of file Lattice.ih.

{
if ( myX0 != 0 ) delete[] myX0;
if ( myV != 0 ) delete[] myV;
myX0 = 0;
myV = 0;
myN = 0;
myM = 0;
}
template<typename TSpace>
static void DGtal::Lattice< TSpace >::defaultZ2toZ3 ( Lattice< TSpace > &  l,
const double *  x0,
double  dh = 1.0 
)
static

Constructs a default 2D lattice centered at [x0], with vectors (dh,0,0) and (0,dh,0).

Parameters:
l(returns) the lattice
x0the origin of the lattice embedding (a 3D point)
dhthe grid step or length of each vector.
template<typename TSpace>
static void DGtal::Lattice< TSpace >::defaultZ3toZ3 ( Lattice< TSpace > &  l,
const double *  x0,
double  dh = 1.0 
)
static

Constructs a default 3D lattice centered at [x0], with vectors (dh,0,0) and (0,dh,0) and (0,0,dh).

Parameters:
l(returns) the lattice
x0the origin of the lattice embedding (a 3D point)
dhthe grid step or length of each vector.
template<typename TSpace >
void DGtal::Lattice< TSpace >::immerse ( const Integer p,
double *  x 
) const
inline

Immerse a point of the lattice into the target space of dimension m.

Parameters:
pthe n coordinates of a point in the lattice.
x(returns) its m coordinates in the target space of dimension m.

Definition at line 260 of file Lattice.ih.

{
for ( Dimension j = 0; j < myM; j++ )
x[ j ] = myX0[ j ];
double* off_v = myV;
for ( Dimension i = 0; i < myN; i++ )
{
Integer pi = p[ i ];
for ( Dimension j = 0; j < myM; j++ )
{
x[ j ] += (*off_v) * pi;
++off_v;
}
}
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::immerse ( const Point p,
double *  x 
) const
inline

Immerse a point of the lattice into the target space of dimension m.

Parameters:
pthe n coordinates of a point in the lattice.
x(returns) its m coordinates in the target space of dimension m.

Definition at line 286 of file Lattice.ih.

{
for ( Dimension j = 0; j < myM; j++ )
x[ j ] = myX0[ j ];
double* off_v = myV;
for ( Dimension i = 0; i < myN; i++ )
{
Integer pi = p[ i ];
for ( Dimension j = 0; j < myM; j++ )
{
x[ j ] += (*off_v) * pi;
++off_v;
}
}
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::immerse ( const Integer p,
float *  x 
) const
inline

Immerse a point of the lattice into the target space of dimension m.

Parameters:
pthe n coordinates of a point in the lattice.
x(returns) its m coordinates in the target space of dimension m.

Definition at line 312 of file Lattice.ih.

{
for ( Dimension j = 0; j < myM; j++ )
x[ j ] = (float) myX0[ j ];
double* off_v = myV;
for ( Dimension i = 0; i < myN; i++ )
{
Integer pi = p[ i ];
for ( Dimension j = 0; j < myM; j++ )
{
x[ j ] += (float) ((*off_v) * pi);
++off_v;
}
}
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::immerse ( const Point p,
float *  x 
) const
inline

Immerse a point of the lattice into the target space of dimension m.

Parameters:
pthe n coordinates of a point in the lattice.
x(returns) its m coordinates in the target space of dimension m.

Definition at line 338 of file Lattice.ih.

{
for ( Dimension j = 0; j < myM; j++ )
x[ j ] = (float) myX0[ j ];
double* off_v = myV;
for ( Dimension i = 0; i < myN; i++ )
{
Integer pi = p[ i ];
for ( Dimension j = 0; j < myM; j++ )
{
x[ j ] += (float) ((*off_v) * pi);
++off_v;
}
}
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::init ( Dimension  aN,
Dimension  aM,
double  dh = 1.0 
)
inline

Defines the standard lattice when aN=aM, the standard injection when aN < aM, and when aM > aN, vectors are overlapping.

Parameters:
aNthe dimension of the lattice space
aMthe dimension of the target space where the lattice is represented.
dhthe length of the elementary displacement.

Defines the standard lattice when n=m, the standard injection when n < m, and when m > n, vectors are overlapping.

Parameters:
nthe dimension of the lattice space
mthe dimension of the target space where the lattice is represented.
dhthe length of the elementary displacement.

Definition at line 186 of file Lattice.ih.

Referenced by DGtal::DGtalInventor< TSpace >::DGtalInventor().

{
ASSERT( aN > 0 );
ASSERT( aM > 0 );
if ( ( aM != myM ) || ( aN != myN ) )
{
myN = aN;
myM = aM;
if ( myX0 != 0 ) delete[] myX0;
if ( myV != 0 ) delete[] myV;
myX0 = new double[ aM ];
myV = new double[ aM*aN ];
}
for ( Dimension j = 0; j < aM; j++ )
myX0[ j ] = 0.0;
for ( Dimension i = 0; i < aN; i++ )
{
for ( Dimension j = 0; j < aM; j++ )
myV[ aM*i + j ] = ( j == ( i % aM ) ) ? dh : 0.0;
}
}
template<typename TSpace >
bool DGtal::Lattice< TSpace >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 85 of file Lattice.ih.

{
return true;
}
template<typename TSpace >
TSpace::Dimension DGtal::Lattice< TSpace >::m ( ) const
inline
Returns:
the dimension of the target space.

Definition at line 58 of file Lattice.ih.

{
return myM;
}
template<typename TSpace >
TSpace::Dimension DGtal::Lattice< TSpace >::n ( ) const
inline
Returns:
the dimension of the lattice space.

Definition at line 47 of file Lattice.ih.

Referenced by DGtal::DGtalInventor< TSpace >::setLattice().

{
return myN;
}
template<typename TSpace >
DGtal::Lattice< TSpace > & DGtal::Lattice< TSpace >::operator= ( const Lattice< Space > &  other)
inline

Assignment.

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

Definition at line 143 of file Lattice.ih.

References DGtal::Lattice< TSpace >::myM, DGtal::Lattice< TSpace >::myN, DGtal::Lattice< TSpace >::myV, and DGtal::Lattice< TSpace >::myX0.

{
if ( this != &other )
{
if ( ( other.myM != myM ) || ( other.myN != myN ) )
{
if ( myX0 != 0 ) delete[] myX0;
if ( myV != 0 ) delete[] myV;
myN = other.myN;
myM = other.myM;
if ( ( myN == 0 ) || ( myM == 0 ) )
{
myX0 =0;
myV = 0;
}
else
{
myX0 = new double[ myM ];
myV = new double[ myM * myN ];
}
}
for ( Dimension j = 0; j < myM; j++ )
myX0[ j ] = other.myX0[ j ];
for ( Dimension i = 0; i < myN; i++ )
{
for ( Dimension j = 0; j < myM; j++ )
myV[ m*i + j ] = other.myV[ m*i + j ];
}
}
return *this;
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::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 73 of file Lattice.ih.

{
out << "[Lattice n=" << myN << " m=" << myM << "]";
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::setOrigin ( const double *  x)
inline

Sets the origin of the space.

Parameters:
xis a vector of size m.

Definition at line 228 of file Lattice.ih.

{
for ( Dimension j = 0; j < myM; j++ )
myX0[ j ] = x[ j ];
}
template<typename TSpace >
void DGtal::Lattice< TSpace >::setVector ( Dimension  i,
const double *  v 
)
inline

Sets the elementary vector along direction i

Parameters:
iis a coordinate between 0 and n-1.
vis a vector of size m.

Definition at line 243 of file Lattice.ih.

{
double* off_v = myV + myM*i;
for ( Dimension j = 0; j < myM; j++ )
off_v[ j ] = v[ j ];
}

Field Documentation

template<typename TSpace>
unsigned int DGtal::Lattice< TSpace >::myM
private

Dimension of target space;

Definition at line 227 of file Lattice.h.

Referenced by DGtal::Lattice< TSpace >::Lattice(), and DGtal::Lattice< TSpace >::operator=().

template<typename TSpace>
unsigned int DGtal::Lattice< TSpace >::myN
private

Dimension of lattice space;

Definition at line 222 of file Lattice.h.

Referenced by DGtal::Lattice< TSpace >::Lattice(), and DGtal::Lattice< TSpace >::operator=().

template<typename TSpace>
double* DGtal::Lattice< TSpace >::myV
private

Vectors for each dimension. Array of size m_n times m_m;

Definition at line 237 of file Lattice.h.

Referenced by DGtal::Lattice< TSpace >::Lattice(), and DGtal::Lattice< TSpace >::operator=().

template<typename TSpace>
double* DGtal::Lattice< TSpace >::myX0
private

Origin. Array of size m_m;

Definition at line 232 of file Lattice.h.

Referenced by DGtal::Lattice< TSpace >::Lattice(), and DGtal::Lattice< TSpace >::operator=().


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