SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Array3d.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 
75 #ifndef SLIP_ARRAY3D_HPP
76 #define SLIP_ARRAY3D_HPP
77 #include <iostream>
78 #include <iterator>
79 #include <cassert>
80 #include <string>
81 #include <cstddef>
82 #include "Box3d.hpp"
83 #include "Point3d.hpp"
84 #include "DPoint3d.hpp"
85 #include "stride_iterator.hpp"
86 #include "iterator3d_plane.hpp"
87 #include "iterator3d_box.hpp"
88 #include "iterator3d_range.hpp"
89 
90 #include <boost/serialization/access.hpp>
91 #include <boost/serialization/split_member.hpp>
92 #include <boost/serialization/string.hpp>
93 #include <boost/serialization/complex.hpp>
94 #include <boost/serialization/version.hpp>
95 
96 namespace slip
97 {
98 
99  template<class T>
100  class stride_iterator;
101 
102  template<class T>
103  class iterator2d_box;
104 
105  template<class T>
106  class const_iterator2d_box;
107 
108  template <typename T>
109  class Array3d;
110 
111  template <typename T>
112  std::ostream& operator<<(std::ostream & out,
113  const slip::Array3d<T>& a);
114 
115  template<typename T>
116  bool operator==(const slip::Array3d<T>& x,
117  const slip::Array3d<T>& y);
118 
119  template<typename T>
120  bool operator!=(const slip::Array3d<T>& x,
121  const slip::Array3d<T>& y);
122 
123  template<typename T>
124  bool operator<(const slip::Array3d<T>& x,
125  const slip::Array3d<T>& y);
126 
127  template<typename T>
128  bool operator>(const slip::Array3d<T>& x,
129  const slip::Array3d<T>& y);
130 
131  template<typename T>
132  bool operator<=(const slip::Array3d<T>& x,
133  const slip::Array3d<T>& y);
134 
135  template<typename T>
136  bool operator>=(const slip::Array3d<T>& x,
137  const slip::Array3d<T>& y);
138 
161  template <typename T>
162  class Array3d
163  {
164  public:
165 
166  typedef T value_type;
167  typedef Array3d<T> self;
168  typedef const Array3d<T> const_self;
169 
171  typedef value_type const & const_reference;
172 
173  typedef value_type * pointer;
174  typedef value_type const * const_pointer;
175 
176  typedef ptrdiff_t difference_type;
177  typedef std::size_t size_type;
178 
179  typedef value_type * iterator;
180  typedef value_type const * const_iterator;
181 
182  typedef std::reverse_iterator<iterator> reverse_iterator;
183  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
184 
185  //slice, row and col iterator
198 
199  typedef std::reverse_iterator<slice_iterator> reverse_slice_iterator;
200  typedef std::reverse_iterator<const_slice_iterator> const_reverse_slice_iterator;
201  typedef std::reverse_iterator<iterator> reverse_row_iterator;
202  typedef std::reverse_iterator<const_iterator> const_reverse_row_iterator;
203  typedef std::reverse_iterator<col_iterator> reverse_col_iterator;
204  typedef std::reverse_iterator<const_col_iterator> const_reverse_col_iterator;
205  typedef std::reverse_iterator<slice_range_iterator> reverse_slice_range_iterator;
206  typedef std::reverse_iterator<const_slice_range_iterator> const_reverse_slice_range_iterator;
207  typedef std::reverse_iterator<row_range_iterator> reverse_row_range_iterator;
208  typedef std::reverse_iterator<const_row_range_iterator> const_reverse_row_range_iterator;
209  typedef std::reverse_iterator<col_range_iterator> reverse_col_range_iterator;
210  typedef std::reverse_iterator<const_col_range_iterator> const_reverse_col_range_iterator;
211 
212 #ifdef ALL_PLANE_ITERATOR3D
213  //generic 1d iterator
214  typedef slip::stride_iterator<pointer> iterator1d;
215  typedef slip::stride_iterator<const_pointer> const_iterator1d;
216 
217  typedef std::reverse_iterator<iterator1d> reverse_iterator1d;
218  typedef std::reverse_iterator<const_iterator1d> const_reverse_iterator1d;
219 #endif //ALL_PLANE_ITERATOR3D
220 
221  //iterator 2d
224 
225  typedef std::reverse_iterator<iterator2d> reverse_iterator2d;
226  typedef std::reverse_iterator<const_iterator2d> const_reverse_iterator2d;
227 
228  //iterator 3d
233 
234  typedef std::reverse_iterator<iterator3d> reverse_iterator3d;
235  typedef std::reverse_iterator<const_iterator3d> const_reverse_iterator3d;
236  typedef std::reverse_iterator<iterator3d_range> reverse_iterator3d_range;
237  typedef std::reverse_iterator<const_iterator3d_range> const_reverse_iterator3d_range;
238 
239  //default iterator of the container
242 
243  static const std::size_t DIM = 3;
244 
249 
253  Array3d();
254 
263  Array3d(const std::size_t d1,
264  const std::size_t d2,
265  const std::size_t d3);
266 
274  Array3d(const std::size_t d1,
275  const std::size_t d2,
276  const std::size_t d3,
277  const T& val);
285  Array3d(const std::size_t d1,
286  const std::size_t d2,
287  const std::size_t d3,
288  const T* val);
289 
302  template<typename InputIterator>
303  Array3d(const size_type d1,
304  const size_type d2,
305  const size_type d3,
306  InputIterator first,
307  InputIterator last):
308  d1_(d1),d2_(d2),d3_(d3),size_(d1 * d2 * d3), slice_size_(d2 * d3)
309  {
310  this->allocate();
311  std::fill_n(this->begin(),this->size_,T());
312  std::copy(first,last, this->begin());
313  }
314 
318  Array3d(const Array3d<T>& rhs);
319 
320 
324  ~Array3d();
325 
326 
338  void resize(std::size_t d1,
339  std::size_t d2,
340  std::size_t d3,
341  const T& val = T());
346 
347  //****************************************************************************
348  // One dimensional iterators
349  //****************************************************************************
350 
351 
352 
353  //----------------------Global iterators------------------------------
354 
374  const_iterator begin() const;
375 
395  iterator begin();
396 
416  iterator end();
417 
437  const_iterator end() const;
438 
459 
480 
501 
522 
528  //--------------------One dimensional slice iterators----------------------
529 
530 
552  slice_iterator slice_begin(const size_type row, const size_type col);
553 
575  const_slice_iterator slice_begin(const size_type row, const size_type col) const;
576 
598  slice_iterator slice_end(const size_type row, const size_type col);
599 
621  const_slice_iterator slice_end(const size_type row, const size_type col) const;
622 
623 
647 
670  const_reverse_slice_iterator slice_rbegin(const size_type row, const size_type col) const;
671 
695 
696 
719  const_reverse_slice_iterator slice_rend(const size_type row, const size_type col) const;
720 
727  //-------------------row iterators----------
728 
739  row_iterator row_begin(const size_type slice,
740  const size_type row);
741 
753  const size_type row) const;
754 
755 
766  row_iterator row_end(const size_type slice,
767  const size_type row);
768 
769 
781  const size_type row) const;
782 
783 
795  const size_type row);
796 
808  const size_type row) const;
809 
810 
822  const size_type row);
823 
824 
836  const size_type row) const;
837 
843  //-------------------col iterators----------
844 
855  col_iterator col_begin(const size_type slice,
856  const size_type col);
857 
858 
870  const size_type col) const;
871 
882  col_iterator col_end(const size_type slice,
883  const size_type col);
884 
885 
897  const size_type col) const;
898 
899 
911  const size_type col);
912 
913 
925  const size_type col) const;
926 
938  const size_type col);
939 
940 
952  const size_type col) const;
953 
961  //------------------------slice range iterators -----------------------
962 
990  const slip::Range<int>& range);
991 
992 
1019  slice_range_iterator slice_end(const size_type row,const size_type col,
1020  const slip::Range<int>& range);
1021 
1022 
1049  const slip::Range<int>& range) const;
1050 
1077  const slip::Range<int>& range) const;
1078 
1079 
1097  const slip::Range<int>& range);
1098 
1099 
1117  const slip::Range<int>& range);
1118 
1119 
1137  const slip::Range<int>& range) const;
1138 
1156  const slip::Range<int>& range) const;
1157 
1158 
1165  //------------------------row range iterators -----------------------
1166 
1192  row_range_iterator row_begin(const size_type slice,const size_type row,
1193  const slip::Range<int>& range);
1194 
1220  row_range_iterator row_end(const size_type slice,const size_type row,
1221  const slip::Range<int>& range);
1222 
1223 
1249  const_row_range_iterator row_begin(const size_type slice,const size_type row,
1250  const slip::Range<int>& range) const;
1251 
1252 
1277  const_row_range_iterator row_end(const size_type slice,const size_type row,
1278  const slip::Range<int>& range) const;
1279 
1295  const slip::Range<int>& range);
1296 
1297 
1315  const slip::Range<int>& range);
1316 
1317 
1318 
1333  const slip::Range<int>& range) const;
1334 
1335 
1352  const slip::Range<int>& range) const;
1353 
1359  //------------------------col range iterators -----------------------
1360 
1386  col_range_iterator col_begin(const size_type slice,const size_type col,
1387  const slip::Range<int>& range);
1388 
1415  col_range_iterator col_end(const size_type slice,const size_type col,
1416  const slip::Range<int>& range);
1417 
1418 
1444  const_col_range_iterator col_begin(const size_type slice,const size_type col,
1445  const slip::Range<int>& range) const;
1446 
1473  const_col_range_iterator col_end(const size_type slice,const size_type col,
1474  const slip::Range<int>& range) const;
1475 
1492  const slip::Range<int>& range);
1493 
1511  const slip::Range<int>& range);
1512 
1529  const slip::Range<int>& range) const;
1530 
1547  const slip::Range<int>& range) const;
1548 
1551  //****************************************************************************
1552  // One dimensional plane iterators
1553  //****************************************************************************
1554 
1559 
1560  //----------------------Global plane iterators------------------------------
1561 
1579  iterator plane_begin(const size_type slice);
1580 
1598  const_iterator plane_begin(const size_type slice) const;
1599 
1617  iterator plane_end(const size_type slice);
1618 
1636  const_iterator plane_end(const size_type slice) const;
1637 
1656 
1674  const_reverse_iterator plane_rbegin(const size_type slice) const;
1675 
1693  reverse_iterator plane_rend(const size_type slice);
1694 
1712  const_reverse_iterator plane_rend(const size_type slice) const;
1713 
1717 #ifdef ALL_PLANE_ITERATOR3D
1718 
1723  //-------------------row and col plane iterators----------
1724 
1725 
1737  const_iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1738  const size_type row) const;
1739 
1751  iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1752  const size_type row);
1753 
1766  iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type row);
1767 
1779  const_iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type row) const;
1780 
1781 
1793  reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1794  const size_type row);
1795 
1807  const_reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1808  const size_type row) const;
1809 
1821  reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type row);
1822 
1834  const_reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type row) const;
1835 
1847  iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1848  const size_type col);
1849 
1861  const_iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1862  const size_type col) const;
1863 
1875  iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type col);
1876 
1888  const_iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type col) const;
1889 
1890 
1902  reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1903  const size_type col);
1904 
1914  const_reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1915  const size_type col) const;
1916 
1928  reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type col);
1929 
1941  const_reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type col) const;
1942 
1949  //-------------------plane box iterators----------
1950 
1962  const_iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1963  const size_type row, const Box2d<int> & b) const;
1964 
1977  iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1978  const size_type row, const Box2d<int> & b);
1979 
1991  iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
1992  const size_type row, const Box2d<int> & b);
1993 
2006  const_iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2007  const size_type row, const Box2d<int> & b) const;
2008 
2009 
2021  reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2022  const size_type row, const Box2d<int> & b);
2023 
2036  const_reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2037  const size_type row, const Box2d<int> & b) const;
2038 
2049  reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2050  const size_type row, const Box2d<int> & b);
2051 
2064  const_reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2065  const size_type row, const Box2d<int> & b) const;
2066 
2077  iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2078  const size_type col, const Box2d<int> & b);
2079 
2091  const_iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2092  const size_type col, const Box2d<int> & b) const;
2093 
2106  iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2107  const size_type col, const Box2d<int> & b);
2108 
2121  const_iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2122  const size_type col, const Box2d<int> & b) const;
2123 
2124 
2137  reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2138  const size_type col, const Box2d<int> & b);
2139 
2152  const_reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2153  const size_type col, const Box2d<int> & b) const;
2154 
2167  reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2168  const size_type col, const Box2d<int> & b);
2169 
2182  const_reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2183  const size_type col, const Box2d<int> & b) const;
2184 
2185 
2188 #endif //ALL_PLANE_ITERATOR3D
2189 
2190  //****************************************************************************
2191  // Two dimensional plane iterators
2192  //****************************************************************************
2193 
2198 
2218  iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate);
2219 
2241  iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate);
2242 
2264  const_iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2265 
2285  const_iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2286 
2306 
2326 
2345  const_reverse_iterator2d plane_rupper_left(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2346 
2366 
2367 
2374 
2397  iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate
2398  , const Box2d<int> & b);
2399 
2422  iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate
2423  , const Box2d<int> & b);
2424 
2448  , const Box2d<int> & b) const;
2449 
2473  , const Box2d<int> & b) const;
2474 
2498  , const Box2d<int> & b);
2499 
2523  , const Box2d<int> & b);
2524 
2548  , const Box2d<int> & b) const;
2549 
2573  , const Box2d<int> & b) const;
2574 
2575 
2578  //****************************************************************************
2579  // Three dimensional iterators
2580  //****************************************************************************
2581 
2586 
2587  //------------------------ Global iterators------------------------------------
2588 
2606 
2607 
2625 
2626 
2644 
2645 
2663 
2681 
2699 
2717 
2718 
2736 
2743 
2744  //------------------------ Box iterators------------------------------------
2745 
2767 
2768 
2791 
2792 
2814  const_iterator3d front_upper_left(const Box3d<int>& box) const;
2815 
2816 
2839  const_iterator3d back_bottom_right(const Box3d<int>& box) const;
2840 
2841 
2842 
2858 
2874 
2890 
2891 
2907 
2908 
2916 
2917  //------------------------ Range iterators------------------------------------
2918 
2945  iterator3d_range front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
2946  const Range<int>& col_range);
2947 
2974  iterator3d_range back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
2975  const Range<int>& col_range);
2976 
2977 
3004  const_iterator3d_range front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3005  const Range<int>& col_range) const;
3006 
3007 
3034  const_iterator3d_range back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3035  const Range<int>& col_range) const;
3036 
3064  reverse_iterator3d_range rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3065  const Range<int>& col_range);
3066 
3094  reverse_iterator3d_range rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3095  const Range<int>& col_range);
3096 
3124  const_reverse_iterator3d_range rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3125  const Range<int>& col_range) const;
3126 
3154  const_reverse_iterator3d_range rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3155  const Range<int>& col_range) const;
3156 
3157 
3160  //********************************************************************
3161 
3171  friend std::ostream& operator<< <>(std::ostream & out,
3172  const self& a);
3173 
3188  self& operator=(const Array3d<T> & rhs);
3189 
3190 
3191 
3199  self& operator=(const T& value);
3200 
3201 
3207  void fill(const T& value)
3208  {
3209  std::fill_n(this->begin(),this->size_,value);
3210  }
3211 
3218  void fill(const T* value)
3219  {
3220  std::copy(value,value + this->size_, this->begin());
3221  }
3222 
3231  template<typename InputIterator>
3232  void fill(InputIterator first,
3233  InputIterator last)
3234  {
3235  std::copy(first,last, this->begin());
3236  }
3251  friend bool operator== <>(const Array3d<T>& x,
3252  const Array3d<T>& y);
3253 
3260  friend bool operator!= <>(const Array3d<T>& x,
3261  const Array3d<T>& y);
3262 
3269  friend bool operator< <>(const Array3d<T>& x,
3270  const Array3d<T>& y);
3271 
3278  friend bool operator> <>(const Array3d<T>& x,
3279  const Array3d<T>& y);
3280 
3287  friend bool operator<= <>(const Array3d<T>& x,
3288  const Array3d<T>& y);
3289 
3296  friend bool operator>= <>(const Array3d<T>& x,
3297  const Array3d<T>& y);
3298 
3299 
3306 
3307  T** operator[](const size_type k);
3308 
3309  const T* const* operator[](const size_type k) const;
3310 
3311 
3325  reference operator()(const size_type k,
3326  const size_type i,
3327  const size_type j);
3328 
3343  const size_type i,
3344  const size_type j) const;
3345 
3352  std::string name() const;
3353 
3358  size_type dim1() const;
3359 
3364  size_type slices() const;
3365 
3370  size_type dim2() const;
3371 
3376  size_type rows() const;
3377 
3382  size_type dim3() const;
3383 
3388  size_type cols() const;
3389 
3394  size_type columns() const;
3395 
3396 
3397 
3401  size_type size() const;
3402 
3403 
3407  size_type max_size() const;
3408 
3409 
3413  size_type slice_size() const;
3414 
3418  bool empty()const;
3419 
3428  void swap(Array3d& M);
3429 
3430 
3431 
3432 
3433  private:
3434  size_type d1_;
3435  size_type d2_;
3436  size_type d3_;
3437  size_type size_;
3438  size_type slice_size_;
3439  T*** data_;
3440 
3442  void allocate();
3443 
3445  void desallocate();
3446 
3451  void copy_attributes(const self& rhs);
3452 
3454  template<class Archive>
3455  void save(Archive & ar, const unsigned int version) const
3456  {
3457  ar & this->d1_ & this->d2_ & this->d3_ & this->size_ & this->slice_size_;
3458  for (size_t i = 0; i < this->size_; ++i)
3459  {
3460  ar & (**data_)[i];
3461  }
3462  }
3463  template<class Archive>
3464  void load(Archive & ar, const unsigned int version)
3465  {
3466  ar & this->d1_ & this->d2_ & this->d3_ & this->size_ & this->slice_size_;
3467  desallocate();
3468  allocate();
3469  for (size_t i = 0; i < this->size_; ++i)
3470  {
3471  ar & (**data_)[i];
3472  }
3473  }
3474  BOOST_SERIALIZATION_SPLIT_MEMBER();
3475  }; // end of Containers3d group
3477 
3498 }//slip::
3499 
3500 
3501 namespace slip
3502 {
3503 
3505  // Constructors
3507  template<typename T>
3508  inline
3510  d1_(0),d2_(0),d3_(0),size_(0),slice_size_(0),data_(0)
3511  {}
3512 
3513 
3514  template<typename T>
3515  inline
3517  const typename Array3d<T>::size_type d2,
3518  const typename Array3d<T>::size_type d3):
3519  d1_(d1),d2_(d2),d3_(d3),size_(d1 * d2 * d3),slice_size_(d2*d3)
3520  {
3521  this->allocate();
3522  std::fill_n(this->data_[0][0],this->size_,T());
3523  }
3524 
3525  template<typename T>
3526  inline
3528  const typename Array3d<T>::size_type d2,
3529  const typename Array3d<T>::size_type d3,
3530  const T& val):
3531  d1_(d1),d2_(d2),d3_(d3),size_(d1 * d2 * d3),slice_size_(d2*d3)
3532  {
3533  this->allocate();
3534  std::fill_n(this->data_[0][0],this->size_,val);
3535  }
3536 
3537  template<typename T>
3538  inline
3540  const typename Array3d<T>::size_type d2,
3541  const typename Array3d<T>::size_type d3,
3542  const T* val):
3543  d1_(d1),d2_(d2),d3_(d3),size_(d1 * d2 * d3),slice_size_(d2*d3)
3544  {
3545  this->allocate();
3546  std::copy(val,val + this->size_, this->data_[0][0]);
3547  }
3548 
3549  template<typename T>
3550  inline
3552  d1_(rhs.d1_),d2_(rhs.d2_),d3_(rhs.d3_),size_(rhs.size_),slice_size_(rhs.slice_size_)
3553  {
3554  this->allocate();
3555  if(this->size_ != 0)
3556  {
3557  std::copy(rhs.data_[0][0],rhs.data_[0][0] + this->size_,this->data_[0][0]);
3558  }
3559  }
3560 
3561  template<typename T>
3562  inline
3564  {
3565  this->desallocate();
3566  }
3567 
3569 
3570 
3572  // Assignment operators
3574  template<typename T>
3575  inline
3577  {
3578  if(this != &rhs)
3579  {
3580  if( this->d1_ != rhs.d1_ || this->d2_ != rhs.d2_ || this->d3_ != rhs.d3_)
3581  {
3582  this->desallocate();
3583  this->copy_attributes(rhs);
3584  this->allocate();
3585  }
3586  if(rhs.size_ != 0)
3587  {
3588  std::copy(rhs.data_[0][0],rhs.data_[0][0] + this->size_,this->data_[0][0]);
3589  }
3590  }
3591  return *this;
3592  }
3593 
3594  template<typename T>
3595  inline
3597  {
3598  this->fill(value);
3599  return *this;
3600  }
3602 
3603 
3604  template<typename T>
3605  inline
3607  const typename Array3d<T>::size_type d2,
3608  const typename Array3d<T>::size_type d3,
3609  const T& val)
3610  {
3611  if( this->d1_ != d1 || this->d2_ != d2 || this->d3_ != d3)
3612  {
3613  this->desallocate();
3614  this->d1_ = d1;
3615  this->d2_ = d2;
3616  this->d3_ = d3;
3617  this->size_ = d1 * d2 * d3;
3618  this->slice_size_ = d2 * d3;
3619  this->allocate();
3620  }
3621  if( this->d1_ != 0 && this->d2_ != 0 && this->d3_ != 0)
3622  {
3623  std::fill_n(this->data_[0][0],this->size_,val);
3624  }
3625 
3626  }
3627 
3628 
3629 
3631  // Iterators
3633 
3634  //****************************************************************************
3635  // One dimensional iterators
3636  //****************************************************************************
3637 
3638 
3639 
3640  //----------------------Global iterators------------------------------
3641 
3642  template<typename T>
3643  inline
3645  {
3646  return this->data_[0][0];
3647  }
3648 
3649  template<typename T>
3650  inline
3652  {
3653  return this->data_[0][0] + this->size_;
3654  }
3655 
3656  template<typename T>
3657  inline
3659  {
3660  return this->data_[0][0];
3661  }
3662 
3663  template<typename T>
3664  inline
3666  {
3667  return this->data_[0][0] + this->size_;
3668  }
3669 
3670  template<typename T>
3671  inline
3673  {
3674  return typename Array3d<T>::reverse_iterator(this->end());
3675  }
3676 
3677  template<typename T>
3678  inline
3680  {
3681  return typename Array3d<T>::const_reverse_iterator(this->end());
3682  }
3683 
3684  template<typename T>
3685  inline
3687  {
3688  return typename Array3d<T>::reverse_iterator(this->begin());
3689  }
3690 
3691 
3692  template<typename T>
3693  inline
3695  {
3696  return typename Array3d<T>::const_reverse_iterator(this->begin());
3697  }
3698 
3699  //--------------------Constant slice global iterators----------------------
3700 
3701  template<typename T>
3702  inline
3703  typename Array3d<T>::slice_iterator
3704  Array3d<T>::slice_begin(const typename Array3d<T>::size_type row,
3705  const typename Array3d<T>::size_type col)
3706  {
3707  assert(row < this->d2_);
3708  assert(col < this->d3_);
3709  return typename Array3d<T>::slice_iterator(this->data_[0][row] + col,this->d2_*this->d3_);
3710  }
3711 
3712  template<typename T>
3713  inline
3714  typename Array3d<T>::const_slice_iterator
3715  Array3d<T>::slice_begin(const typename Array3d<T>::size_type row,
3716  const typename Array3d<T>::size_type col) const
3717  {
3718  assert(row < this->d2_);
3719  assert(col < this->d3_);
3720  return typename Array3d<T>::const_slice_iterator(this->data_[0][row] + col,this->d2_*this->d3_);
3721  }
3722 
3723  template<typename T>
3724  inline
3725  typename Array3d<T>::slice_iterator
3726  Array3d<T>::slice_end(const typename Array3d<T>::size_type row,
3727  const typename Array3d<T>::size_type col)
3728  {
3729  assert(row < this->d2_);
3730  assert(col < this->d3_);
3731  return (this->slice_begin(row,col) + this->d1_);
3732  }
3733 
3734  template<typename T>
3735  inline
3736  typename Array3d<T>::const_slice_iterator
3737  Array3d<T>::slice_end(const typename Array3d<T>::size_type row,
3738  const typename Array3d<T>::size_type col) const
3739  {
3740  assert(row < this->d2_);
3741  assert(col < this->d3_);
3742  slip::Array3d<T> const * tp(this);
3743  return (tp->slice_begin(row,col) + this->d1_);
3744  }
3745 
3746  template<typename T>
3747  inline
3748  typename Array3d<T>::reverse_slice_iterator
3749  Array3d<T>::slice_rbegin(const typename Array3d<T>::size_type row,
3750  const typename Array3d<T>::size_type col)
3751  {
3752  assert(row < this->d2_);
3753  assert(col < this->d3_);
3754  return typename Array3d<T>::reverse_slice_iterator(this->slice_end(row,col));
3755  }
3756 
3757  template<typename T>
3758  inline
3759  typename Array3d<T>::const_reverse_slice_iterator
3760  Array3d<T>::slice_rbegin(const typename Array3d<T>::size_type row,
3761  const typename Array3d<T>::size_type col) const
3762  {
3763  assert(row < this->d2_);
3764  assert(col < this->d3_);
3765  return typename Array3d<T>::const_reverse_slice_iterator(this->slice_end(row,col));
3766  }
3767 
3768  template<typename T>
3769  inline
3770  typename Array3d<T>::reverse_slice_iterator
3771  Array3d<T>::slice_rend(const typename Array3d<T>::size_type row,
3772  const typename Array3d<T>::size_type col)
3773  {
3774  assert(row < this->d2_);
3775  assert(col < this->d3_);
3776  return typename Array3d<T>::reverse_slice_iterator(this->slice_begin(row,col));
3777  }
3778 
3779  template<typename T>
3780  inline
3781  typename Array3d<T>::const_reverse_slice_iterator
3782  Array3d<T>::slice_rend(const typename Array3d<T>::size_type row,
3783  const typename Array3d<T>::size_type col) const
3784  {
3785  assert(row < this->d2_);
3786  assert(col < this->d3_);
3787  return typename Array3d<T>::const_reverse_slice_iterator(this->slice_begin(row,col));
3788  }
3789 
3790  //--------------------simple row iterators----------------------
3791 
3792  template<typename T>
3793  inline
3794  typename Array3d<T>::row_iterator
3795  Array3d<T>::row_begin(const typename Array3d<T>::size_type slice,
3796  const typename Array3d<T>::size_type row)
3797  {
3798  assert(slice < this->d1_);
3799  assert(row < this->d2_);
3800  return this->data_[slice][row];
3801  }
3802 
3803  template<typename T>
3804  inline
3805  typename Array3d<T>::const_row_iterator
3806  Array3d<T>::row_begin(const typename Array3d<T>::size_type slice,
3807  const typename Array3d<T>::size_type row) const
3808  {
3809  assert(slice < this->d1_);
3810  assert(row < this->d2_);
3811  return this->data_[slice][row];
3812  }
3813 
3814  template<typename T>
3815  inline
3816  typename Array3d<T>::row_iterator
3817  Array3d<T>::row_end(const typename Array3d<T>::size_type slice,
3818  const typename Array3d<T>::size_type row)
3819  {
3820  assert(slice < this->d1_);
3821  assert(row < this->d2_);
3822  return this->data_[slice][row] + this->d3_;
3823  }
3824 
3825  template<typename T>
3826  inline
3827  typename Array3d<T>::const_row_iterator
3828  Array3d<T>::row_end(const typename Array3d<T>::size_type slice,
3829  const typename Array3d<T>::size_type row) const
3830  {
3831  assert(slice < this->d1_);
3832  assert(row < this->d2_);
3833  return this->data_[slice][row] + this->d3_;
3834  }
3835 
3836 
3837  template<typename T>
3838  inline
3839  typename Array3d<T>::reverse_row_iterator
3840  Array3d<T>::row_rbegin(const typename Array3d<T>::size_type slice,
3841  const typename Array3d<T>::size_type row)
3842  {
3843  assert(slice < this->d1_);
3844  assert(row < this->d2_);
3845  return typename Array3d<T>::reverse_row_iterator(this->row_end(slice,row));
3846  }
3847 
3848  template<typename T>
3849  inline
3850  typename Array3d<T>::const_reverse_row_iterator
3851  Array3d<T>::row_rbegin(const typename Array3d<T>::size_type slice,
3852  const typename Array3d<T>::size_type row) const
3853  {
3854  assert(slice < this->d1_);
3855  assert(row < this->d2_);
3856  return typename Array3d<T>::const_reverse_row_iterator(this->row_end(slice,row));
3857  }
3858 
3859 
3860  template<typename T>
3861  inline
3862  typename Array3d<T>::reverse_row_iterator
3863  Array3d<T>::row_rend(const typename Array3d<T>::size_type slice,
3864  const typename Array3d<T>::size_type row)
3865  {
3866  assert(slice < this->d1_);
3867  assert(row < this->d2_);
3868  return typename Array3d<T>::reverse_row_iterator(this->row_begin(slice,row));
3869  }
3870 
3871  template<typename T>
3872  inline
3873  typename Array3d<T>::const_reverse_row_iterator
3874  Array3d<T>::row_rend(const typename Array3d<T>::size_type slice,
3875  const typename Array3d<T>::size_type row) const
3876  {
3877  assert(slice < this->d1_);
3878  assert(row < this->d2_);
3879  return typename Array3d<T>::const_reverse_row_iterator(this->row_begin(slice,row));
3880  }
3881 
3882  //--------------------Simple col iterators----------------------
3883 
3884  template<typename T>
3885  inline
3886  typename Array3d<T>::col_iterator
3887  Array3d<T>::col_begin(const typename Array3d<T>::size_type slice,
3888  const typename Array3d<T>::size_type col)
3889  {
3890  assert(slice < this->d1_);
3891  assert(col < this->d3_);
3892  return typename Array3d<T>::col_iterator(this->data_[slice][0] + col,this->d3_);
3893  }
3894 
3895  template<typename T>
3896  inline
3897  typename Array3d<T>::const_col_iterator
3898  Array3d<T>::col_begin(const typename Array3d<T>::size_type slice,
3899  const typename Array3d<T>::size_type col) const
3900  {
3901  assert(slice < this->d1_);
3902  assert(col < this->d3_);
3903  return typename Array3d<T>::const_col_iterator(this->data_[slice][0] + col,this->d3_);
3904  }
3905 
3906 
3907  template<typename T>
3908  inline
3909  typename Array3d<T>::col_iterator
3910  Array3d<T>::col_end(const typename Array3d<T>::size_type slice,
3911  const typename Array3d<T>::size_type col)
3912  {
3913  assert(slice < this->d1_);
3914  assert(col < this->d3_);
3915  return ++(typename Array3d<T>::col_iterator(this->data_[slice][this->d2_- 1] + col,this->d3_));
3916  }
3917 
3918  template<typename T>
3919  inline
3920  typename Array3d<T>::const_col_iterator
3921  Array3d<T>::col_end(const typename Array3d<T>::size_type slice,
3922  const typename Array3d<T>::size_type col) const
3923  {
3924  assert(slice < this->d1_);
3925  assert(col < this->d3_);
3926  return ++(typename Array3d<T>::const_col_iterator(this->data_[slice][this->d2_- 1] + col,this->d3_));
3927 
3928  }
3929 
3930  template<typename T>
3931  inline
3932  typename Array3d<T>::reverse_col_iterator
3933  Array3d<T>::col_rbegin(const typename Array3d<T>::size_type slice,
3934  const typename Array3d<T>::size_type col)
3935  {
3936  assert(slice < this->d1_);
3937  assert(col < this->d3_);
3938  return typename Array3d<T>::reverse_col_iterator(this->col_end(slice,col));
3939  }
3940 
3941  template<typename T>
3942  inline
3943  typename Array3d<T>::const_reverse_col_iterator
3944  Array3d<T>::col_rbegin(const typename Array3d<T>::size_type slice,
3945  const typename Array3d<T>::size_type col) const
3946  {
3947  assert(slice < this->d1_);
3948  assert(col < this->d3_);
3949  return typename Array3d<T>::const_reverse_col_iterator(this->col_end(slice,col));
3950  }
3951 
3952 
3953  template<typename T>
3954  inline
3955  typename Array3d<T>::reverse_col_iterator
3956  Array3d<T>::col_rend(const typename Array3d<T>::size_type slice,
3957  const typename Array3d<T>::size_type col)
3958  {
3959  assert(slice < this->d1_);
3960  assert(col < this->d3_);
3961  return typename Array3d<T>::reverse_col_iterator(this->col_begin(slice,col));
3962  }
3963 
3964  template<typename T>
3965  inline
3966  typename Array3d<T>::const_reverse_col_iterator
3967  Array3d<T>::col_rend(const typename Array3d<T>::size_type slice,
3968  const typename Array3d<T>::size_type col) const
3969  {
3970  assert(slice < this->d1_);
3971  assert(col < this->d3_);
3972  return typename Array3d<T>::const_reverse_col_iterator(this->col_begin(slice,col));
3973  }
3974 
3975 
3976  //--------------------Constant slice range iterators----------------------
3977 
3978  template<typename T>
3979  inline
3980  typename Array3d<T>::slice_range_iterator
3981  Array3d<T>::slice_begin(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
3982  const slip::Range<int>& range)
3983  {
3984  assert(row < this->d2_);
3985  assert(col < this->d3_);
3986  assert(range.is_valid());
3987  assert(range.start() >= 0);
3988  assert(range.stop() >= 0);
3989  assert(range.start() < (int)this->d1_);
3990  assert(range.stop() < (int)this->d1_);
3991  return slip::stride_iterator<typename Array3d<T>::slice_iterator>(this->slice_begin(row,col) + range.start(),range.stride());
3992  }
3993 
3994  template<typename T>
3995  inline
3996  typename Array3d<T>::const_slice_range_iterator
3997  Array3d<T>::slice_begin(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
3998  const slip::Range<int>& range) const
3999  {
4000  assert(row < this->d2_);
4001  assert(col < this->d3_);
4002  assert(range.is_valid());
4003  assert(range.start() >= 0);
4004  assert(range.stop() >= 0);
4005  assert(range.start() < (int)this->d1_);
4006  assert(range.stop() < (int)this->d1_);
4007  return slip::stride_iterator<typename Array3d<T>::const_slice_iterator>(this->slice_begin(row,col) + range.start(),range.stride());
4008  }
4009 
4010  template<typename T>
4011  inline
4012  typename Array3d<T>::slice_range_iterator
4013  Array3d<T>::slice_end(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4014  const slip::Range<int>& range)
4015  {
4016  assert(row < this->d2_);
4017  assert(col < this->d3_);
4018  assert(range.start() < (int)this->d1_);
4019  assert(range.stop() < (int)this->d1_);
4020  return ++(slip::stride_iterator<typename Array3d<T>::slice_iterator>(this->slice_begin(row,col,range) + range.iterations()));
4021  }
4022 
4023  template<typename T>
4024  inline
4025  typename Array3d<T>::const_slice_range_iterator
4026  Array3d<T>::slice_end(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4027  const slip::Range<int>& range) const
4028  {
4029  assert(row < this->d2_);
4030  assert(col < this->d3_);
4031  assert(range.start() < (int)this->d1_);
4032  assert(range.stop() < (int)this->d1_);
4033  return ++(slip::stride_iterator<typename Array3d<T>::const_slice_iterator>(this->slice_begin(row,col,range) + range.iterations()));
4034  }
4035 
4036  template<typename T>
4037  inline
4038  typename Array3d<T>::reverse_slice_range_iterator
4039  Array3d<T>::slice_rbegin(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4040  const slip::Range<int>& range)
4041  {
4042  assert(row < this->d2_);
4043  assert(col < this->d3_);
4044  assert(range.start() < (int)this->d1_);
4045  return typename Array3d<T>::reverse_slice_range_iterator(this->slice_end(row,col,range));
4046  }
4047 
4048  template<typename T>
4049  inline
4050  typename Array3d<T>::const_reverse_slice_range_iterator
4051  Array3d<T>::slice_rbegin(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4052  const slip::Range<int>& range) const
4053  {
4054  assert(row < this->d2_);
4055  assert(col < this->d3_);
4056  assert(range.start() < (int)this->d1_);
4057  return typename Array3d<T>::const_reverse_slice_range_iterator(this->slice_end(row,col,range));
4058  }
4059 
4060  template<typename T>
4061  inline
4062  typename Array3d<T>::reverse_slice_range_iterator
4063  Array3d<T>::slice_rend(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4064  const slip::Range<int>& range)
4065  {
4066  assert(row < this->d2_);
4067  assert(col < this->d3_);
4068  assert(range.start() < (int)this->d1_);
4069  return typename Array3d<T>::reverse_slice_range_iterator(this->slice_begin(row,col,range));
4070  }
4071 
4072  template<typename T>
4073  inline
4074  typename Array3d<T>::const_reverse_slice_range_iterator
4075  Array3d<T>::slice_rend(const typename Array3d<T>::size_type row, const typename Array3d<T>::size_type col,
4076  const slip::Range<int>& range) const
4077  {
4078  assert(row < this->d2_);
4079  assert(col < this->d3_);
4080  assert(range.start() < (int)this->d1_);
4081  return typename Array3d<T>::const_reverse_slice_range_iterator(this->slice_begin(row,col,range));
4082  }
4083 
4084  //--------------------Constant row range iterators----------------------
4085 
4086  template<typename T>
4087  inline
4088  typename Array3d<T>::row_range_iterator
4089  Array3d<T>::row_begin(const typename Array3d<T>::size_type slice, const typename Array3d<T>::size_type row,const slip::Range<int>& range)
4090  {
4091  assert(row < this->d2_);
4092  assert(range.is_valid());
4093  assert(range.start() >= 0);
4094  assert(range.stop() >= 0);
4095  assert(range.start() < (int)this->d3_);
4096  assert(range.stop() < (int)this->d3_);
4097  return slip::stride_iterator<typename Array3d<T>::row_iterator>(this->row_begin(slice,row) + range.start(),range.stride());
4098  }
4099 
4100  template<typename T>
4101  inline
4102  typename Array3d<T>::const_row_range_iterator
4103  Array3d<T>::row_begin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4104  const slip::Range<int>& range) const
4105  {
4106  assert(row < this->d2_);
4107  assert(range.is_valid());
4108  assert(range.start() >= 0);
4109  assert(range.stop() >= 0);
4110  assert(range.start() < (int)this->d3_);
4111  assert(range.stop() < (int)this->d3_);
4112  return slip::stride_iterator<typename Array3d<T>::const_row_iterator>(this->row_begin(slice,row) + range.start(),range.stride());
4113  }
4114 
4115  template<typename T>
4116  inline
4117  typename Array3d<T>::row_range_iterator
4118  Array3d<T>::row_end(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4119  const slip::Range<int>& range)
4120  {
4121  assert(row < this->d2_);
4122  assert(range.start() < (int)this->d3_);
4123  assert(range.stop() < (int)this->d3_);
4124  return ++(slip::stride_iterator<typename Array3d<T>::row_iterator>(this->row_begin(slice,row) + range.start() + range.stride() * range.iterations(),range.stride()));
4125  }
4126 
4127  template<typename T>
4128  inline
4129  typename Array3d<T>::const_row_range_iterator
4130  Array3d<T>::row_end(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4131  const slip::Range<int>& range) const
4132  {
4133  assert(row < this->d2_);
4134  assert(range.start() < (int)this->d3_);
4135  assert(range.stop() < (int)this->d3_);
4136  return ++(slip::stride_iterator<typename Array3d<T>::const_row_iterator>(this->row_begin(slice,row) + range.start() + range.stride() * range.iterations(),range.stride()));
4137  }
4138 
4139  template<typename T>
4140  inline
4141  typename Array3d<T>::reverse_row_range_iterator
4142  Array3d<T>::row_rbegin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4143  const slip::Range<int>& range)
4144  {
4145  assert(row < this->d2_);
4146  assert(range.start() < (int)this->d3_);
4147  return typename Array3d<T>::reverse_row_range_iterator(this->row_end(slice,row,range));
4148  }
4149 
4150  template<typename T>
4151  inline
4152  typename Array3d<T>::const_reverse_row_range_iterator
4153  Array3d<T>::row_rbegin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4154  const slip::Range<int>& range) const
4155  {
4156  assert(row < this->d2_);
4157  assert(range.start() < (int)this->d3_);
4158  return typename Array3d<T>::const_reverse_row_range_iterator(this->row_end(slice,row,range));
4159  }
4160 
4161  template<typename T>
4162  inline
4163  typename Array3d<T>::reverse_row_range_iterator
4164  Array3d<T>::row_rend(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4165  const slip::Range<int>& range)
4166  {
4167  assert(row < this->d2_);
4168  assert(range.start() < (int)this->d3_);
4169  return typename Array3d<T>::reverse_row_range_iterator(this->row_begin(slice,row,range));
4170  }
4171 
4172  template<typename T>
4173  inline
4174  typename Array3d<T>::const_reverse_row_range_iterator
4175  Array3d<T>::row_rend(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type row,
4176  const slip::Range<int>& range) const
4177  {
4178  assert(row < this->d2_);
4179  assert(range.start() < (int)this->d3_);
4180  return typename Array3d<T>::const_reverse_row_range_iterator(this->row_begin(slice,row,range));
4181  }
4182 
4183  //--------------------Constant col range iterators----------------------
4184 
4185  template<typename T>
4186  inline
4187  typename Array3d<T>::col_range_iterator
4188  Array3d<T>::col_begin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4189  const slip::Range<int>& range)
4190  {
4191  assert(col < this->d3_);
4192  assert(range.is_valid());
4193  assert(range.start() >= 0);
4194  assert(range.stop() >= 0);
4195  assert(range.start() < (int)this->d2_);
4196  assert(range.stop() < (int)this->d2_);
4197  return slip::stride_iterator<typename Array3d<T>::col_iterator>(this->col_begin(slice,col) + range.start(),range.stride());
4198  }
4199 
4200  template<typename T>
4201  inline
4202  typename Array3d<T>::const_col_range_iterator
4203  Array3d<T>::col_begin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4204  const slip::Range<int>& range) const
4205  {
4206  assert(col < this->d3_);
4207  assert(range.is_valid());
4208  assert(range.start() >= 0);
4209  assert(range.stop() >= 0);
4210  assert(range.start() < (int)this->d2_);
4211  assert(range.stop() < (int)this->d2_);
4212  return slip::stride_iterator<typename Array3d<T>::const_col_iterator>(this->col_begin(slice,col) + range.start(),range.stride());
4213  }
4214 
4215  template<typename T>
4216  inline
4217  typename Array3d<T>::col_range_iterator
4218  Array3d<T>::col_end(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4219  const slip::Range<int>& range)
4220  {
4221  assert(col < this->d3_);
4222  assert(range.start() < (int)this->d2_);
4223  assert(range.stop() < (int)this->d2_);
4224  return ++(slip::stride_iterator<typename Array3d<T>::col_iterator>(this->col_begin(slice,col) + range.start() + range.stride() * range.iterations(),range.stride()));
4225  }
4226 
4227  template<typename T>
4228  inline
4229  typename Array3d<T>::const_col_range_iterator
4230  Array3d<T>::col_end(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4231  const slip::Range<int>& range) const
4232  {
4233  assert(col < this->d3_);
4234  assert(range.start() < (int)this->d2_);
4235  assert(range.stop() < (int)this->d2_);
4236  return ++(slip::stride_iterator<typename Array3d<T>::const_col_iterator>(this->col_begin(slice,col) + range.start() + range.stride() * range.iterations(),range.stride()));
4237  }
4238 
4239  template<typename T>
4240  inline
4241  typename Array3d<T>::reverse_col_range_iterator
4242  Array3d<T>::col_rbegin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4243  const slip::Range<int>& range)
4244  {
4245  assert(col < this->d3_);
4246  assert(range.start() < (int)this->d2_);
4247  return typename Array3d<T>::reverse_col_range_iterator(this->col_end(slice,col,range));
4248  }
4249 
4250  template<typename T>
4251  inline
4252  typename Array3d<T>::const_reverse_col_range_iterator
4253  Array3d<T>::col_rbegin(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4254  const slip::Range<int>& range) const
4255  {
4256  assert(col < this->d3_);
4257  assert(range.start() < (int)this->d2_);
4258  return typename Array3d<T>::const_reverse_col_range_iterator(this->col_end(slice,col,range));
4259  }
4260 
4261  template<typename T>
4262  inline
4263  typename Array3d<T>::reverse_col_range_iterator
4264  Array3d<T>::col_rend(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4265  const slip::Range<int>& range)
4266  {
4267  assert(col < this->d3_);
4268  assert(range.start() < (int)this->d2_);
4269  return typename Array3d<T>::reverse_col_range_iterator(this->col_begin(slice,col,range));
4270  }
4271 
4272  template<typename T>
4273  inline
4274  typename Array3d<T>::const_reverse_col_range_iterator
4275  Array3d<T>::col_rend(const typename Array3d<T>::size_type slice,const typename Array3d<T>::size_type col,
4276  const slip::Range<int>& range) const
4277  {
4278  assert(col < this->d3_);
4279  assert(range.start() < (int)this->d2_);
4280  return typename Array3d<T>::const_reverse_col_range_iterator(this->col_begin(slice,col,range));
4281  }
4282 
4283  //-------------------plane global iterators----------
4284 
4285  template<typename T>
4286  inline
4287  typename Array3d<T>::iterator
4288  Array3d<T>::plane_begin(const typename Array3d<T>::size_type slice)
4289  {
4290  return this->data_[slice][0];
4291  }
4292 
4293  template<typename T>
4294  inline
4295  typename Array3d<T>::const_iterator
4296  Array3d<T>::plane_begin(const typename Array3d<T>::size_type slice) const
4297  {
4298  return this->data_[slice][0];
4299  }
4300 
4301  template<typename T>
4302  inline
4303  typename Array3d<T>::iterator
4304  Array3d<T>::plane_end(const typename Array3d<T>::size_type slice)
4305  {
4306  return this->data_[slice][0] + this->slice_size_;
4307  }
4308 
4309  template<typename T>
4310  inline
4311  typename Array3d<T>::const_iterator
4312  Array3d<T>::plane_end(const typename Array3d<T>::size_type slice) const
4313  {
4314  return this->data_[slice][0] + this->slice_size_;
4315  }
4316 
4317  template<typename T>
4318  inline
4319  typename Array3d<T>::reverse_iterator
4320  Array3d<T>::plane_rbegin(const typename Array3d<T>::size_type slice)
4321  {
4322  return typename Array3d<T>::reverse_iterator(this->plane_end(slice));
4323  }
4324 
4325  template<typename T>
4326  inline
4327  typename Array3d<T>::const_reverse_iterator
4328  Array3d<T>::plane_rbegin(const typename Array3d<T>::size_type slice) const
4329  {
4330  return typename Array3d<T>::const_reverse_iterator(this->plane_end(slice));
4331  }
4332 
4333  template<typename T>
4334  inline
4335  typename Array3d<T>::reverse_iterator
4336  Array3d<T>::plane_rend(const typename Array3d<T>::size_type slice)
4337  {
4338  return typename Array3d<T>::reverse_iterator(this->plane_begin(slice));
4339  }
4340 
4341  template<typename T>
4342  inline
4343  typename Array3d<T>::const_reverse_iterator
4344  Array3d<T>::plane_rend(const typename Array3d<T>::size_type slice) const
4345  {
4346  return typename Array3d<T>::const_reverse_iterator(this->plane_begin(slice));
4347  }
4348 
4349 #ifdef ALL_PLANE_ITERATOR3D
4350 
4351  //-------------------plane row and col iterators----------
4352 
4353  template<typename T>
4354  inline
4355  typename Array3d<T>::iterator1d
4356  Array3d<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4357  const typename Array3d<T>::size_type row)
4358  {
4359  if(P == 0)
4360  return typename Array3d<T>::iterator1d (this->data_[plane_coordinate][row],1);
4361  if(P == 1)
4362  return typename Array3d<T>::iterator1d (this->data_[row][plane_coordinate],1);
4363  return typename Array3d<T>::iterator1d (this->data_[row][0] + plane_coordinate,this->d3_);
4364  }
4365 
4366  template<typename T>
4367  inline
4368  typename Array3d<T>::const_iterator1d
4369  Array3d<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4370  const typename Array3d<T>::size_type row) const
4371  {
4372  if(P == 0)
4373  return typename Array3d<T>::const_iterator1d (this->data_[plane_coordinate][row],1);
4374  if(P == 1)
4375  return typename Array3d<T>::const_iterator1d (this->data_[row][plane_coordinate],1);
4376  return typename Array3d<T>::const_iterator1d (this->data_[row][0] + plane_coordinate,this->d3_);
4377  }
4378 
4379  template<typename T>
4380  inline
4381  typename Array3d<T>::iterator1d
4382  Array3d<T>::plane_row_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4383  const typename Array3d<T>::size_type row)
4384  {
4385  if(P==2)
4386  return this->plane_row_begin(P,plane_coordinate,row) + this->d2_;
4387  return this->plane_row_begin(P,plane_coordinate,row) + this->d3_;
4388  }
4389 
4390  template<typename T>
4391  inline
4392  typename Array3d<T>::const_iterator1d
4393  Array3d<T>::plane_row_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4394  const typename Array3d<T>::size_type row) const
4395  {
4396  if(P==2)
4397  return this->plane_row_begin(P,plane_coordinate,row) + this->d2_;
4398  return this->plane_row_begin(P,plane_coordinate,row) + this->d3_;
4399  }
4400 
4401  template<typename T>
4402  inline
4403  typename Array3d<T>::reverse_iterator1d
4404  Array3d<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4405  const typename Array3d<T>::size_type row)
4406  {
4407  return typename Array3d<T>::reverse_iterator1d(this->plane_row_end(P,plane_coordinate,row));
4408  }
4409 
4410  template<typename T>
4411  inline
4412  typename Array3d<T>::const_reverse_iterator1d
4413  Array3d<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4414  const typename Array3d<T>::size_type row) const
4415  {
4416  return typename Array3d<T>::const_reverse_iterator1d(this->plane_row_end(P,plane_coordinate,row));
4417  }
4418 
4419  template<typename T>
4420  inline
4421  typename Array3d<T>::reverse_iterator1d
4422  Array3d<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4423  const typename Array3d<T>::size_type row)
4424  {
4425  return typename Array3d<T>::reverse_iterator1d(this->plane_row_begin(P,plane_coordinate,row));
4426  }
4427 
4428  template<typename T>
4429  inline
4430  typename Array3d<T>::const_reverse_iterator1d
4431  Array3d<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4432  const typename Array3d<T>::size_type row) const
4433  {
4434  return typename Array3d<T>::const_reverse_iterator1d(this->plane_row_begin(P,plane_coordinate,row));
4435  }
4436 
4437  template<typename T>
4438  inline
4439  typename Array3d<T>::iterator1d
4440  Array3d<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4441  const typename Array3d<T>::size_type col)
4442  {
4443  if(P == 0)
4444  return typename Array3d<T>::iterator1d (this->data_[plane_coordinate][0] + col,this->d3_);
4445  if(P == 1)
4446  return typename Array3d<T>::iterator1d (this->data_[0][plane_coordinate] + col,this->d2_ * this->d3_);
4447  return typename Array3d<T>::iterator1d (this->data_[0][col] + plane_coordinate,this->d2_ * this->d3_);
4448  }
4449 
4450  template<typename T>
4451  inline
4452  typename Array3d<T>::const_iterator1d
4453  Array3d<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4454  const typename Array3d<T>::size_type col) const
4455  {
4456  // std::cout << "const" << std::endl;
4457  if(P == 0)
4458  return typename Array3d<T>::const_iterator1d (this->data_[plane_coordinate][0] + col,this->d3_);
4459  if(P == 1)
4460  return typename Array3d<T>::const_iterator1d (this->data_[0][plane_coordinate] + col,this->d2_ * this->d3_);
4461  return typename Array3d<T>::const_iterator1d (this->data_[0][col] + plane_coordinate,this->d2_ * this->d3_);
4462  }
4463 
4464  template<typename T>
4465  inline
4466  typename Array3d<T>::iterator1d
4467  Array3d<T>::plane_col_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4468  const typename Array3d<T>::size_type col)
4469  {
4470  if(P == 0)
4471  return this->Array3d::plane_col_begin(P,plane_coordinate,col) + this->d2_;
4472  return this->Array3d::plane_col_begin(P,plane_coordinate,col) + this->d1_;
4473  }
4474 
4475  template<typename T>
4476  inline
4477  typename Array3d<T>::const_iterator1d
4478  Array3d<T>::plane_col_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4479  const typename Array3d<T>::size_type col) const
4480  {
4481  if(P == 0)
4482  return this->Array3d::plane_col_begin(P,plane_coordinate,col) + this->d2_;
4483  return this->Array3d::plane_col_begin(P,plane_coordinate,col) + this->d1_;
4484  }
4485 
4486  template<typename T>
4487  inline
4488  typename Array3d<T>::reverse_iterator1d
4489  Array3d<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4490  const typename Array3d<T>::size_type col)
4491  {
4492  return typename Array3d<T>::reverse_iterator1d(this->plane_col_end(P,plane_coordinate,col));
4493  }
4494 
4495  template<typename T>
4496  inline
4497  typename Array3d<T>::const_reverse_iterator1d
4498  Array3d<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4499  const typename Array3d<T>::size_type col) const
4500  {
4501  return typename Array3d<T>::const_reverse_iterator1d(this->plane_col_end(P,plane_coordinate,col));
4502  }
4503 
4504  template<typename T>
4505  inline
4506  typename Array3d<T>::reverse_iterator1d
4507  Array3d<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4508  const typename Array3d<T>::size_type col)
4509  {
4510  return typename Array3d<T>::reverse_iterator1d(this->plane_col_begin(P,plane_coordinate,col));
4511  }
4512 
4513  template<typename T>
4514  inline
4515  typename Array3d<T>::const_reverse_iterator1d
4516  Array3d<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4517  const typename Array3d<T>::size_type col) const
4518  {
4519  return typename Array3d<T>::const_reverse_iterator1d(this->plane_col_begin(P,plane_coordinate,col));
4520  }
4521 
4522  //-------------------plane row and col box iterators----------
4523 
4524  template<typename T>
4525  inline
4526  typename Array3d<T>::const_iterator1d
4527  Array3d<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4528  const size_type row, const Box2d<int> & b) const
4529  {
4530  if(P == 0)
4531  return typename Array3d<T>::const_iterator1d (this->data_[plane_coordinate][b.upper_left()[0] + row] + b.upper_left()[1],1);
4532  if(P == 1)
4533  return typename Array3d<T>::const_iterator1d (this->data_[b.upper_left()[0] + row][plane_coordinate] + b.upper_left()[1],1);
4534  return typename Array3d<T>::const_iterator1d (this->data_[b.upper_left()[0] + row][b.upper_left()[1]] + plane_coordinate,this->d3_);
4535  }
4536 
4537  template<typename T>
4538  inline
4539  typename Array3d<T>::iterator1d
4540  Array3d<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4541  const size_type row, const Box2d<int> & b)
4542  {
4543  if(P == 0)
4544  return typename Array3d<T>::iterator1d (this->data_[plane_coordinate][b.upper_left()[0] + row] + b.upper_left()[1],1);
4545  if(P == 1)
4546  return typename Array3d<T>::iterator1d (this->data_[b.upper_left()[0] + row][plane_coordinate] + b.upper_left()[1],1);
4547  return typename Array3d<T>::iterator1d (this->data_[b.upper_left()[0] + row][b.upper_left()[1]] + plane_coordinate,this->d3_);
4548  }
4549 
4550  template<typename T>
4551  inline
4552  typename Array3d<T>::iterator1d
4553  Array3d<T>:: plane_row_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4554  const size_type row, const Box2d<int> & b)
4555  {
4556  return this->plane_row_begin(P,plane_coordinate,row,b) + b.width();
4557  }
4558 
4559  template<typename T>
4560  inline
4561  typename Array3d<T>::const_iterator1d
4562  Array3d<T>::plane_row_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4563  const size_type row, const Box2d<int> & b) const
4564  {
4565  return this->plane_row_begin(P,plane_coordinate,row,b) + b.width();
4566  }
4567 
4568  template<typename T>
4569  inline
4570  typename Array3d<T>::reverse_iterator1d
4571  Array3d<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4572  const size_type row, const Box2d<int> & b)
4573  {
4574  return typename Array3d<T>::reverse_iterator1d(this->plane_row_end(P,plane_coordinate,row,b));
4575  }
4576 
4577  template<typename T>
4578  inline
4579  typename Array3d<T>::const_reverse_iterator1d
4580  Array3d<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4581  const size_type row, const Box2d<int> & b) const
4582  {
4583  return typename Array3d<T>::const_reverse_iterator1d(this->plane_row_end(P,plane_coordinate,row,b));
4584  }
4585 
4586  template<typename T>
4587  inline
4588  typename Array3d<T>::reverse_iterator1d
4589  Array3d<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4590  const size_type row, const Box2d<int> & b)
4591  {
4592  return typename Array3d<T>::reverse_iterator1d(this->plane_row_begin(P,plane_coordinate,row,b));
4593  }
4594 
4595  template<typename T>
4596  inline
4597  typename Array3d<T>::const_reverse_iterator1d
4598  Array3d<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4599  const size_type row, const Box2d<int> & b) const
4600  {
4601  return typename Array3d<T>::const_reverse_iterator1d(this->plane_row_begin(P,plane_coordinate,row,b));
4602  }
4603 
4604  template<typename T>
4605  inline
4606  typename Array3d<T>::iterator1d
4607  Array3d<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4608  const size_type col, const Box2d<int> & b)
4609  {
4610  if(P == 0)
4611  return typename Array3d<T>::iterator1d (this->data_[plane_coordinate][b.upper_left()[0]] + b.upper_left()[1] + col,this->d3_);
4612  if(P == 1)
4613  return typename Array3d<T>::iterator1d (this->data_[b.upper_left()[0]][plane_coordinate] + b.upper_left()[1] + col,this->d2_ * this->d3_);
4614  return typename Array3d<T>::iterator1d (this->data_[b.upper_left()[0]][b.upper_left()[1] + col] + plane_coordinate,this->d2_ * this->d3_);
4615  }
4616 
4617  template<typename T>
4618  inline
4619  typename Array3d<T>::const_iterator1d
4620  Array3d<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4621  const size_type col, const Box2d<int> & b) const
4622  {
4623  if(P == 0)
4624  return typename Array3d<T>::const_iterator1d (this->data_[plane_coordinate][b.upper_left()[0]] + b.upper_left()[1] + col,this->d3_);
4625  if(P == 1)
4626  return typename Array3d<T>::const_iterator1d (this->data_[b.upper_left()[0]][plane_coordinate] + b.upper_left()[1] + col,this->d2_ * this->d3_);
4627  return typename Array3d<T>::const_iterator1d (this->data_[b.upper_left()[0]][b.upper_left()[1] + col] + plane_coordinate,this->d2_ * this->d3_);
4628  }
4629 
4630  template<typename T>
4631  inline
4632  typename Array3d<T>::iterator1d
4633  Array3d<T>::plane_col_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4634  const size_type col, const Box2d<int> & b)
4635  {
4636  return this->Array3d::plane_col_begin(P,plane_coordinate,col,b) + b.height();
4637  }
4638 
4639  template<typename T>
4640  inline
4641  typename Array3d<T>::const_iterator1d
4642  Array3d<T>::plane_col_end(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4643  const size_type col, const Box2d<int> & b) const
4644  {
4645  return this->Array3d::plane_col_begin(P,plane_coordinate,col,b) + b.height();
4646  }
4647 
4648  template<typename T>
4649  inline
4650  typename Array3d<T>::reverse_iterator1d
4651  Array3d<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4652  const size_type col, const Box2d<int> & b)
4653  {
4654  return typename Array3d<T>::reverse_iterator1d(this->plane_col_end(P,plane_coordinate,col,b));
4655  }
4656 
4657  template<typename T>
4658  inline
4659  typename Array3d<T>::const_reverse_iterator1d
4660  Array3d<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4661  const size_type col, const Box2d<int> & b) const
4662  {
4663  return typename Array3d<T>::const_reverse_iterator1d(this->plane_col_end(P,plane_coordinate,col,b));
4664  }
4665 
4666  template<typename T>
4667  inline
4668  typename Array3d<T>::reverse_iterator1d
4669  Array3d<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4670  const size_type col, const Box2d<int> & b)
4671  {
4672  return typename Array3d<T>::reverse_iterator1d(this->plane_col_begin(P,plane_coordinate,col,b));
4673  }
4674 
4675  template<typename T>
4676  inline
4677  typename Array3d<T>::const_reverse_iterator1d
4678  Array3d<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate,
4679  const size_type col, const Box2d<int> & b) const
4680  {
4681  return typename Array3d<T>::const_reverse_iterator1d(this->plane_col_begin(P,plane_coordinate,col,b));
4682  }
4683 
4684 #endif //ALL_PLANE_ITERATOR3D
4685 
4686  //****************************************************************************
4687  // Two dimensional iterators
4688  //****************************************************************************
4689 
4690  template<typename T>
4691  inline
4692  typename Array3d<T>::iterator2d
4693  Array3d<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate)
4694  {
4695  if(P==0)
4696  {
4697  Box3d<int> b(plane_coordinate,0,0,plane_coordinate,this->d2_-1,this->d3_-1);
4698  return typename Array3d<T>::iterator2d(this,b);
4699  }
4700  if(P==1)
4701  {
4702  Box3d<int> b(0,plane_coordinate,0,this->d1_-1,plane_coordinate,this->d3_-1);
4703  return typename Array3d<T>::iterator2d(this,b);
4704  }
4705  Box3d<int> b(0,0,plane_coordinate,this->d1_-1,this->d2_-1,plane_coordinate);
4706  return typename Array3d<T>::iterator2d(this,b);
4707  }
4708 
4709  template<typename T>
4710  inline
4711  typename Array3d<T>::iterator2d
4712  Array3d<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate)
4713  {
4714  typename Array3d<T>::iterator2d it = this->plane_upper_left(P,plane_coordinate);
4715  if(P==0)
4716  {
4717  DPoint2d<int> dp(this->d2_,this->d3_);
4718  return it + dp;
4719  }
4720  if(P==1)
4721  {
4722  DPoint2d<int> dp(this->d1_,this->d3_);
4723  return it + dp;
4724  }
4725  DPoint2d<int> dp(this->d1_,this->d2_);
4726  return it + dp;
4727  }
4728 
4729  template<typename T>
4730  inline
4731  typename Array3d<T>::const_iterator2d
4732  Array3d<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate) const
4733  {
4734  if(P==0)
4735  {
4736  Box3d<int> b(plane_coordinate,0,0,plane_coordinate,this->d2_-1,this->d3_-1);
4737  return typename Array3d<T>::const_iterator2d(this,b);
4738  }
4739  if(P==1)
4740  {
4741  Box3d<int> b(0,plane_coordinate,0,this->d1_-1,plane_coordinate,this->d3_-1);
4742  return typename Array3d<T>::const_iterator2d(this,b);
4743  }
4744  Box3d<int> b(0,0,plane_coordinate,this->d1_-1,this->d2_-1,plane_coordinate);
4745  return typename Array3d<T>::const_iterator2d(this,b);
4746  }
4747 
4748  template<typename T>
4749  inline
4750  typename Array3d<T>::const_iterator2d
4751  Array3d<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate) const
4752  {
4753  typename Array3d<T>::const_iterator2d it = this->plane_upper_left(P,plane_coordinate);
4754  if(P==0)
4755  {
4756  DPoint2d<int> dp(this->d2_,this->d3_);
4757  return it + dp;
4758  }
4759  if(P==1)
4760  {
4761  DPoint2d<int> dp(this->d1_,this->d3_);
4762  return it + dp;
4763  }
4764  DPoint2d<int> dp(this->d1_,this->d2_);
4765  return it + dp;
4766  }
4767 
4768  template<typename T>
4769  inline
4770  typename Array3d<T>::reverse_iterator2d
4771  Array3d<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate)
4772  {
4773  DPoint2d<int> dp(1,0);
4774  return typename Array3d<T>::reverse_iterator2d(this->plane_bottom_right(P,plane_coordinate) - dp);
4775  }
4776 
4777  template<typename T>
4778  inline
4779  typename Array3d<T>::reverse_iterator2d
4780  Array3d<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate)
4781  {
4782  return typename Array3d<T>::reverse_iterator2d(this->plane_upper_left(P,plane_coordinate));
4783  }
4784 
4785  template<typename T>
4786  inline
4787  typename Array3d<T>::const_reverse_iterator2d
4788  Array3d<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate) const
4789  {
4790  DPoint2d<int> dp(1,0);
4791  return typename Array3d<T>::const_reverse_iterator2d(this->plane_bottom_right(P,plane_coordinate) - dp);
4792  }
4793 
4794  template<typename T>
4795  inline
4796  typename Array3d<T>::const_reverse_iterator2d
4797  Array3d<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate) const
4798  {
4799  return typename Array3d<T>::const_reverse_iterator2d(this->plane_upper_left(P,plane_coordinate));
4800  }
4801 
4802  //-------------------- Box plane iterators 2d----------------------
4803 
4804  template<typename T>
4805  inline
4806  typename Array3d<T>::iterator2d
4807  Array3d<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b)
4808  {
4809  return typename Array3d<T>::iterator2d(this,P,plane_coordinate,b);
4810  }
4811 
4812  template<typename T>
4813  inline
4814  typename Array3d<T>::iterator2d
4815  Array3d<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b)
4816  {
4817  DPoint2d<int> dp(b.height(),b.width());
4818  typename Array3d<T>::iterator2d it = this->plane_upper_left(P,plane_coordinate,b);
4819  return it + dp;
4820  }
4821 
4822  template<typename T>
4823  inline
4824  typename Array3d<T>::const_iterator2d
4825  Array3d<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b) const
4826  {
4827  return typename Array3d<T>::const_iterator2d(this,P,plane_coordinate,b);
4828  }
4829 
4830  template<typename T>
4831  inline
4832  typename Array3d<T>::const_iterator2d
4833  Array3d<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b) const
4834  {
4835  DPoint2d<int> dp(b.height(),b.width());
4836  typename Array3d<T>::const_iterator2d it = this->plane_upper_left(P,plane_coordinate,b);
4837  return it + dp;
4838  }
4839 
4840  template<typename T>
4841  inline
4842  typename Array3d<T>::reverse_iterator2d
4843  Array3d<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b)
4844  {
4845  DPoint2d<int> dp(1,0);
4846  return typename Array3d<T>::reverse_iterator2d(this->plane_bottom_right(P,plane_coordinate,b)-dp);
4847  }
4848 
4849  template<typename T>
4850  inline
4851  typename Array3d<T>::reverse_iterator2d
4852  Array3d<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b)
4853  {
4854  return typename Array3d<T>::reverse_iterator2d(this->plane_upper_left(P,plane_coordinate,b));
4855  }
4856 
4857  template<typename T>
4858  inline
4859  typename Array3d<T>::const_reverse_iterator2d
4860  Array3d<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b) const
4861  {
4862  DPoint2d<int> dp(1,0);
4863  return typename Array3d<T>::const_reverse_iterator2d(this->plane_bottom_right(P,plane_coordinate,b)-dp);
4864  }
4865 
4866  template<typename T>
4867  inline
4868  typename Array3d<T>::const_reverse_iterator2d
4869  Array3d<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Array3d<T>::size_type plane_coordinate, const Box2d<int>& b) const
4870  {
4871  return typename Array3d<T>::const_reverse_iterator2d(this->plane_upper_left(P,plane_coordinate,b));
4872  }
4873 
4874  //****************************************************************************
4875  // Three dimensional iterators
4876  //****************************************************************************
4877 
4878  //------------------------ Global iterators------------------------------------
4879 
4880  template<typename T>
4881  inline
4883  {
4884  return typename Array3d<T>::iterator3d(this,Box3d<int>(0,0,0,this->d1_-1,this->d2_-1,this->d3_-1));
4885  }
4886 
4887  template<typename T>
4888  inline
4890  {
4891  return typename Array3d<T>::const_iterator3d(this,Box3d<int>(0,0,0,this->d1_-1,this->d2_-1,this->d3_-1));
4892  }
4893 
4894 
4895  template<typename T>
4896  inline
4898  {
4899  DPoint3d<int> dp(this->d1_,this->d2_,this->d3_);
4900  typename Array3d<T>::iterator3d it = (*this).front_upper_left() + dp;
4901  return it;
4902  }
4903 
4904  template<typename T>
4905  inline
4907  {
4908  DPoint3d<int> dp(this->d1_,this->d2_,this->d3_);
4909  typename Array3d<T>::const_iterator3d it = (*this).front_upper_left() + dp;
4910  return it;
4911  }
4912 
4913  template<typename T>
4914  inline
4917  {
4918  return typename Array3d<T>::reverse_iterator3d(this->front_upper_left());
4919  }
4920 
4921  template<typename T>
4922  inline
4925  {
4926  return typename Array3d<T>::const_reverse_iterator3d(this->front_upper_left());
4927  }
4928 
4929  template<typename T>
4930  inline
4933  {
4934  DPoint3d<int> dp(1,1,0);
4935  return typename Array3d<T>::reverse_iterator3d(this->back_bottom_right() - dp);
4936  }
4937 
4938  template<typename T>
4939  inline
4942  {
4943  DPoint3d<int> dp(1,1,0);
4944  return typename Array3d<T>::const_reverse_iterator3d(this->back_bottom_right() - dp);
4945  }
4946 
4947  //------------------------ Box iterators------------------------------------
4948 
4949  template<typename T>
4950  inline
4952  {
4953  return typename Array3d<T>::iterator3d(this,box);
4954  }
4955 
4956  template<typename T>
4957  inline
4959  {
4960  return typename Array3d<T>::const_iterator3d(this,box);
4961  }
4962 
4963 
4964  template<typename T>
4965  inline
4966  typename Array3d<T>::iterator3d
4968  {
4969  DPoint3d<int> dp(box.depth(),box.height(),box.width());
4970  typename Array3d<T>::iterator3d it = (*this).front_upper_left(box) + dp;
4971  return it;
4972  }
4973 
4974  template<typename T>
4975  inline
4978  {
4979  DPoint3d<int> dp(box.depth(),box.height(),box.width());
4980  typename Array3d<T>::const_iterator3d it = (*this).front_upper_left(box) + dp;
4981  return it;
4982  }
4983 
4984  template<typename T>
4985  inline
4988  {
4989  return typename Array3d<T>::reverse_iterator3d(this->front_upper_left(box));
4990  }
4991 
4992  template<typename T>
4993  inline
4996  {
4997  return typename Array3d<T>::const_reverse_iterator3d(this->front_upper_left(box));
4998  }
4999 
5000  template<typename T>
5001  inline
5004  {
5005  DPoint3d<int> dp(1,1,0);
5006  return typename Array3d<T>::reverse_iterator3d(this->back_bottom_right(box) - dp);
5007  }
5008 
5009  template<typename T>
5010  inline
5013  {
5014  DPoint3d<int> dp(1,1,0);
5015  return typename Array3d<T>::const_reverse_iterator3d(this->back_bottom_right(box) - dp);
5016  }
5017 
5018  //------------------------ Range iterators------------------------------------
5019 
5020  template<typename T>
5021  inline
5023  Array3d<T>::front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
5024  const Range<int>& col_range)
5025  {
5026  return typename Array3d<T>::iterator3d_range(this,slice_range,row_range,col_range);
5027  }
5028 
5029  template<typename T>
5030  inline
5032  Array3d<T>::back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
5033  const Range<int>& col_range)
5034  {
5035  DPoint3d<int> dp(slice_range.iterations()+1,row_range.iterations()+1,col_range.iterations()+1);
5036  return typename Array3d<T>::iterator3d_range((*this).front_upper_left(slice_range,row_range,col_range) + dp);
5037  }
5038 
5039 
5040  template<typename T>
5041  inline
5043  Array3d<T>::front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
5044  const Range<int>& col_range) const
5045  {
5046  return typename Array3d<T>::const_iterator3d_range(this,slice_range,row_range,col_range);
5047  }
5048 
5049 
5050  template<typename T>
5051  inline
5053  Array3d<T>::back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
5054  const Range<int>& col_range) const
5055  {
5056  DPoint3d<int> dp(slice_range.iterations()+1,row_range.iterations()+1,col_range.iterations()+1);
5057  return typename Array3d<T>::const_iterator3d_range((*this).front_upper_left(slice_range,row_range,col_range) + dp);
5058  }
5059 
5060  template<typename T>
5061  inline
5063  Array3d<T>::rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
5064  const Range<int>& col_range)
5065  {
5066  slip::DPoint3d<int> dp(1,1,0);
5067  return typename Array3d<T>::reverse_iterator3d_range(this->back_bottom_right(slice_range,row_range,col_range) - dp);
5068  }
5069 
5070  template<typename T>
5071  inline
5073  Array3d<T>::rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
5074  const Range<int>& col_range) const
5075  {
5076  slip::DPoint3d<int> dp(1,1,0);
5077  return typename Array3d<T>::const_reverse_iterator3d_range(this->back_bottom_right(slice_range,row_range,col_range)- dp);
5078  }
5079 
5080  template<typename T>
5081  inline
5083  Array3d<T>::rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
5084  const Range<int>& col_range)
5085  {
5086  return typename Array3d<T>::reverse_iterator3d_range(this->front_upper_left(slice_range,row_range,col_range));
5087  }
5088 
5089  template<typename T>
5090  inline
5092  Array3d<T>::rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
5093  const Range<int>& col_range) const
5094  {
5095  return typename Array3d<T>::const_reverse_iterator3d_range(this->front_upper_left(slice_range,row_range,col_range));
5096  }
5097 
5098 
5100 
5101 
5103  // i/o operators
5105 
5106  /* @{ */
5107  template <typename T>
5108  inline
5109  std::ostream& operator<<(std::ostream & out, const Array3d<T>& a)
5110  {
5111  for(std::size_t i = 0; i < a.d1_; ++i)
5112  {
5113  for(std::size_t j = 0; j < a.d2_; ++j)
5114  {
5115  for(std::size_t k = 0; k < a.d3_; ++k)
5116  {
5117  out<<a.data_[i][j][k]<<" ";
5118  }
5119  out<<std::endl;
5120  }
5121  out<<std::endl;
5122  }
5123  out<<std::endl;
5124  return out;
5125  }
5126  /* @} */
5128 
5129 
5131  // Elements access operators
5133  template<typename T>
5134  inline
5135  T** Array3d<T>::operator[](const typename Array3d<T>::size_type k)
5136  {
5137  assert(this->data_ != 0);
5138  assert(k < this->d1_);
5139  return this->data_[k];
5140  }
5141 
5142  template<typename T>
5143  inline
5144  const T* const* Array3d<T>::operator[](const typename Array3d<T>::size_type k) const
5145  {
5146  assert(this->data_ != 0);
5147  assert(k < this->d1_);
5148  return this->data_[k];
5149  }
5150 
5151 
5152 
5153  template<typename T>
5154  inline
5155  typename Array3d<T>::reference
5156  Array3d<T>::operator()(const typename Array3d<T>::size_type k,
5157  const typename Array3d<T>::size_type i,
5158  const typename Array3d<T>::size_type j)
5159  {
5160  assert(this->data_ != 0);
5161  assert(k < this->d1_);
5162  assert(i < this->d2_);
5163  assert(j < this->d3_);
5164  return this->data_[k][i][j];
5165  }
5166 
5167  template<typename T>
5168  inline
5169  typename Array3d<T>::const_reference
5170  Array3d<T>::operator()(const typename Array3d<T>::size_type k,
5171  const typename Array3d<T>::size_type i,
5172  const typename Array3d<T>::size_type j) const
5173  {
5174  assert(this->data_ != 0);
5175  assert(k < this->d1_);
5176  assert(i < this->d2_);
5177  assert(j < this->d3_);
5178  return this->data_[k][i][j];
5179  }
5181 
5182  template<typename T>
5183  inline
5184  std::string
5185  Array3d<T>::name() const {return "Array3d";}
5186 
5187 
5188  template<typename T>
5189  inline
5190  typename Array3d<T>::size_type
5191  Array3d<T>::dim1() const {return this->d1_;}
5192 
5193  template<typename T>
5194  inline
5195  typename Array3d<T>::size_type
5196  Array3d<T>::slices() const {return this->dim1();}
5197 
5198  template<typename T>
5199  inline
5200  typename Array3d<T>::size_type
5201  Array3d<T>::dim2() const {return this->d2_;}
5202 
5203  template<typename T>
5204  inline
5205  typename Array3d<T>::size_type
5206  Array3d<T>::rows() const {return this->dim2();}
5207 
5208  template<typename T>
5209  inline
5210  typename Array3d<T>::size_type
5211  Array3d<T>::dim3() const {return this->d3_;}
5212 
5213  template<typename T>
5214  inline
5215  typename Array3d<T>::size_type
5216  Array3d<T>::cols() const {return this->dim3();}
5217 
5218  template<typename T>
5219  inline
5220  typename Array3d<T>::size_type
5221  Array3d<T>::columns() const {return this->dim3();}
5222 
5223 
5224  template<typename T>
5225  inline
5226  typename Array3d<T>::size_type
5227  Array3d<T>::size() const {return this->size_;}
5228 
5229  template<typename T>
5230  inline
5231  typename Array3d<T>::size_type
5233  {
5234  return typename Array3d<T>::size_type(-1)/sizeof(T);
5235  }
5236 
5237  template<typename T>
5238  inline
5239  typename Array3d<T>::size_type
5240  Array3d<T>::slice_size() const {return this->slice_size_;}
5241 
5242 
5243  template<typename T>
5244  inline
5245  bool Array3d<T>::empty()const {return this->size_ == 0;}
5246 
5247  template<typename T>
5248  inline
5250  {
5251  assert(this->d1_ == M.d1_);
5252  assert(this->d2_ == M.d2_);
5253  assert(this->d3_ == M.d3_);
5254  std::swap_ranges(this->begin(),this->end(),M.begin());
5255  }
5256 
5257 
5259  // comparison operators
5261 
5262  /* @{ */
5263  template<typename T>
5264  inline
5265  bool operator==(const Array3d<T>& x,
5266  const Array3d<T>& y)
5267  {
5268  return ( x.size() == y.size()
5269  && std::equal(x.begin(),x.end(),y.begin()));
5270  }
5271 
5272  template<typename T>
5273  inline
5274  bool operator!=(const Array3d<T>& x,
5275  const Array3d<T>& y)
5276  {
5277  return !(x == y);
5278  }
5279  /* @} */
5281  /* @{ */
5282  template<typename T>
5283  inline
5284  bool operator<(const Array3d<T>& x,
5285  const Array3d<T>& y)
5286  {
5287  return std::lexicographical_compare(x.begin(), x.end(),
5288  y.begin(), y.end());
5289  }
5290 
5291 
5292  template<typename T>
5293  inline
5294  bool operator>(const Array3d<T>& x,
5295  const Array3d<T>& y)
5296  {
5297  return (y < x);
5298  }
5299 
5300  template<typename T>
5301  inline
5302  bool operator<=(const Array3d<T>& x,
5303  const Array3d<T>& y)
5304  {
5305  return !(y < x);
5306  }
5307 
5308  template<typename T>
5309  inline
5310  bool operator>=(const Array3d<T>& x,
5311  const Array3d<T>& y)
5312  {
5313  return !(x < y);
5314  }
5315  /* @} */
5316 
5318 
5319 
5321  // private methods
5323 
5324  template<typename T>
5325  inline
5326  void Array3d<T>::allocate()
5327  {
5328  if( this->d1_ != 0 && this->d2_ != 0 && this->d3_ != 0)
5329  {
5330  this->data_ = new T**[this->d1_];
5331  this->data_[0] = new T*[this->d1_ * this->d2_];
5332  this->data_[0][0] = new T[this->d1_ * this->d2_ * this->d3_];
5333 
5334  for(std::size_t j = 1; j < this->d2_; ++j)
5335  {
5336  this->data_[0][j] = this->data_[0][j-1] + this->d3_;
5337  }
5338  for(std::size_t i = 1; i < this->d1_; ++i)
5339  {
5340  this->data_[i] = this->data_[i-1] + this->d2_;
5341  this->data_[i][0] = this->data_[i-1][0] + this->d2_*this->d3_;
5342  for(std::size_t j = 1; j < this->d2_; ++j)
5343  {
5344  this->data_[i][j] = this->data_[i][j-1] + this->d3_;
5345  }
5346  }
5347  }
5348  else
5349  {
5350  this->data_ = 0;
5351  }
5352  }
5353 
5354  template<typename T>
5355  inline
5356  void Array3d<T>::desallocate()
5357  {
5358  if(this->data_ != 0)
5359  {
5360  delete[] (this->data_[0][0]);
5361  delete[] (this->data_[0]);
5362  delete[] (this->data_);
5363  }
5364  }
5365 
5366  template<typename T>
5367  inline
5368  void Array3d<T>::copy_attributes(const Array3d<T>& rhs)
5369  {
5370  this->d1_ = rhs.d1_;
5371  this->d2_ = rhs.d2_;
5372  this->d3_ = rhs.d3_;
5373  this->size_ = rhs.size_;
5374  this->slice_size_ = rhs.slice_size_;
5375  }
5376 
5377 
5379 
5380 }//slip::
5381 
5382 #endif //SLIP_ARRAY3D_HH
size_type max_size() const
Returns the maximal size (number of elements) in the Array3d.
Definition: Array3d.hpp:5232
slip::stride_iterator< const_col_iterator > const_col_range_iterator
Definition: Array3d.hpp:197
value_type const & const_reference
Definition: Array3d.hpp:171
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
const Array3d< T > const_self
Definition: Array3d.hpp:168
std::size_t iterations() const
Rerturns the number of iterations of the range.
Definition: Range.hpp:305
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
Definition: Array3d.hpp:3218
This is some iterator to iterate a 3d container into a plane area defined by the subscripts of the 3d...
iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate)
Returns a read/write iterator that points to the last element of the plane in the Array3d...
Provides a class to modelize 3d points.
pointer row_iterator
Definition: Array3d.hpp:188
CoordType width() const
compute the width of the Box3d.
Definition: Box3d.hpp:408
iterator3d front_upper_left()
Returns a read/write iterator3d that points to the first element of the Array3d. It points to the fro...
Definition: Array3d.hpp:4882
std::reverse_iterator< slice_iterator > reverse_slice_iterator
Definition: Array3d.hpp:199
Difference of Point3D class, specialization of DPoint<CoordType,DIM> with DIM = 3.
slice_iterator slice_end(const size_type row, const size_type col)
Returns a read/write iterator that points to the one past the end element of the line (row...
reverse_iterator3d rback_bottom_right()
Returns a read/write reverse iterator3d. It points to past the front upper left element of the Array3...
Definition: Array3d.hpp:4916
size_type dim1() const
Returns the number of slices (first dimension size) in the Array3d.
Definition: Array3d.hpp:5191
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
This is a three-dimensional dynamic and generic container. This container statisfies the Bidirectionn...
Definition: Array3d.hpp:109
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
Definition: Array3d.hpp:226
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Array3d. Iteration is done in ordinary element order.
Definition: Array3d.hpp:3644
std::reverse_iterator< const_slice_iterator > const_reverse_slice_iterator
Definition: Array3d.hpp:200
size_type columns() const
Returns the number of columns (third dimension size) in the Array3d.
Definition: Array3d.hpp:5221
std::reverse_iterator< const_slice_range_iterator > const_reverse_slice_range_iterator
Definition: Array3d.hpp:206
slip::Array3d< unsigned char > Array3d_uc
unsigned char alias
Definition: Array3d.hpp:3497
self & operator=(const Array3d< T > &rhs)
Assign a Array3d.
Definition: Array3d.hpp:3576
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
Definition: Array3d.hpp:204
std::size_t size_type
Definition: Array3d.hpp:177
value_type * iterator
Definition: Array3d.hpp:179
std::reverse_iterator< const_iterator3d > const_reverse_iterator3d
Definition: Array3d.hpp:235
slip::Array3d< float > Array3d_f
float alias
Definition: Array3d.hpp:3481
T ** operator[](const size_type k)
slip::iterator3d_plane< self > iterator2d
Definition: Array3d.hpp:222
Provides a class to modelize the difference of slip::Point3d.
size_type cols() const
Returns the number of columns (third dimension size) in the Array3d.
Definition: Array3d.hpp:5216
size_type slices() const
Returns the number of slices (first dimension size) in the Array3d.
Definition: Array3d.hpp:5196
iterator3d default_iterator
Definition: Array3d.hpp:240
slip::const_iterator3d_range< const_self > const_iterator3d_range
Definition: Array3d.hpp:232
std::reverse_iterator< iterator3d > reverse_iterator3d
Definition: Array3d.hpp:234
std::reverse_iterator< iterator > reverse_iterator
Definition: Array3d.hpp:182
row_iterator row_begin(const size_type slice, const size_type row)
Returns a read/write iterator that points to the first element of the row row of the slice slice in t...
slip::stride_iterator< const_pointer > const_col_iterator
Definition: Array3d.hpp:191
slip::stride_iterator< slice_iterator > slice_range_iterator
Definition: Array3d.hpp:192
row_iterator row_end(const size_type slice, const size_type row)
Returns a read/write iterator that points to the past-the-end element of the row row of the slice sli...
stride_iterator< pointer > slice_iterator
Definition: Array3d.hpp:186
reverse_row_iterator row_rbegin(const size_type slice, const size_type row)
Returns a read/write reverse iterator that points to the last element of the row row of the slice sli...
reverse_slice_iterator slice_rbegin(const size_type row, const size_type col)
Returns a read/write iterator that points to the last element of the line (row,col) threw the slices ...
stride_iterator< const_pointer > const_slice_iterator
Definition: Array3d.hpp:187
PLANE_ORIENTATION
Choose between different plane orientations.
reverse_iterator plane_rbegin(const size_type slice)
Returns a read/write reverse iterator that points to the last element in the slice plane of the Array...
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
Provides a class to manipulate iterator3d within a slip::Range. It is used to iterate throw 3d contai...
const_iterator3d const_default_iterator
Definition: Array3d.hpp:241
slip::Array3d< char > Array3d_c
char alias
Definition: Array3d.hpp:3495
slip::Array3d< double > Array3d_d
double alias
Definition: Array3d.hpp:3479
std::string name() const
Returns the name of the class.
Definition: Array3d.hpp:5185
std::reverse_iterator< col_iterator > reverse_col_iterator
Definition: Array3d.hpp:203
slip::stride_iterator< pointer > row_range_iterator
Definition: Array3d.hpp:194
size_type rows() const
Returns the number of rows (second dimension size) in the Array3d.
Definition: Array3d.hpp:5206
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
Definition: Array3d.hpp:207
iterator end()
Returns a read/write iterator that points one past the last element in the Array3d. Iteration is done in ordinary element order.
Definition: Array3d.hpp:3665
reverse_iterator2d plane_rupper_left(PLANE_ORIENTATION P, const size_type plane_coordinate)
Returns a read/write reverse_iterator that points to the bottom right element of the plane in the Arr...
std::reverse_iterator< slice_range_iterator > reverse_slice_range_iterator
Definition: Array3d.hpp:205
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
Definition: Array3d.hpp:208
reverse_iterator3d rfront_upper_left()
Returns a read/write reverse iterator3d. It points to the back bottom right element of the Array3d...
Definition: Array3d.hpp:4932
slip::Array3d< short > Array3d_s
short alias
Definition: Array3d.hpp:3487
void swap(Array3d &M)
Swaps data with another Array3d.
Definition: Array3d.hpp:5249
size_type dim2() const
Returns the number of rows (second dimension size) in the Array3d.
Definition: Array3d.hpp:5201
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
Definition: Array3d.hpp:209
Array3d()
Constructs a Array3d.
Definition: Array3d.hpp:3509
slip::iterator3d_range< self > iterator3d_range
Definition: Array3d.hpp:231
std::reverse_iterator< iterator2d > reverse_iterator2d
Definition: Array3d.hpp:225
Provides a class to manipulate 3d box.
reverse_slice_iterator slice_rend(const size_type row, const size_type col)
Returns a read/write iterator that points to the one before the first element of the line (row...
~Array3d()
Destructor of the Array3d.
Definition: Array3d.hpp:3563
std::reverse_iterator< const_iterator > const_reverse_row_iterator
Definition: Array3d.hpp:202
ptrdiff_t difference_type
Definition: Array3d.hpp:176
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Definition: copy_ext.hpp:177
bool is_valid() const
Returns true if the range is valid :
Definition: Range.hpp:322
SubType start() const
Accessor of the start subscript of the Range.
Definition: Range.hpp:284
Provides a class to manipulate iterator2d within a slip::Box3d. It is used to iterate throw 3d contai...
size_type slice_size() const
Returns the number of elements in a slice of the Array3d.
Definition: Array3d.hpp:5240
slip::Array3d< unsigned long > Array3d_ul
unsigned long alias
Definition: Array3d.hpp:3485
col_iterator col_end(const size_type slice, const size_type col)
Returns a read/write iterator that points to the past-the-end element of the column column of the sli...
slip::stride_iterator< pointer > col_iterator
Definition: Array3d.hpp:190
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Array3d...
Definition: Array3d.hpp:3686
slip::Array3d< long > Array3d_l
long alias
Definition: Array3d.hpp:3483
reverse_col_iterator col_rbegin(const size_type slice, const size_type col)
Returns a read/write reverse iterator that points to the last element of the column column of the sli...
static const std::size_t DIM
Definition: Array3d.hpp:243
reverse_iterator2d plane_rbottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate)
Returns a read/write reverse_iterator that points to the upper left element of the plane in the Array...
value_type const * const_pointer
Definition: Array3d.hpp:174
slip::iterator3d_box< self > iterator3d
Definition: Array3d.hpp:229
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator
Definition: Array3d.hpp:210
CoordType depth() const
compute the depth of the Box3d.
Definition: Box3d.hpp:416
slip::Array3d< unsigned int > Array3d_ui
unsigned int alias
Definition: Array3d.hpp:3493
Provides a class to iterate 3d containers throw a planes.
slip::Array3d< int > Array3d_i
int alias
Definition: Array3d.hpp:3491
This is some iterator to iterate a 3d container into a Box area defined by the subscripts of the 3d c...
col_iterator col_begin(const size_type slice, const size_type col)
Returns a read/write iterator that points to the first element of the column column of the slice slic...
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Array3d. Iteration is done in reverse element order.
Definition: Array3d.hpp:3672
slip::stride_iterator< const_pointer > const_row_range_iterator
Definition: Array3d.hpp:195
iterator plane_end(const size_type slice)
Returns a read/write iterator that points one past the last element in the slice plane of the Array3d...
iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate)
Returns a read/write iterator that points to the first element of the plane in the Array3d...
std::ostream & operator<<(std::ostream &out, const Array< T > &a)
Definition: Array.hpp:1282
std::reverse_iterator< iterator3d_range > reverse_iterator3d_range
Definition: Array3d.hpp:236
iterator3d back_bottom_right()
Returns a read/write iterator3d that points to the past the end element of the Array3d. It points to past the end element of the back bottom right element of the Array3d.
Definition: Array3d.hpp:4897
size_type dim3() const
Returns the number of columns (third dimension size) in the Array3d.
Definition: Array3d.hpp:5211
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
Definition: Array3d.hpp:3232
reverse_iterator plane_rend(const size_type slice)
Returns a read/write reverse iterator that points to one before the first element in the slice plane ...
std::reverse_iterator< iterator > reverse_row_iterator
Definition: Array3d.hpp:201
Array3d(const size_type d1, const size_type d2, const size_type d3, InputIterator first, InputIterator last)
Contructs a Array3d from a range.
Definition: Array3d.hpp:303
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
slice_iterator slice_begin(const size_type row, const size_type col)
Returns a read/write iterator that points to the first element of the line (row,col) threw the slices...
reference operator()(const size_type k, const size_type i, const size_type j)
Subscript access to the data contained in the Array3d.
slip::const_iterator3d_plane< const_self > const_iterator2d
Definition: Array3d.hpp:223
value_type & reference
Definition: Array3d.hpp:170
reverse_row_iterator row_rend(const size_type slice, const size_type row)
Returns a read/write reverse iterator that points to the first element of the row row of the slice sl...
int stride() const
Accessor of the stride of the Range.
Definition: Range.hpp:298
void resize(std::size_t d1, std::size_t d2, std::size_t d3, const T &val=T())
Resizes a Array3d.
Definition: Array3d.hpp:3606
const_pointer const_row_iterator
Definition: Array3d.hpp:189
This is some iterator to iterate a 3d container into a plane area defined by the subscripts of the 3d...
size_type size() const
Returns the number of elements in the Array3d.
Definition: Array3d.hpp:5227
value_type * pointer
Definition: Array3d.hpp:173
slip::stride_iterator< col_iterator > col_range_iterator
Definition: Array3d.hpp:196
bool empty() const
Returns true if the Array3d is empty. (Thus size() == 0)
Definition: Array3d.hpp:5245
Provides a class to iterate a 1d range according to a step.
slip::const_iterator3d_box< const_self > const_iterator3d
Definition: Array3d.hpp:230
friend class boost::serialization::access
Definition: Array3d.hpp:3453
slip::stride_iterator< const_slice_iterator > const_slice_range_iterator
Definition: Array3d.hpp:193
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
slip::Array3d< unsigned short > Array3d_us
unsigned long alias
Definition: Array3d.hpp:3489
reverse_col_iterator col_rend(const size_type slice, const size_type col)
Returns a read/write reverse iterator that points to the first element of the column column of the sl...
iterator plane_begin(const size_type slice)
Returns a read/write iterator that points to the first element in the in the slice plane of the Array...
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Array3d.hpp:183
CoordType height() const
compute the height of the Box3d.
Definition: Box3d.hpp:412
value_type const * const_iterator
Definition: Array3d.hpp:180
SubType stop() const
Accessor of the stop subscript of the Range.
Definition: Range.hpp:291
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
Definition: Array3d.hpp:3207
bool operator>=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1485
std::reverse_iterator< const_iterator3d_range > const_reverse_iterator3d_range
Definition: Array3d.hpp:237
This is some iterator to iterate a 3d container into a Box area defined by the subscripts of the 3d c...