DGtal  1.0.beta
Public Types | Public Member Functions | Private Attributes
DGtal::HyperRectDomain_Iterator< TPoint > Class Template Reference

#include <DGtal/kernel/domains/HyperRectDomain_Iterator.h>

Collaboration diagram for DGtal::HyperRectDomain_Iterator< TPoint >:
[legend]

Public Types

typedef std::bidirectional_iterator_tag iterator_category
 
typedef TPoint value_type
 
typedef ptrdiff_t difference_type
 
typedef TPoint * pointer
 
typedef TPoint & reference
 
typedef TPoint::Dimension Dimension
 

Public Member Functions

 HyperRectDomain_Iterator (const TPoint &p, const TPoint &lower, const TPoint &upper)
 
const TPoint & operator* () const
 
TPoint & operator* ()
 
bool operator== (const HyperRectDomain_Iterator< TPoint > &it) const
 
bool operator!= (const HyperRectDomain_Iterator< TPoint > &aIt) const
 
void nextLexicographicOrder ()
 
HyperRectDomain_Iterator< TPoint > & operator++ ()
 
HyperRectDomain_Iterator< TPoint > operator++ (int)
 
void prevLexicographicOrder ()
 
HyperRectDomain_Iterator< TPoint > & operator-- ()
 
HyperRectDomain_Iterator< TPoint > operator-- (int)
 

Private Attributes

TPoint myPoint
 
TPoint mylower
 
TPoint myupper
 

Detailed Description

template<typename TPoint>
class DGtal::HyperRectDomain_Iterator< TPoint >

Description of class 'HyperRectDomain_Iterator'

Aim:

Examples:
geometry/curves/exampleGridCurve2d.cpp, geometry/volumes/distance/distancetransform3D.cpp, images/exampleRigidtransformation2d.cpp, images/exampleRigidtransformation3d.cpp, io/viewDualSurface.cpp, io/viewers/viewer3D-7-planes.cpp, io/viewers/viewer3D-7-stdplane.cpp, io/viewers/viewer3D-7bis-planes.cpp, io/viewers/viewer3D-7bis-stdplane.cpp, io/viewers/viewer3D-9-3Dimages.cpp, topology/3dBorderExtraction.cpp, topology/3dKSSurfaceExtraction.cpp, topology/frontierAndBoundary.cpp, topology/generateSimplicityTables2D.cpp, topology/homotopicThinning3D.cpp, and tutorial-examples/volDTGranulo.cpp.

Definition at line 158 of file HyperRectDomain_Iterator.h.

Member Typedef Documentation

template<typename TPoint>
typedef ptrdiff_t DGtal::HyperRectDomain_Iterator< TPoint >::difference_type

Definition at line 163 of file HyperRectDomain_Iterator.h.

template<typename TPoint>
typedef TPoint::Dimension DGtal::HyperRectDomain_Iterator< TPoint >::Dimension

Definition at line 166 of file HyperRectDomain_Iterator.h.

template<typename TPoint>
typedef std::bidirectional_iterator_tag DGtal::HyperRectDomain_Iterator< TPoint >::iterator_category

Definition at line 161 of file HyperRectDomain_Iterator.h.

template<typename TPoint>
typedef TPoint* DGtal::HyperRectDomain_Iterator< TPoint >::pointer

Definition at line 164 of file HyperRectDomain_Iterator.h.

template<typename TPoint>
typedef TPoint& DGtal::HyperRectDomain_Iterator< TPoint >::reference

Definition at line 165 of file HyperRectDomain_Iterator.h.

template<typename TPoint>
typedef TPoint DGtal::HyperRectDomain_Iterator< TPoint >::value_type
Todo:
construct a RANDOM-ACCESS iterator

Definition at line 162 of file HyperRectDomain_Iterator.h.

Constructor & Destructor Documentation

template<typename TPoint>
DGtal::HyperRectDomain_Iterator< TPoint >::HyperRectDomain_Iterator ( const TPoint &  p,
const TPoint &  lower,
const TPoint &  upper 
)
inline

Definition at line 169 of file HyperRectDomain_Iterator.h.

170  : myPoint( p ), mylower( lower ), myupper( upper )
171  {
172  ASSERT_MSG( // For an empty domain, lower = upper + diag(1) so that begin() == end().
173  lower.isLower(upper) || lower == upper + TPoint::diagonal(1),
174  "The lower bound must be lower than the upper bound or, for an empty domain, be equal to the upper bound + diagonal(1)."
175  );
176 
177  ASSERT_MSG(
178  ( lower.isLower(p) && p.isLower(upper) ) || p == lower || p == upper,
179  "The point must be inside the domain or be equal to one of his bound."
180  );
181  }
TPoint mylower
Copies of the Domain limits.
TPoint myPoint
Current Point in the domain.

Member Function Documentation

template<typename TPoint>
void DGtal::HyperRectDomain_Iterator< TPoint >::nextLexicographicOrder ( )
inline

Implements the next() method to scan the domain points dimension by dimension (lexicographic order).

Definition at line 225 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::mylower, DGtal::HyperRectDomain_Iterator< TPoint >::myPoint, and DGtal::HyperRectDomain_Iterator< TPoint >::myupper.

Referenced by DGtal::HyperRectDomain_Iterator< TPoint >::operator++().

