cartodata  5.1.2
volumeoperators.h
Go to the documentation of this file.
1 /* This software and supporting documentation are distributed by
2  * Institut Federatif de Recherche 49
3  * CEA/NeuroSpin, Batiment 145,
4  * 91191 Gif-sur-Yvette cedex
5  * France
6  *
7  * This software is governed by the CeCILL-B license under
8  * French law and abiding by the rules of distribution of free software.
9  * You can use, modify and/or redistribute the software under the
10  * terms of the CeCILL-B license as circulated by CEA, CNRS
11  * and INRIA at the following URL "http://www.cecill.info".
12  *
13  * As a counterpart to the access to the source code and rights to copy,
14  * modify and redistribute granted by the license, users are provided only
15  * with a limited warranty and the software's author, the holder of the
16  * economic rights, and the successive licensors have only limited
17  * liability.
18  *
19  * In this respect, the user's attention is drawn to the risks associated
20  * with loading, using, modifying and/or developing or reproducing the
21  * software by the user in light of its specific status of free software,
22  * that may mean that it is complicated to manipulate, and that also
23  * therefore means that it is reserved for developers and experienced
24  * professionals having in-depth computer knowledge. Users are therefore
25  * encouraged to load and test the software's suitability as regards their
26  * requirements in conditions enabling the security of their systems and/or
27  * data to be ensured and, more generally, to use and operate it in the
28  * same conditions as regards security.
29  *
30  * The fact that you are presently reading this means that you have had
31  * knowledge of the CeCILL-B license and that you accept its terms.
32  */
33 
34 #ifndef CARTODATA_VOLUME_VOLUMEOPERATORS_H
35 #define CARTODATA_VOLUME_VOLUMEOPERATORS_H
36 
37 #if 0
38 
40 #include <functional>
41 
42 
43 namespace carto
44 {
45 
46  template <typename T> inline
47  VolumeRef<T> operator - ( const VolumeRef<T> & o1 )
48  {
49  return VolumeUtil<T>::apply( std::negate<T>(), o1 );
50  }
51 
52 
53  template <typename T> inline
54  VolumeRef<T> operator + ( const VolumeRef<T> & o1, const VolumeRef<T> & o2 )
55  {
56  return VolumeUtil<T>::apply( std::plus<T>(), o1, o2 );
57  }
58 
59 
60  template <typename T> inline
61  VolumeRef<T> & operator += ( VolumeRef<T> & o1, const VolumeRef<T> & o2 )
62  {
63  VolumeUtil<T>::selfApply( std::plus<T>(), o1, o2 );
64  return o1;
65  }
66 
67 
68  template <typename T> inline
69  VolumeRef<T> operator - ( const VolumeRef<T> & o1, const VolumeRef<T> & o2 )
70  {
71  return VolumeUtil<T>::apply( std::minus<T>(), o1, o2 );
72  }
73 
74 
75  template <typename T> inline
76  VolumeRef<T> & operator -= ( VolumeRef<T> & o1, const VolumeRef<T> & o2 )
77  {
78  VolumeUtil<T>::selfApply( std::minus<T>(), o1, o2 );
79  return o1;
80  }
81 
82 
83  template <typename T> inline
84  VolumeRef<T> operator * ( const VolumeRef<T> & o1, const VolumeRef<T> & o2 )
85  {
86  return VolumeUtil<T>::apply( std::multiplies<T>(), o1, o2 );
87  }
88 
89 
90  template <typename T> inline
91  VolumeRef<T> & operator *= ( VolumeRef<T> & o1, const VolumeRef<T> & o2 )
92  {
93  VolumeUtil<T>::selfApply( std::multiplies<T>(), o1, o2 );
94  return o1;
95  }
96 
97 
98  template <typename T> inline
99  VolumeRef<T> operator / ( const VolumeRef<T> & o1, const VolumeRef<T> & o2 )
100  {
101  return VolumeUtil<T>::apply( std::divides<T>(), o1, o2 );
102  }
103 
104 
105  template <typename T> inline
106  VolumeRef<T> & operator /= ( VolumeRef<T> & o1, const VolumeRef<T> & o2 )
107  {
108  VolumeUtil<T>::selfApply( std::divides<T>(), o1, o2 );
109  return o1;
110  }
111 
112 
113  template <typename T> inline
114  VolumeRef<T> operator + ( const VolumeRef<T> & o1, const T & val )
115  {
116  return VolumeUtil<T>::apply
117  ( UnaryFromConstantBinaryFunctor<T, std::plus<T> >
118  ( val, std::plus<T>() ), o1 );
119  }
120 
121 
122  template <typename T> inline
123  VolumeRef<T> operator + ( const T & val, const VolumeRef<T> & o1 )
124  {
125  return VolumeUtil<T>::apply
126  ( UnaryFromConstantBinaryFunctor2<T, std::plus<T> >
127  ( val, std::plus<T>() ), o1 );
128  }
129 
130 
131  template <typename T> inline
132  VolumeRef<T> & operator += ( VolumeRef<T> & o1, const T & val )
133  {
134  VolumeUtil<T>::selfApply( UnaryFromConstantBinaryFunctor<T, std::plus<T> >
135  ( val, std::plus<T>() ), o1 );
136  return o1;
137  }
138 
139 
140  template <typename T> inline
141  VolumeRef<T> operator - ( const VolumeRef<T> & o1, const T & val )
142  {
143  return VolumeUtil<T>::apply
144  ( UnaryFromConstantBinaryFunctor<T, std::minus<T> >
145  ( val, std::minus<T>() ), o1 );
146  }
147 
148 
149  template <typename T> inline
150  VolumeRef<T> operator - ( const T & val, const VolumeRef<T> & o1 )
151  {
152  return VolumeUtil<T>::apply
153  ( UnaryFromConstantBinaryFunctor2<T, std::minus<T> >
154  ( val, std::minus<T>() ), o1 );
155  }
156 
157 
158  template <typename T> inline
159  VolumeRef<T> & operator -= ( VolumeRef<T> & o1, const T & val )
160  {
161  VolumeUtil<T>::selfApply( UnaryFromConstantBinaryFunctor<T, std::minus<T> >
162  ( val, std::minus<T>() ), o1 );
163  return o1;
164  }
165 
166 
167  template <typename T, typename U> inline
168  VolumeRef<T> operator * ( const VolumeRef<T> & o1, U val )
169  {
170  return VolumeUtil<T>::apply( Scaler<T, U>( val ), o1 );
171  }
172 
173 
174  template <typename T, typename U> inline
175  VolumeRef<T> operator * ( U val, const VolumeRef<T> & o1 )
176  {
177  return VolumeUtil<T>::apply( Scaler<T, U>( val ), o1 );
178  }
179 
180 
181  template <typename T, typename U> inline
182  VolumeRef<T> & operator *= ( VolumeRef<T> & o1, U val )
183  {
184  VolumeUtil<T>::selfApply( Scaler<T, U>( val ), o1 );
185  return o1;
186  }
187 
188 
189  template <typename T, typename U> inline
190  VolumeRef<T> operator / ( const VolumeRef<T> & o1, U val )
191  {
192  return VolumeUtil<T>::apply( Divider<T, U>( val ), o1 );
193  }
194 
195 
196  template <typename T> inline
197  VolumeRef<T> operator / ( double val, const VolumeRef<T> & o1 )
198  {
199  return VolumeUtil<T>::apply
200  ( UnaryFromConstantBinaryFunctor2<T, std::divides<T> >
201  ( val, std::divides<T>() ), o1 );
202  }
203 
204 
205  template <typename T, typename U> inline
206  VolumeRef<T> & operator /= ( VolumeRef<T> & o1, U val )
207  {
208  VolumeUtil<T>::selfApply( Divider<T, U>( val ), o1 );
209  return o1;
210  }
211 
212 }
213 
214 #endif
215 
216 #endif
217 
static void selfApply(UnaryFunction f, VolumeRef< T > &o)
applies a binary function to each voxel of a pair of volumes
Definition: volumeutil_d.h:299
static VolumeRef< T > apply(UnaryFunction f, const VolumeRef< T > &o)
applies a unary function to each voxel of a volume
Definition: volumeutil_d.h:74
carto::Volume< T > & operator*=(carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator/=(carto::Volume< T > &vol, const U &value)
VoxelRGB operator/(const VoxelRGB &aa, const uint8_t &bb)
VoxelRGB operator+(const VoxelRGB &aa, const VoxelRGB &bb)
VoxelRGB operator-(const VoxelRGB &aa, const VoxelRGB &bb)
VoxelRGB operator*(const VoxelRGB &aa, const uint8_t &bb)
carto::Volume< T > & operator-=(carto::Volume< T > &vol, const U &value)
carto::Volume< T > & operator+=(carto::Volume< T > &vol, const U &value)