DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Data Structures | Public Member Functions | Data Fields | Protected Types | Private Attributes | Friends
DGtal::FrechetShortcut< TIterator, TInteger >::Backpath Class Reference

#include <FrechetShortcut.h>

Collaboration diagram for DGtal::FrechetShortcut< TIterator, TInteger >::Backpath:
Collaboration graph
[legend]

Data Structures

struct  occulter_attributes

Public Member Functions

 Backpath ()
 Backpath (const FrechetShortcut< ConstIterator, Integer > *s, int q)
 Backpath (const Backpath &other)
 ~Backpath ()
void reset ()
void addPositivePoint ()
void addNegativePoint ()
void updateBackPathFirstQuad (int d, const ConstIterator &)
void updateOcculters ()
void updateIntervals ()

Data Fields

int myQuad
bool myFlag
occulter_list myOcculters
boost::icl::interval_set< double > myForbiddenIntervals
ConstIterator myIt

Protected Types

typedef struct
DGtal::FrechetShortcut::Backpath::occulter_attributes 
occulter_attributes
typedef map< ConstIterator,
occulter_attributes
occulter_list

Private Attributes

const FrechetShortcut
< ConstIterator, Integer > * 
myS

Friends

class FrechetShortcut< ConstIterator, Integer >

Detailed Description

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
class DGtal::FrechetShortcut< TIterator, TInteger >::Backpath

Class backpath: data structures and methods to handle the backpath update

Definition at line 133 of file FrechetShortcut.h.


Member Typedef Documentation

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
typedef struct DGtal::FrechetShortcut::Backpath::occulter_attributes DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::occulter_attributes
protected

Attributes of occulter points: angles min and max for chich the point is an occulter

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
typedef map<ConstIterator,occulter_attributes > DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::occulter_list
protected

Map between the point and their attributes if they are occulters

Definition at line 156 of file FrechetShortcut.h.


Constructor & Destructor Documentation

template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::Backpath ( )
inline
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::Backpath ( const FrechetShortcut< ConstIterator, Integer > *  s,
int  q 
)
inline

Constructor

Parameters:
pointerto a shortcut s
quadrantq

Definition at line 57 of file FrechetShortcut.ih.