226  {
227  ++myPoint[0];
228  if (( TPoint::dimension > 1 ) &&
229  ( myPoint[0] > myupper[0] ) )
230  {
231  Dimension current_pos = 0;
232  do
233  {
234  myPoint[current_pos] = mylower[current_pos];
235  current_pos++;
236  if ( current_pos < TPoint::dimension )
237  ++myPoint[current_pos];
238  }
239  while (( current_pos + 1 < TPoint::dimension ) &&
240  ( myPoint[ current_pos ] > myupper[ current_pos ] ) );
241  }
242  }
TPoint mylower
Copies of the Domain limits.
TPoint myPoint
Current Point in the domain.
template<typename TPoint>
bool DGtal::HyperRectDomain_Iterator< TPoint >::operator!= ( const HyperRectDomain_Iterator< TPoint > &  aIt) const
inline

Operator !=

Definition at line 216 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::myPoint.

217  {
218  return ( myPoint!=aIt.myPoint );
219  }
TPoint myPoint
Current Point in the domain.
template<typename TPoint>
const TPoint& DGtal::HyperRectDomain_Iterator< TPoint >::operator* ( ) const
inline

Definition at line 183 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::mylower, DGtal::HyperRectDomain_Iterator< TPoint >::myPoint, and DGtal::HyperRectDomain_Iterator< TPoint >::myupper.

184  {
185  ASSERT_MSG( // we must be between [begin,end]
186  mylower.isLower(myPoint) && myPoint.isLower(myupper),
187  "The iterator points outside the domain."
188  );
189 
190  return myPoint;
191  }
TPoint mylower
Copies of the Domain limits.
TPoint myPoint
Current Point in the domain.
template<typename TPoint>
TPoint& DGtal::HyperRectDomain_Iterator< TPoint >::operator* ( )
inline

Definition at line 193 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::mylower, DGtal::HyperRectDomain_Iterator< TPoint >::myPoint, and DGtal::HyperRectDomain_Iterator< TPoint >::myupper.

194  {
195  ASSERT_MSG( // we must be between [begin,end]
196  mylower.isLower(myPoint) && myPoint.isLower(myupper),
197  "The iterator points outside the domain."
198  );
199 
200  return myPoint;
201  }
TPoint mylower
Copies of the Domain limits.
TPoint myPoint
Current Point in the domain.
template<typename TPoint>
HyperRectDomain_Iterator<TPoint>& DGtal::HyperRectDomain_Iterator< TPoint >::operator++ ( )
inline

Operator ++ (++it)

Definition at line 247 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::nextLexicographicOrder().

248  {
250  return *this;
251  }
template<typename TPoint>
HyperRectDomain_Iterator<TPoint> DGtal::HyperRectDomain_Iterator< TPoint >::operator++ ( int  )
inline

Operator ++ (it++)

Definition at line 257 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::nextLexicographicOrder().

258  {
259  HyperRectDomain_Iterator<TPoint> tmp = *this;
261  return tmp;
262  }
template<typename TPoint>
HyperRectDomain_Iterator<TPoint>& DGtal::HyperRectDomain_Iterator< TPoint >::operator-- ( )
inline

Operator – (–it)

Definition at line 291 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::prevLexicographicOrder().

292  {
294  return *this;
295  }
template<typename TPoint>
HyperRectDomain_Iterator<TPoint> DGtal::HyperRectDomain_Iterator< TPoint >::operator-- ( int  )
inline

Operator – (it–)

Definition at line 300 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::prevLexicographicOrder().

301  {
302  HyperRectDomain_Iterator<TPoint> tmp = *this;
304  return tmp;
305  }
template<typename TPoint>
bool DGtal::HyperRectDomain_Iterator< TPoint >::operator== ( const HyperRectDomain_Iterator< TPoint > &  it) const
inline

Operator ==

Definition at line 207 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::myPoint.

208  {
209  return ( myPoint==it.myPoint );
210  }
TPoint myPoint
Current Point in the domain.
template<typename TPoint>
void DGtal::HyperRectDomain_Iterator< TPoint >::prevLexicographicOrder ( )
inline

Implements the prev() method to scan the domain points dimension by dimension (lexicographic order).

Definition at line 268 of file HyperRectDomain_Iterator.h.

References DGtal::HyperRectDomain_Iterator< TPoint >::mylower, DGtal::HyperRectDomain_Iterator< TPoint >::myPoint, and DGtal::HyperRectDomain_Iterator< TPoint >::myupper.

Referenced by DGtal::HyperRectDomain_Iterator< TPoint >::operator--().

269  {
270  --myPoint[0];
271  if (( TPoint::dimension > 1 ) &&
272  ( myPoint[0] < mylower[0] ) )
273  {
274  Dimension current_pos = 0;
275  do
276  {
277  myPoint[ current_pos ] = myupper[ current_pos ];
278  ++current_pos;
279  if ( current_pos < TPoint::dimension )
280  --myPoint[ current_pos ];
281  }
282  while (( current_pos + 1 < TPoint::dimension ) &&
283  ( myPoint[ current_pos ] < mylower[ current_pos ] ) );
284  }
285  }
TPoint mylower
Copies of the Domain limits.
TPoint myPoint
Current Point in the domain.

Field Documentation

template<typename TPoint>
TPoint DGtal::HyperRectDomain_Iterator< TPoint >::mylower
private
template<typename TPoint>
TPoint DGtal::HyperRectDomain_Iterator< TPoint >::myPoint
private
template<typename TPoint>
TPoint DGtal::HyperRectDomain_Iterator< TPoint >::myupper
private

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