78 #ifndef SLIP_COMPONENT_ITERATOR3d_RANGE_HPP
79 #define SLIP_COMPONENT_ITERATOR3d_RANGE_HPP
110 template <
class MultiComponentContainer3d, std::
size_t N>
116 typedef typename MultiComponentContainer3d::value_type
Block;
124 typedef typename MultiComponentContainer3d::size_type
size_type;
135 cont3d_(0),pos_(0),x1_(0),x2_(0),x3_(0),cp_(0),range_x1_(0,0),range_x2_(0,0),range_x3_(0,0)
155 pos_(&(*c)[0][0][0][cp] +
156 (r1.start() * static_cast<int>(c->rows()) * static_cast<int>(c->cols()) * N) +
157 (r2.start() * static_cast<int>(c->cols()) * N) + (r3.start() * N)),
158 x1_(r1.start()),x2_(r2.start()),x3_(r3.start()),
159 cp_(cp),range_x1_(r1),range_x2_(r2),range_x3_(r3)
168 cont3d_(o.cont3d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_),cp_(o.cp_),
169 range_x1_(o.range_x1_), range_x2_(o.range_x2_), range_x3_(o.range_x3_)
190 this->cont3d_ = o.cont3d_;
196 this->range_x1_ = o.range_x1_;
197 this->range_x2_ = o.range_x2_;
198 this->range_x3_ = o.range_x3_;
235 this->x3_+= range_x3_.
stride();
236 this->pos_+= range_x3_.
stride()*N;
240 this->x2_+= range_x2_.
stride();
241 this->x3_ = range_x3_.
start();
242 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
243 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
244 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
247 this->x1_+= range_x1_.
stride();
248 this->x2_ = range_x2_.
start();
249 this->x3_ = range_x3_.
start();
250 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
251 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
252 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
258 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
259 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
260 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
295 this->x3_ -= range_x3_.
stride();
296 this->pos_ -= N * range_x3_.
stride();
298 else if (x2_ > static_cast<int>(range_x2_.
stop() - range_x2_.
iterations() * range_x2_.
stride()))
301 this->x2_ -= range_x2_.
stride();
302 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
303 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
304 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
306 else if (x1_ > static_cast<int>(range_x1_.
stop() - range_x1_.
iterations() * range_x1_.
stride()))
310 this->x1_ -= range_x1_.
stride();
311 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
312 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
313 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
316 this->x3_ =
static_cast<int>(range_x3_.
stop() + (range_x3_.
iterations() + 1) * range_x3_.
stride());
317 this->x2_ =
static_cast<int>(range_x2_.
stop() + (range_x2_.
iterations() + 1) * range_x2_.
stride());
318 this->x1_ =
static_cast<int>(range_x1_.
stop() + (range_x1_.
iterations() + 1) * range_x1_.
stride());
319 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
320 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
321 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
358 return ( (i1.cont3d_ == i2.cont3d_) && (i1.pos_ == i2.pos_)
359 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) && (i1.x3_ == i2.x3_)
360 && (i1.cp_ == i2.cp_));
373 return ( (i1.cont3d_ != i2.cont3d_) || (i1.pos_ != i2.pos_)
374 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_)
375 || (i1.x3_ != i2.x3_) || (i1.cp_ != i2.cp_));
394 return ( i1.pos_ < i2.pos_);
455 this->x1_ += this->range_x1_.
stride() * d.
dx1();
456 this->x2_ += this->range_x2_.
stride() * d.
dx2();
457 this->x3_ += this->range_x3_.
stride() * d.
dx3();
458 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
459 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
460 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
474 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
475 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
476 this->x3_ -= this->range_x3_.
stride() * d.
dx3();
477 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
478 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
479 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
525 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
526 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
527 assert(i1.range_x3_.stride() == i2.range_x3_.stride());
528 return difference_type(static_cast<int>((i1.x1_ - i2.x1_)/i1.range_x1_.stride()),
529 static_cast<int>((i1.x2_ - i2.x2_))/i1.range_x2_.stride(),
530 static_cast<int>((i1.x3_ - i2.x3_))/i1.range_x3_.stride());
545 assert( (this->x1_+ range_x1_.
stride() * d.
dx1()) < cont3d_->dim1() );
546 assert( (this->x2_+ range_x2_.
stride() * d.
dx2()) < cont3d_->dim2() );
547 assert( (this->x3_+ range_x3_.
stride() * d.
dx3()) < cont3d_->dim3() );
548 return (*cont3d_)[this->x1_+ range_x1_.
stride() * d.
dx1()]
549 [this->x2_+ range_x2_.
stride() * d.
dx2()]
550 [this->x3_+ range_x3_.
stride() * d.
dx3()][cp_];
561 typename MultiComponentContainer3d::component_slice_range_iterator
564 return cont3d_->slice_begin(this->cp_, range_x1_, range_x2_.
start() + row * range_x2_.
stride(),
577 typename MultiComponentContainer3d::component_slice_range_iterator
592 typename MultiComponentContainer3d::component_row_range_iterator
595 return cont3d_->row_begin(this->cp_, range_x1_.
start() + slice * range_x1_.
stride(),
596 range_x2_.
start() + row * range_x2_.
stride(), range_x3_);
608 typename MultiComponentContainer3d::component_row_range_iterator
624 typename MultiComponentContainer3d::component_col_range_iterator
627 return cont3d_->col_begin(this->cp_, range_x1_.
start() + slice * range_x1_.
stride(),
628 range_x3_.
start() + col * range_x3_.
stride(), range_x2_);
639 typename MultiComponentContainer3d::component_col_range_iterator
726 MultiComponentContainer3d* cont3d_;
757 template <
class MultiComponentContainer3d, std::
size_t N>
763 typedef typename MultiComponentContainer3d::value_type
Block;
771 typedef typename MultiComponentContainer3d::size_type
size_type;
782 cont3d_(0),pos_(0),x1_(0),x2_(0),x3_(0),cp_(0),range_x1_(0,0),range_x2_(0,0),range_x3_(0,0)
801 pos_(&(*c)[0][0][0][cp] +
802 (r1.start() * static_cast<int>(c->rows()) * static_cast<int>(c->cols()) * N) +
803 (r2.start() * static_cast<int>(c->cols()) * N) + (r3.start() * N)),
804 x1_(r1.start()),x2_(r2.start()),x3_(r3.start()),
805 cp_(cp),range_x1_(r1),range_x2_(r2),range_x3_(r3)
814 cont3d_(o.cont3d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_),cp_(o.cp_),
815 range_x1_(o.range_x1_), range_x2_(o.range_x2_), range_x3_(o.range_x3_)
836 this->cont3d_ = o.cont3d_;
842 this->range_x1_ = o.range_x1_;
843 this->range_x2_ = o.range_x2_;
844 this->range_x3_ = o.range_x3_;
885 this->x3_+= range_x3_.
stride();
886 this->pos_+= range_x3_.
stride()*N;
890 this->x2_+= range_x2_.
stride();
891 this->x3_ = range_x3_.
start();
892 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
893 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
894 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
897 this->x1_+= range_x1_.
stride();
898 this->x2_ = range_x2_.
start();
899 this->x3_ = range_x3_.
start();
900 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
901 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
902 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
908 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
909 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
910 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
944 this->x3_ -= range_x3_.
stride();
945 this->pos_ -= N * range_x3_.
stride();
947 else if (x2_ > static_cast<int>(range_x2_.
stop() - range_x2_.
iterations() * range_x2_.
stride()))
950 this->x2_ -= range_x2_.
stride();
951 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
952 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
953 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
955 else if (x1_ > static_cast<int>(range_x1_.
stop() - range_x1_.
iterations() * range_x1_.
stride()))
959 this->x1_ -= range_x1_.
stride();
960 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
961 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
962 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
965 this->x3_ =
static_cast<int>(range_x3_.
stop() + (range_x3_.
iterations() + 1) * range_x3_.
stride());
966 this->x2_ =
static_cast<int>(range_x2_.
stop() + (range_x2_.
iterations() + 1) * range_x2_.
stride());
967 this->x1_ =
static_cast<int>(range_x1_.
stop() + (range_x1_.
iterations() + 1) * range_x1_.
stride());
968 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
969 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
970 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
1007 return ( (i1.cont3d_ == i2.cont3d_) && (i1.pos_ == i2.pos_)
1008 && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_)
1009 && (i1.x3_ == i2.x3_) && (i1.cp_ == i2.cp_));
1022 return ( (i1.cont3d_ != i2.cont3d_) || (i1.pos_ != i2.pos_)
1023 || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_)
1024 || (i1.x3_ != i2.x3_) || (i1.cp_ != i2.cp_));
1043 return ( i1.pos_ < i2.pos_);
1106 this->x1_ += this->range_x1_.
stride() * d.
dx1();
1107 this->x2_ += this->range_x2_.
stride() * d.
dx2();
1108 this->x3_ += this->range_x3_.
stride() * d.
dx3();
1109 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
1110 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
1111 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
1125 this->x1_ -= this->range_x1_.
stride() * d.
dx1();
1126 this->x2_ -= this->range_x2_.
stride() * d.
dx2();
1127 this->x3_ -= this->range_x3_.
stride() * d.
dx3();
1128 this->pos_ = &(*cont3d_)[0][0][0][this->cp_] +
1129 (this->x1_ *
static_cast<int>(cont3d_->rows()) * static_cast<int>(cont3d_->cols()) * N) +
1130 (this->x2_ *
static_cast<int>(cont3d_->cols()) * N) + (this->x3_ * N);
1176 assert(i1.range_x1_.stride() == i2.range_x1_.stride());
1177 assert(i1.range_x2_.stride() == i2.range_x2_.stride());
1178 assert(i1.range_x3_.stride() == i2.range_x3_.stride());
1179 return difference_type(static_cast<int>((i1.x1_ - i2.x1_)/i1.range_x1_.stride()),
1180 static_cast<int>((i1.x2_ - i2.x2_))/i1.range_x2_.stride(),
1181 static_cast<int>((i1.x3_ - i2.x3_))/i1.range_x3_.stride());
1195 assert( (this->x1_+ range_x1_.
stride() * d.
dx1()) < cont3d_->dim1() );
1196 assert( (this->x2_+ range_x2_.
stride() * d.
dx2()) < cont3d_->dim2() );
1197 assert( (this->x3_+ range_x3_.
stride() * d.
dx3()) < cont3d_->dim3() );
1198 return (*cont3d_)[this->x1_+ range_x1_.
stride() * d.
dx1()]
1199 [this->x2_+ range_x2_.
stride() * d.
dx2()]
1200 [this->x3_+ range_x3_.
stride() * d.
dx3()][cp_];
1211 typename MultiComponentContainer3d::const_component_slice_range_iterator
1214 return cont3d_->slice_begin(this->cp_, range_x1_, range_x2_.
start() + row * range_x2_.
stride(),
1227 typename MultiComponentContainer3d::const_component_slice_range_iterator
1242 typename MultiComponentContainer3d::const_component_row_range_iterator
1245 return cont3d_->row_begin(this->cp_, range_x1_.
start() + slice * range_x1_.
stride(),
1246 range_x2_.
start() + row * range_x2_.
stride(), range_x3_);
1258 typename MultiComponentContainer3d::const_component_row_range_iterator
1274 typename MultiComponentContainer3d::const_component_col_range_iterator
1277 return cont3d_->col_begin(this->cp_, range_x1_.
start() + slice * range_x1_.
stride(),
1278 range_x3_.
start() + col * range_x3_.
stride(), range_x2_);
1289 typename MultiComponentContainer3d::const_component_col_range_iterator
1372 MultiComponentContainer3d* cont3d_;
1388 #endif //SLIP_COMPONENT_ITERATOR3d_RANGE_HPP
MultiComponentContainer3d::const_component_col_range_iterator col_begin(size_type slice, size_type col) const
const_component_iterator3d_range element assignment operator.
MultiComponentContainer3d::value_type Block
self operator++(int)
Postincrement a const_component_iterator3d_range. Iterate to the next location inside the Range3d...
self operator-(const difference_type &d)
component_iterator3d_range substraction.
std::size_t iterations() const
Rerturns the number of iterations of the range.
friend bool operator<(const self &i1, const self &i2)
< operator.
reference operator*() const
Dereference operator. Returns the element that the current const_component_iterator3d_range i point t...
Provides a class to modelize 3d points.
Block::value_type value_type
void dx3(const CoordType &dx)
Accessor of the first coordinate of DPoint3d.
DPoint3d< int > difference_type
self operator++(int)
Postincrement a component_iterator3d_range. Iterate to the next location inside the Range3d...
Difference of Point3D class, specialization of DPoint<CoordType,DIM> with DIM = 3.
MultiComponentContainer3d::component_slice_range_iterator slice_end(size_type row, size_type col)
component_iterator3d_range element assignment operator.
self operator+(const difference_type &d)
component_iterator3d_range addition.
int k() const
Access to the first index of the current const_component_iterator3d_range.
const_component_iterator3d_range(const self &o)
Constructs a copy of the const_component_iterator3d_range o.
self operator+(const difference_type &d)
const_component_iterator3d_range addition.
const_component_iterator3d_range(MultiComponentContainer3d *c, std::size_t cp, const slip::Range< int > &r1, const slip::Range< int > &r2, const slip::Range< int > &r3)
Constructs a const_component_iterator3d_range.
Provides a class to tag SLIP iterators.
friend bool operator<(const self &i1, const self &i2)
< operator.
self & operator+=(const difference_type &d)
component_iterator3d_range addition.
MultiComponentContainer3d::const_component_row_range_iterator row_end(size_type slice, size_type row) const
const_component_iterator3d_range element assignment operator.
int x3() const
Access to the third index of the current component_iterator3d_range.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
MultiComponentContainer3d::size_type size_type
Provides a class to modelize the difference of slip::Point3d.
friend difference_type operator-(const self &i1, const self &i2)
const_component_iterator3d_range difference operator.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
reference operator[](difference_type d) const
const_component_iterator3d_range element assignment operator. Equivalent to *(i + d)...
reference operator*()
Dereference assignment operator. Returns the element that the current component_iterator3d_range i po...
self & operator=(const self &o)
Assign a component_iterator3d_range.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
self & operator--()
Predecrement a const_component_iterator3d_range. Iterate to the previous location inside the Range3d...
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
std::random_access_iterator3d_tag iterator_category
MultiComponentContainer3d::component_col_range_iterator col_begin(size_type slice, size_type col)
component_iterator3d_range element assignment operator.
value_type const * pointer
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
MultiComponentContainer3d::const_component_slice_range_iterator slice_begin(size_type row, size_type col) const
const_component_iterator3d_range element assignment operator.
component_iterator3d_range(const self &o)
Constructs a copy of the component_iterator3d_range o.
self & operator-=(const difference_type &d)
component_iterator3d_range substraction.
int x2() const
Access to the second index of the current const_component_iterator3d_range.
int j() const
Access to the third index of the current const_component_iterator3d_range.
int k() const
Access to the first index of the current component_iterator3d_range.
self & operator+=(const difference_type &d)
const_component_iterator3d_range addition.
MultiComponentContainer3d::const_component_col_range_iterator col_end(size_type slice, size_type col) const
const_component_iterator3d_range element assignment operator.
MultiComponentContainer3d::const_component_row_range_iterator row_begin(size_type slice, size_type row) const
const_component_iterator3d_range element assignment operator.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
void dx2(const CoordType &dx)
Accessor of the second coordinate of DPoint3d.
self & operator++()
Preincrement a component_iterator3d_range. Iterate to the next location inside the Range...
SubType start() const
Accessor of the start subscript of the Range.
self & operator=(const self &o)
Assign a const_component_iterator3d_range.
DPoint3d< int > difference_type
friend bool operator>(const self &i1, const self &i2)
operator.
int i() const
Access to the second index of the current const_component_iterator3d_range.
self operator--(int)
Postdecrement a const_component_iterator3d_range. Iterate to the previous location inside the Range3d...
MultiComponentContainer3d::component_row_range_iterator row_end(size_type slice, size_type row)
component_iterator3d_range element assignment operator.
self & operator--()
Predecrement a component_iterator3d_range. Iterate to the previous location inside the Range3d...
int x2() const
Access to the second index of the current component_iterator3d_range.
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
self & operator-=(const difference_type &d)
const_component_iterator3d_range substraction.
int cp() const
Access to the component index of the current component_iterator3d_range.
MultiComponentContainer3d::value_type Block
reference operator[](difference_type d)
component_iterator3d_range element assignment operator. Equivalent to *(i + d) = t.
friend bool operator==(const self &i1, const self &i2)
Equality operator.
int cp() const
Access to the component index of the current const_component_iterator3d_box.
component_iterator3d_range()
Constructs a component_iterator3d_range.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
MultiComponentContainer3d::const_component_slice_range_iterator slice_end(size_type row, size_type col) const
const_component_iterator3d_range element assignment operator.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
friend difference_type operator-(const self &i1, const self &i2)
component_iterator3d_range difference operator.
self operator--(int)
Postdecrement a component_iterator3d_range. Iterate to the previous location inside the Range3d...
MultiComponentContainer3d::component_row_range_iterator row_begin(size_type slice, size_type row)
component_iterator3d_range element assignment operator.
int stride() const
Accessor of the stride of the Range.
int i() const
Access to the second index of the current component_iterator3d_range.
MultiComponentContainer3d::component_slice_range_iterator slice_begin(size_type row, size_type col)
component_iterator3d_range element assignment operator.
MultiComponentContainer3d::component_col_range_iterator col_end(size_type slice, size_type col)
component_iterator3d_range element assignment operator.
self operator-(const difference_type &d)
const_component_iterator3d_range substraction.
self & operator++()
Preincrement a const_component_iterator3d_range. Iterate to the next location inside the Range...
Block::value_type value_type
MultiComponentContainer3d::size_type size_type
component_iterator3d_range(MultiComponentContainer3d *c, std::size_t cp, const slip::Range< int > &r1, const slip::Range< int > &r2, const slip::Range< int > &r3)
Constructs a component_iterator3d_range.
int x1() const
Access to the first index of the current const_component_iterator3d_range.
void dx1(const CoordType &dx)
Accessor of the first coordinate of DPoint3d.
std::random_access_iterator3d_tag iterator_category
int j() const
Access to the third index of the current component_iterator3d_range.
value_type const & reference
const_component_iterator3d_range()
Constructs a const_component_iterator3d_range.
Provides a class to manipulate Ranges.
pointer operator->() const
friend bool operator>(const self &i1, const self &i2)
operator.
SubType stop() const
Accessor of the stop subscript of the Range.
int x1() const
Access to the first index of the current component_iterator3d_range.
int x3() const
Access to the third index of the current const_component_iterator3d_range.