SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
component_iterator3d_range.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 
67 
68 
78 #ifndef SLIP_COMPONENT_ITERATOR3d_RANGE_HPP
79 #define SLIP_COMPONENT_ITERATOR3d_RANGE_HPP
80 
81 #include <iterator>
82 #include <cassert>
83 
84 #include "Point3d.hpp"
85 #include "DPoint3d.hpp"
86 #include "Range.hpp"
87 #include "iterator_types.hpp"
88 
89 namespace slip
90 {
110 template <class MultiComponentContainer3d, std::size_t N>
112 {
113 public:
114  //typedef std::random_access_iterator_tag iterator_category;
116  typedef typename MultiComponentContainer3d::value_type Block;
117  typedef typename Block::value_type value_type;
119  typedef value_type* pointer;
121 
123 
124  typedef typename MultiComponentContainer3d::size_type size_type;
129 
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)
136  {}
137 
150  component_iterator3d_range(MultiComponentContainer3d* c, std::size_t cp,
151  const slip::Range<int>& r1,
152  const slip::Range<int>& r2,
153  const slip::Range<int>& r3):
154  cont3d_(c),
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)
160  {}
161 
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_)
170  {}
171 
186  self& operator=(const self& o)
187  {
188  if(this != &o)
189  {
190  this->cont3d_ = o.cont3d_;
191  this->pos_ = o.pos_;
192  this->x1_ = o.x1_;
193  this->x2_ = o.x2_;
194  this->x3_ = o.x3_;
195  this->cp_ = o.cp_;
196  this->range_x1_ = o.range_x1_;
197  this->range_x2_ = o.range_x2_;
198  this->range_x3_ = o.range_x3_;
199  }
200  return *this;
201  }
210  inline
212  {
213  return *pos_;
214  }
215 
216  inline
218  {
219  return &(operator*());
220  }
221 
226 
231  inline
232  self& operator++()
233  {
234  if( (x3_ < static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.stride()))){
235  this->x3_+= range_x3_.stride();
236  this->pos_+= range_x3_.stride()*N;
237  }
238  else if(x2_ < static_cast<int>(range_x2_.start() + range_x2_.iterations() * range_x2_.stride()))
239  {
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);
245  }
246  else if(x1_ < static_cast<int>(range_x1_.start() + range_x1_.iterations() * range_x1_.stride())){
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);
253  }
254  else{
255  this->x1_ = static_cast<int>(range_x1_.start() + (range_x1_.iterations() + 1) * range_x1_.stride());
256  this->x2_ = static_cast<int>(range_x2_.start() + (range_x2_.iterations() + 1) * range_x2_.stride());
257  this->x3_ = static_cast<int>(range_x3_.start() + (range_x3_.iterations() + 1) * range_x3_.stride());
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);
261  }
262 
263  return *this;
264  }
265 
271  inline
272  self operator++(int)
273  {
274  self tmp = *this;
275  ++(*this);
276  return tmp;
277  }
278 
290  inline
291  self& operator--()
292  {
293  if(x3_ > static_cast<int>(range_x1_.stop() - range_x1_.iterations() * range_x1_.stride()))
294  {
295  this->x3_ -= range_x3_.stride();
296  this->pos_ -= N * range_x3_.stride();
297  }
298  else if (x2_ > static_cast<int>(range_x2_.stop() - range_x2_.iterations() * range_x2_.stride()))
299  {
300  this->x3_ = static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.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);
305  }
306  else if (x1_ > static_cast<int>(range_x1_.stop() - range_x1_.iterations() * range_x1_.stride()))
307  {
308  this->x3_ = static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.stride());
309  this->x2_ = static_cast<int>(range_x2_.start() + range_x2_.iterations() * range_x2_.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);
314  }
315  else{
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);
322  }
323 
324  return *this;
325  }
326 
332  inline
333  self operator--(int)
334  {
335  self tmp = *this;
336  --(*this);
337  return tmp;
338  }
339 
353  inline
354  friend bool operator==(const self& i1,
355  const self& i2)
356  {
357 
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_));
361  }
362 
369  inline
370  friend bool operator!=(const self& i1,
371  const self& i2)
372  {
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_));
376  }
389  inline
390  friend bool operator<(const self& i1,
391  const self& i2)
392  {
393 
394  return ( i1.pos_ < i2.pos_);
395  }
396 
403  inline
404  friend bool operator>(const self& i1,
405  const self& i2)
406  {
407 
408  return (i2 < i1);
409  }
410 
417  inline
418  friend bool operator<=(const self& i1,
419  const self& i2)
420  {
421 
422  return !(i2 < i1);
423  }
424 
431  inline
432  friend bool operator>=(const self& i1,
433  const self& i2)
434  {
435 
436  return !(i1 < i2);
437  }
452  inline
453  self& operator+=(const difference_type& d)
454  {
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);
461  return *this;
462  }
463 
471  inline
472  self& operator-=(const difference_type& d)
473  {
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);
480  return *this;
481  }
482 
490  inline
491  self operator+(const difference_type& d)
492  {
493  self tmp = *this;
494  tmp += d;
495  return tmp;
496  }
497 
505  inline
506  self operator-(const difference_type& d)
507  {
508  self tmp = *this;
509  tmp -= d;
510  return tmp;
511  }
512 
521  inline
522  friend difference_type operator-(const self& i1,
523  const self& i2)
524  {
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());
531  }
532 
533 
542  inline
544  {
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_];
551  }
552 
560  inline
561  typename MultiComponentContainer3d::component_slice_range_iterator
563  {
564  return cont3d_->slice_begin(this->cp_, range_x1_, range_x2_.start() + row * range_x2_.stride(),
565  range_x3_.start() + col * range_x3_.stride());
566  }
567 
568 
576  inline
577  typename MultiComponentContainer3d::component_slice_range_iterator
579  {
580  return this->slice_begin(row, col) + ((range_x1_.iterations() + 1) * N);
581  }
582 
583 
591  inline
592  typename MultiComponentContainer3d::component_row_range_iterator
594  {
595  return cont3d_->row_begin(this->cp_, range_x1_.start() + slice * range_x1_.stride(),
596  range_x2_.start() + row * range_x2_.stride(), range_x3_);
597  }
598 
599 
607  inline
608  typename MultiComponentContainer3d::component_row_range_iterator
610  {
611  return this->row_begin(slice, row) + ((range_x3_.iterations() + 1) * N);
612  }
613 
614 
615 
623  inline
624  typename MultiComponentContainer3d::component_col_range_iterator
626  {
627  return cont3d_->col_begin(this->cp_, range_x1_.start() + slice * range_x1_.stride(),
628  range_x3_.start() + col * range_x3_.stride(), range_x2_);
629  }
630 
638  inline
639  typename MultiComponentContainer3d::component_col_range_iterator
641  {
642  return this->col_begin(slice, col) + ((range_x2_.iterations() + 1) * N);
643  }
644 
645 
653 
658  inline
659  int x1() const
660  {
661  return this->x1_;
662  }
667  inline
668  int k() const
669  {
670  return this->x1_;
671  }
672 
677  inline
678  int x2() const
679  {
680  return this->x2_;
681  }
686  inline
687  int i() const
688  {
689  return this->x2_;
690  }
695  inline
696  int x3() const
697  {
698  return this->x3_;
699  }
704  inline
705  int j() const
706  {
707  return this->x3_;
708  }
709 
714  inline
715  int cp() const
716  {
717  return this->cp_;
718  }
719 
720 
725 private:
726  MultiComponentContainer3d* cont3d_; // pointer to the 3d container
727  pointer pos_; // linear position within the container
728  int x1_; // first index position
729  int x2_; // second index position
730  int x3_; // third index position
731  int cp_; // component index number
732  slip::Range<int> range_x1_; // range to iterate on the first axis
733  slip::Range<int> range_x2_; //range to iterate on the second axis
734  slip::Range<int> range_x3_; //range to iterate on the third axis
735 };
736 
737 
757 template <class MultiComponentContainer3d, std::size_t N>
759 {
760 public:
761  //typedef std::random_access_iterator_tag iterator_category;
763  typedef typename MultiComponentContainer3d::value_type Block;
764  typedef typename Block::value_type value_type;
766  typedef value_type const * pointer;
767  typedef value_type const & reference;
768 
770 
771  typedef typename MultiComponentContainer3d::size_type size_type;
776 
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)
783  {}
784 
796  const_component_iterator3d_range(MultiComponentContainer3d* c, std::size_t cp,
797  const slip::Range<int>& r1,
798  const slip::Range<int>& r2,
799  const slip::Range<int>& r3):
800  cont3d_(c),
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)
806  {}
807 
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_)
816  {}
817 
832  self& operator=(const self& o)
833  {
834  if(this != &o)
835  {
836  this->cont3d_ = o.cont3d_;
837  this->pos_ = o.pos_;
838  this->x1_ = o.x1_;
839  this->x2_ = o.x2_;
840  this->x3_ = o.x3_;
841  this->cp_ = o.cp_;
842  this->range_x1_ = o.range_x1_;
843  this->range_x2_ = o.range_x2_;
844  this->range_x3_ = o.range_x3_;
845  }
846  return *this;
847  }
857  inline
859  {
860  return *pos_;
861  }
862 
863  inline
865  {
866  return &(operator*());
867  }
868 
869 
870 
875 
881  inline
882  self& operator++()
883  {
884  if( (x3_ < static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.stride()))){
885  this->x3_+= range_x3_.stride();
886  this->pos_+= range_x3_.stride()*N;
887  }
888  else if(x2_ < static_cast<int>(range_x2_.start() + range_x2_.iterations() * range_x2_.stride()))
889  {
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);
895  }
896  else if(x1_ < static_cast<int>(range_x1_.start() + range_x1_.iterations() * range_x1_.stride())){
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);
903  }
904  else{
905  this->x1_ = static_cast<int>(range_x1_.start() + (range_x1_.iterations() + 1) * range_x1_.stride());
906  this->x2_ = static_cast<int>(range_x2_.start() + (range_x2_.iterations() + 1) * range_x2_.stride());
907  this->x3_ = static_cast<int>(range_x3_.start() + (range_x3_.iterations() + 1) * range_x3_.stride());
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);
911  }
912  return *this;
913  }
914 
920  inline
921  self operator++(int)
922  {
923  self tmp = *this;
924  ++(*this);
925  return tmp;
926  }
927 
939  inline
940  self& operator--()
941  {
942  if(x3_ > static_cast<int>(range_x1_.stop() - range_x1_.iterations() * range_x1_.stride()))
943  {
944  this->x3_ -= range_x3_.stride();
945  this->pos_ -= N * range_x3_.stride();
946  }
947  else if (x2_ > static_cast<int>(range_x2_.stop() - range_x2_.iterations() * range_x2_.stride()))
948  {
949  this->x3_ = static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.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);
954  }
955  else if (x1_ > static_cast<int>(range_x1_.stop() - range_x1_.iterations() * range_x1_.stride()))
956  {
957  this->x3_ = static_cast<int>(range_x3_.start() + range_x3_.iterations() * range_x3_.stride());
958  this->x2_ = static_cast<int>(range_x2_.start() + range_x2_.iterations() * range_x2_.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);
963  }
964  else{
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);
971  }
972 
973  return *this;
974  }
975 
981  inline
982  self operator--(int)
983  {
984  self tmp = *this;
985  --(*this);
986  return tmp;
987  }
988 
1002  inline
1003  friend bool operator==(const self& i1,
1004  const self& i2)
1005  {
1006 
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_));
1010  }
1011 
1018  inline
1019  friend bool operator!=(const self& i1,
1020  const self& i2)
1021  {
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_));
1025  }
1038  inline
1039  friend bool operator<(const self& i1,
1040  const self& i2)
1041  {
1042 
1043  return ( i1.pos_ < i2.pos_);
1044  }
1045 
1052  inline
1053  friend bool operator>(const self& i1,
1054  const self& i2)
1055  {
1056 
1057  return (i2 < i1);
1058  }
1059 
1066  inline
1067  friend bool operator<=(const self& i1,
1068  const self& i2)
1069  {
1070 
1071  return !(i2 < i1);
1072  }
1073 
1080  inline
1081  friend bool operator>=(const self& i1,
1082  const self& i2)
1083  {
1084 
1085  return !(i1 < i2);
1086  }
1103  inline
1104  self& operator+=(const difference_type& d)
1105  {
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);
1112  return *this;
1113  }
1114 
1122  inline
1123  self& operator-=(const difference_type& d)
1124  {
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);
1131  return *this;
1132  }
1133 
1141  inline
1143  {
1144  self tmp = *this;
1145  tmp += d;
1146  return tmp;
1147  }
1148 
1156  inline
1158  {
1159  self tmp = *this;
1160  tmp -= d;
1161  return tmp;
1162  }
1163 
1172  inline
1173  friend difference_type operator-(const self& i1,
1174  const self& i2)
1175  {
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());
1182  }
1183 
1184 
1192  inline
1194  {
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_];
1201  }
1202 
1210  inline
1211  typename MultiComponentContainer3d::const_component_slice_range_iterator
1213  {
1214  return cont3d_->slice_begin(this->cp_, range_x1_, range_x2_.start() + row * range_x2_.stride(),
1215  range_x3_.start() + col * range_x3_.stride());
1216  }
1217 
1218 
1226  inline
1227  typename MultiComponentContainer3d::const_component_slice_range_iterator
1229  {
1230  return this->slice_begin(row, col) + ((range_x1_.iterations() + 1) * N);
1231  }
1232 
1233 
1241  inline
1242  typename MultiComponentContainer3d::const_component_row_range_iterator
1243  row_begin(size_type slice, size_type row) const
1244  {
1245  return cont3d_->row_begin(this->cp_, range_x1_.start() + slice * range_x1_.stride(),
1246  range_x2_.start() + row * range_x2_.stride(), range_x3_);
1247  }
1248 
1249 
1257  inline
1258  typename MultiComponentContainer3d::const_component_row_range_iterator
1259  row_end(size_type slice, size_type row) const
1260  {
1261  return this->row_begin(slice, row) + ((range_x3_.iterations() + 1) * N);
1262  }
1263 
1264 
1265 
1273  inline
1274  typename MultiComponentContainer3d::const_component_col_range_iterator
1275  col_begin(size_type slice, size_type col) const
1276  {
1277  return cont3d_->col_begin(this->cp_, range_x1_.start() + slice * range_x1_.stride(),
1278  range_x3_.start() + col * range_x3_.stride(), range_x2_);
1279  }
1280 
1288  inline
1289  typename MultiComponentContainer3d::const_component_col_range_iterator
1290  col_end(size_type slice, size_type col) const
1291  {
1292  return this->col_begin(slice, col) + ((range_x2_.iterations() + 1) * N);
1293  }
1294 
1295 
1307  inline
1308  int x1() const
1309  {
1310  return this->x1_;
1311  }
1316  inline
1317  int k() const
1318  {
1319  return this->x1_;
1320  }
1321 
1326  inline
1327  int x2() const
1328  {
1329  return this->x2_;
1330  }
1335  inline
1336  int i() const
1337  {
1338  return this->x2_;
1339  }
1344  inline
1345  int x3() const
1346  {
1347  return this->x3_;
1348  }
1353  inline
1354  int j() const
1355  {
1356  return this->x3_;
1357  }
1358 
1363  inline
1364  int cp() const
1365  {
1366  return this->cp_;
1367  }
1368 
1371 private:
1372  MultiComponentContainer3d* cont3d_; // pointer to the 3d container
1373  pointer pos_; // linear position within the container
1374  int x1_; // first index position
1375  int x2_; // second index position
1376  int x3_; // third index position
1377  int cp_; // component index number
1378  slip::Range<int> range_x1_; // range to iterate on the first axis
1379  slip::Range<int> range_x2_; //range to iterate on the second axis
1380  slip::Range<int> range_x3_; //range to iterate on the third axis
1381 };
1382 
1383 
1384 
1385 
1386 }//slip::
1387 
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.
Definition: Range.hpp:305
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.
void dx3(const CoordType &dx)
Accessor of the first coordinate of DPoint3d.
Definition: DPoint3d.hpp:273
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.
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.
Definition: DPoint3d.hpp:261
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.
Definition: Range.hpp:284
self & operator=(const self &o)
Assign a const_component_iterator3d_range.
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.
Definition: Range.hpp:298
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...
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.
Definition: DPoint3d.hpp:249
std::random_access_iterator3d_tag iterator_category
int j() const
Access to the third index of the current component_iterator3d_range.
const_component_iterator3d_range()
Constructs a const_component_iterator3d_range.
Provides a class to manipulate Ranges.
friend bool operator>(const self &i1, const self &i2)
operator.
SubType stop() const
Accessor of the stop subscript of the Range.
Definition: Range.hpp:291
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.