1 #ifndef AIMSDATA_BORDER_BORDERITERATOR_H 
    2 #define AIMSDATA_BORDER_BORDERITERATOR_H 
  262   template <
typename T>
 
  268   template <
typename T>
 
  282   template <
typename T>
 
  289   template <
typename T>
 
  292     _border(other._border),
 
  293     _current(other._current)
 
  296   template <
typename T>
 
  299     _border(other._border),
 
  300     _current(other._current)
 
  303   template <
typename T>
 
  308     _current = other._current;
 
  312   template <
typename T>
 
  317     _current = other._current;
 
  321   template <
typename T>
 
  324     return _border._volume( _current[0], _current[1], _current[2], _current[3] );
 
  327   template <
typename T>
 
  330     return &( _border._volume( _current[0], _current[1], _current[2], _current[3] ) );
 
  333   template <
typename T>
 
  339   template <
typename T>
 
  345   template <
typename T>
 
  348     return !(*
this == other);
 
  351   template <
typename T>
 
  354     return !(*
this == other);
 
  357   template <
typename T>
 
  366   template <
typename T>
 
  369     if( _border._inside )
 
  370       return _border._volume.getSizeX() - _border._sizesup[0];
 
  372       return _border._volume.getSizeX();
 
  375   template <
typename T>
 
  378     if( _border._inside )
 
  381       if( ( p[0] < 0 ) || ( p[0] >= _border._volume.getSizeX() ) ||
 
  382           ( p[1] < 0 ) || ( p[1] >= _border._volume.getSizeY() ) ||
 
  383           ( p[2] < 0 ) || ( p[2] >= _border._volume.getSizeZ() ) ||
 
  384           ( p[3] < 0 ) || ( p[3] >= _border._volume.getSizeT() ) )
 
  387       else if( ( p[0] < _border._sizeinf[0] ) ||
 
  388                ( p[0] >= _border._volume.getSizeX() - _border._sizesup[0] + 1 ) ||
 
  389                ( p[1] < _border._sizeinf[1] ) ||
 
  390                ( p[1] >= _border._volume.getSizeY() - _border._sizesup[1] + 1 ) ||
 
  391                ( p[2] < _border._sizeinf[2] ) ||
 
  392                ( p[2] >= _border._volume.getSizeZ() - _border._sizesup[2] + 1 ) ||
 
  393                ( p[3] < _border._sizeinf[3] ) ||
 
  394                ( p[3] >= _border._volume.getSizeT() - _border._sizesup[3] + 1 ) )
 
  403       if( ( p[0] < -_border._sizeinf[0] ) ||
 
  404           ( p[0] >= _border._volume.getSizeX() + _border._sizesup[0] ) ||
 
  405           ( p[1] < -_border._sizeinf[1] ) ||
 
  406           ( p[1] >= _border._volume.getSizeY() + _border._sizesup[1] ) ||
 
  407           ( p[2] < -_border._sizeinf[2] ) ||
 
  408           ( p[2] >= _border._volume.getSizeZ() + _border._sizesup[2] ) ||
 
  409           ( p[3] < -_border._sizeinf[3] ) ||
 
  410           ( p[3] >= _border._volume.getSizeT() + _border._sizesup[3] ) )
 
  413       else if( ( p[0] < 0 ) || ( p[0] >= _border._volume.getSizeX() ) ||
 
  414                ( p[1] < 0 ) || ( p[1] >= _border._volume.getSizeY() ) ||
 
  415                ( p[2] < 0 ) || ( p[2] >= _border._volume.getSizeZ() ) ||
 
  416                ( p[3] < 0 ) || ( p[3] >= _border._volume.getSizeT() ) )
 
  424   template <
