SLIP  1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Volume.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_VOLUME_HPP
76 #define SLIP_VOLUME_HPP
77 
78 #include <iostream>
79 #include <iomanip>
80 #include <fstream>
81 #include <iterator>
82 #include <cassert>
83 #include <numeric>
84 #include <algorithm>
85 #include <cmath>
86 #include <vector>
87 #include <string>
88 #include <cstddef>
89 #include "Matrix3d.hpp"
90 #include "stride_iterator.hpp"
91 #include "apply.hpp"
92 #include "io_tools.hpp"
93 #include "iterator3d_plane.hpp"
94 #include "iterator3d_box.hpp"
95 #include "iterator3d_range.hpp"
96 
97 
98 #include <boost/serialization/access.hpp>
99 #include <boost/serialization/split_member.hpp>
100 #include <boost/serialization/version.hpp>
101 
102 
103 namespace slip
104 {
105 
106  template <typename T>
107  class Volume;
108 
109  template <typename T>
110  class Matrix3d;
111 
112  template <typename T>
113  std::ostream& operator<<(std::ostream & out, const slip::Volume<T>& a);
114 
115  template<typename T>
116  bool operator==(const slip::Volume<T>& x,
117  const slip::Volume<T>& y);
118 
119  template<typename T>
120  bool operator!=(const slip::Volume<T>& x,
121  const slip::Volume<T>& y);
122 
123  template<typename T>
124  bool operator<(const slip::Volume<T>& x,
125  const slip::Volume<T>& y);
126 
127  template<typename T>
128  bool operator>(const slip::Volume<T>& x,
129  const slip::Volume<T>& y);
130 
131  template<typename T>
132  bool operator<=(const slip::Volume<T>& x,
133  const slip::Volume<T>& y);
134 
135  template<typename T>
136  bool operator>=(const slip::Volume<T>& x,
137  const slip::Volume<T>& y);
138 
161  template <typename T>
162  class Volume
163  {
164  public :
165 
166  typedef T value_type;
167  typedef Volume<T> self;
168 
169  typedef value_type* pointer;
170  typedef const value_type* const_pointer;
172  typedef const value_type& const_reference;
173 
174  typedef ptrdiff_t difference_type;
175  typedef std::size_t size_type;
176 
177  typedef pointer iterator;
179 
180  typedef std::reverse_iterator<iterator> reverse_iterator;
181  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
182 
183 
184  //slice, row and col iterator
197  typedef std::reverse_iterator<slice_range_iterator> reverse_slice_range_iterator;
198  typedef std::reverse_iterator<const_slice_range_iterator> const_reverse_slice_range_iterator;
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 
206  typedef std::reverse_iterator<row_range_iterator> reverse_row_range_iterator;
207  typedef std::reverse_iterator<const_row_range_iterator> const_reverse_row_range_iterator;
208  typedef std::reverse_iterator<col_range_iterator> reverse_col_range_iterator;
209  typedef std::reverse_iterator<const_col_range_iterator> const_reverse_col_range_iterator;
210 
211 #ifdef ALL_PLANE_ITERATOR3D
212  //generic 1d iterator
213  typedef slip::stride_iterator<pointer> iterator1d;
214  typedef slip::stride_iterator<const_pointer> const_iterator1d;
215 
216  typedef std::reverse_iterator<iterator1d> reverse_iterator1d;
217  typedef std::reverse_iterator<const_iterator1d> const_reverse_iterator1d;
218 #endif //ALL_PLANE_ITERATOR3D
219 
220  //iterator 2d
223  typedef std::reverse_iterator<iterator2d> reverse_iterator2d;
224  typedef std::reverse_iterator<const_iterator2d> const_reverse_iterator2d;
225 
226  //iterator 3d
231 
232  typedef std::reverse_iterator<iterator3d> reverse_iterator3d;
233  typedef std::reverse_iterator<const_iterator3d> const_reverse_iterator3d;
234  typedef std::reverse_iterator<iterator3d_range> reverse_iterator3d_range;
235  typedef std::reverse_iterator<const_iterator3d_range> const_reverse_iterator3d_range;
236 
237  //default iterator of the container
240 
241  static const std::size_t DIM = 3;
242  public:
247 
251  Volume();
252 
261  Volume(const std::size_t d1,
262  const std::size_t d2,
263  const std::size_t d3);
264 
272  Volume(const std::size_t d1,
273  const std::size_t d2,
274  const std::size_t d3,
275  const T& val);
283  Volume(const std::size_t d1,
284  const std::size_t d2,
285  const std::size_t d3,
286  const T* val);
287 
300  template<typename InputIterator>
301  Volume(const size_type d1,
302  const size_type d2,
303  const size_type d3,
304  InputIterator first,
305  InputIterator last):
306  matrix_(new slip::Matrix3d<T>(d1,d2,d3,first,last))
307  {}
308 
312  Volume(const Volume<T>& rhs);
313 
314 
318  ~Volume();
319 
320 
332  void resize(std::size_t d1,
333  std::size_t d2,
334  std::size_t d3,
335  const T& val = T());
336 
341 
342  //****************************************************************************
343  // One dimensional iterators
344  //****************************************************************************
345 
346 
347 
348  //----------------------Global iterators------------------------------
349 
369  const_iterator begin() const;
370 
390  iterator begin();
391 
411  iterator end();
412 
432  const_iterator end() const;
433 
454 
475 
496 
517 
523  //--------------------One dimensional slice iterators----------------------
524 
525 
547  slice_iterator slice_begin(const size_type row, const size_type col);
548 
570  const_slice_iterator slice_begin(const size_type row, const size_type col) const;
571 
593  slice_iterator slice_end(const size_type row, const size_type col);
594 
616  const_slice_iterator slice_end(const size_type row, const size_type col) const;
617 
618 
642 
665  const_reverse_slice_iterator slice_rbegin(const size_type row, const size_type col) const;
666 
690 
691 
714  const_reverse_slice_iterator slice_rend(const size_type row, const size_type col) const;
715 
722  //-------------------row iterators----------
723 
734  row_iterator row_begin(const size_type slice,
735  const size_type row);
736 
748  const size_type row) const;
749 
750 
761  row_iterator row_end(const size_type slice,
762  const size_type row);
763 
764 
776  const size_type row) const;
777 
778 
790  const size_type row);
791 
803  const size_type row) const;
804 
805 
817  const size_type row);
818 
819 
831  const size_type row) const;
832 
838  //-------------------col iterators----------
839 
850  col_iterator col_begin(const size_type slice,
851  const size_type col);
852 
853 
865  const size_type col) const;
866 
877  col_iterator col_end(const size_type slice,
878  const size_type col);
879 
880 
892  const size_type col) const;
893 
894 
906  const size_type col);
907 
908 
920  const size_type col) const;
921 
933  const size_type col);
934 
935 
947  const size_type col) const;
948 
956  //------------------------slice range iterators -----------------------
957 
985  const slip::Range<int>& range);
986 
987 
1014  slice_range_iterator slice_end(const size_type row,const size_type col,
1015  const slip::Range<int>& range);
1016 
1017 
1044  const slip::Range<int>& range) const;
1045 
1072  const slip::Range<int>& range) const;
1073 
1074 
1092  const slip::Range<int>& range);
1093 
1094 
1112  const slip::Range<int>& range);
1113 
1114 
1132  const slip::Range<int>& range) const;
1133 
1151  const slip::Range<int>& range) const;
1152 
1153 
1160  //------------------------row range iterators -----------------------
1161 
1187  row_range_iterator row_begin(const size_type slice,const size_type row,
1188  const slip::Range<int>& range);
1189 
1215  row_range_iterator row_end(const size_type slice,const size_type row,
1216  const slip::Range<int>& range);
1217 
1218 
1244  const_row_range_iterator row_begin(const size_type slice,const size_type row,
1245  const slip::Range<int>& range) const;
1246 
1247 
1272  const_row_range_iterator row_end(const size_type slice,const size_type row,
1273  const slip::Range<int>& range) const;
1274 
1290  const slip::Range<int>& range);
1291 
1292 
1310  const slip::Range<int>& range);
1311 
1312 
1313 
1328  const slip::Range<int>& range) const;
1329 
1330 
1347  const slip::Range<int>& range) const;
1348 
1354  //------------------------col range iterators -----------------------
1355 
1381  col_range_iterator col_begin(const size_type slice,const size_type col,
1382  const slip::Range<int>& range);
1383 
1410  col_range_iterator col_end(const size_type slice,const size_type col,
1411  const slip::Range<int>& range);
1412 
1413 
1439  const_col_range_iterator col_begin(const size_type slice,const size_type col,
1440  const slip::Range<int>& range) const;
1441 
1468  const_col_range_iterator col_end(const size_type slice,const size_type col,
1469  const slip::Range<int>& range) const;
1470 
1487  const slip::Range<int>& range);
1488 
1506  const slip::Range<int>& range);
1507 
1524  const slip::Range<int>& range) const;
1525 
1542  const slip::Range<int>& range) const;
1543 
1546  //****************************************************************************
1547  // One dimensional plane iterators
1548  //****************************************************************************
1549 
1554 
1555  //----------------------Global plane iterators------------------------------
1556 
1574  iterator plane_begin(const size_type slice);
1575 
1593  const_iterator plane_begin(const size_type slice) const;
1594 
1612  iterator plane_end(const size_type slice);
1613 
1631  const_iterator plane_end(const size_type slice) const;
1632 
1651 
1669  const_reverse_iterator plane_rbegin(const size_type slice) const;
1670 
1688  reverse_iterator plane_rend(const size_type slice);
1689 
1707  const_reverse_iterator plane_rend(const size_type slice) const;
1708 
1712 #ifdef ALL_PLANE_ITERATOR3D
1713 
1718  //-------------------row and col plane iterators----------
1719 
1720 
1732  const_iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1733  const size_type row) const;
1734 
1746  iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1747  const size_type row);
1748 
1761  iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type row);
1762 
1774  const_iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type row) const;
1775 
1776 
1788  reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1789  const size_type row);
1790 
1802  const_reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1803  const size_type row) const;
1804 
1816  reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type row);
1817 
1829  const_reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type row) const;
1830 
1842  iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1843  const size_type col);
1844 
1856  const_iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1857  const size_type col) const;
1858 
1870  iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type col);
1871 
1883  const_iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type col) const;
1884 
1885 
1897  reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1898  const size_type col);
1899 
1909  const_reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1910  const size_type col) const;
1911 
1923  reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate, const size_type col);
1924 
1936  const_reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,const size_type col) const;
1937 
1944  //-------------------plane box iterators----------
1945 
1957  const_iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1958  const size_type row, const Box2d<int> & b) const;
1959 
1972  iterator1d plane_row_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
1973  const size_type row, const Box2d<int> & b);
1974 
1986  iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
1987  const size_type row, const Box2d<int> & b);
1988 
2001  const_iterator1d plane_row_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2002  const size_type row, const Box2d<int> & b) const;
2003 
2004 
2016  reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2017  const size_type row, const Box2d<int> & b);
2018 
2031  const_reverse_iterator1d plane_row_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2032  const size_type row, const Box2d<int> & b) const;
2033 
2044  reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2045  const size_type row, const Box2d<int> & b);
2046 
2059  const_reverse_iterator1d plane_row_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2060  const size_type row, const Box2d<int> & b) const;
2061 
2072  iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2073  const size_type col, const Box2d<int> & b);
2074 
2086  const_iterator1d plane_col_begin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2087  const size_type col, const Box2d<int> & b) const;
2088 
2101  iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2102  const size_type col, const Box2d<int> & b);
2103 
2116  const_iterator1d plane_col_end(PLANE_ORIENTATION P, const size_type plane_coordinate,
2117  const size_type col, const Box2d<int> & b) const;
2118 
2119 
2132  reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2133  const size_type col, const Box2d<int> & b);
2134 
2147  const_reverse_iterator1d plane_col_rbegin(PLANE_ORIENTATION P, const size_type plane_coordinate,
2148  const size_type col, const Box2d<int> & b) const;
2149 
2162  reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2163  const size_type col, const Box2d<int> & b);
2164 
2177  const_reverse_iterator1d plane_col_rend(PLANE_ORIENTATION P, const size_type plane_coordinate,
2178  const size_type col, const Box2d<int> & b) const;
2179 
2180 
2183 #endif //ALL_PLANE_ITERATOR3D
2184 
2185  //****************************************************************************
2186  // Two dimensional plane iterators
2187  //****************************************************************************
2188 
2193 
2213  iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate);
2214 
2236  iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate);
2237 
2259  const_iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2260 
2280  const_iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2281 
2301 
2321 
2340  const_reverse_iterator2d plane_rupper_left(PLANE_ORIENTATION P, const size_type plane_coordinate) const;
2341 
2361 
2362 
2369 
2392  iterator2d plane_upper_left(PLANE_ORIENTATION P, const size_type plane_coordinate
2393  , const Box2d<int> & b);
2394 
2417  iterator2d plane_bottom_right(PLANE_ORIENTATION P, const size_type plane_coordinate
2418  , const Box2d<int> & b);
2419 
2443  , const Box2d<int> & b) const;
2444 
2468  , const Box2d<int> & b) const;
2469 
2493  , const Box2d<int> & b);
2494 
2518  , const Box2d<int> & b);
2519 
2543  , const Box2d<int> & b) const;
2544 
2568  , const Box2d<int> & b) const;
2569 
2570 
2573  //****************************************************************************
2574  // Three dimensional iterators
2575  //****************************************************************************
2576 
2581 
2582  //------------------------ Global iterators------------------------------------
2583 
2601 
2602 
2620 
2621 
2639 
2640 
2658 
2676 
2694 
2712 
2713 
2731 
2738 
2739  //------------------------ Box iterators------------------------------------
2740 
2762 
2763 
2786 
2787 
2809  const_iterator3d front_upper_left(const Box3d<int>& box) const;
2810 
2811 
2834  const_iterator3d back_bottom_right(const Box3d<int>& box) const;
2835 
2836 
2837 
2853 
2869 
2885 
2886 
2902 
2903 
2911 
2912  //------------------------ Range iterators------------------------------------
2913 
2940  iterator3d_range front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
2941  const Range<int>& col_range);
2942 
2969  iterator3d_range back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
2970  const Range<int>& col_range);
2971 
2972 
2999  const_iterator3d_range front_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3000  const Range<int>& col_range) const;
3001 
3002 
3029  const_iterator3d_range back_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3030  const Range<int>& col_range) const;
3031 
3059  reverse_iterator3d_range rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3060  const Range<int>& col_range);
3061 
3089  reverse_iterator3d_range rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3090  const Range<int>& col_range);
3091 
3119  const_reverse_iterator3d_range rfront_upper_left(const Range<int>& slice_range, const Range<int>& row_range,
3120  const Range<int>& col_range) const;
3121 
3149  const_reverse_iterator3d_range rback_bottom_right(const Range<int>& slice_range, const Range<int>& row_range,
3150  const Range<int>& col_range) const;
3151 
3152 
3155  //********************************************************************
3156 
3157 
3158 
3168  friend std::ostream& operator<< <>(std::ostream & out,
3169  const self& a);
3170 
3171 //read/write image with ImageMagick
3172 //breaking the ImageMagick dependency possibility
3173 // Author : denis.arrivault\AT\inria.fr
3174 // Date : 2013/04/05
3175 // \since 1.4.0
3176 #ifdef HAVE_MAGICK
3177 
3187  void read_from_images(const std::string& file_path_name,
3188  const std::size_t from,
3189  const std::size_t to);
3190 
3201  void write_to_images(const std::string& file_path_name,
3202  const std::size_t from,
3203  const std::size_t to ) const;
3204 
3205  #endif//HAVE_MAGICK
3206 
3215  void read_raw(const std::string& file_path_name,
3216  const std::size_t slices,
3217  const std::size_t rows,
3218  const std::size_t cols);
3219 
3225  void write_raw(const std::string& file_path_name) const;
3226 
3227 
3228 
3229 
3244  void write_tecplot(const std::string& file_path_name,
3245  const std::string& title) const;
3246 
3266  void write_to_images_tecplot(const std::string& file_path_name,
3267  const std::string& title,
3268  const std::size_t from,
3269  const std::size_t to) const;
3270 
3271 
3286  self& operator=(const Volume<T> & rhs);
3287 
3288 
3289 
3297  self& operator=(const T& value);
3298 
3299 
3305  void fill(const T& value)
3306  {
3307  std::fill_n(this->begin(),this->size(),value);
3308  }
3309 
3316  void fill(const T* value)
3317  {
3318  std::copy(value,value + this->size(), this->begin());
3319  }
3320 
3329  template<typename InputIterator>
3330  void fill(InputIterator first,
3331  InputIterator last)
3332  {
3333  std::copy(first,last, this->begin());
3334  }
3349  friend bool operator== <>(const Volume<T>& x,
3350  const Volume<T>& y);
3351 
3358  friend bool operator!= <>(const Volume<T>& x,
3359  const Volume<T>& y);
3360 
3367  friend bool operator< <>(const Volume<T>& x,
3368  const Volume<T>& y);
3369 
3376  friend bool operator> <>(const Volume<T>& x,
3377  const Volume<T>& y);
3378 
3385  friend bool operator<= <>(const Volume<T>& x,
3386  const Volume<T>& y);
3387 
3394  friend bool operator>= <>(const Volume<T>& x,
3395  const Volume<T>& y);
3396 
3397 
3407 
3408  T** operator[](const size_type k);
3409 
3410  const T* const* operator[](const size_type k) const;
3411 
3412 
3426  reference operator()(const size_type k,
3427  const size_type i,
3428  const size_type j);
3429 
3444  const size_type i,
3445  const size_type j) const;
3446 
3453  std::string name() const;
3454 
3455 
3460  size_type dim1() const;
3461 
3466  size_type slices() const;
3467 
3472  size_type dim2() const;
3473 
3478  size_type rows() const;
3479 
3484  size_type dim3() const;
3485 
3490  size_type cols() const;
3491 
3496  size_type columns() const;
3497 
3501  size_type size() const;
3502 
3503 
3507  size_type max_size() const;
3508 
3509 
3513  size_type slice_size() const;
3514 
3515 
3519  bool empty()const;
3520 
3529  void swap(Volume& M);
3530 
3540  self& operator+=(const T& val);
3541  self& operator-=(const T& val);
3542  self& operator*=(const T& val);
3543  self& operator/=(const T& val);
3544  // self& operator%=(const T& val);
3545  // self& operator^=(const T& val);
3546  // self& operator&=(const T& val);
3547  // self& operator|=(const T& val);
3548  // self& operator<<=(const T& val);
3549  // self& operator>>=(const T& val);
3550 
3551 
3552  self operator-() const;
3553  //self operator!() const;
3554 
3555 
3556 
3557  self& operator+=(const self& rhs);
3558  self& operator-=(const self& rhs);
3559  self& operator*=(const self& rhs);
3560  self& operator/=(const self& rhs);
3561 
3562 
3574  T& min() const;
3575 
3576 
3582  T& max() const;
3583 
3588  T sum() const;
3589 
3590 
3597  Volume<T>& apply(T (*fun)(T));
3598 
3605  Volume<T>& apply(T (*fun)(const T&));
3606 
3609  private:
3610  Matrix3d<T>* matrix_;
3611  private:
3613  template<class Archive>
3614  void save(Archive & ar, const unsigned int version) const
3615  {
3616  ar & this->matrix_;
3617  }
3618  template<class Archive>
3619  void load(Archive & ar, const unsigned int version)
3620  {
3621  ar & this->matrix_;
3622  }
3623  BOOST_SERIALIZATION_SPLIT_MEMBER();
3624 
3625  };
3626 
3647 
3648 }//slip::
3649 
3650 
3651 namespace slip{
3660  template<typename T>
3661  Volume<T> operator+(const Volume<T>& M1,
3662  const Volume<T>& M2);
3663 
3670  template<typename T>
3671  Volume<T> operator+(const Volume<T>& M1,
3672  const T& val);
3673 
3680  template<typename T>
3681  Volume<T> operator+(const T& val,
3682  const Volume<T>& M1);
3683 
3692  template<typename T>
3693  Volume<T> operator-(const Volume<T>& M1,
3694  const Volume<T>& M2);
3695 
3702  template<typename T>
3703  Volume<T> operator-(const Volume<T>& M1,
3704  const T& val);
3705 
3712  template<typename T>
3713  Volume<T> operator-(const T& val,
3714  const Volume<T>& M1);
3715 
3724  template<typename T>
3725  Volume<T> operator*(const Volume<T>& M1,
3726  const Volume<T>& M2);
3727 
3734  template<typename T>
3735  Volume<T> operator*(const Volume<T>& M1,
3736  const T& val);
3737 
3744  template<typename T>
3745  Volume<T> operator*(const T& val,
3746  const Volume<T>& M1);
3747 
3756  template<typename T>
3757  Volume<T> operator/(const Volume<T>& M1,
3758  const Volume<T>& M2);
3759 
3766  template<typename T>
3767  Volume<T> operator/(const Volume<T>& M1,
3768  const T& val);
3769 
3770 
3777  template<typename T>
3778  T& min(const Volume<T>& M1);
3779 
3786  template<typename T>
3787  T& max(const Volume<T>& M1);
3788 
3795  template<typename T>
3796  Volume<T> abs(const Volume<T>& V);
3797 
3804  template<typename T>
3805  Volume<T> sqrt(const Volume<T>& V);
3806 
3813  template<typename T>
3814  Volume<T> cos(const Volume<T>& V);
3815 
3822  template<typename T>
3823  Volume<T> acos(const Volume<T>& V);
3824 
3831  template<typename T>
3832  Volume<T> sin(const Volume<T>& V);
3833 
3840  template<typename T>
3841  Volume<T> asin(const Volume<T>& V);
3842 
3843 
3850  template<typename T>
3851  Volume<T> tan(const Volume<T>& V);
3852 
3859  template<typename T>
3860  Volume<T> atan(const Volume<T>& V);
3861 
3868  template<typename T>
3869  Volume<T> exp(const Volume<T>& V);
3870 
3877  template<typename T>
3878  Volume<T> log(const Volume<T>& V);
3879 
3886  template<typename T>
3887  Volume<T> cosh(const Volume<T>& V);
3888 
3895  template<typename T>
3896  Volume<T> sinh(const Volume<T>& V);
3897 
3904  template<typename T>
3905  Volume<T> tanh(const Volume<T>& V);
3906 
3913  template<typename T>
3914  Volume<T> log10(const Volume<T>& V);
3915 
3916 
3917 }//slip::
3918 
3919 
3920 
3921 namespace slip
3922 {
3924  // Constructors
3926  template<typename T>
3927  inline
3929  matrix_(new slip::Matrix3d<T>())
3930  {}
3931 
3932  template<typename T>
3933  inline
3935  const typename Volume<T>::size_type d2,
3936  const typename Volume<T>::size_type d3):
3937  matrix_(new slip::Matrix3d<T>(d1,d2,d3))
3938  {}
3939 
3940  template<typename T>
3941  inline
3943  const typename Volume<T>::size_type d2,
3944  const typename Volume<T>::size_type d3,
3945  const T& val):
3946  matrix_(new slip::Matrix3d<T>(d1,d2,d3,val))
3947  {}
3948 
3949  template<typename T>
3950  inline
3952  const typename Volume<T>::size_type d2,
3953  const typename Volume<T>::size_type d3,
3954  const T* val):
3955  matrix_(new slip::Matrix3d<T>(d1,d2,d3,val))
3956  {}
3957 
3958 
3959  template<typename T>
3960  inline
3962  matrix_(new slip::Matrix3d<T>((*rhs.matrix_)))
3963  {}
3964 
3965  template<typename T>
3966  inline
3968  {
3969  delete matrix_;
3970  }
3971 
3973 
3974 
3976  // Assignment operators
3978  template<typename T>
3979  inline
3981  {
3982  if(this != &rhs)
3983  {
3984  *matrix_ = *(rhs.matrix_);
3985  }
3986  return *this;
3987  }
3988 
3989  template<typename T>
3990  inline
3992  {
3993  std::fill_n((*matrix_)[0][0],matrix_->size(),value);
3994  return *this;
3995  }
3996 
3997  template<typename T>
3998  inline
3999  void Volume<T>::resize(const typename Volume<T>::size_type d1,
4000  const typename Volume<T>::size_type d2,
4001  const typename Volume<T>::size_type d3,
4002  const T& val)
4003  {
4004  matrix_->resize(d1,d2,d3,val);
4005  }
4007 
4008 
4010  // Iterators
4012 
4013  //****************************************************************************
4014  // One dimensional iterators
4015  //****************************************************************************
4016 
4017 
4018 
4019  //----------------------Global iterators------------------------------
4020 
4021  template<typename T>
4022  inline
4024  {
4025  return matrix_->begin();
4026  }
4027 
4028  template<typename T>
4029  inline
4031  {
4032  return matrix_->end();
4033  }
4034 
4035  template<typename T>
4036  inline
4038  {
4039  Matrix3d<T> const * tp(matrix_);
4040  return tp->begin();
4041  }
4042 
4043  template<typename T>
4044  inline
4046  {
4047  Matrix3d<T> const * tp(matrix_);
4048  return tp->end();
4049  }
4050 
4051 
4052  template<typename T>
4053  inline
4055  {
4056  return typename Volume<T>::reverse_iterator(this->end());
4057  }
4058 
4059  template<typename T>
4060  inline
4062  {
4063  return typename Volume<T>::reverse_iterator(this->begin());
4064  }
4065 
4066  template<typename T>
4067  inline
4069  {
4070  return typename Volume<T>::const_reverse_iterator(this->end());
4071  }
4072 
4073  template<typename T>
4074  inline
4076  {
4077  return typename Volume<T>::const_reverse_iterator(this->begin());
4078  }
4079 
4080  //--------------------Constant slice global iterators----------------------
4081 
4082  template<typename T>
4083  inline
4084  typename Volume<T>::slice_iterator
4085  Volume<T>::slice_begin(const typename Volume<T>::size_type row,
4086  const typename Volume<T>::size_type col)
4087  {
4088  return matrix_->slice_begin(row,col);
4089  }
4090 
4091  template<typename T>
4092  inline
4093  typename Volume<T>::const_slice_iterator
4094  Volume<T>::slice_begin(const typename Volume<T>::size_type row,
4095  const typename Volume<T>::size_type col) const
4096  {
4097  Matrix3d<T> const * tp(matrix_);
4098  return tp->slice_begin(row,col);
4099  }
4100 
4101  template<typename T>
4102  inline
4103  typename Volume<T>::slice_iterator
4104  Volume<T>::slice_end(const typename Volume<T>::size_type row,
4105  const typename Volume<T>::size_type col)
4106  {
4107  return matrix_->slice_end(row,col);
4108  }
4109 
4110  template<typename T>
4111  inline
4112  typename Volume<T>::const_slice_iterator
4113  Volume<T>::slice_end(const typename Volume<T>::size_type row,
4114  const typename Volume<T>::size_type col) const
4115  {
4116  Matrix3d<T> const * tp(matrix_);
4117  return tp->slice_end(row,col);
4118  }
4119 
4120 
4121  template<typename T>
4122  inline
4123  typename Volume<T>::reverse_slice_iterator
4124  Volume<T>::slice_rbegin(const typename Volume<T>::size_type row,
4125  const typename Volume<T>::size_type col)
4126  {
4127  return matrix_->slice_rbegin(row,col);
4128  }
4129 
4130  template<typename T>
4131  inline
4132  typename Volume<T>::const_reverse_slice_iterator
4133  Volume<T>::slice_rbegin(const typename Volume<T>::size_type row,
4134  const typename Volume<T>::size_type col) const
4135  {
4136  Matrix3d<T> const * tp(matrix_);
4137  return tp->slice_rbegin(row,col);
4138  }
4139 
4140  template<typename T>
4141  inline
4142  typename Volume<T>::reverse_slice_iterator
4143  Volume<T>::slice_rend(const typename Volume<T>::size_type row,
4144  const typename Volume<T>::size_type col)
4145  {
4146  return matrix_->slice_rend(row,col);
4147  }
4148 
4149 
4150  template<typename T>
4151  inline
4152  typename Volume<T>::const_reverse_slice_iterator
4153  Volume<T>::slice_rend(const typename Volume<T>::size_type row,
4154  const typename Volume<T>::size_type col) const
4155  {
4156  Matrix3d<T> const * tp(matrix_);
4157  return tp->slice_rend(row,col);
4158  }
4159 
4160  //--------------------simple row iterators----------------------
4161 
4162 
4163  template<typename T>
4164  inline
4165  typename Volume<T>::row_iterator
4166  Volume<T>::row_begin(const typename Volume<T>::size_type slice,
4167  const typename Volume<T>::size_type row)
4168  {
4169  return matrix_->row_begin(slice,row);
4170  }
4171 
4172  template<typename T>
4173  inline
4174  typename Volume<T>::const_row_iterator
4175  Volume<T>::row_begin(const typename Volume<T>::size_type slice,
4176  const typename Volume<T>::size_type row) const
4177  {
4178  Matrix3d<T> const * tp(matrix_);
4179  return tp->row_begin(slice,row);
4180  }
4181 
4182  template<typename T>
4183  inline
4184  typename Volume<T>::row_iterator
4185  Volume<T>::row_end(const typename Volume<T>::size_type slice,
4186  const typename Volume<T>::size_type row)
4187  {
4188  return matrix_->row_end(slice,row);
4189  }
4190 
4191  template<typename T>
4192  inline
4193  typename Volume<T>::const_row_iterator
4194  Volume<T>::row_end(const typename Volume<T>::size_type slice,
4195  const typename Volume<T>::size_type row) const
4196  {
4197  Matrix3d<T> const * tp(matrix_);
4198  return tp->row_end(slice,row);
4199  }
4200 
4201 
4202  template<typename T>
4203  inline
4204  typename Volume<T>::reverse_row_iterator
4205  Volume<T>::row_rbegin(const typename Volume<T>::size_type slice,
4206  const typename Volume<T>::size_type row)
4207  {
4208  return matrix_->row_rbegin(slice,row);
4209  }
4210 
4211  template<typename T>
4212  inline
4213  typename Volume<T>::const_reverse_row_iterator
4214  Volume<T>::row_rbegin(const typename Volume<T>::size_type slice,
4215  const typename Volume<T>::size_type row) const
4216  {
4217  Matrix3d<T> const * tp(matrix_);
4218  return tp->row_rbegin(slice,row);
4219  }
4220 
4221 
4222  template<typename T>
4223  inline
4224  typename Volume<T>::reverse_row_iterator
4225  Volume<T>::row_rend(const typename Volume<T>::size_type slice,
4226  const typename Volume<T>::size_type row)
4227  {
4228  return matrix_->row_rend(slice,row);
4229  }
4230 
4231  template<typename T>
4232  inline
4233  typename Volume<T>::const_reverse_row_iterator
4234  Volume<T>::row_rend(const typename Volume<T>::size_type slice,
4235  const typename Volume<T>::size_type row) const
4236  {
4237  Matrix3d<T> const * tp(matrix_);
4238  return tp->row_rend(slice,row);
4239  }
4240 
4241  //--------------------Simple col iterators----------------------
4242 
4243  template<typename T>
4244  inline
4245  typename Volume<T>::col_iterator
4246  Volume<T>::col_begin(const typename Volume<T>::size_type slice,
4247  const typename Volume<T>::size_type col)
4248  {
4249  return matrix_->col_begin(slice,col);
4250  }
4251 
4252  template<typename T>
4253  inline
4254  typename Volume<T>::const_col_iterator
4255  Volume<T>::col_begin(const typename Volume<T>::size_type slice,
4256  const typename Volume<T>::size_type col) const
4257  {
4258  Matrix3d<T> const * tp(matrix_);
4259  return tp->col_begin(slice,col);
4260  }
4261 
4262 
4263  template<typename T>
4264  inline
4265  typename Volume<T>::col_iterator
4266  Volume<T>::col_end(const typename Volume<T>::size_type slice,
4267  const typename Volume<T>::size_type col)
4268  {
4269  return matrix_->col_end(slice,col);
4270  }
4271 
4272  template<typename T>
4273  inline
4274  typename Volume<T>::const_col_iterator
4275  Volume<T>::col_end(const typename Volume<T>::size_type slice,
4276  const typename Volume<T>::size_type col) const
4277  {
4278  Matrix3d<T> const * tp(matrix_);
4279  return tp->col_end(slice,col);
4280  }
4281 
4282 
4283  template<typename T>
4284  inline
4285  typename Volume<T>::reverse_col_iterator
4286  Volume<T>::col_rbegin(const typename Volume<T>::size_type slice,
4287  const typename Volume<T>::size_type col)
4288  {
4289  return matrix_->col_rbegin(slice,col);
4290  }
4291 
4292  template<typename T>
4293  inline
4294  typename Volume<T>::const_reverse_col_iterator
4295  Volume<T>::col_rbegin(const typename Volume<T>::size_type slice,
4296  const typename Volume<T>::size_type col) const
4297  {
4298  Matrix3d<T> const * tp(matrix_);
4299  return tp->col_rbegin(slice,col);
4300  }
4301 
4302 
4303  template<typename T>
4304  inline
4305  typename Volume<T>::reverse_col_iterator
4306  Volume<T>::col_rend(const typename Volume<T>::size_type slice,
4307  const typename Volume<T>::size_type col)
4308  {
4309  return matrix_->col_rend(slice,col);
4310  }
4311 
4312  template<typename T>
4313  inline
4314  typename Volume<T>::const_reverse_col_iterator
4315  Volume<T>::col_rend(const typename Volume<T>::size_type slice,
4316  const typename Volume<T>::size_type col) const
4317  {
4318  Matrix3d<T> const * tp(matrix_);
4319  return tp->col_rend(slice,col);
4320  }
4321 
4322  //--------------------Constant slice range iterators----------------------
4323 
4324  template<typename T>
4325  inline
4326  typename Volume<T>::slice_range_iterator
4327  Volume<T>::slice_begin(const typename Volume<T>::size_type row,
4328  const typename Volume<T>::size_type col,
4329  const slip::Range<int>& range)
4330  {
4331  return matrix_->slice_begin(row,col,range);
4332  }
4333 
4334  template<typename T>
4335  inline
4336  typename Volume<T>::const_slice_range_iterator
4337  Volume<T>::slice_begin(const typename Volume<T>::size_type row,
4338  const typename Volume<T>::size_type col,
4339  const slip::Range<int>& range) const
4340  {
4341  Matrix3d<T> const * tp(matrix_);
4342  return tp->slice_begin(row,col,range);
4343  }
4344 
4345  template<typename T>
4346  inline
4347  typename Volume<T>::slice_range_iterator
4348  Volume<T>::slice_end(const typename Volume<T>::size_type row,
4349  const typename Volume<T>::size_type col,
4350  const slip::Range<int>& range)
4351  {
4352  return matrix_->slice_end(row,col,range);
4353  }
4354 
4355  template<typename T>
4356  inline
4357  typename Volume<T>::const_slice_range_iterator
4358  Volume<T>::slice_end(const typename Volume<T>::size_type row,
4359  const typename Volume<T>::size_type col,
4360  const slip::Range<int>& range) const
4361  {
4362  Matrix3d<T> const * tp(matrix_);
4363  return tp->slice_end(row,col,range);
4364  }
4365 
4366  template<typename T>
4367  inline
4368  typename Volume<T>::reverse_slice_range_iterator
4369  Volume<T>::slice_rbegin(const typename Volume<T>::size_type row,
4370  const typename Volume<T>::size_type col,
4371  const slip::Range<int>& range)
4372  {
4373  return matrix_->slice_rbegin(row,col,range);
4374  }
4375 
4376  template<typename T>
4377  inline
4378  typename Volume<T>::const_reverse_slice_range_iterator
4379  Volume<T>::slice_rbegin(const typename Volume<T>::size_type row,
4380  const typename Volume<T>::size_type col,
4381  const slip::Range<int>& range) const
4382  {
4383  Matrix3d<T> const * tp(matrix_);
4384  return tp->slice_rbegin(row,col,range);
4385  }
4386 
4387  template<typename T>
4388  inline
4389  typename Volume<T>::reverse_slice_range_iterator
4390  Volume<T>::slice_rend(const typename Volume<T>::size_type row,
4391  const typename Volume<T>::size_type col,
4392  const slip::Range<int>& range)
4393  {
4394  return matrix_->slice_rend(row,col,range);
4395  }
4396 
4397  template<typename T>
4398  inline
4399  typename Volume<T>::const_reverse_slice_range_iterator
4400  Volume<T>::slice_rend(const typename Volume<T>::size_type row,
4401  const typename Volume<T>::size_type col,
4402  const slip::Range<int>& range) const
4403  {
4404  Matrix3d<T> const * tp(matrix_);
4405  return tp->slice_rend(row,col,range);
4406  }
4407 
4408  //--------------------Constant row range iterators----------------------
4409 
4410  template<typename T>
4411  inline
4412  typename Volume<T>::row_range_iterator
4413  Volume<T>::row_begin(const typename Volume<T>::size_type slice,
4414  const typename Volume<T>::size_type row,
4415  const slip::Range<int>& range)
4416  {
4417  return matrix_->row_begin(slice,row,range);
4418  }
4419 
4420  template<typename T>
4421  inline
4422  typename Volume<T>::const_row_range_iterator
4423  Volume<T>::row_begin(const typename Volume<T>::size_type slice,
4424  const typename Volume<T>::size_type row,
4425  const slip::Range<int>& range) const
4426  {
4427  Matrix3d<T> const * tp(matrix_);
4428  return tp->row_begin(slice,row,range);
4429  }
4430 
4431  template<typename T>
4432  inline
4433  typename Volume<T>::row_range_iterator
4434  Volume<T>::row_end(const typename Volume<T>::size_type slice,
4435  const typename Volume<T>::size_type row,
4436  const slip::Range<int>& range)
4437  {
4438  return matrix_->row_end(slice,row,range);
4439  }
4440 
4441  template<typename T>
4442  inline
4443  typename Volume<T>::const_row_range_iterator
4444  Volume<T>::row_end(const typename Volume<T>::size_type slice,
4445  const typename Volume<T>::size_type row,
4446  const slip::Range<int>& range) const
4447  {
4448  Matrix3d<T> const * tp(matrix_);
4449  return tp->row_end(slice,row,range);
4450  }
4451 
4452  template<typename T>
4453  inline
4454  typename Volume<T>::reverse_row_range_iterator
4455  Volume<T>::row_rbegin(const typename Volume<T>::size_type slice,
4456  const typename Volume<T>::size_type row,
4457  const slip::Range<int>& range)
4458  {
4459  return matrix_->row_rbegin(slice,row,range);
4460  }
4461 
4462  template<typename T>
4463  inline
4464  typename Volume<T>::const_reverse_row_range_iterator
4465  Volume<T>::row_rbegin(const typename Volume<T>::size_type slice,
4466  const typename Volume<T>::size_type row,
4467  const slip::Range<int>& range) const
4468  {
4469  Matrix3d<T> const * tp(matrix_);
4470  return tp->row_rbegin(slice,row,range);
4471  }
4472 
4473  template<typename T>
4474  inline
4475  typename Volume<T>::reverse_row_range_iterator
4476  Volume<T>::row_rend(const typename Volume<T>::size_type slice,
4477  const typename Volume<T>::size_type row,
4478  const slip::Range<int>& range)
4479  {
4480  return matrix_->row_rend(slice,row,range);
4481  }
4482 
4483  template<typename T>
4484  inline
4485  typename Volume<T>::const_reverse_row_range_iterator
4486  Volume<T>::row_rend(const typename Volume<T>::size_type slice,
4487  const typename Volume<T>::size_type row,
4488  const slip::Range<int>& range) const
4489  {
4490  Matrix3d<T> const * tp(matrix_);
4491  return tp->row_rend(slice,row,range);
4492  }
4493 
4494  //--------------------Constant col range iterators----------------------
4495 
4496  template<typename T>
4497  inline
4498  typename Volume<T>::col_range_iterator
4499  Volume<T>::col_begin(const typename Volume<T>::size_type slice,
4500  const typename Volume<T>::size_type col,
4501  const slip::Range<int>& range)
4502  {
4503  return matrix_->col_begin(slice,col,range);
4504  }
4505 
4506  template<typename T>
4507  inline
4508  typename Volume<T>::const_col_range_iterator
4509  Volume<T>::col_begin(const typename Volume<T>::size_type slice,
4510  const typename Volume<T>::size_type col,
4511  const slip::Range<int>& range) const
4512  {
4513  Matrix3d<T> const * tp(matrix_);
4514  return tp->col_begin(slice,col,range);
4515  }
4516 
4517  template<typename T>
4518  inline
4519  typename Volume<T>::col_range_iterator
4520  Volume<T>::col_end(const typename Volume<T>::size_type slice,
4521  const typename Volume<T>::size_type col,
4522  const slip::Range<int>& range)
4523  {
4524  return matrix_->col_end(slice,col,range);
4525  }
4526 
4527  template<typename T>
4528  inline
4529  typename Volume<T>::const_col_range_iterator
4530  Volume<T>::col_end(const typename Volume<T>::size_type slice,
4531  const typename Volume<T>::size_type col,
4532  const slip::Range<int>& range) const
4533  {
4534  Matrix3d<T> const * tp(matrix_);
4535  return tp->col_end(slice,col,range);
4536  }
4537 
4538  template<typename T>
4539  inline
4540  typename Volume<T>::reverse_col_range_iterator
4541  Volume<T>::col_rbegin(const typename Volume<T>::size_type slice,
4542  const typename Volume<T>::size_type col,
4543  const slip::Range<int>& range)
4544  {
4545  return matrix_->col_rbegin(slice,col,range);
4546  }
4547 
4548  template<typename T>
4549  inline
4550  typename Volume<T>::const_reverse_col_range_iterator
4551  Volume<T>::col_rbegin(const typename Volume<T>::size_type slice,
4552  const typename Volume<T>::size_type col,
4553  const slip::Range<int>& range) const
4554  {
4555  Matrix3d<T> const * tp(matrix_);
4556  return tp->col_rbegin(slice,col,range);
4557  }
4558 
4559  template<typename T>
4560  inline
4561  typename Volume<T>::reverse_col_range_iterator
4562  Volume<T>::col_rend(const typename Volume<T>::size_type slice,
4563  const typename Volume<T>::size_type col,
4564  const slip::Range<int>& range)
4565  {
4566  return matrix_->col_rend(slice,col,range);
4567  }
4568 
4569  template<typename T>
4570  inline
4571  typename Volume<T>::const_reverse_col_range_iterator
4572  Volume<T>::col_rend(const typename Volume<T>::size_type slice,
4573  const typename Volume<T>::size_type col,
4574  const slip::Range<int>& range) const
4575  {
4576  Matrix3d<T> const * tp(matrix_);
4577  return tp->col_rend(slice,col,range);
4578  }
4579 
4580  //-------------------plane global iterators----------
4581 
4582  template<typename T>
4583  inline
4584  typename Volume<T>::iterator
4585  Volume<T>::plane_begin(const typename Volume<T>::size_type slice)
4586  {
4587  return matrix_->plane_begin(slice);
4588  }
4589 
4590  template<typename T>
4591  inline
4592  typename Volume<T>::const_iterator
4593  Volume<T>::plane_begin(const typename Volume<T>::size_type slice) const
4594  {
4595  Matrix3d<T> const * tp(matrix_);
4596  return tp->plane_begin(slice);
4597  }
4598 
4599  template<typename T>
4600  inline
4601  typename Volume<T>::iterator
4602  Volume<T>::plane_end(const typename Volume<T>::size_type slice)
4603  {
4604  return matrix_->plane_end(slice);
4605  }
4606 
4607  template<typename T>
4608  inline
4609  typename Volume<T>::const_iterator
4610  Volume<T>::plane_end(const typename Volume<T>::size_type slice) const
4611  {
4612  Matrix3d<T> const * tp(matrix_);
4613  return tp->plane_end(slice);
4614  }
4615 
4616  template<typename T>
4617  inline
4618  typename Volume<T>::reverse_iterator
4619  Volume<T>::plane_rbegin(const typename Volume<T>::size_type slice)
4620  {
4621  return matrix_->plane_rbegin(slice);
4622  }
4623 
4624  template<typename T>
4625  inline
4626  typename Volume<T>::const_reverse_iterator
4627  Volume<T>::plane_rbegin(const typename Volume<T>::size_type slice) const
4628  {
4629  Matrix3d<T> const * tp(matrix_);
4630  return tp->plane_rbegin(slice);
4631  }
4632 
4633  template<typename T>
4634  inline
4635  typename Volume<T>::reverse_iterator
4636  Volume<T>::plane_rend(const typename Volume<T>::size_type slice)
4637  {
4638  return matrix_->plane_rend(slice);
4639  }
4640 
4641  template<typename T>
4642  inline
4643  typename Volume<T>::const_reverse_iterator
4644  Volume<T>::plane_rend(const typename Volume<T>::size_type slice) const
4645  {
4646  Matrix3d<T> const * tp(matrix_);
4647  return tp->plane_rend(slice);
4648  }
4649 
4650 #ifdef ALL_PLANE_ITERATOR3D
4651 
4652  //-------------------plane row and col iterators----------
4653 
4654 
4655  template<typename T>
4656  inline
4657  typename Volume<T>::iterator1d
4658  Volume<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4659  const typename Volume<T>::size_type row)
4660  {
4661  return matrix_->plane_row_begin(P,plane_coordinate,row);
4662  }
4663 
4664  template<typename T>
4665  inline
4666  typename Volume<T>::const_iterator1d
4667  Volume<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4668  const typename Volume<T>::size_type row) const
4669  {
4670  Matrix3d<T> const * tp(matrix_);
4671  return tp->plane_row_begin(P,plane_coordinate,row);
4672  }
4673 
4674  template<typename T>
4675  inline
4676  typename Volume<T>::iterator1d
4677  Volume<T>::plane_row_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4678  const typename Volume<T>::size_type row)
4679  {
4680  return matrix_->plane_row_end(P,plane_coordinate,row);
4681  }
4682 
4683  template<typename T>
4684  inline
4685  typename Volume<T>::const_iterator1d
4686  Volume<T>::plane_row_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4687  const typename Volume<T>::size_type row) const
4688  {
4689  Matrix3d<T> const * tp(matrix_);
4690  return tp->plane_row_end(P,plane_coordinate,row);
4691  }
4692 
4693  template<typename T>
4694  inline
4695  typename Volume<T>::reverse_iterator1d
4696  Volume<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4697  const typename Volume<T>::size_type row)
4698  {
4699  return matrix_->plane_row_rbegin(P,plane_coordinate,row);
4700  }
4701 
4702  template<typename T>
4703  inline
4704  typename Volume<T>::const_reverse_iterator1d
4705  Volume<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4706  const typename Volume<T>::size_type row) const
4707  {
4708  Matrix3d<T> const * tp(matrix_);
4709  return tp->plane_row_rbegin(P,plane_coordinate,row);
4710  }
4711 
4712  template<typename T>
4713  inline
4714  typename Volume<T>::reverse_iterator1d
4715  Volume<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4716  const typename Volume<T>::size_type row)
4717  {
4718  return matrix_->plane_row_rend(P,plane_coordinate,row);
4719  }
4720 
4721  template<typename T>
4722  inline
4723  typename Volume<T>::const_reverse_iterator1d
4724  Volume<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4725  const typename Volume<T>::size_type row) const
4726  {
4727  Matrix3d<T> const * tp(matrix_);
4728  return tp->plane_row_rend(P,plane_coordinate,row);
4729  }
4730 
4731  template<typename T>
4732  inline
4733  typename Volume<T>::iterator1d
4734  Volume<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4735  const typename Volume<T>::size_type col)
4736  {
4737  return matrix_->plane_col_begin(P,plane_coordinate,col);
4738  }
4739 
4740  template<typename T>
4741  inline
4742  typename Volume<T>::const_iterator1d
4743  Volume<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4744  const typename Volume<T>::size_type col) const
4745  {
4746  Matrix3d<T> const * tp(matrix_);
4747  return tp->plane_col_begin(P,plane_coordinate,col);
4748  }
4749 
4750  template<typename T>
4751  inline
4752  typename Volume<T>::iterator1d
4753  Volume<T>::plane_col_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4754  const typename Volume<T>::size_type col)
4755  {
4756  return matrix_->plane_col_end(P,plane_coordinate,col);
4757  }
4758 
4759  template<typename T>
4760  inline
4761  typename Volume<T>::const_iterator1d
4762  Volume<T>::plane_col_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4763  const typename Volume<T>::size_type col) const
4764  {
4765  Matrix3d<T> const * tp(matrix_);
4766  return tp->plane_col_end(P,plane_coordinate,col);
4767  }
4768 
4769  template<typename T>
4770  inline
4771  typename Volume<T>::reverse_iterator1d
4772  Volume<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4773  const typename Volume<T>::size_type col)
4774  {
4775  return matrix_->plane_col_rbegin(P,plane_coordinate,col);
4776  }
4777 
4778  template<typename T>
4779  inline
4780  typename Volume<T>::const_reverse_iterator1d
4781  Volume<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4782  const typename Volume<T>::size_type col) const
4783  {
4784  Matrix3d<T> const * tp(matrix_);
4785  return tp->plane_col_rbegin(P,plane_coordinate,col);
4786  }
4787 
4788  template<typename T>
4789  inline
4790  typename Volume<T>::reverse_iterator1d
4791  Volume<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4792  const typename Volume<T>::size_type col)
4793  {
4794  return matrix_->plane_col_rend(P,plane_coordinate,col);
4795  }
4796 
4797  template<typename T>
4798  inline
4799  typename Volume<T>::const_reverse_iterator1d
4800  Volume<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4801  const typename Volume<T>::size_type col) const
4802  {
4803  Matrix3d<T> const * tp(matrix_);
4804  return tp->plane_col_rend(P,plane_coordinate,col);
4805  }
4806 
4807  //-------------------plane box iterators----------
4808 
4809  template<typename T>
4810  inline
4811  typename Volume<T>::const_iterator1d
4812  Volume<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4813  const size_type row, const Box2d<int> & b) const
4814  {
4815  Matrix3d<T> const * tp(matrix_);
4816  return tp->plane_row_begin(P,plane_coordinate,row,b);
4817  }
4818 
4819  template<typename T>
4820  inline
4821  typename Volume<T>::iterator1d
4822  Volume<T>::plane_row_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4823  const size_type row, const Box2d<int> & b)
4824  {
4825  return matrix_->plane_row_begin(P,plane_coordinate,row,b);
4826  }
4827 
4828  template<typename T>
4829  inline
4830  typename Volume<T>::iterator1d
4831  Volume<T>:: plane_row_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4832  const size_type row, const Box2d<int> & b)
4833  {
4834  return matrix_->plane_row_end(P,plane_coordinate,row,b);
4835  }
4836 
4837  template<typename T>
4838  inline
4839  typename Volume<T>::const_iterator1d
4840  Volume<T>::plane_row_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4841  const size_type row, const Box2d<int> & b) const
4842  {
4843  Matrix3d<T> const * tp(matrix_);
4844  return tp->plane_row_end(P,plane_coordinate,row,b);
4845  }
4846 
4847  template<typename T>
4848  inline
4849  typename Volume<T>::reverse_iterator1d
4850  Volume<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4851  const size_type row, const Box2d<int> & b)
4852  {
4853  return matrix_->plane_row_rbegin(P,plane_coordinate,row,b);
4854  }
4855 
4856  template<typename T>
4857  inline
4858  typename Volume<T>::const_reverse_iterator1d
4859  Volume<T>::plane_row_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4860  const size_type row, const Box2d<int> & b) const
4861  {
4862  Matrix3d<T> const * tp(matrix_);
4863  return tp->plane_row_rbegin(P,plane_coordinate,row,b);
4864  }
4865 
4866  template<typename T>
4867  inline
4868  typename Volume<T>::reverse_iterator1d
4869  Volume<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4870  const size_type row, const Box2d<int> & b)
4871  {
4872  return matrix_->plane_row_rend(P,plane_coordinate,row,b);
4873  }
4874 
4875  template<typename T>
4876  inline
4877  typename Volume<T>::const_reverse_iterator1d
4878  Volume<T>::plane_row_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4879  const size_type row, const Box2d<int> & b) const
4880  {
4881  Matrix3d<T> const * tp(matrix_);
4882  return tp->plane_row_rend(P,plane_coordinate,row,b);
4883  }
4884 
4885  template<typename T>
4886  inline
4887  typename Volume<T>::iterator1d
4888  Volume<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4889  const size_type col, const Box2d<int> & b)
4890  {
4891  return matrix_->plane_col_begin(P,plane_coordinate,col,b);
4892  }
4893 
4894  template<typename T>
4895  inline
4896  typename Volume<T>::const_iterator1d
4897  Volume<T>::plane_col_begin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4898  const size_type col, const Box2d<int> & b) const
4899  {
4900  Matrix3d<T> const * tp(matrix_);
4901  return tp->plane_col_begin(P,plane_coordinate,col,b);
4902  }
4903 
4904  template<typename T>
4905  inline
4906  typename Volume<T>::iterator1d
4907  Volume<T>::plane_col_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4908  const size_type col, const Box2d<int> & b)
4909  {
4910  return matrix_->plane_col_end(P,plane_coordinate,col,b);
4911  }
4912 
4913  template<typename T>
4914  inline
4915  typename Volume<T>::const_iterator1d
4916  Volume<T>::plane_col_end(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4917  const size_type col, const Box2d<int> & b) const
4918  {
4919  Matrix3d<T> const * tp(matrix_);
4920  return tp->plane_col_end(P,plane_coordinate,col,b);
4921  }
4922 
4923  template<typename T>
4924  inline
4925  typename Volume<T>::reverse_iterator1d
4926  Volume<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4927  const size_type col, const Box2d<int> & b)
4928  {
4929  return matrix_->plane_col_rbegin(P,plane_coordinate,col,b);
4930  }
4931 
4932  template<typename T>
4933  inline
4934  typename Volume<T>::const_reverse_iterator1d
4935  Volume<T>::plane_col_rbegin(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4936  const size_type col, const Box2d<int> & b) const
4937  {
4938  Matrix3d<T> const * tp(matrix_);
4939  return tp->plane_col_rbegin(P,plane_coordinate,col,b);
4940  }
4941 
4942  template<typename T>
4943  inline
4944  typename Volume<T>::reverse_iterator1d
4945  Volume<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4946  const size_type col, const Box2d<int> & b)
4947  {
4948  return matrix_->plane_col_rend(P,plane_coordinate,col,b);
4949  }
4950 
4951  template<typename T>
4952  inline
4953  typename Volume<T>::const_reverse_iterator1d
4954  Volume<T>::plane_col_rend(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate,
4955  const size_type col, const Box2d<int> & b) const
4956  {
4957  Matrix3d<T> const * tp(matrix_);
4958  return tp->plane_col_rend(P,plane_coordinate,col,b);
4959  }
4960 
4961 #endif //ALL_PLANE_ITERATOR3D
4962 
4963  //****************************************************************************
4964  // Two dimensional plane iterators
4965  //****************************************************************************
4966 
4967  //------------------------ Global iterators------------------------------------
4968 
4969  template<typename T>
4970  inline
4971  typename Volume<T>::iterator2d
4972  Volume<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate)
4973  {
4974  return matrix_->plane_upper_left(P,plane_coordinate);
4975  }
4976 
4977  template<typename T>
4978  inline
4979  typename Volume<T>::iterator2d
4980  Volume<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate)
4981  {
4982  return matrix_->plane_bottom_right(P,plane_coordinate);
4983  }
4984 
4985  template<typename T>
4986  inline
4987  typename Volume<T>::const_iterator2d
4988  Volume<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate) const
4989  {
4990  Matrix3d<T> const * tp(matrix_);
4991  return tp->plane_upper_left(P,plane_coordinate);
4992  }
4993 
4994  template<typename T>
4995  inline
4996  typename Volume<T>::const_iterator2d
4997  Volume<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate) const
4998  {
4999  Matrix3d<T> const * tp(matrix_);
5000  return tp->plane_bottom_right(P,plane_coordinate);
5001  }
5002 
5003  template<typename T>
5004  inline
5005  typename Volume<T>::reverse_iterator2d
5006  Volume<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate)
5007  {
5008  return matrix_->plane_rupper_left(P,plane_coordinate);
5009  }
5010 
5011  template<typename T>
5012  inline
5013  typename Volume<T>::reverse_iterator2d
5014  Volume<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate)
5015  {
5016  return matrix_->plane_rbottom_right(P,plane_coordinate);
5017  }
5018 
5019  template<typename T>
5020  inline
5021  typename Volume<T>::const_reverse_iterator2d
5022  Volume<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate) const
5023  {
5024  Matrix3d<T> const * tp(matrix_);
5025  return tp->plane_rupper_left(P,plane_coordinate);
5026  }
5027 
5028  template<typename T>
5029  inline
5030  typename Volume<T>::const_reverse_iterator2d
5031  Volume<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate) const
5032  {
5033  Matrix3d<T> const * tp(matrix_);
5034  return tp->plane_rbottom_right(P,plane_coordinate);
5035  }
5036 
5037  //------------------------ Box iterators------------------------------------
5038 
5039  template<typename T>
5040  inline
5041  typename Volume<T>::iterator2d
5042  Volume<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b)
5043  {
5044  return matrix_->plane_upper_left(P,plane_coordinate,b);
5045  }
5046 
5047  template<typename T>
5048  inline
5049  typename Volume<T>::iterator2d
5050  Volume<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b)
5051  {
5052  return matrix_->plane_bottom_right(P,plane_coordinate,b);
5053  }
5054 
5055  template<typename T>
5056  inline
5057  typename Volume<T>::const_iterator2d
5058  Volume<T>::plane_upper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b) const
5059  {
5060  Matrix3d<T> const * tp(matrix_);
5061  return tp->plane_upper_left(P,plane_coordinate,b);
5062  }
5063 
5064  template<typename T>
5065  inline
5066  typename Volume<T>::const_iterator2d
5067  Volume<T>::plane_bottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b) const
5068  {
5069  Matrix3d<T> const * tp(matrix_);
5070  return tp->plane_bottom_right(P,plane_coordinate,b);
5071  }
5072 
5073  template<typename T>
5074  inline
5075  typename Volume<T>::reverse_iterator2d
5076  Volume<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b)
5077  {
5078  return matrix_->plane_rupper_left(P,plane_coordinate,b);
5079  }
5080 
5081  template<typename T>
5082  inline
5083  typename Volume<T>::reverse_iterator2d
5084  Volume<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b)
5085  {
5086  return matrix_->plane_rbottom_right(P,plane_coordinate,b);
5087  }
5088 
5089  template<typename T>
5090  inline
5091  typename Volume<T>::const_reverse_iterator2d
5092  Volume<T>::plane_rupper_left(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b) const
5093  {
5094  Matrix3d<T> const * tp(matrix_);
5095  return tp->plane_rupper_left(P,plane_coordinate,b);
5096  }
5097 
5098  template<typename T>
5099  inline
5100  typename Volume<T>::const_reverse_iterator2d
5101  Volume<T>::plane_rbottom_right(PLANE_ORIENTATION P, const typename Volume<T>::size_type plane_coordinate, const Box2d<int>& b) const
5102  {
5103  Matrix3d<T> const * tp(matrix_);
5104  return tp->plane_rbottom_right(P,plane_coordinate,b);
5105  }
5106 
5107  //****************************************************************************
5108  // Three dimensional iterators
5109  //****************************************************************************
5110 
5111  //------------------------ Global iterators------------------------------------
5112 
5113  template<typename T>
5114  inline
5116  {
5117  return matrix_->front_upper_left();
5118  }
5119 
5120  template<typename T>
5121  inline
5123  {
5124  Matrix3d<T> const * tp(matrix_);
5125  return tp->front_upper_left();
5126  }
5127 
5128  template<typename T>
5129  inline
5131  {
5132  return matrix_->back_bottom_right();
5133  }
5134 
5135  template<typename T>
5136  inline
5138  {
5139  Matrix3d<T> const * tp(matrix_);
5140  return tp->back_bottom_right();
5141  }
5142 
5143  template<typename T>
5144  inline
5147  {
5148  return matrix_->rback_bottom_right();
5149  }
5150 
5151  template<typename T>
5152  inline
5155  {
5156  Matrix3d<T> const * tp(matrix_);
5157  return tp->rback_bottom_right();
5158  }
5159 
5160  template<typename T>
5161  inline
5164  {
5165  return matrix_->rfront_upper_left();
5166  }
5167 
5168  template<typename T>
5169  inline
5172  {
5173  Matrix3d<T> const * tp(matrix_);
5174  return tp->rfront_upper_left();
5175  }
5176 
5177  //------------------------ Box iterators------------------------------------
5178 
5179  template<typename T>
5180  inline
5182  {
5183  return matrix_->front_upper_left(box);
5184  }
5185 
5186  template<typename T>
5187  inline
5189  {
5190  Matrix3d<T> const * tp(matrix_);
5191  return tp->front_upper_left(box);
5192  }
5193 
5194 
5195  template<typename T>
5196  inline
5197  typename Volume<T>::iterator3d
5199  {
5200  return matrix_->back_bottom_right(box);
5201  }
5202 
5203  template<typename T>
5204  inline
5205  typename Volume<T>::const_iterator3d
5207  {
5208  Matrix3d<T> const * tp(matrix_);
5209  return tp->back_bottom_right(box);
5210  }
5211 
5212  template<typename T>
5213  inline
5216  {
5217  return matrix_->rback_bottom_right(box);
5218  }
5219 
5220  template<typename T>
5221  inline
5224  {
5225  Matrix3d<T> const * tp(matrix_);
5226  return tp->rback_bottom_right(box);
5227  }
5228 
5229  template<typename T>
5230  inline
5233  {
5234  return matrix_->rfront_upper_left(box);
5235  }
5236 
5237  template<typename T>
5238  inline
5241  {
5242  Matrix3d<T> const * tp(matrix_);
5243  return tp->rfront_upper_left(box);
5244  }
5245 
5246  //------------------------ Range iterators------------------------------------
5247 
5248  template<typename T>
5249  inline
5250  typename Volume<T>::iterator3d_range
5252  const Range<int>& row_range,
5253  const Range<int>& col_range)
5254  {
5255  return matrix_->front_upper_left(slice_range,row_range,col_range);
5256  }
5257 
5258  template<typename T>
5259  inline
5260  typename Volume<T>::iterator3d_range
5262  const Range<int>& row_range,
5263  const Range<int>& col_range)
5264  {
5265  return matrix_->back_bottom_right(slice_range,row_range,col_range);
5266  }
5267 
5268 
5269  template<typename T>
5270  inline
5273  const Range<int>& row_range,
5274  const Range<int>& col_range) const
5275  {
5276  Matrix3d<T> const * tp(matrix_);
5277  return tp->front_upper_left(slice_range,row_range,col_range);
5278  }
5279 
5280 
5281  template<typename T>
5282  inline
5285  const Range<int>& row_range,
5286  const Range<int>& col_range) const
5287  {
5288  Matrix3d<T> const * tp(matrix_);
5289  return tp->back_bottom_right(slice_range,row_range,col_range);
5290  }
5291 
5292  template<typename T>
5293  inline
5296  const Range<int>& row_range,
5297  const Range<int>& col_range)
5298  {
5299  return matrix_->rfront_upper_left(slice_range,row_range,col_range);
5300  }
5301 
5302  template<typename T>
5303  inline
5306  const Range<int>& row_range,
5307  const Range<int>& col_range) const
5308  {
5309  Matrix3d<T> const * tp(matrix_);
5310  return tp->rfront_upper_left(slice_range,row_range,col_range);
5311  }
5312 
5313  template<typename T>
5314  inline
5317  const Range<int>& row_range,
5318  const Range<int>& col_range)
5319  {
5320  return matrix_->rback_bottom_right(slice_range,row_range,col_range);
5321  }
5322 
5323  template<typename T>
5324  inline
5327  const Range<int>& row_range,
5328  const Range<int>& col_range) const
5329  {
5330  Matrix3d<T> const * tp(matrix_);
5331  return tp->rback_bottom_right(slice_range,row_range,col_range);
5332  }
5333 
5334 
5336 
5337 
5339  /* @{ */
5340  template <typename T>
5341  inline
5342  std::ostream& operator<<(std::ostream & out, const Volume<T>& a)
5343  {
5344  out<<*(a.matrix_);
5345  return out;
5346  }
5347 
5348  /* @} */
5349  #ifdef HAVE_MAGICK
5350  template<>
5351  inline
5352  void Volume<double>::read_from_images(const std::string& file_path_name,
5353  const std::size_t from,
5354  const std::size_t to)
5355  {
5356 
5357  slip::read_from_images_double(file_path_name,from,to,*this);
5358  // assert(((to - from) + 1) > 0);
5359 // //read first slice
5360 // std::string file_name_img = slip::compose_file_name(file_path_name,from);
5361 // std::ifstream input(file_name_img.c_str(),std::ios::in);
5362 // if (!input)
5363 // {
5364 // std::cerr<<"Fail to open file "<<file_name_img<<std::endl;
5365 // input.close();
5366 // exit(1);
5367 // }
5368 // //Create the wand
5369 // MagickWand* wand = NewMagickWand();
5370 // //Read the image located at file_path_name
5371 // MagickReadImage(wand,file_name_img.c_str());
5372 // unsigned long width = MagickGetImageWidth(wand);
5373 // unsigned long height = MagickGetImageHeight(wand);
5374 // std::cout<<width<<"x"<<height<<std::endl;
5375 // matrix_->resize((to-from) + 1,std::size_t(height),std::size_t(width),0);
5376 
5377 // MagickGetImagePixels(wand,0,0,width,height,"I",DoublePixel,matrix_->plane_begin(0));
5378 // wand = DestroyMagickWand(wand);
5379 
5380 
5381 // input.close();
5382 
5383 // for(std::size_t img = (from + 1); img <= to; ++img)
5384 // {
5385 // file_name_img = slip::compose_file_name(file_path_name,img);
5386 // std::ifstream input_i(file_name_img.c_str(),std::ios::in);
5387 // if (!input_i)
5388 // {
5389 // std::cerr<<"Fail to open file "<<file_name_img<<std::endl;
5390 // input_i.close();
5391 // exit(1);
5392 // }
5393 // //Create the wand
5394 // MagickWand* wand_i = NewMagickWand();
5395 // //Read the image located at file_path_name
5396 // MagickReadImage(wand_i,file_name_img.c_str());
5397 // unsigned long width_i = MagickGetImageWidth(wand_i);
5398 // unsigned long height_i = MagickGetImageHeight(wand_i);
5399 // std::cout<<width_i<<"x"<<height_i<<std::endl;
5400 // assert(width == width_i);
5401 // assert(height == height_i);
5402 // MagickGetImagePixels(wand_i,0,0,width_i,height_i,"I",DoublePixel,matrix_->plane_begin(img - from));
5403 // wand_i = DestroyMagickWand(wand_i);
5404 
5405 // input_i.close();
5406 
5407 // }
5408  }
5409 
5410  template<>
5411  inline
5412  void Volume<float>::read_from_images(const std::string& file_path_name,
5413  const std::size_t from,
5414  const std::size_t to)
5415  {
5416  slip::read_from_images_float(file_path_name,from,to,*this);
5417  }
5418 
5419 
5420  template<>
5421  inline
5422  void Volume<long>::read_from_images(const std::string& file_path_name,
5423  const std::size_t from,
5424  const std::size_t to)
5425  {
5426  slip::read_from_images_long(file_path_name,from,to,*this);
5427  }
5428 
5429 
5430  template<>
5431  inline
5432  void Volume<int>::read_from_images(const std::string& file_path_name,
5433  const std::size_t from,
5434  const std::size_t to)
5435  {
5436  slip::read_from_images_int(file_path_name,from,to,*this);
5437  }
5438 
5439 
5440  template<>
5441  inline
5442  void Volume<short>::read_from_images(const std::string& file_path_name,
5443  const std::size_t from,
5444  const std::size_t to)
5445  {
5446  slip::read_from_images_short(file_path_name,from,to,*this);
5447  }
5448 
5449 
5450  template<>
5451  inline
5452  void Volume<unsigned char>::read_from_images(const std::string& file_path_name,
5453  const std::size_t from,
5454  const std::size_t to)
5455  {
5456  slip::read_from_images_char(file_path_name,from,to,*this);
5457  }
5458 
5459 
5460  template<>
5461  inline
5462  void Volume<double>::write_to_images(const std::string& file_path_name,
5463  const std::size_t from,
5464  const std::size_t to) const
5465  {
5466 
5467  std::vector<slip::Volume<double>::const_iterator> planes((to - from) + 1);
5468  for(std::size_t i = from; i <= to; ++i)
5469  {
5470  planes[i-from] = this->plane_begin(i);
5471  }
5472  slip::write_to_images_double(file_path_name,from,to,this->cols(),this->rows(),planes);
5473 
5474  }
5475 
5476  template<>
5477  inline
5478  void Volume<float>::write_to_images(const std::string& file_path_name,
5479  const std::size_t from,
5480  const std::size_t to) const
5481  {
5482  std::vector<slip::Volume<float>::const_iterator> planes((to - from) + 1);
5483  for(std::size_t i = from; i <= to; ++i)
5484  {
5485  planes[i-from] = this->plane_begin(i);
5486  }
5487  slip::write_to_images_float(file_path_name,from,to,this->cols(),this->rows(),planes);
5488  }
5489 
5490  template<>
5491  inline
5492  void Volume<long>::write_to_images(const std::string& file_path_name,
5493  const std::size_t from,
5494  const std::size_t to) const
5495  {
5496  std::vector<slip::Volume<long>::const_iterator> planes((to - from) + 1);
5497  for(std::size_t i = from; i <= to; ++i)
5498  {
5499  planes[i-from] = this->plane_begin(i);
5500  }
5501  slip::write_to_images_long(file_path_name,from,to,this->cols(),this->rows(),planes);
5502  }
5503 
5504  template<>
5505  inline
5506  void Volume<int>::write_to_images(const std::string& file_path_name,
5507  const std::size_t from,
5508  const std::size_t to) const
5509  {
5510  std::vector<slip::Volume<int>::const_iterator> planes((to - from) + 1);
5511  for(std::size_t i = from; i <= to; ++i)
5512  {
5513  planes[i-from] = this->plane_begin(i);
5514  }
5515  slip::write_to_images_int(file_path_name,from,to,this->cols(),this->rows(),planes);
5516 
5517  }
5518 
5519  template<>
5520  inline
5521  void Volume<short>::write_to_images(const std::string& file_path_name,
5522  const std::size_t from,
5523  const std::size_t to) const
5524  {
5525  std::vector<slip::Volume<short>::const_iterator> planes((to - from) + 1);
5526  for(std::size_t i = from; i <= to; ++i)
5527  {
5528  planes[i-from] = this->plane_begin(i);
5529  }
5530  slip::write_to_images_short(file_path_name,from,to,this->cols(),this->rows(),planes);
5531  }
5532 
5533 
5534  template<>
5535  inline
5536  void Volume<unsigned char>::write_to_images(const std::string& file_path_name,
5537  const std::size_t from,
5538  const std::size_t to) const
5539  {
5540  std::vector<slip::Volume<unsigned char>::const_iterator> planes((to - from) + 1);
5541  for(std::size_t i = from; i <= to; ++i)
5542  {
5543  planes[i-from] = this->plane_begin(i);
5544  }
5545  slip::write_to_images_char(file_path_name,from,to,this->cols(),this->rows(),planes);
5546 
5547  }
5548 #endif //HAVE_MAGICK
5549 
5550  template<typename T>
5551  inline
5552  void Volume<T>::read_raw(const std::string& file_path_name,
5553  const std::size_t slices,
5554  const std::size_t rows,
5555  const std::size_t cols)
5556  {
5557  matrix_->resize(slices,rows,cols,0);
5558  slip::read_raw(file_path_name,this->begin(),this->end());
5559  }
5560 
5561 
5562  template<typename T>
5563  inline
5564  void Volume<T>::write_raw(const std::string& file_path_name) const
5565  {
5566  slip::write_raw(this->begin(),this->end(),file_path_name);
5567  }
5568 
5569  template<typename T>
5570  inline
5571  void Volume<T>::write_tecplot(const std::string& file_path_name,
5572  const std::string& title) const
5573  {
5574  slip::write_tecplot_vol(*this,file_path_name,title);
5575  }
5576 
5577  template<typename T>
5578  inline
5579  void Volume<T>::write_to_images_tecplot(const std::string& file_path_name,
5580  const std::string& title,
5581  const std::size_t from,
5582  const std::size_t to) const
5583  {
5584  slip::write_to_images_tecplot(*this,file_path_name,title,from,to);
5585  }
5587 
5588 
5590  // Elements access operators
5592  template<typename T>
5593  inline
5594  T**
5596  {
5597  return (*matrix_)[k];
5598  }
5599 
5600  template<typename T>
5601  inline
5602  const T* const*
5603  Volume<T>::operator[](const typename Volume<T>::size_type k) const
5604  {
5605  return (*matrix_)[k];
5606  }
5607 
5608  template<typename T>
5609  inline
5610  typename Volume<T>::reference
5611  Volume<T>::operator()(const typename Volume<T>::size_type k,
5612  const typename Volume<T>::size_type i,
5613  const typename Volume<T>::size_type j)
5614  {
5615  return (*matrix_)[k][i][j];
5616  }
5617 
5618  template<typename T>
5619  inline
5620  typename Volume<T>::const_reference
5621  Volume<T>::operator()(const typename Volume<T>::size_type k,
5622  const typename Volume<T>::size_type i,
5623  const typename Volume<T>::size_type j) const
5624  {
5625  return (*matrix_)[k][i][j];
5626  }
5627 
5629 
5630  template<typename T>
5631  inline
5632  std::string
5633  Volume<T>::name() const {return "Volume";}
5634 
5635 
5636  template<typename T>
5637  inline
5638  typename Volume<T>::size_type
5639  Volume<T>::dim1() const {return matrix_->dim1();}
5640 
5641  template<typename T>
5642  inline
5643  typename Volume<T>::size_type
5644  Volume<T>::slices() const {return matrix_->dim1();}
5645 
5646  template<typename T>
5647  inline
5648  typename Volume<T>::size_type
5649  Volume<T>::dim2() const {return matrix_->dim2();}
5650 
5651  template<typename T>
5652  inline
5653  typename Volume<T>::size_type
5654  Volume<T>::rows() const {return matrix_->dim2();}
5655 
5656  template<typename T>
5657  inline
5658  typename Volume<T>::size_type
5659  Volume<T>::dim3() const {return matrix_->dim3();;}
5660 
5661  template<typename T>
5662  inline
5663  typename Volume<T>::size_type
5664  Volume<T>::cols() const {return matrix_->dim3();}
5665 
5666  template<typename T>
5667  inline
5668  typename Volume<T>::size_type
5669  Volume<T>::columns() const {return matrix_->dim3();;}
5670 
5671 
5672  template<typename T>
5673  inline
5674  typename Volume<T>::size_type
5675  Volume<T>::size() const {return matrix_->size();}
5676 
5677  template<typename T>
5678  inline
5679  typename Volume<T>::size_type
5680  Volume<T>::max_size() const {return matrix_->max_size();}
5681 
5682  template<typename T>
5683  inline
5684  typename Volume<T>::size_type
5685  Volume<T>::slice_size() const {return matrix_->slice_size();}
5686 
5687 
5688  template<typename T>
5689  inline
5690  bool Volume<T>::empty()const {return matrix_->empty();}
5691 
5692  template<typename T>
5693  inline
5695  {
5696  matrix_->swap(*(M.matrix_));
5697  }
5698 
5699 
5701  /* @{ */
5702  template<typename T>
5703  inline
5704  bool operator==(const Volume<T>& x,
5705  const Volume<T>& y)
5706  {
5707  return ( x.size() == y.size()
5708  && std::equal(x.begin(),x.end(),y.begin()));
5709  }
5710 
5711  template<typename T>
5712  inline
5713  bool operator!=(const Volume<T>& x,
5714  const Volume<T>& y)
5715  {
5716  return !(x == y);
5717  }
5718  /* @} */
5719 
5720 
5722  /* @{ */
5723  template<typename T>
5724  inline
5725  bool operator<(const Volume<T>& x,
5726  const Volume<T>& y)
5727  {
5728  return std::lexicographical_compare(x.begin(), x.end(),
5729  y.begin(), y.end());
5730  }
5731 
5732 
5733  template<typename T>
5734  inline
5735  bool operator>(const Volume<T>& x,
5736  const Volume<T>& y)
5737  {
5738  return (y < x);
5739  }
5740 
5741  template<typename T>
5742  inline
5743  bool operator<=(const Volume<T>& x,
5744  const Volume<T>& y)
5745  {
5746  return !(y < x);
5747  }
5748 
5749  template<typename T>
5750  inline
5751  bool operator>=(const Volume<T>& x,
5752  const Volume<T>& y)
5753  {
5754  return !(x < y);
5755  }
5756  /* @} */
5758 
5759 
5761  // arithmetic and mathematic operators
5763  template<typename T>
5764  inline
5766  {
5767  std::transform(matrix_->begin(),matrix_->end(),matrix_->begin(),std::bind2nd(std::plus<T>(),val));
5768  return *this;
5769  }
5770 
5771  template<typename T>
5772  inline
5774  {
5775  std::transform(matrix_->begin(),matrix_->end(),matrix_->begin(),std::bind2nd(std::minus<T>(),val));
5776  return *this;
5777  }
5778 
5779  template<typename T>
5780  inline
5782  {
5783  std::transform(matrix_->begin(),matrix_->end(),matrix_->begin(),std::bind2nd(std::multiplies<T>(),val));
5784  return *this;
5785  }
5786 
5787  template<typename T>
5788  inline
5790  {
5791  std::transform(matrix_->begin(),matrix_->end(),matrix_->begin(),std::bind2nd(std::multiplies<T>(),T(1)/val));
5792  return *this;
5793  }
5794 
5795  template<typename T>
5796  inline
5798  {
5799  Volume<T> tmp(*this);
5800  std::transform(matrix_->begin(),matrix_->end(),tmp.begin(),std::negate<T>());
5801  return tmp;
5802  }
5803 
5804  template<typename T>
5805  inline
5807  {
5808  assert(this->dim1() == rhs.dim1());
5809  assert(this->dim2() == rhs.dim2());
5810  assert(this->dim3() == rhs.dim3());
5811 
5812  std::transform(matrix_->begin(),matrix_->end(),(*(rhs.matrix_)).begin(),matrix_->begin(),std::plus<T>());
5813  return *this;
5814  }
5815 
5816  template<typename T>
5817  inline
5819  {
5820  assert(this->dim1() == rhs.dim1());
5821  assert(this->dim2() == rhs.dim2());
5822  assert(this->dim3() == rhs.dim3());
5823  std::transform(matrix_->begin(),matrix_->end(),(*(rhs.matrix_)).begin(),matrix_->begin(),std::minus<T>());
5824  return *this;
5825  }
5826 
5827  template<typename T>
5828  inline
5830  {
5831  assert(this->dim1() == rhs.dim1());
5832  assert(this->dim2() == rhs.dim2());
5833  assert(this->dim3() == rhs.dim3());
5834  std::transform(matrix_->begin(),matrix_->end(),(*(rhs.matrix_)).begin(),matrix_->begin(),std::multiplies<T>());
5835  return *this;
5836  }
5837 
5838  template<typename T>
5839  inline
5841  {
5842  assert(this->size() == rhs.size());
5843  std::transform(matrix_->begin(),matrix_->end(),(*(rhs.matrix_)).begin(),matrix_->begin(),std::divides<T>());
5844  return *this;
5845  }
5846 
5847 
5848 
5849  template<typename T>
5850  inline
5851  T& Volume<T>::min() const
5852  {
5853  assert(matrix_->size() != 0);
5854  return *std::min_element(matrix_->begin(),matrix_->end());
5855  }
5856 
5857  template<typename T>
5858  inline
5859  T& Volume<T>::max() const
5860  {
5861  assert(matrix_->size() != 0);
5862  return *std::max_element(matrix_->begin(),matrix_->end());
5863  }
5864 
5865  template<typename T>
5866  inline
5867  T Volume<T>::sum() const
5868  {
5869  assert(matrix_->size() != 0);
5870  return std::accumulate(matrix_->begin(),matrix_->end(),T());
5871  }
5872 
5873 
5874  template<typename T>
5875  inline
5877  {
5878  slip::apply(this->begin(),this->end(),this->begin(),fun);
5879  return *this;
5880  }
5881 
5882  template<typename T>
5883  inline
5884  Volume<T>& Volume<T>::apply(T (*fun)(const T&))
5885  {
5886  slip::apply(this->begin(),this->end(),this->begin(),fun);
5887  return *this;
5888  }
5889 
5890 
5891 
5892 
5893  template<typename T>
5894  inline
5896  const Volume<T>& M2)
5897  {
5898  assert(M1.dim1() == M2.dim1());
5899  assert(M1.dim2() == M2.dim2());
5900  assert(M1.dim3() == M2.dim3());
5901 
5902  Volume<T> tmp(M1.dim1(),M1.dim2(),M1.dim3());
5903  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::plus<T>());
5904  return tmp;
5905  }
5906 
5907  template<typename T>
5908  inline
5910  const T& val)
5911  {
5912  Volume<T> tmp(M1);
5913  tmp+=val;
5914  return tmp;
5915  }
5916 
5917  template<typename T>
5918  inline
5919  Volume<T> operator+(const T& val,
5920  const Volume<T>& M1)
5921  {
5922  return M1 + val;
5923  }
5924 
5925 
5926  template<typename T>
5927  inline
5929  const Volume<T>& M2)
5930  {
5931  assert(M1.dim1() == M2.dim1());
5932  assert(M1.dim2() == M2.dim2());
5933  assert(M1.dim3() == M2.dim3());
5934 
5935  Volume<T> tmp(M1.dim1(),M1.dim2(),M1.dim3());
5936  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::minus<T>());
5937  return tmp;
5938  }
5939 
5940  template<typename T>
5941  inline
5943  const T& val)
5944  {
5945  Volume<T> tmp(M1);
5946  tmp-=val;
5947  return tmp;
5948  }
5949 
5950  template<typename T>
5951  inline
5952  Volume<T> operator-(const T& val,
5953  const Volume<T>& M1)
5954  {
5955  return -(M1 - val);
5956  }
5957 
5958  template<typename T>
5959  inline
5961  const Volume<T>& M2)
5962  {
5963  assert(M1.dim1() == M2.dim1());
5964  assert(M1.dim2() == M2.dim2());
5965  assert(M1.dim3() == M2.dim3());
5966 
5967  Volume<T> tmp(M1.dim1(),M1.dim2(),M1.dim3());
5968  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::multiplies<T>());
5969  return tmp;
5970  }
5971 
5972  template<typename T>
5973  inline
5975  const T& val)
5976  {
5977  Volume<T> tmp(M1);
5978  tmp*=val;
5979  return tmp;
5980  }
5981 
5982  template<typename T>
5983  inline
5984  Volume<T> operator*(const T& val,
5985  const Volume<T>& M1)
5986  {
5987  return M1 * val;
5988  }
5989 
5990  template<typename T>
5991  inline
5993  const Volume<T>& M2)
5994  {
5995  assert(M1.dim1() == M2.dim1());
5996  assert(M1.dim2() == M2.dim2());
5997  assert(M1.dim3() == M2.dim3());
5998 
5999  Volume<T> tmp(M1.dim1(),M1.dim2(),M1.dim3());
6000  std::transform(M1.begin(),M1.end(),M2.begin(),tmp.begin(),std::divides<T>());
6001  return tmp;
6002  }
6003 
6004  template<typename T>
6005  inline
6007  const T& val)
6008  {
6009  Volume<T> tmp(M1);
6010  tmp/=val;
6011  return tmp;
6012  }
6013 
6014 
6015  template<typename T>
6016  inline
6017  T& min(const Volume<T>& M1)
6018  {
6019  return M1.min();
6020  }
6021 
6022  template<typename T>
6023  inline
6024  T& max(const Volume<T>& M1)
6025  {
6026  return M1.max();
6027  }
6028 
6029  template<typename T>
6030  inline
6032  {
6033 
6034  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6035  slip::apply(M.begin(),M.end(),tmp.begin(),std::abs);
6036  return tmp;
6037  }
6038 
6039  template<typename T>
6040  inline
6042  {
6043  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6044  slip::apply(M.begin(),M.end(),tmp.begin(),std::sqrt);
6045  return tmp;
6046  }
6047 
6048  template<typename T>
6049  inline
6051  {
6052  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6053  slip::apply(M.begin(),M.end(),tmp.begin(),std::cos);
6054  return tmp;
6055  }
6056 
6057  template<typename T>
6058  inline
6060  {
6061  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6062  slip::apply(M.begin(),M.end(),tmp.begin(),std::acos);
6063  return tmp;
6064  }
6065 
6066  template<typename T>
6067  inline
6069  {
6070  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6071  slip::apply(M.begin(),M.end(),tmp.begin(),std::sin);
6072  return tmp;
6073  }
6074 
6075  template<typename T>
6076  inline
6078  {
6079  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6080  slip::apply(M.begin(),M.end(),tmp.begin(),std::asin);
6081  return tmp;
6082  }
6083 
6084  template<typename T>
6085  inline
6087  {
6088  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6089  slip::apply(M.begin(),M.end(),tmp.begin(),std::tan);
6090  return tmp;
6091  }
6092 
6093  template<typename T>
6094  inline
6096  {
6097  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6098  slip::apply(M.begin(),M.end(),tmp.begin(),std::atan);
6099  return tmp;
6100  }
6101 
6102  template<typename T>
6103  inline
6105  {
6106  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6107  slip::apply(M.begin(),M.end(),tmp.begin(),std::exp);
6108  return tmp;
6109  }
6110 
6111  template<typename T>
6112  inline
6114  {
6115  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6116  slip::apply(M.begin(),M.end(),tmp.begin(),std::log);
6117  return tmp;
6118  }
6119 
6120  template<typename T>
6121  inline
6123  {
6124  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6125  slip::apply(M.begin(),M.end(),tmp.begin(),std::cosh);
6126  return tmp;
6127  }
6128 
6129  template<typename T>
6130  inline
6132  {
6133  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6134  slip::apply(M.begin(),M.end(),tmp.begin(),std::sinh);
6135  return tmp;
6136  }
6137 
6138  template<typename T>
6139  inline
6141  {
6142  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6143  slip::apply(M.begin(),M.end(),tmp.begin(),std::tanh);
6144  return tmp;
6145  }
6146 
6147  template<typename T>
6148  inline
6150  {
6151  Volume<T> tmp(M.dim1(),M.dim2(),M.dim3());
6152  slip::apply(M.begin(),M.end(),tmp.begin(),std::log10);
6153  return tmp;
6154  }
6155 
6156 
6157 
6158 }//slip::
6159 
6160 #endif //SLIP_VOLUME_HPP
reverse_iterator3d rfront_upper_left()
Returns a read/write reverse iterator3d. It points to the back bottom right element of the Volume...
Definition: Volume.hpp:5163
Volume(const size_type d1, const size_type d2, const size_type d3, InputIterator first, InputIterator last)
Contructs a Volume from a range.
Definition: Volume.hpp:301
HyperVolume< T > tanh(const HyperVolume< T > &M)
size_type dim1() const
Returns the number of slices (first dimension size) in the Volume.
Definition: Volume.hpp:5639
bool operator!=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1448
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 Volum...
ptrdiff_t difference_type
Definition: Volume.hpp:174
slip::Array3d< T >::const_iterator3d const_iterator3d
Definition: Volume.hpp:228
This is some iterator to iterate a 3d container into a plane area defined by the subscripts of the 3d...
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: Volume.hpp:181
std::reverse_iterator< slice_iterator > reverse_slice_iterator
Definition: Volume.hpp:199
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< col_iterator > col_range_iterator
Definition: Volume.hpp:195
Volume< T > sqrt(const Volume< T > &M)
Definition: Volume.hpp:6041
iterator3d back_bottom_right()
Returns a read/write iterator3d that points to the past the end element of the Volume. It points to past the end element of the back bottom right element of the Volume.
Definition: Volume.hpp:5130
slip::stride_iterator< pointer > row_range_iterator
Definition: Volume.hpp:193
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...
iterator3d default_iterator
Definition: Volume.hpp:238
Volume< T > tanh(const Volume< T > &M)
Definition: Volume.hpp:6140
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 ...
slip::Array3d< T >::iterator3d iterator3d
Definition: Volume.hpp:227
reference operator()(const size_type k, const size_type i, const size_type j)
Subscript access to the data contained in the Volume.
void write_tecplot_vol(const Container3d &container, const std::string &file_path_name, const std::string &title)
Write a Container3D to a tecplot file.
Definition: io_tools.hpp:3531
void fill(const T &value)
Fills the container range [begin(),begin()+size()) with copies of value.
Definition: Volume.hpp:3305
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 Vol...
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
Volume< T > atan(const Volume< T > &M)
Definition: Volume.hpp:6095
HyperVolume< T > cosh(const HyperVolume< T > &M)
T & min(const GrayscaleImage< T > &M1)
Returns the min element of a GrayscaleImage.
std::reverse_iterator< col_range_iterator > reverse_col_range_iterator
Definition: Volume.hpp:208
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 Volum...
std::reverse_iterator< iterator3d_range > reverse_iterator3d_range
Definition: Volume.hpp:234
Color< T > operator+(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:602
Volume< T > sinh(const Volume< T > &M)
Definition: Volume.hpp:6131
Volume< T > log10(const Volume< T > &M)
Definition: Volume.hpp:6149
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 ...
slip::Volume< long > Volume_l
long alias
Definition: Volume.hpp:3632
iterator3d front_upper_left()
Returns a read/write iterator3d that points to the first element of the Volume. It points to the fron...
Definition: Volume.hpp:5115
slip::stride_iterator< const_pointer > const_col_iterator
Definition: Volume.hpp:190
HyperVolume< T > atan(const HyperVolume< T > &M)
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...
slip::Volume< int > Volume_i
int alias
Definition: Volume.hpp:3640
void resize(std::size_t d1, std::size_t d2, std::size_t d3, const T &val=T())
Resizes a Volume.
Definition: Volume.hpp:3999
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...
slip::Volume< unsigned int > Volume_ui
unsigned int alias
Definition: Volume.hpp:3642
void write_tecplot(const std::string &file_path_name, const std::string &title) const
Write a Volume to a tecplot file.
Definition: Volume.hpp:5571
std::reverse_iterator< const_iterator > const_reverse_row_iterator
Definition: Volume.hpp:202
std::reverse_iterator< iterator > reverse_iterator
Definition: Volume.hpp:180
value_type * pointer
Definition: Volume.hpp:169
void swap(Volume &M)
Swaps data with another Volume.
Definition: Volume.hpp:5694
static const std::size_t DIM
Definition: Volume.hpp:241
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Matrix3d. Iteration is done in ordinary element order.
Definition: Matrix3d.hpp:3953
slip::Volume< unsigned char > Volume_uc
unsigned char alias
Definition: Volume.hpp:3646
slip::Volume< unsigned long > Volume_ul
unsigned long alias
Definition: Volume.hpp:3634
HyperVolume< T > exp(const HyperVolume< T > &M)
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...
Volume< T > tan(const Volume< T > &M)
Definition: Volume.hpp:6086
Numerical volume class This is a two-dimensional dynamic and generic container. This container statis...
Definition: Volume.hpp:107
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...
std::reverse_iterator< iterator2d > reverse_iterator2d
Definition: Volume.hpp:223
~Volume()
Destructor of the Volume.
Definition: Volume.hpp:3967
slip::Volume< char > Volume_c
char alias
Definition: Volume.hpp:3644
void fill(const T *value)
Fills the container range [begin(),begin()+size()) with a copy of the value array.
Definition: Volume.hpp:3316
Volume< T > cos(const Volume< T > &M)
Definition: Volume.hpp:6050
slip::Volume< double > Volume_d
double alias
Definition: Volume.hpp:3628
PLANE_ORIENTATION
Choose between different plane orientations.
size_type slices() const
Returns the number of slices (first dimension size) in the Volume.
Definition: Volume.hpp:5644
HyperVolume< T > abs(const HyperVolume< T > &M)
bool operator>(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1469
slip::Array3d< T >::const_iterator3d_range const_iterator3d_range
Definition: Volume.hpp:230
Provides a class to manipulate iterator3d within a slip::Range. It is used to iterate throw 3d contai...
std::size_t size_type
Definition: Volume.hpp:175
HyperVolume< T > sin(const HyperVolume< T > &M)
T & max() const
Returns the max element of the Volume according to the operator <.
Definition: Volume.hpp:5859
HyperVolume< T > cos(const HyperVolume< T > &M)
Volume< T > acos(const Volume< T > &M)
Definition: Volume.hpp:6059
slip::Volume< short > Volume_s
short alias
Definition: Volume.hpp:3636
Volume< T > exp(const Volume< T > &M)
Definition: Volume.hpp:6104
slip::stride_iterator< pointer > col_iterator
Definition: Volume.hpp:189
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 Volume...
const_pointer const_iterator
Definition: Volume.hpp:178
slip::stride_iterator< const_pointer > const_slice_iterator
Definition: Volume.hpp:186
slip::Array3d< T >::const_iterator2d const_iterator2d
Definition: Volume.hpp:222
slip::Array3d< T >::iterator3d_range iterator3d_range
Definition: Volume.hpp:229
size_type dim2() const
Returns the number of rows (second dimension size) in the Volume.
Definition: Volume.hpp:5649
slip::Array3d< T >::iterator2d iterator2d
Definition: Volume.hpp:221
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...
void write_to_images_tecplot(Container3d &container, const std::string &file_path_name, const std::string &title, const std::size_t from, const std::size_t to)
Write slices of a Container3D to a tecplot file.
Definition: io_tools.hpp:3597
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...
std::reverse_iterator< const_iterator2d > const_reverse_iterator2d
Definition: Volume.hpp:224
size_type max_size() const
Returns the maximal size (number of elements) in the Volume.
Definition: Volume.hpp:5680
Volume()
Constructs a Volume.
Definition: Volume.hpp:3928
Numerical matrix3d class. This container statisfies the RandomAccessContainer concepts of the STL exc...
size_type columns() const
Returns the number of columns (third dimension size) in the Volume.
Definition: Volume.hpp:5669
reverse_iterator3d rfront_upper_left()
Returns a read/write reverse iterator3d. It points to the back bottom right element of the Matrix3d...
Definition: Matrix3d.hpp:5078
const_iterator3d const_default_iterator
Definition: Volume.hpp:239
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...
std::reverse_iterator< const_iterator3d > const_reverse_iterator3d
Definition: Volume.hpp:233
void copy(_II first, _II last, _OI output_first)
Copy algorithm optimized for slip iterators.
Definition: copy_ext.hpp:177
reverse_iterator3d rback_bottom_right()
Returns a read/write reverse iterator3d. It points to past the front upper left element of the Volume...
Definition: Volume.hpp:5146
Provides a class to manipulate iterator2d within a slip::Box3d. It is used to iterate throw 3d contai...
Volume< T > & apply(T(*fun)(T))
Applys the one-parameter C-function fun to each element of the Volume.
Definition: Volume.hpp:5876
std::reverse_iterator< const_slice_range_iterator > const_reverse_slice_range_iterator
Definition: Volume.hpp:198
pointer row_iterator
Definition: Volume.hpp:187
void fill(InputIterator first, InputIterator last)
Fills the container range [begin(),begin()+size()) with a copy of the range [first,last)
Definition: Volume.hpp:3330
std::reverse_iterator< const_row_range_iterator > const_reverse_row_range_iterator
Definition: Volume.hpp:207
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 Volume...
T & min() const
Returns the min element of the Volume according to the operator <.
Definition: Volume.hpp:5851
HyperVolume< T > sqrt(const HyperVolume< T > &M)
size_type cols() const
Returns the number of columns (third dimension size) in the Volume.
Definition: Volume.hpp:5664
reverse_iterator3d rback_bottom_right()
Returns a read/write reverse iterator3d. It points to past the front upper left element of the Matrix...
Definition: Matrix3d.hpp:5061
HyperVolume< T > sinh(const HyperVolume< T > &M)
std::reverse_iterator< row_range_iterator > reverse_row_range_iterator
Definition: Volume.hpp:206
Provides some input/ouput algorithms.
Volume< T > cosh(const Volume< T > &M)
Definition: Volume.hpp:6122
size_type slice_size() const
Returns the number of elements in a slice of the Volume.
Definition: Volume.hpp:5685
Provides a class to iterate 3d containers throw a planes.
size_type rows() const
Returns the number of rows (second dimension size) in the Volume.
Definition: Volume.hpp:5654
This is some iterator to iterate a 3d container into a Box area defined by the subscripts of the 3d c...
self operator-() const
Definition: Volume.hpp:5797
const_iterator begin() const
Returns a read-only (constant) iterator that points to the first element in the Volume. Iteration is done in ordinary element order.
Definition: Volume.hpp:4037
Volume< T > asin(const Volume< T > &M)
Definition: Volume.hpp:6077
Provides a class to manipulate Matrix3d.
std::reverse_iterator< const_col_iterator > const_reverse_col_iterator
Definition: Volume.hpp:204
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...
self & operator-=(const T &val)
Definition: Volume.hpp:5773
T sum() const
Returns the sum of the elements of the Volume.
Definition: Volume.hpp:5867
slip::stride_iterator< const_pointer > const_row_range_iterator
Definition: Volume.hpp:194
HyperVolume< T > log(const HyperVolume< T > &M)
slip::Volume< float > Volume_f
float alias
Definition: Volume.hpp:3630
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...
slip::stride_iterator< pointer > slice_iterator
Definition: Volume.hpp:185
Volume< T > sin(const Volume< T > &M)
Definition: Volume.hpp:6068
void write_raw(const std::string &file_path_name) const
Write a Volume to a file path name.
Definition: Volume.hpp:5564
size_type size() const
Returns the number of elements in the Volume.
Definition: Volume.hpp:5675
This is some iterator to iterate a 3d container into two Range defined by the indices and strides of ...
T ** operator[](const size_type k)
HyperVolume< T > acos(const HyperVolume< T > &M)
void read_raw(const std::string &file_path_name, const std::size_t slices, const std::size_t rows, const std::size_t cols)
Reads a Volume from a file path name.
Definition: Volume.hpp:5552
self & operator=(const Volume< T > &rhs)
Assign a Volume.
Definition: Volume.hpp:3980
slip::stride_iterator< const_col_iterator > const_col_range_iterator
Definition: Volume.hpp:196
HyperVolume< T > log10(const HyperVolume< T > &M)
slip::stride_iterator< slice_iterator > slice_range_iterator
Definition: Volume.hpp:191
std::reverse_iterator< iterator3d > reverse_iterator3d
Definition: Volume.hpp:232
self & operator*=(const T &val)
Definition: Volume.hpp:5781
pointer iterator
Definition: Volume.hpp:177
self & operator/=(const T &val)
Definition: Volume.hpp:5789
const value_type & const_reference
Definition: Volume.hpp:172
void write_to_images_tecplot(const std::string &file_path_name, const std::string &title, const std::size_t from, const std::size_t to) const
Write slices of a Container3D to a tecplot file.
Definition: Volume.hpp:5579
std::reverse_iterator< const_slice_iterator > const_reverse_slice_iterator
Definition: Volume.hpp:200
std::reverse_iterator< const_col_range_iterator > const_reverse_col_range_iterator
Definition: Volume.hpp:209
self & operator+=(const T &val)
Add val to each element of the Volume.
Definition: Volume.hpp:5765
std::reverse_iterator< col_iterator > reverse_col_iterator
Definition: Volume.hpp:203
const_pointer const_row_iterator
Definition: Volume.hpp:188
This is some iterator to iterate a 3d container into a plane area defined by the subscripts of the 3d...
Provides some algorithms to apply C like functions to ranges.
Provides a class to iterate a 1d range according to a step.
HyperVolume< T > tan(const HyperVolume< T > &M)
Volume< T > log(const Volume< T > &M)
Definition: Volume.hpp:6113
slip::Volume< unsigned short > Volume_us
unsigned long alias
Definition: Volume.hpp:3638
bool operator==(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1439
HyperVolume< T > asin(const HyperVolume< T > &M)
void write_raw(InputIterator first, InputIterator last, const std::string &file_path_name)
Write a Container to an raw file.
Definition: io_tools.hpp:290
Volume< T > abs(const Volume< T > &M)
Definition: Volume.hpp:6031
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 Volume...
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 Volum...
std::reverse_iterator< iterator > reverse_row_iterator
Definition: Volume.hpp:201
std::string name() const
Returns the name of the class.
Definition: Volume.hpp:5633
size_type dim3() const
Returns the number of columns (third dimension size) in the Volume.
Definition: Volume.hpp:5659
std::reverse_iterator< slice_range_iterator > reverse_slice_range_iterator
Definition: Volume.hpp:197
Color< T > operator*(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:658
std::reverse_iterator< const_iterator3d_range > const_reverse_iterator3d_range
Definition: Volume.hpp:235
iterator end()
Returns a read/write iterator that points one past the last element in the Matrix3d. Iteration is done in ordinary element order.
Definition: Matrix3d.hpp:3946
bool empty() const
Returns true if the Volume is empty. (Thus size() == 0)
Definition: Volume.hpp:5690
iterator end()
Returns a read/write iterator that points one past the last element in the Volume. Iteration is done in ordinary element order.
Definition: Volume.hpp:4030
void apply(InputIterator first, InputIterator last, OutputIterator result, typename std::iterator_traits< OutputIterator >::value_type(*function)(typename std::iterator_traits< InputIterator >::value_type))
Applies a C-function to each element of a range.
Definition: apply.hpp:128
T & max(const GrayscaleImage< T > &M1)
Returns the max element of a GrayscaleImage.
Color< T > operator/(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:686
iterator3d front_upper_left()
Returns a read/write iterator3d that points to the first element of the Matrix3d. It points to the fr...
Definition: Matrix3d.hpp:5030
iterator3d back_bottom_right()
Returns a read/write iterator3d that points to the past the end element of the Matrix3d. It points to past the end element of the back bottom right element of the Matrix3d.
Definition: Matrix3d.hpp:5045
bool operator>=(const Array< T > &x, const Array< T > &y)
Definition: Array.hpp:1485
const value_type * const_pointer
Definition: Volume.hpp:170
Color< T > operator-(const Color< T > &V1, const Color< T > &V2)
Definition: Color.hpp:630
reverse_iterator rbegin()
Returns a read/write reverse iterator that points to the last element in the Volume. Iteration is done in reverse element order.
Definition: Volume.hpp:4054
friend class boost::serialization::access
Definition: Volume.hpp:3612
slip::stride_iterator< const_slice_iterator > const_slice_range_iterator
Definition: Volume.hpp:192
reverse_iterator rend()
Returns a read/write reverse iterator that points to one before the first element in the Volume...
Definition: Volume.hpp:4061
value_type & reference
Definition: Volume.hpp:171
void read_raw(const std::string &file_path_name, InputIterator first, InputIterator last)
Write a Container to an raw file.
Definition: io_tools.hpp:345
This is some iterator to iterate a 3d container into a Box area defined by the subscripts of the 3d c...