: myS(s),myQuad(q),myFlag(false)
{
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::Backpath ( const Backpath other)
inline

Copy constructor

Parameters:
othera backpath

Definition at line 63 of file FrechetShortcut.ih.

: myS(other.myS),myQuad(other.myQuad),myFlag(other.myFlag),myOcculters(other.myOcculters),myForbiddenIntervals(other.myForbiddenIntervals)
{
}
template<typename TIterator , typename TInteger >
DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::~Backpath ( )
inline

Destructor

Definition at line 82 of file FrechetShortcut.ih.

{ }

Member Function Documentation

template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::addNegativePoint ( )
inline

Updates the backpath when a negative poitn is added

Definition at line 315 of file FrechetShortcut.ih.

{
// if we were on a monotone backpath, do nothing, the backpath
// continues
// otherwise it is the beggining of a new monotone backpath,
// possibly a locally maximal occulting point
//trace.info() << "add negative point" << std::endl;
if(!myFlag)
{
myFlag=true;
}
else
{
}
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::addPositivePoint ( )
inline

Updates the backpath when a positive point is added

Definition at line 298 of file FrechetShortcut.ih.

{
// if we were on a monotone backpath, the point is an end of backpath
// otherwise, do nothing
if(myFlag)
{
myFlag=false;
}
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::reset ( )
inline

Resets the backpath (myFlag, myOcculters)

Definition at line 71 of file FrechetShortcut.ih.

{
myFlag = false;
myOcculters.clear();
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::updateBackPathFirstQuad ( int  d,
const ConstIterator it 
)
inline

General update procedure: call to addNegativePoint or addPositivePoint according to the point *myIt. Each octant is treated as if it was the first one, the chain code between *myIt-1 and *myIt is rotated accordingly.

Definition at line 87 of file FrechetShortcut.ih.

{
myIt = it;
switch(d)
{
case 0:
case 1:
case 2:
case 7:
{
break;
}
case 3:
case 4:
case 5:
case 6:
{
break;
}
}
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::updateIntervals ( )
inline

Updates the list of intervals

Definition at line 246 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Tools::angleVectVect(), DGtal::FrechetShortcut< TIterator, TInteger >::Tools::chainCode2Vect(), DGtal::IntegerComputer< TInteger >::crossProduct(), and DGtal::IntegerComputer< TInteger >::dotProduct().

{
Point p = Point(*myIt);
Point pi,v;
Vector dir,dir1;
IntegerComputer<TInteger> ic;
for(typename occulter_list::iterator iter =
myOcculters.begin(); iter!=myOcculters.end() ;++iter)
{
pi = Point(*(iter->first));
v = p-pi;
if(ic.dotProduct(v,dir)<0 || ic.dotProduct(v,dir1)<0)
{
if(v.norm()>=myS->myError/sqrt(2.0F))
{
if(ic.crossProduct(dir,v)<=0)
{
v[0] = -v[0];
v[1] = -v[1];
}
double angle_v = Tools::angleVectVect(v,dir);
double tmp = acos((double) myS->myError/(sqrt(2.0F)*v.norm()));
double angle1 = -tmp+angle_v;
double angle2 = tmp+angle_v;
if(angle1 < 0)
angle1 = 0;
if(angle2 > M_PI_4)
angle2 = M_PI_4;
// Define a new interval of forbidden angles and insert it in the list.
boost::icl::interval<double>::type s = boost::icl::interval<double>::closed(angle1,angle2);
}
}
}
}
template<typename TIterator , typename TInteger >
void DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::updateOcculters ( )
inline

Updates the list of occulters

Definition at line 116 of file FrechetShortcut.ih.

References DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::occulter_attributes::angle_max, DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::occulter_attributes::angle_min, DGtal::FrechetShortcut< TIterator, TInteger >::Tools::angleVectVect(), DGtal::FrechetShortcut< TIterator, TInteger >::Tools::chainCode2Vect(), DGtal::IntegerComputer< TInteger >::dotProduct(), and M_PI.

{
// The potential new occulter is the last-but-one point
Point p = Point(*(myIt-1));
Point pi,v;
Vector dir_ortho = Tools::chainCode2Vect((myQuad+6)%8);
Point u1,u2;
u1 = dir;
double angle_min=0;
double angle_max=M_PI_4;
bool ok = true;
bool occ = false;
IntegerComputer<TInteger> ic;
if(myOcculters.size()==0)
{
occ =true;
angle_min=0;
angle_max=M_PI_4;
}
else
{
typename occulter_list::iterator iter;
for(iter = myOcculters.begin();ok && iter!=myOcculters.end() ;++iter)
{
pi = Point(*(iter->first));
v = p-pi;
// pi is after p for all directions -> p is not an occulter
if(ic.dotProduct(v,u1) < 0 && ic.dotProduct(v,u2) <0)
{
ok = false;
occ = false;
}
else
// p is after pi for all directions -> pi is not an occulter
// anymore, p is a new occulter.
if(ic.dotProduct(v,u1) > 0 && ic.dotProduct(v,u2) > 0)
{
myOcculters.erase(iter);
occ = true;
angle_min = 0;
angle_max = M_PI_4;
}
else
// p is after pi on [0,alpha], before pi on [alpha,pi/4]
if(ic.dotProduct(v,u1) > 0 && ic.dotProduct(v,u2) <= 0)
{
double alpha = Tools::angleVectVect(v,dir_ortho);
if(alpha >= iter->second.angle_min && alpha <=
iter->second.angle_max)
{
// p is a new occulter
occ = true;
angle_min = 0;
angle_max = alpha;
// pi's angle_min is updated
iter->second.angle_min = alpha;
}
else
if(alpha > iter->second.angle_max)
{
//pi is not an occulter anymore
myOcculters.erase(iter);
occ=true;
angle_min = 0;
angle_max = M_PI_4;
}
// if alpha < iter->second.angle_min, pi does not
// change, p may be an occulter -> do nothing
}
else // scalar_product(v,u1) < 0 && scalar_product(v,u2) > 0
// p is after pi on [alpha,pi/4], before pi on [0,alpha]
{
double alpha = Tools::angleVectVect(v,dir_ortho);
alpha = M_PI - alpha;
if(alpha >= iter->second.angle_min && alpha <=
iter->second.angle_max)
{
occ = true;
angle_min = alpha;
angle_max = M_PI_4;
// pi's angle_max is updated
iter->second.angle_max = alpha;
}
else
if(alpha < iter->second.angle_min)
{
//pi is not an occulter anymore
myOcculters.erase(iter);
occ=true;
angle_min = 0;
angle_max = M_PI_4;
}
// if(alpha > iter->second.angle_max), pi does not
// change, p may be an occulter -> do nothing
}
}
}
if(occ)
{
new_occ.angle_min = angle_min;
new_occ.angle_max = angle_max;
myOcculters.insert(myOcculters.end(),pair<const ConstIterator,occulter_attributes>(myIt-1,new_occ));
}
}

Friends And Related Function Documentation

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
friend class FrechetShortcut< ConstIterator, Integer >
friend

Definition at line 159 of file FrechetShortcut.h.


Field Documentation

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
bool DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myFlag

Current state myFlag=true if we are on a backpath, false otherwise

Definition at line 173 of file FrechetShortcut.h.

Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::Backpath().

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
boost::icl::interval_set<double> DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myForbiddenIntervals

List of forbidden intervals: intervals of angle for which there exist a backpath of length greater than the error

Definition at line 181 of file FrechetShortcut.h.

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
ConstIterator DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myIt

pointer to the next point to be scanned: set to myEnd + 1

Definition at line 186 of file FrechetShortcut.h.

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
occulter_list DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myOcculters

Definition at line 175 of file FrechetShortcut.h.

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
int DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myQuad

Octant of work

Definition at line 167 of file FrechetShortcut.h.

Referenced by DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::Backpath().

template<typename TIterator, typename TInteger = typename IteratorCirculatorTraits<TIterator>::Value::Coordinate>
const FrechetShortcut<ConstIterator,Integer>* DGtal::FrechetShortcut< TIterator, TInteger >::Backpath::myS
private

Pointer to the FrechetShortcut

Definition at line 139 of file FrechetShortcut.h.


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