74 #ifndef SLIP_ITERATOR3D_RANGE_HPP
75 #define SLIP_ITERATOR3D_RANGE_HPP
120 template <
class Container3D>
121 class iterator3d_range
129 typedef typename Container3D::pointer
pointer;
146 cont3d_(0),pos_(0),x1_(0),x2_(0),x3_(0),range_x1_(0,0),range_x2_(0,0),range_x3_(0,0)
164 cont3d_(c),pos_((*c)[r1.start()][r2.start()] + r3.start())
165 ,x1_(r1.start()),x2_(r2.start()),x3_(r3.start())
166 ,range_x1_(r1),range_x2_(r2),range_x3_(r3)
175 cont3d_(o.cont3d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_),
176 range_x1_(o.range_x1_),range_x2_(o.range_x2_),range_x3_(o.range_x3_)
197 this->cont3d_ = o.cont3d_;
202 this->range_x1_ = o.range_x1_;
203 this->range_x2_ = o.range_x2_;
204 this->range_x3_ = o.range_x3_;
243 this->x3_+= range_x3_.
stride();
244 this->pos_+= range_x3_.
stride();
248 this->x2_+= range_x2_.
stride();
249 this->x3_ = range_x3_.
start();
250 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
254 this->x1_+= range_x1_.
stride();
255 this->x2_ = range_x2_.
start();
256 this->x3_ = range_x3_.
start();
257 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
264 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
296 if((x3_ >
int(range_x3_.
start())) && (x2_ >= int(range_x2_.
start())) && (x1_ >= int(range_x1_.
start())))
298 this->x3_-= range_x3_.
stride();
299 this->pos_-= range_x3_.
stride();
301 else if((x2_ >
int(range_x2_.
start())) && (x1_ >= int(range_x1_.
start())))
303 this->x2_-= range_x2_.
stride();
305 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
307 else if(x1_ >
int(range_x2_.
start()))
309 this->x1_-= range_x1_.
stride();
312 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
316 this->x1_ = int(range_x1_.
start()-range_x1_.
stride());
317 this->x2_ = int(range_x2_.
start()-range_x2_.
stride());
318 this->x3_ = int(range_x3_.
start()-range_x3_.
stride());
319 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
355 return ( (i1.cont3d_ == i2.cont3d_) && (i1.pos_ == i2.pos_)
356 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) && (i1.x3_ == i2.x3_));
369 return ( (i1.cont3d_ != i2.cont3d_) || (i1.pos_ != i2.pos_)
370 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_)|| (i1.x3_ != i2.x3_) );
389 return ( i1.pos_ < i2.pos_);
449 this->x1_ += this->range_x1_.
stride() * d.
dx1();
450 this->x2_ += this->range_x2_.
stride() * d.
dx2();
451 this->x3_ += this->range_x3_.
stride() * d.
dx3();
452 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
466 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
467 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
468 this->x3_ -= this->range_x3_.
stride() * d.
dx3();
469 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
515 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
516 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
517 assert(i1.range_x3_.stride() == i2.range_x3_.stride());
519 int((i1.x2_ - i2.x2_))/i1.range_x2_.stride(),
520 int((i1.x3_ - i2.x3_))/i1.range_x3_.stride());
535 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * d.
dx1()]
536 [this->x2_+ this->range_x2_.
stride() * d.
dx2()]
537 [this->x3_+ this->range_x3_.
stride() * d.
dx3()];
552 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * d.
dx1()]
553 [this->x2_ + this->range_x2_.
stride() * d.
dx2()];
568 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * n];
588 return cont3d_->row_begin(range_x1_.
start() + slice * range_x1_.
stride(), range_x2_.
start()
589 + row * range_x2_.
stride(), range_x3_);
617 return cont3d_->col_begin(range_x1_.
start() + slice * range_x1_.
stride()
619 + col * range_x3_.
stride(), range_x2_);
702 Container3D* cont3d_;
746 template <
class Container3D>
747 class const_iterator3d_range
755 typedef typename Container3D::const_pointer
pointer;
756 typedef typename Container3D::const_reference
reference;
772 cont3d_(0),pos_(0),x1_(0),x2_(0),x3_(0),range_x1_(0,0),range_x2_(0,0),range_x3_(0,0)
791 cont3d_(c),pos_((*c)[r1.start()][r2.start()] + r3.start())
792 ,x1_(r1.start()),x2_(r2.start()),x3_(r3.start())
793 ,range_x1_(r1),range_x2_(r2),range_x3_(r3)
802 cont3d_(o.cont3d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_)
803 ,range_x1_(o.range_x1_),range_x2_(o.range_x2_),range_x3_(o.range_x3_)
824 this->cont3d_ = o.cont3d_;
829 this->range_x1_ = o.range_x1_;
830 this->range_x2_ = o.range_x2_;
831 this->range_x3_ = o.range_x3_;
873 this->x3_+= range_x3_.
stride();
874 this->pos_+= range_x3_.
stride();
878 this->x2_+= range_x2_.
stride();
879 this->x3_ = range_x3_.
start();
880 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
884 this->x1_+= range_x1_.
stride();
885 this->x2_ = range_x2_.
start();
886 this->x3_ = range_x3_.
start();
887 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
894 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
926 if((x3_ >
int(range_x3_.
start())) && (x2_ >= int(range_x2_.
start())) && (x1_ >= int(range_x1_.
start())))
928 this->x3_-= range_x3_.
stride();
929 this->pos_-= range_x3_.
stride();
931 else if((x2_ >
int(range_x2_.
start())) && (x1_ >= int(range_x1_.
start())))
933 this->x2_-= range_x2_.
stride();
935 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
937 else if(x1_ >
int(range_x2_.
start()))
939 this->x1_-= range_x1_.
stride();
942 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
946 this->x1_ = int(range_x1_.
start()-range_x1_.
stride());
947 this->x2_ = int(range_x2_.
start()-range_x2_.
stride());
948 this->x3_ = int(range_x3_.
start()-range_x3_.
stride());
949 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
985 return ( (i1.cont3d_ == i2.cont3d_) && (i1.pos_ == i2.pos_)
986 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) && (i1.x3_ == i2.x3_));
999 return ( (i1.cont3d_ != i2.cont3d_) || (i1.pos_ != i2.pos_)
1000 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_) || (i1.x3_ != i2.x3_));
1019 return ( i1.pos_ < i2.pos_);
1080 this->x1_ += this->range_x1_.
stride() * d.
dx1();
1081 this->x2_ += this->range_x2_.
stride() * d.
dx2();
1082 this->x3_ += this->range_x3_.
stride() * d.
dx3();
1083 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
1097 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
1098 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
1099 this->x3_ -= this->range_x3_.
stride() * d.
dx3();
1100 this->pos_ = cont3d_->begin() + (this->x1_ * int(cont3d_->rows() * int(cont3d_->cols()))) + (this->x2_*
int(cont3d_->cols())) + this->x3_;
1146 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
1147 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
1148 assert(i1.range_x3_.stride() == i2.range_x3_.stride());
1150 int((i1.x2_ - i2.x2_))/i1.range_x2_.stride(),
1151 int((i1.x3_ - i2.x3_))/i1.range_x3_.stride());
1166 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * d.
dx1()]
1167 [this->x2_+ this->range_x2_.
stride() * d.
dx2()]
1168 [this->x3_+ this->range_x3_.
stride() * d.
dx3()];
1183 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * d.
dx1()]
1184 [this->x2_ + this->range_x2_.
stride() * d.
dx2()];
1198 return (*cont3d_)[this->x1_+ this->range_x1_.
stride() * n];
1219 return cont3d_->row_begin(range_x1_.
start() + slice * range_x1_.
stride()
1220 , range_x2_.
start() + row * range_x2_.
stride(), range_x3_);
1250 return cont3d_->col_begin(range_x1_.
start() + slice * range_x1_.
stride()
1251 , range_x3_.
start() + col * range_x3_.
stride(), range_x2_);
1336 Container3D* cont3d_;
1351 #endif //SLIP_ITERATOR3D_RANGE_HPP
self operator--(int)
Postdecrement a iterator3d_range. Iterate to the previous location inside the Range3d.
self & operator-=(const difference_type &d)
const_iterator3d_range substraction.
std::size_t iterations() const
Rerturns the number of iterations of the range.
int x3() const
Access to the third subscript of the current iterator3d_range.
Container3D::reference reference
Provides a class to modelize 3d points.
DPoint3d< int > difference_type
Provides a class to modelize the difference of slip::Point2d.
void dx3(const CoordType &dx)
Accessor of the first coordinate of DPoint3d.
Container3D::row_range_iterator row_end(size_type slice, size_type row)
iterator3d_range element assignment operator.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
void dx2(const CoordType &dx)
Accessor of the second coordinate of DPoint2d.
Difference of Point3D class, specialization of DPoint<CoordType,DIM> with DIM = 3.
self & operator++()
Preincrement a const_iterator3d_range. Iterate to the next location inside the Range.
reference operator[](difference_type d)
iterator3d_range element assignment operator. Equivalent to *(k + d) = t.
reference operator*()
Dereference assignment operator. Returns the element that the current iterator3d_range i point to...
int x2() const
Access to the second subscript of the current iterator3d_range.
std::random_access_iterator3d_tag iterator_category
iterator3d_range()
Constructs a iterator3d_range.
self operator+(const difference_type &d)
iterator3d_range addition.
self & operator-=(const difference_type &d)
iterator3d_range substraction.
int k()
Access to the first subscript of the current const_iterator3d_range.
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
Container3D::size_type size_type
Provides a class to tag SLIP iterators.
self operator-(const difference_type &d)
iterator3d_range substraction.
int j()
Access to the third subscript of the current const_iterator3d_range.
pointer * operator[](int n)
iterator3d_range element assignment operator. Equivalent to *(k + n) = t.
self operator++(int)
Postincrement a const_iterator3d_range. Iterate to the next location inside the Range3d.
pointer operator[](diff2d d) const
const_iterator3d_range element assignment operator. Equivalent to *(k + d) = t.
pointer operator[](diff2d d)
iterator3d_range element assignment operator. Equivalent to *(k + d) = t.
Provides a class to modelize the difference of slip::Point3d.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
int x1() const
Access to the first subscript of the current iterator3d_range.
Container3D::col_range_iterator col_end(size_type slice, size_type col)
iterator3d_range element assignment operator.
self operator++(int)
Postincrement a iterator3d_range. Iterate to the next location inside the Range3d.
self operator+(const difference_type &d)
const_iterator3d_range addition.
Container3D::pointer pointer
friend bool operator<(const self &i1, const self &i2)
< operator.
Container3D::const_reference reference
int x3()
Access to the third subscript of the current const_iterator3d_range.
Container3D::const_col_range_iterator col_begin(size_type slice, size_type col) const
const_iterator3d_range element assignment operator.
friend difference_type operator-(const self &i1, const self &i2)
const_iterator3d_range difference operator.
Container3D::const_row_range_iterator row_end(size_type slice, size_type row) const
const_iterator3d_range element assignment operator.
void dx1(const CoordType &dx)
Accessor of the first coordinate of DPoint2d.
reference operator[](difference_type d) const
const_iterator3d_range element assignment operator. Equivalent to *(k + d) = t.
self & operator=(const self &o)
Assign a iterator3d_range.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
self operator-(const difference_type &d)
const_iterator3d_range substraction.
self & operator--()
Predecrement a iterator3d_range. Iterate to the previous location inside the Range3d.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
iterator3d_range(Container3D *c, const slip::Range< int > &r1, const slip::Range< int > &r2, const slip::Range< int > &r3)
Constructs a iterator3d_range.
const_iterator3d_range(Container3D *c, const slip::Range< int > &r1, const slip::Range< int > &r2, const slip::Range< int > &r3)
Constructs a const_iterator3d_range.
int j() const
Access to the third subscript of the current iterator3d_range.
friend difference_type operator-(const self &i1, const self &i2)
iterator3d_range difference operator.
iterator3d_range(const self &o)
Constructs a copy of the iterator3d_range o.
int k() const
Access to the first subscript of the current iterator3d_range.
void dx2(const CoordType &dx)
Accessor of the second coordinate of DPoint3d.
Difference of Point2D class, specialization of DPoint<CoordType,DIM> with DIM = 2.
SubType start() const
Accessor of the start subscript of the Range.
Container3D::row_range_iterator row_begin(size_type slice, size_type row)
iterator3d_range element assignment operator.
Container3D::value_type value_type
pointer operator->() const
const_iterator3d_range(const self &o)
Constructs a copy of the const_iterator3d_range o.
friend bool operator>(const self &i1, const self &i2)
operator.
DPoint3d< int > difference_type
self & operator+=(const difference_type &d)
iterator3d_range addition.
friend bool operator>(const self &i1, const self &i2)
operator.
Container3D::col_range_iterator col_begin(size_type slice, size_type col)
iterator3d_range element assignment operator.
int x1()
Access to the first subscript of the current const_iterator3d_range.
int i()
Access to the second subscript of the current const_iterator3d_range.
pointer * operator[](int n) const
const_iterator3d_range element assignment operator. Equivalent to *(k + n).
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
std::random_access_iterator3d_tag iterator_category
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
Container3D::size_type size_type
Container3D::const_row_range_iterator row_begin(size_type slice, size_type row) const
const_iterator3d_range element assignment operator.
reference operator*() const
Dereference operator. Returns the element that the current const_iterator3d_range i point to...
int stride() const
Accessor of the stride of the Range.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
int x2()
Access to the second subscript of the current const_iterator3d_range.
self & operator+=(const difference_type &d)
const_iterator3d_range addition.
void dx1(const CoordType &dx)
Accessor of the first coordinate of DPoint3d.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
self & operator--()
Predecrement a const_iterator3d_range. Iterate to the previous location inside the Range3d...
Provides a class to manipulate Ranges.
Container3D::value_type value_type
Container3D::const_col_range_iterator col_end(size_type slice, size_type col) const
const_iterator3d_range element assignment operator.
const_iterator3d_range()
Constructs a const_iterator3d_range.
self operator--(int)
Postdecrement a const_iterator3d_range. Iterate to the previous location inside the Range3d...
int i() const
Access to the second subscript of the current iterator3d_range.
friend bool operator<(const self &i1, const self &i2)
< operator.
Container3D::const_pointer pointer
self & operator++()
Preincrement a iterator3d_range. Iterate to the next location inside the Range.
self & operator=(const self &o)
Assign a const_iterator3d_range.