SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
component_iterator4d_box.hpp
Go to the documentation of this file.
1 /*
2  * Copyright(c):
3  * Signal Image and Communications (SIC) Department
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * - University of Poitiers, France http://www.univ-poitiers.fr
6  * - XLIM Institute UMR CNRS 7252 http://www.xlim.fr/
7  *
8  * and
9  *
10  * D2 Fluid, Thermic and Combustion
11  * - University of Poitiers, France http://www.univ-poitiers.fr
12  * - PPRIME Institute - UPR CNRS 3346 http://www.pprime.fr
13  * - ISAE-ENSMA http://www.ensma.fr
14  *
15  * Contributor(s):
16  * The SLIP team,
17  * Benoit Tremblais <tremblais_AT_sic.univ-poitiers.fr>,
18  * Laurent David <laurent.david_AT_lea.univ-poitiers.fr>,
19  * Ludovic Chatellier <ludovic.chatellier_AT_univ-poitiers.fr>,
20  * Lionel Thomas <lionel.thomas_AT_univ-poitiers.fr>,
21  * Denis Arrivault <arrivault_AT_sic.univ-poitiers.fr>,
22  * Julien Dombre <julien.dombre_AT_univ-poitiers.fr>.
23  *
24  * Description:
25  * The Simple Library of Image Processing (SLIP) is a new image processing
26  * library. It is written in the C++ language following as much as possible
27  * the ISO/ANSI C++ standard. It is consequently compatible with any system
28  * satisfying the ANSI C++ complience. It works on different Unix , Linux ,
29  * Mircrosoft Windows and Mac OS X plateforms. SLIP is a research library that
30  * was created by the Signal, Image and Communications (SIC) departement of
31  * the XLIM, UMR 7252 CNRS Institute in collaboration with the Fluids, Thermic
32  * and Combustion departement of the P', UPR 3346 CNRS Institute of the
33  * University of Poitiers.
34  *
35  * The SLIP Library source code has been registered to the APP (French Agency
36  * for the Protection of Programs) by the University of Poitiers and CNRS,
37  * under registration number IDDN.FR.001.300034.000.S.P.2010.000.21000.
38 
39  * http://www.sic.sp2mi.univ-poitiers.fr/slip/
40  *
41  * This software is governed by the CeCILL-C license under French law and
42  * abiding by the rules of distribution of free software. You can use,
43  * modify and/ or redistribute the software under the terms of the CeCILL-C
44  * license as circulated by CEA, CNRS and INRIA at the following URL
45  * http://www.cecill.info.
46  * As a counterpart to the access to the source code and rights to copy,
47  * modify and redistribute granted by the license, users are provided only
48  * with a limited warranty and the software's author, the holder of the
49  * economic rights, and the successive licensors have only limited
50  * liability.
51  *
52  * In this respect, the user's attention is drawn to the risks associated
53  * with loading, using, modifying and/or developing or reproducing the
54  * software by the user in light of its specific status of free software,
55  * that may mean that it is complicated to manipulate, and that also
56  * therefore means that it is reserved for developers and experienced
57  * professionals having in-depth computer knowledge. Users are therefore
58  * encouraged to load and test the software's suitability as regards their
59  * requirements in conditions enabling the security of their systems and/or
60  * data to be ensured and, more generally, to use and operate it in the
61  * same conditions as regards security.
62  *
63  * The fact that you are presently reading this means that you have had
64  * knowledge of the CeCILL-C license and that you accept its terms.
65  */
66 
75 #ifndef SLIP_COMPONENT_ITERATOR4D_BOX_HPP
76 #define SLIP_COMPONENT_ITERATOR4D_BOX_HPP
77 
78 #include <iterator>
79 #include <cassert>
80 
81 #include "Point4d.hpp"
82 #include "DPoint4d.hpp"
83 #include "Box4d.hpp"
84 #include "iterator_types.hpp"
85 
86 namespace slip
87 {
107 template <class MultiComponentContainer4D, std::size_t N>
109 {
110 
111 public:
112 
114  typedef typename MultiComponentContainer4D::value_type Block;
115  typedef typename Block::value_type value_type;
117  typedef value_type* pointer;
119 
121 
122  typedef typename MultiComponentContainer4D::size_type size_type;
127 
133  cont4d_(0),pos_(0),x1_(0),x2_(0),x3_(0),x4_(0),cp_(0),box_(0,0,0,0,0)
134  {}
135 
143  component_iterator4d_box(MultiComponentContainer4D* c, std::size_t cp,
144  const Box4d<int>& b):
145  cont4d_(c),pos_(&(*c)[0][0][0][0][cp] +
146  ((b.first_front_upper_left())[0] * static_cast<int>(c->slices()) * static_cast<int>(c->rows()) * static_cast<int>(c->cols()) * N) +
147  ((b.first_front_upper_left())[1] * static_cast<int>(c->rows()) * static_cast<int>(c->cols()) * N) +
148  ((b.first_front_upper_left())[2] * static_cast<int>(c->cols()) * N) +
149  ((b.first_front_upper_left())[3] * N)),
150  x1_((b.first_front_upper_left())[0]),x2_((b.first_front_upper_left())[1]),
151  x3_((b.first_front_upper_left())[2]),x4_((b.first_front_upper_left())[3]),cp_(cp),box_(b)
152  {}
153 
159  component_iterator4d_box(const self& o):
160  cont4d_(o.cont4d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_),x4_(o.x4_),cp_(o.cp_),box_(o.box_)
161  {}
162 
177  self& operator=(const self& o)
178  {
179  if(this != &o)
180  {
181  this->cont4d_ = o.cont4d_;
182  this->pos_ = o.pos_;
183  this->x1_ = o.x1_;
184  this->x2_ = o.x2_;
185  this->x3_ = o.x3_;
186  this->x4_ = o.x4_;
187  this->cp_ = o.cp_;
188  this->box_ = o.box_;
189  }
190  return *this;
191  }
200  inline
202  {
203  return *pos_;
204  }
205 
206  inline
208  {
209  return &(operator*());
210  }
211 
216 
222  inline
223  self& operator++()
224  {
225  if(x4_ < (box_.last_back_bottom_right())[3])
226  {
227  this->x4_++;
228  this->pos_+=N;
229  }
230  else if(x3_ < (box_.last_back_bottom_right())[2])
231  {
232  this->x3_++;
233  this->x4_ = (box_.first_front_upper_left())[3];
234  this->pos_+= N * (static_cast<int>(cont4d_->cols()) - box_.width() + 1) ;
235  }
236  else if(x2_ < (box_.last_back_bottom_right())[1]){
237  this->x2_++;
238  this->x3_ = (box_.first_front_upper_left())[2];
239  this->x4_ = (box_.first_front_upper_left())[3];
240  this->pos_ += N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows()) -
241  box_.height() + 1) - box_.width() + 1 );
242  }else if(x1_ < (box_.last_back_bottom_right())[0]){
243  this->x1_++;
244  this->x2_ = (box_.first_front_upper_left())[1];
245  this->x3_ = (box_.first_front_upper_left())[2];
246  this->x4_ = (box_.first_front_upper_left())[3];
247  this->pos_ += N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows())
248  *(static_cast<int>(cont4d_->slices()) - box_.depth() + 1)
249  - box_.height() + 1) - box_.width() + 1 );
250  }
251  else{
252  this->x1_ = (box_.last_back_bottom_right())[0] + 1;
253  this->x2_ = (box_.last_back_bottom_right())[1] + 1;
254  this->x3_ = (box_.last_back_bottom_right())[2] + 1;
255  this->x4_ = (box_.last_back_bottom_right())[3] + 1;
256  this->pos_ += N * (static_cast<int>(cont4d_->cols()) * (static_cast<int>(cont4d_->rows())
257  * (static_cast<int>(cont4d_->slices()) + 1) + 1) + 1);
258  }
259  return *this;
260  }
261 
266  inline
267  self operator++(int)
268  {
269  self tmp = *this;
270  ++(*this);
271  return tmp;
272  }
273 
285  inline
286  self& operator--()
287  {
288  if(x4_ > (box_.first_front_upper_left())[3])
289  {
290  this->x4_--;
291  this->pos_-=N;
292  }
293  else if (x3_ > (box_.first_front_upper_left())[2])
294  {
295  this->x4_ = (box_.last_back_bottom_right())[3];
296  this->x3_--;
297  this->pos_ -= N * (static_cast<int>(cont4d_->cols()) - box_.width() + 1);
298  }
299  else if (x2_ > (box_.first_front_upper_left())[1])
300  {
301  this->x4_ = (box_.last_back_bottom_right())[3];
302  this->x3_ = (box_.last_back_bottom_right())[2];
303  this->x2_--;
304  this->pos_ -= N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows()) -
305  box_.height() + 1) - box_.width() + 1);
306  }
307  else if (x1_ > (box_.first_front_upper_left())[0])
308  {
309  this->x4_ = (box_.last_back_bottom_right())[3];
310  this->x3_ = (box_.last_back_bottom_right())[2];
311  this->x2_ = (box_.last_back_bottom_right())[1];
312  this->x1_--;
313  this->pos_ -= N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows())
314  * (static_cast<int>(cont4d_->slices()) - box_.depth() + 1)
315  - box_.height() + 1) - box_.width() + 1);
316  }
317  else{
318  this->x4_ = (box_.first_front_upper_left())[3] - 1;
319  this->x3_ = (box_.first_front_upper_left())[2] - 1;
320  this->x2_ = (box_.first_front_upper_left())[1] - 1;
321  this->x1_ = (box_.first_front_upper_left())[0] - 1;
322  this->pos_ -= N * (static_cast<int>(cont4d_->cols()) * (static_cast<int>(cont4d_->rows())
323  * (static_cast<int>(cont4d_->slices()) + 1) + 1) + 1);
324  }
325  return *this;
326  }
327 
333  inline
334  self operator--(int)
335  {
336  self tmp = *this;
337  --(*this);
338  return tmp;
339  }
340 
354  inline
355  friend bool operator==(const self& i1,
356  const self& i2)
357  {
358 
359  return ( (i1.cont4d_ == i2.cont4d_) && (i1.pos_ == i2.pos_)
360  && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) && (i1.x3_ == i2.x3_)
361  && (i1.x4_ == i2.x4_) && (i1.cp_ == i2.cp_));
362  }
363 
370  inline
371  friend bool operator!=(const self& i1,
372  const self& i2)
373  {
374  return ( (i1.cont4d_ != i2.cont4d_) || (i1.pos_ != i2.pos_)
375  || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_) || (i1.x3_ != i2.x3_)
376  || (i1.x4_ != i2.x4_) || (i1.cp_ != i2.cp_));
377  }
378 
392  inline
393  friend bool operator<(const self& i1,
394  const self& i2)
395  {
396 
397  return ( i1.pos_ < i2.pos_);
398  }
399 
406  inline
407  friend bool operator>(const self& i1,
408  const self& i2)
409  {
410  return (i2 < i1);
411  }
412 
419  inline
420  friend bool operator<=(const self& i1,
421  const self& i2)
422  {
423 
424  return !(i2 < i1);
425  }
426 
433  inline
434  friend bool operator>=(const self& i1,
435  const self& i2)
436  {
437 
438  return !(i1 < i2);
439  }
454  inline
455  self& operator+=(const difference_type& d)
456  {
457  this->x1_ += d.dx1();
458  this->x2_ += d.dx2();
459  this->x3_ += d.dx3();
460  this->x4_ += d.dx4();
461  this->pos_ = &(*cont4d_)[0][0][0][0][this->cp_] +
462  (this->x1_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) *
463  static_cast<int>(cont4d_->slices()) * N) +
464  (this->x2_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) * N) +
465  (this->x3_ * static_cast<int>(cont4d_->cols()) * N) +
466  this->x4_ * N;
467  return *this;
468  }
469 
470 
471 
479  inline
480  self& operator-=(const difference_type& d)
481  {
482  this->x1_ -= d.dx1();
483  this->x2_ -= d.dx2();
484  this->x3_ -= d.dx3();
485  this->x4_ -= d.dx4();
486  this->pos_ = &(*cont4d_)[0][0][0][0][this->cp_] +
487  (this->x1_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) *
488  static_cast<int>(cont4d_->slices()) * N) +
489  (this->x2_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) * N) +
490  (this->x3_ * static_cast<int>(cont4d_->cols()) * N) +
491  this->x4_ * N;
492  return *this;
493  }
494 
502  inline
503  self operator+(const difference_type& d)
504  {
505  self tmp = *this;
506  tmp += d;
507  return tmp;
508  }
509 
517  inline
518  self operator-(const difference_type& d)
519  {
520  self tmp = *this;
521  tmp -= d;
522  return tmp;
523  }
524 
525 
533  inline
534  friend difference_type operator-(const self& i1,
535  const self& i2)
536  {
537  return difference_type(static_cast<int>(i1.x1_ - i2.x1_),static_cast<int>(i1.x2_ - i2.x2_),
538  static_cast<int>(i1.x3_ - i2.x3_),static_cast<int>(i1.x4_ - i2.x4_));
539  }
540 
541 
550  inline
552  {
553  assert( (this->x1_+d.dx1()) < cont4d_->dim1() );
554  assert( (this->x2_+d.dx2()) < cont4d_->dim2() );
555  assert( (this->x3_+d.dx3()) < cont4d_->dim3() );
556  assert( (this->x4_+d.dx4()) < cont4d_->dim4() );
557  return (*cont4d_)[this->x1_+d.dx1()][this->x2_+d.dx2()][this->x3_+d.dx3()][this->x4_+d.dx4()][cp_];
558  }
559 
568  inline
569  typename MultiComponentContainer4D::component_slab_iterator slab_begin(size_type slice, size_type row,
570  size_type col)
571  {
572  return cont4d_->slab_begin(this->cp_,
573  this->box_.first_front_upper_left()[1] + slice,
574  this->box_.first_front_upper_left()[2] + row,
575  this->box_.first_front_upper_left()[3] + col)
576  + this->box_.first_front_upper_left()[0];
577  }
578 
579 
588  inline
589  typename MultiComponentContainer4D::component_slab_iterator slab_end(size_type slice, size_type row,
590  size_type col)
591  {
592  return this->slab_begin(slice,row,col) + this->box_.duration();
593  }
594 
603  inline
604  typename MultiComponentContainer4D::component_slice_iterator slice_begin(size_type slab, size_type row,
605  size_type col)
606  {
607  return cont4d_->slice_begin(this->cp_,
608  this->box_.first_front_upper_left()[0] + slab,
609  this->box_.first_front_upper_left()[2] + row,
610  this->box_.first_front_upper_left()[3] + col)
611  + this->box_.first_front_upper_left()[1];
612  }
613 
614 
623  inline
624  typename MultiComponentContainer4D::component_slice_iterator slice_end(size_type slab, size_type row,
625  size_type col)
626  {
627  return this->slice_begin(slab,row,col) + this->box_.depth();
628  }
629 
638  inline
639  typename MultiComponentContainer4D::component_row_iterator row_begin(size_type slab, size_type slice,
640  size_type row)
641  {
642  return cont4d_->row_begin(this->cp_,
643  this->box_.first_front_upper_left()[0] + slab,
644  this->box_.first_front_upper_left()[1] + slice,
645  this->box_.first_front_upper_left()[2] + row)
646  + this->box_.first_front_upper_left()[3];
647  }
648 
649 
658  inline
659  typename MultiComponentContainer4D::component_row_iterator row_end(size_type slab, size_type slice,
660  size_type row)
661  {
662  return this->row_begin(slab,slice,row) + this->box_.width();
663  }
664 
665 
674  inline
675  typename MultiComponentContainer4D::component_col_iterator col_begin(size_type slab, size_type slice,
676  size_type col)
677  {
678  return cont4d_->col_begin(this->cp_,
679  this->box_.first_front_upper_left()[0] + slab,
680  this->box_.first_front_upper_left()[1] + slice,
681  this->box_.first_front_upper_left()[3] + col)
682  + this->box_.first_front_upper_left()[2];
683  }
684 
685 
694  inline
695  typename MultiComponentContainer4D::component_col_iterator col_end(size_type slab, size_type slice,
696  size_type col)
697  {
698  return this->col_begin(slab,slice,col) + this->box_.height();
699  }
700 
708 
713  inline
714  int x1() const
715  {
716  return this->x1_;
717  }
718 
723  inline
724  int t() const
725  {
726  return this->x1_;
727  }
728 
733  inline
734  int x2() const
735  {
736  return this->x2_;
737  }
738 
743  inline
744  int k() const
745  {
746  return this->x2_;
747  }
748 
753  inline
754  int x3() const
755  {
756  return this->x3_;
757  }
758 
763  inline
764  int i() const
765  {
766  return this->x3_;
767  }
768 
773  inline
774  int x4() const
775  {
776  return this->x4_;
777  }
778 
783  inline
784  int j() const
785  {
786  return this->x4_;
787  }
792  inline
793  size_type cp() const
794  {
795  return this->cp_;
796  }
797 
798 
802 private:
803  MultiComponentContainer4D* cont4d_; // pointer to the 4d container
804  pointer pos_; // linear position within the container
805  int x1_; // first index position
806  int x2_; // second index position
807  int x3_; // Third index position
808  int x4_; // Fourth index position
809  size_type cp_; // component index number
810  Box4d<int> box_; // box to iterate
811 };
812 
813 
832 template <class MultiComponentContainer4D, std::size_t N>
834 {
835 
836 public:
837 
838  //typedef std::random_access_iterator_tag iterator_category;
840  typedef typename MultiComponentContainer4D::value_type Block;
841  typedef typename Block::value_type value_type;
843  typedef value_type const * pointer;
844  typedef value_type const & reference;
845 
847 
848  typedef typename MultiComponentContainer4D::size_type size_type;
853 
859  cont4d_(0),pos_(0),x1_(0),x2_(0),x3_(0),x4_(0),cp_(0),box_(0,0,0,0,0)
860  {}
861 
869  const_component_iterator4d_box(MultiComponentContainer4D* c, std::size_t cp,
870  const Box4d<int>& b):
871  cont4d_(c),pos_(&(*c)[0][0][0][0][cp] +
872  ((b.first_front_upper_left())[0] * static_cast<int>(c->slices()) * static_cast<int>(c->rows())
873  * static_cast<int>(c->cols()) * N) +
874  ((b.first_front_upper_left())[1] * static_cast<int>(c->rows()) * static_cast<int>(c->cols()) * N) +
875  ((b.first_front_upper_left())[2] * static_cast<int>(c->cols()) * N) +
876  ((b.first_front_upper_left())[3] * N)),
877  x1_((b.first_front_upper_left())[0]),x2_((b.first_front_upper_left())[1]),
878  x3_((b.first_front_upper_left())[2]),x4_((b.first_front_upper_left())[3]),cp_(cp),box_(b)
879  {}
880 
887  cont4d_(o.cont4d_),pos_(o.pos_),x1_(o.x1_),x2_(o.x2_),x3_(o.x3_),x4_(o.x4_),cp_(o.cp_),box_(o.box_)
888  {}
889 
904  self& operator=(const self& o)
905  {
906  if(this != &o)
907  {
908  this->cont4d_ = o.cont4d_;
909  this->pos_ = o.pos_;
910  this->x1_ = o.x1_;
911  this->x2_ = o.x2_;
912  this->x3_ = o.x3_;
913  this->x4_ = o.x4_;
914  this->cp_ = o.cp_;
915  this->box_ = o.box_;
916  }
917  return *this;
918  }
927  inline
929  {
930  return *pos_;
931  }
932 
933  inline
935  {
936  return &(operator*());
937  }
938 
943 
949  inline
950  self& operator++()
951  {
952  if(x4_ < (box_.last_back_bottom_right())[3])
953  {
954  this->x4_++;
955  this->pos_+=N;
956  }
957  else if(x3_ < (box_.last_back_bottom_right())[2])
958  {
959  this->x3_++;
960  this->x4_ = (box_.first_front_upper_left())[3];
961  this->pos_+= N * (static_cast<int>(cont4d_->cols()) - box_.width() + 1) ;
962  }
963  else if(x2_ < (box_.last_back_bottom_right())[1]){
964  this->x2_++;
965  this->x3_ = (box_.first_front_upper_left())[2];
966  this->x4_ = (box_.first_front_upper_left())[3];
967  this->pos_ += N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows()) -
968  box_.height() + 1) - box_.width() + 1 );
969  }else if(x1_ < (box_.last_back_bottom_right())[0]){
970  this->x1_++;
971  this->x2_ = (box_.first_front_upper_left())[1];
972  this->x3_ = (box_.first_front_upper_left())[2];
973  this->x4_ = (box_.first_front_upper_left())[3];
974  this->pos_ += N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows())
975  *(static_cast<int>(cont4d_->slices()) - box_.depth() + 1)
976  - box_.height() + 1) - box_.width() + 1 );
977  }
978  else{
979  this->x1_ = (box_.last_back_bottom_right())[0] + 1;
980  this->x2_ = (box_.last_back_bottom_right())[1] + 1;
981  this->x3_ = (box_.last_back_bottom_right())[2] + 1;
982  this->x4_ = (box_.last_back_bottom_right())[3] + 1;
983  this->pos_ += N * (static_cast<int>(cont4d_->cols()) * (static_cast<int>(cont4d_->rows())
984  * (static_cast<int>(cont4d_->slices()) + 1) + 1) + 1);
985  }
986  return *this;
987  }
988 
993  inline
994  self operator++(int)
995  {
996  self tmp = *this;
997  ++(*this);
998  return tmp;
999  }
1000 
1012  inline
1013  self& operator--()
1014  {
1015  if(x4_ > (box_.first_front_upper_left())[3])
1016  {
1017  this->x4_--;
1018  this->pos_-=N;
1019  }
1020  else if (x3_ > (box_.first_front_upper_left())[2])
1021  {
1022  this->x4_ = (box_.last_back_bottom_right())[3];
1023  this->x3_--;
1024  this->pos_ -= N * (static_cast<int>(cont4d_->cols()) - box_.width() + 1);
1025  }
1026  else if (x2_ > (box_.first_front_upper_left())[1])
1027  {
1028  this->x4_ = (box_.last_back_bottom_right())[3];
1029  this->x3_ = (box_.last_back_bottom_right())[2];
1030  this->x2_--;
1031  this->pos_ -= N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows()) -
1032  box_.height() + 1) - box_.width() + 1);
1033  }
1034  else if (x1_ > (box_.first_front_upper_left())[0])
1035  {
1036  this->x4_ = (box_.last_back_bottom_right())[3];
1037  this->x3_ = (box_.last_back_bottom_right())[2];
1038  this->x2_ = (box_.last_back_bottom_right())[1];
1039  this->x1_--;
1040  this->pos_ -= N * (static_cast<int>(cont4d_->cols())*(static_cast<int>(cont4d_->rows())
1041  * (static_cast<int>(cont4d_->slices()) - box_.depth() + 1)
1042  - box_.height() + 1) - box_.width() + 1);
1043  }
1044  else{
1045  this->x4_ = (box_.first_front_upper_left())[3] - 1;
1046  this->x3_ = (box_.first_front_upper_left())[2] - 1;
1047  this->x2_ = (box_.first_front_upper_left())[1] - 1;
1048  this->x1_ = (box_.first_front_upper_left())[0] - 1;
1049  this->pos_ -= N * (static_cast<int>(cont4d_->cols()) * (static_cast<int>(cont4d_->rows())
1050  * (static_cast<int>(cont4d_->slices()) + 1) + 1) + 1);
1051  }
1052  return *this;
1053  }
1054 
1060  inline
1061  self operator--(int)
1062  {
1063  self tmp = *this;
1064  --(*this);
1065  return tmp;
1066  }
1067 
1081  inline
1082  friend bool operator==(const self& i1,
1083  const self& i2)
1084  {
1085 
1086  return ( (i1.cont4d_ == i2.cont4d_) && (i1.pos_ == i2.pos_)
1087  && (i1.x1_ == i2.x1_) && (i1.x2_ == i2.x2_) && (i1.x3_ == i2.x3_)
1088  && (i1.x4_ == i2.x4_) && (i1.cp_ == i2.cp_));
1089  }
1090 
1097  inline
1098  friend bool operator!=(const self& i1,
1099  const self& i2)
1100  {
1101  return ( (i1.cont4d_ != i2.cont4d_) || (i1.pos_ != i2.pos_)
1102  || (i1.x1_ != i2.x1_) || (i1.x2_ != i2.x2_) || (i1.x3_ != i2.x3_)
1103  || (i1.x4_ != i2.x4_) || (i1.cp_ != i2.cp_));
1104  }
1105 
1119  inline
1120  friend bool operator<(const self& i1,
1121  const self& i2)
1122  {
1123 
1124  return ( i1.pos_ < i2.pos_);
1125  }
1126 
1133  inline
1134  friend bool operator>(const self& i1,
1135  const self& i2)
1136  {
1137  return (i2 < i1);
1138  }
1139 
1146  inline
1147  friend bool operator<=(const self& i1,
1148  const self& i2)
1149  {
1150 
1151  return !(i2 < i1);
1152  }
1153 
1160  inline
1161  friend bool operator>=(const self& i1,
1162  const self& i2)
1163  {
1164 
1165  return !(i1 < i2);
1166  }
1181  inline
1182  self& operator+=(const difference_type& d)
1183  {
1184  this->x1_ += d.dx1();
1185  this->x2_ += d.dx2();
1186  this->x3_ += d.dx3();
1187  this->x4_ += d.dx4();
1188  this->pos_ = &(*cont4d_)[0][0][0][0][this->cp_] +
1189  (this->x1_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) *
1190  static_cast<int>(cont4d_->slices()) * N) +
1191  (this->x2_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) * N) +
1192  (this->x3_ * static_cast<int>(cont4d_->cols()) * N) +
1193  this->x4_ * N;
1194  return *this;
1195  }
1196 
1197 
1198 
1206  inline
1207  self& operator-=(const difference_type& d)
1208  {
1209  this->x1_ -= d.dx1();
1210  this->x2_ -= d.dx2();
1211  this->x3_ -= d.dx3();
1212  this->x4_ -= d.dx4();
1213  this->pos_ = &(*cont4d_)[0][0][0][0][this->cp_] +
1214  (this->x1_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) *
1215  static_cast<int>(cont4d_->slices()) * N) +
1216  (this->x2_ * static_cast<int>(cont4d_->cols()) * static_cast<int>(cont4d_->rows()) * N) +
1217  (this->x3_ * static_cast<int>(cont4d_->cols()) * N) +
1218  this->x4_ * N;
1219  return *this;
1220  }
1221 
1229  inline
1231  {
1232  self tmp = *this;
1233  tmp += d;
1234  return tmp;
1235  }
1236 
1244  inline
1246  {
1247  self tmp = *this;
1248  tmp -= d;
1249  return tmp;
1250  }
1251 
1252 
1260  inline
1261  friend difference_type operator-(const self& i1,
1262  const self& i2)
1263  {
1264  return difference_type(int(i1.x1_ - i2.x1_),int(i1.x2_ - i2.x2_),int(i1.x3_ - i2.x3_)
1265  ,int(i1.x4_ - i2.x4_));
1266  }
1267 
1268 
1277  inline
1279  {
1280  assert( (this->x1_+d.dx1()) < cont4d_->dim1() );
1281  assert( (this->x2_+d.dx2()) < cont4d_->dim2() );
1282  assert( (this->x3_+d.dx3()) < cont4d_->dim3() );
1283  assert( (this->x4_+d.dx4()) < cont4d_->dim4() );
1284  return (*cont4d_)[this->x1_+d.dx1()][this->x2_+d.dx2()][this->x3_+d.dx3()][this->x4_+d.dx4()][cp_];
1285  }
1286 
1295  inline
1296  typename MultiComponentContainer4D::const_component_slab_iterator slab_begin(size_type slice, size_type row,
1297  size_type col)
1298  {
1299  return cont4d_->slab_begin(this->cp_,
1300  this->box_.first_front_upper_left()[1] + slice,
1301  this->box_.first_front_upper_left()[2] + row,
1302  this->box_.first_front_upper_left()[3] + col)
1303  + this->box_.first_front_upper_left()[0];
1304  }
1305 
1306 
1315  inline
1316  typename MultiComponentContainer4D::const_component_slab_iterator slab_end(size_type slice, size_type row,
1317  size_type col)
1318  {
1319  return this->slab_begin(slice,row,col) + this->box_.duration();
1320  }
1321 
1330  inline
1331  typename MultiComponentContainer4D::const_component_slice_iterator slice_begin(size_type slab, size_type row,
1332  size_type col)
1333  {
1334  return cont4d_->slice_begin(this->cp_,
1335  this->box_.first_front_upper_left()[0] + slab,
1336  this->box_.first_front_upper_left()[2] + row,
1337  this->box_.first_front_upper_left()[3] + col)
1338  + this->box_.first_front_upper_left()[1];
1339  }
1340 
1341 
1350  inline
1351  typename MultiComponentContainer4D::const_component_slice_iterator slice_end(size_type slab, size_type row,
1352  size_type col)
1353  {
1354  return this->slice_begin(slab,row,col) + this->box_.depth();
1355  }
1356 
1365  inline
1366  typename MultiComponentContainer4D::const_component_row_iterator row_begin(size_type slab, size_type slice,
1367  size_type row)
1368  {
1369  return cont4d_->row_begin(this->cp_,
1370  this->box_.first_front_upper_left()[0] + slab,
1371  this->box_.first_front_upper_left()[1] + slice,
1372  this->box_.first_front_upper_left()[2] + row)
1373  + this->box_.first_front_upper_left()[3];
1374  }
1375 
1376 
1385  inline
1386  typename MultiComponentContainer4D::const_component_row_iterator row_end(size_type slab, size_type slice,
1387  size_type row)
1388  {
1389  return this->row_begin(slab,slice,row) + this->box_.width();
1390  }
1391 
1392 
1401  inline
1402  typename MultiComponentContainer4D::const_component_col_iterator col_begin(size_type slab, size_type slice,
1403  size_type col)
1404  {
1405  return cont4d_->col_begin(this->cp_,
1406  this->box_.first_front_upper_left()[0] + slab,
1407  this->box_.first_front_upper_left()[1] + slice,
1408  this->box_.first_front_upper_left()[3] + col)
1409  + this->box_.first_front_upper_left()[2];
1410  }
1411 
1412 
1421  inline
1422  typename MultiComponentContainer4D::const_component_col_iterator col_end(size_type slab, size_type slice,
1423  size_type col)
1424  {
1425  return this->col_begin(slab,slice,col) + this->box_.height();
1426  }
1427 
1439  inline
1440  int x1() const
1441  {
1442  return this->x1_;
1443  }
1444 
1449  inline
1450  int t() const
1451  {
1452  return this->x1_;
1453  }
1454 
1455 
1460  inline
1461  int x2() const
1462  {
1463  return this->x2_;
1464  }
1465 
1470  inline
1471  int k() const
1472  {
1473  return this->x2_;
1474  }
1475 
1480  inline
1481  int x3() const
1482  {
1483  return this->x3_;
1484  }
1485 
1490  inline
1491  int i() const
1492  {
1493  return this->x3_;
1494  }
1495 
1500  inline
1501  int x4() const
1502  {
1503  return this->x4_;
1504  }
1505 
1510  inline
1511  int j() const
1512  {
1513  return this->x4_;
1514  }
1515 
1520  inline
1521  size_type cp() const
1522  {
1523  return this->cp_;
1524  }
1525 
1526 
1530 private:
1531  MultiComponentContainer4D* cont4d_; // pointer to the 4d container
1532  pointer pos_; // linear position within the container
1533  int x1_; // first index position
1534  int x2_; // second index position
1535  int x3_; // third index position
1536  int x4_; // fourth index position
1537  size_type cp_; // component index number
1538  Box4d<int> box_; // box to iterate
1539 };
1540 
1541 }//slip::
1542 
1543 #endif //SLIP_COMPONENT_ITERATOR4D_BOX_HPP
friend bool operator<(const self &i1, const self &i2)
< operator.
friend bool operator>(const self &i1, const self &i2)
operator.
MultiComponentContainer4D::const_component_slab_iterator slab_end(size_type slice, size_type row, size_type col)
const_component_iterator4d_box element assignment operator.
void first_front_upper_left(slip::Point< CoordType, 4 >)
Accessor/Mutator of the first_front_upper_left point (p1) of Box4d.
Definition: Box4d.hpp:364
self & operator=(const self &o)
Assign a const_component_iterator4d_box.
friend bool operator>(const self &i1, const self &i2)
operator.
MultiComponentContainer4D::component_row_iterator row_begin(size_type slab, size_type slice, size_type row)
component_iterator4d_box element assignment operator.
self operator--(int)
Postdecrement a component_iterator4d_box. Iterate to the previous location inside the Box4d...
MultiComponentContainer4D::const_component_slice_iterator slice_begin(size_type slab, size_type row, size_type col)
const_component_iterator4d_box element assignment operator.
self operator+(const difference_type &d)
const_component_iterator4d_box addition.
MultiComponentContainer4D::const_component_col_iterator col_end(size_type slab, size_type slice, size_type col)
const_component_iterator4d_box element assignment operator.
MultiComponentContainer4D::const_component_row_iterator row_begin(size_type slab, size_type slice, size_type row)
const_component_iterator4d_box element assignment operator.
friend difference_type operator-(const self &i1, const self &i2)
const_component_iterator4d_box difference operator.
CoordType depth() const
compute the depth of the Box4d (second dimension size).
Definition: Box4d.hpp:428
int k() const
Access to the second index of the current const_component_iterator4d_box.
MultiComponentContainer4D::component_slab_iterator slab_begin(size_type slice, size_type row, size_type col)
component_iterator4d_box element assignment operator.
self operator--(int)
Postdecrement a const_component_iterator4d_box. Iterate to the previous location inside the Box4d...
self & operator++()
Preincrement a component_iterator4d_box. Iterate to the next location inside the Box4d.
MultiComponentContainer4D::const_component_slice_iterator slice_end(size_type slab, size_type row, size_type col)
const_component_iterator4d_box element assignment operator.
MultiComponentContainer4D::value_type Block
friend bool operator<(const self &i1, const self &i2)
< operator.
Provides a class to tag SLIP iterators.
This is some iterator to iterate a 4d MultiComponentContainer into a Box area defined by the indices ...
self operator++(int)
Postincrement a component_iterator4d_box. Iterate to the next location inside the Box4d...
Provides a class to modelize 4d points.
size_type cp() const
Access to the component index of the current const_component_iterator4d_box.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
size_type cp() const
Access to the component index of the current component_iterator4d_box.
self operator++(int)
Postincrement a const_component_iterator4d_box. Iterate to the next location inside the Box4d...
MultiComponentContainer4D::component_slice_iterator slice_end(size_type slab, size_type row, size_type col)
component_iterator4d_box element assignment operator.
self & operator=(const self &o)
Assign a component_iterator4d_box.
int x2() const
Access to the second index of the current component_iterator4d_box.
int x3() const
Access to the third index of the current component_iterator4d_box.
int x2() const
Access to the second index of the current const_component_iterator4d_box.
int x4() const
Access to the fourth index of the current component_iterator4d_box.
void dx2(const CoordType &dx)
Accessor of the second coordinate of DPoint4d.
Definition: DPoint4d.hpp:281
int i() const
Access to the third index of the current const_component_iterator4d_box.
void dx1(const CoordType &dx)
Accessor of the first coordinate of DPoint4d.
Definition: DPoint4d.hpp:269
Difference of Point4D class, specialization of DPoint<CoordType,DIM> with DIM = 4.
Definition: DPoint4d.hpp:99
int x1() const
Access to the first index of the current component_iterator4d_box.
Provides a class to modelize the difference of 4d points.
MultiComponentContainer4D::const_component_slab_iterator slab_begin(size_type slice, size_type row, size_type col)
const_component_iterator4d_box element assignment operator.
int x3() const
Access to the third index of the current const_component_iterator4d_box.
reference operator[](difference_type d) const
const_component_iterator4d_box element assignment operator. Equivalent to *(i + d) = t...
void last_back_bottom_right(slip::Point< CoordType, 4 >)
Accessor/Mutator of the last_back_bottom_right point (p2) of Box4d.
Definition: Box4d.hpp:376
int t() const
Access to the first index of the current const_component_iterator4d_box.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
MultiComponentContainer4D::component_slab_iterator slab_end(size_type slice, size_type row, size_type col)
component_iterator4d_box element assignment operator.
MultiComponentContainer4D::component_slice_iterator slice_begin(size_type slab, size_type row, size_type col)
component_iterator4d_box element assignment operator.
MultiComponentContainer4D::component_col_iterator col_end(size_type slab, size_type slice, size_type col)
component_iterator4d_box element assignment operator.
reference operator*()
Dereference assignment operator. Returns the element that the current component_iterator4d_box i poin...
component_iterator4d_box()
Constructs a component_iterator4d_box.
const_component_iterator4d_box(const self &o)
Constructs a copy of the const_component_iterator4d_box o.
void dx3(const CoordType &dx)
Accessor of the third coordinate of DPoint4d.
Definition: DPoint4d.hpp:293
MultiComponentContainer4D::value_type Block
self operator-(const difference_type &d)
component_iterator4d_box substraction.
friend bool operator<=(const self &i1, const self &i2)
<= operator.
self & operator--()
Predecrement a component_iterator4d_box. Iterate to the previous location inside the Box4d...
component_iterator4d_box(MultiComponentContainer4D *c, std::size_t cp, const Box4d< int > &b)
Constructs a component_iterator4d_box.
self & operator++()
Preincrement a const_component_iterator4d_box. Iterate to the next location inside the Box4d...
MultiComponentContainer4D::size_type size_type
reference operator*() const
Dereference assignment operator. Returns the element that the current const_component_iterator4d_box ...
const_component_iterator4d_box()
Constructs a const_component_iterator4d_box.
CoordType width() const
compute the width of the Box4d (fourth dimension size).
Definition: Box4d.hpp:420
MultiComponentContainer4D::const_component_col_iterator col_begin(size_type slab, size_type slice, size_type col)
const_component_iterator4d_box element assignment operator.
self & operator+=(const difference_type &d)
const_component_iterator4d_box addition.
Provides a class to manipulate 4d box.
friend bool operator>=(const self &i1, const self &i2)
>= operator.
void dx4(const CoordType &dx)
Accessor of the fourth coordinate of DPoint4d.
Definition: DPoint4d.hpp:305
friend bool operator==(const self &i1, const self &i2)
Equality operator.
int i() const
Access to the third index of the current component_iterator4d_box.
std::random_access_iterator4d_tag iterator_category
int j() const
Access to the fourth index of the current component_iterator4d_box.
MultiComponentContainer4D::component_row_iterator row_end(size_type slab, size_type slice, size_type row)
component_iterator4d_box element assignment operator.
MultiComponentContainer4D::component_col_iterator col_begin(size_type slab, size_type slice, size_type col)
component_iterator4d_box element assignment operator.
reference operator[](difference_type d)
component_iterator4d_box element assignment operator. Equivalent to *(i + d) = t. ...
friend bool operator<=(const self &i1, const self &i2)
<= operator.
CoordType duration() const
compute the duration of the Box4d (first dimension size).
Definition: Box4d.hpp:432
int j() const
Access to the fourth index of the current const_component_iterator4d_box.
self & operator-=(const difference_type &d)
component_iterator4d_box substraction.
self & operator-=(const difference_type &d)
const_component_iterator4d_box substraction.
self operator-(const difference_type &d)
const_component_iterator4d_box substraction.
friend bool operator!=(const self &i1, const self &i2)
Inequality operator.
std::random_access_iterator4d_tag iterator_category
const_component_iterator4d_box(MultiComponentContainer4D *c, std::size_t cp, const Box4d< int > &b)
Constructs a const_component_iterator4d_box.
component_iterator4d_box(const self &o)
Constructs a copy of the component_iterator4d_box o.
int t() const
Access to the first index of the current component_iterator4d_box.
friend difference_type operator-(const self &i1, const self &i2)
component_iterator4d_box difference operator.
CoordType height() const
compute the height of the Box4d (third dimension size).
Definition: Box4d.hpp:424
friend bool operator==(const self &i1, const self &i2)
Equality operator.
self & operator--()
Predecrement a const_component_iterator4d_box. Iterate to the previous location inside the Box4d...
int k() const
Access to the second index of the current component_iterator4d_box.
self & operator+=(const difference_type &d)
component_iterator4d_box addition.
MultiComponentContainer4D::const_component_row_iterator row_end(size_type slab, size_type slice, size_type row)
const_component_iterator4d_box element assignment operator.
int x4() const
Access to the fourth index of the current const_component_iterator4d_box.
int x1() const
Access to the first index of the current const_component_iterator4d_box.
self operator+(const difference_type &d)
component_iterator4d_box addition.
MultiComponentContainer4D::size_type size_type
This is some iterator to iterate a 4d MultiComponentContainer into a Box area defined by the indices ...