typename T>
 
  427     if( _border._inside )
 
  429       return( _border._sizeinf[0] <= p[0] && p[0] < _border._volume.getSizeX() - _border._sizesup[0] &&
 
  430               _border._sizeinf[1] <= p[1] && p[1] < _border._volume.getSizeY() - _border._sizesup[1] &&
 
  431               _border._sizeinf[2] <= p[2] && p[2] < _border._volume.getSizeZ() - _border._sizesup[2] &&
 
  432               _border._sizeinf[3] <= p[3] && p[3] < _border._volume.getSizeT() - _border._sizesup[3] );
 
  436       return( 0 <= p[0] && p[0] < _border._volume.getSizeX() &&
 
  437               0 <= p[1] && p[1] < _border._volume.getSizeY() &&
 
  438               0 <= p[2] && p[2] < _border._volume.getSizeZ() &&
 
  439               0 <= p[3] && p[3] < _border._volume.getSizeT() );
 
  443   template <
typename T>
 
  449     if( _border._inside )
 
  453       else if( move[1] > 0 )
 
  455       else if( move[2] > 0 )
 
  457       else if( move[3] > 0 )
 
  463         newp[0] = -_border._sizeinf[0];
 
  464       else if( move[1] > 0 )
 
  465         newp[1] = -_border._sizeinf[1];
 
  466       else if( move[2] > 0 )
 
  467         newp[2] = -_border._sizeinf[2];
 
  468       else if( move[3] > 0 )
 
  469         newp[3] = -_border._sizeinf[3];
 
  475   template <
typename T>
 
  481     else if( move[1] > 0 )
 
  483     else if( move[2] > 0 )
 
  485     else if( move[3] > 0 )
 
  492   template <
typename T>
 
  498     while( !isBorder(next) && next != 
end() )
 
  501       if( isNonBorderImage( next ) ) {
 
  508         next = reset( next, move );
 
  509         move = nextMove( move );
 
  520   template <
typename T>
 
  523     _current = computeNext( _current );
 
  527   template <
typename T>
 
  531     _current = computeNext( _current );
 
  536   template <
typename T>
 
  541   template <
typename T>
 
  546   template <
typename T>
 
  551   template <
typename T>
 
  557   template <
typename T>
 
  565   template <
typename T>
 
  575   template <
typename T>
 
  585   template <
typename T>
 
  593   template <
typename T>
 
bool isBorder(const Point4dl &p) const
returns true if the p is in the border described by _border
const_iterator(const const_iterator &other)
Copy constructor from a const_iterator.
Point4dl coordinate() const
Returns the coordinates of the current point in the linked volume.
bool isNonBorderImage(const Point4dl &p) const
returns true if p is in the image but not in the border.
bool operator!=(const const_iterator &other) const
Point4dl reset(const Point4dl &p, const Point4dl &move) const
Sets the coordinate (in the dimension described by move) at its most inferior (i.e.
BorderIterator< T > _border
bool operator==(const const_iterator &other) const
const_iterator()
Default constructor Create a non initialized iterator than cannot be incremented or accessed.
const_iterator(const iterator &other)
Copy constructor from an iterator.
carto::VolumeRef< T > volume()
Returns a reference to the linked volume.
const T * operator->() const
long jumpX() const
Gives the size of the non-border volume in the X dimension.
const T & operator*() const
Point4dl nextMove(const Point4dl &move) const
Computes the next move.
const_iterator & operator++()
increment (prefix)
Point4dl computeNext(const Point4dl &p) const
computeNext(p) returns the next point in the border.
const_iterator & operator=(const iterator &other)
assignment from iterator
const_iterator & operator=(const const_iterator &other)
assignment from const_iterator
Point4dl end() const
Point value for the "end" iterator (which points to no voxel).
iterator(const iterator &other)
Copy constructor from an iterator.
iterator()
Default constructor Create a non initialized iterator than cannot be incremented or accessed.
iterator & operator++()
increment (prefix)
iterator & operator=(const iterator &other)
assignment from iterator
Represents the border of a volume.
bool operator==(const BorderIterator< T > &other) const
const_iterator end() const
carto::VolumeRef< T > _volume
BorderIterator(carto::VolumeRef< T > in, bool inside, const Point4dl &sizeinf, const Point4dl &sizesup)
friend class const_iterator
const_iterator begin() const
BorderIterator(carto::VolumeRef< T > in, bool inside=false, const Point4dl &size=Point4dl(-1, -1, -1, -1))
Border constructor.
std::vector< int > getBorders() const
The class for EcatSino data write operation.