ForEachSenaryVoxelFunction.h
1 /*
2  * Medical Image Registration ToolKit (MIRTK)
3  *
4  * Copyright 2013-2015 Imperial College London
5  * Copyright 2013-2015 Andreas Schuh
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * ATTENTION: This source file has been automatically generated using the code
20  * generator mirtkForEachVoxelFunction.py! This generator is
21  * invoked during CMake configuration of the build system when this
22  * source file is missing from the project.
23  *
24  * DO NOT modify this file manually. Instead, modify the code
25  * generator, remove any existing mirtkForEach*VoxelFunction.h
26  * header file from the include/ directory and then re-run CMake.
27  * This will invoke the code generator to re-generate the source files.
28  */
29 
30 #ifndef MIRTK_ForEachSenaryVoxelFunction_H
31 #define MIRTK_ForEachSenaryVoxelFunction_H
32 
33 #include "mirtk/Stream.h"
34 #include "mirtk/VoxelFunction.h"
35 
36 
37 namespace mirtk {
38 
39 
40 inline void _foreachsenaryvoxelfunction_must_not_be_reduction()
41 {
42  cerr << "(Parallel)ForEachVoxel(If): Voxel reductions must be passed by reference!"
43  " Pass voxel functor object(s) as last argument(s) instead of first." << endl;
44  exit(1);
45 }
46 
47 
48 // =============================================================================
49 // 6 const images
50 // =============================================================================
51 
52 // -----------------------------------------------------------------------------
53 /**
54  * ForEachVoxel body for voxel function of 6 const images
55  */
56 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
58 {
59  const GenericImage<T1> &im1;
60  const GenericImage<T2> &im2;
61  const GenericImage<T3> &im3;
62  const GenericImage<T4> &im4;
63  const GenericImage<T5> &im5;
64  const GenericImage<T6> &im6;
65 
66  /// Constructor
68  const GenericImage<T2> &im2,
69  const GenericImage<T3> &im3,
70  const GenericImage<T4> &im4,
71  const GenericImage<T5> &im5,
72  const GenericImage<T6> &im6,
73  VoxelFunc &vf)
74  :
75  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
76  {}
77 
78  /// Copy constructor
80  :
81  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
82  {}
83 
84  /// Split constructor
86  :
87  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
88  {}
89 
90  /// Process entire image
91  void operator ()(const ImageAttributes &attr) const
92  {
93  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
94  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
95  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
96  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
97  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
98  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
99 
100  const int T = (attr._dt ? attr._t : 1);
101 
102  for (int l = 0; l < T; ++l)
103  for (int k = 0; k < attr._z; ++k)
104  for (int j = 0; j < attr._y; ++j)
105  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
106  // const_cast such that voxel functions need only implement
107  // non-const operator() which is required for parallel_reduce
108  const_cast<SenaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
109  }
110  }
111 
112  /// Process image region using linear index
113  void operator ()(const blocked_range<int> &re) const
114  {
115  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
116  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
117  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
118  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
119  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
120  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
121 
122  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
123  // const_cast such that voxel functions need only implement
124  // non-const operator() which is required for parallel_reduce
125  const_cast<SenaryForEachVoxelBody_Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
126  }
127  }
128 
129  /// Process 2D image region
130  void operator ()(const blocked_range2d<int> &re) const
131  {
132  const int bi = re.cols().begin();
133  const int bj = re.rows().begin();
134  const int ei = re.cols().end();
135  const int ej = re.rows().end();
136 
137  const int s1 = im6.GetX() - (ei - bi);
138 
139  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
140  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
141  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
142  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
143  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
144  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
145 
146  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
147  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
148  // const_cast such that voxel functions need only implement
149  // non-const operator() which is required for parallel_reduce
150  const_cast<SenaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
151  }
152  }
153 
154  /// Process 3D image region
155  void operator ()(const blocked_range3d<int> &re) const
156  {
157  const int bi = re.cols ().begin();
158  const int bj = re.rows ().begin();
159  const int bk = re.pages().begin();
160  const int ei = re.cols ().end();
161  const int ej = re.rows ().end();
162  const int ek = re.pages().end();
163 
164  const int s1 = im6.GetX() - (ei - bi);
165  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
166 
167  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
168  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
169  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
170  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
171  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
172  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
173 
174  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
175  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
176  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
177  // const_cast such that voxel functions need only implement
178  // non-const operator() which is required for parallel_reduce
179  const_cast<SenaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
180  }
181  }
182 };
183 
184 // -----------------------------------------------------------------------------
185 /**
186  * ForEachVoxel body for inside and outside unary voxel function of 6 const images
187  */
188 template <class T1, class T2, class T3, class T4, class T5, class T6,
189  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
190  class Domain = ForEachVoxelDomain::Foreground>
191 struct SenaryForEachVoxelIfBody_Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
192 {
193  const GenericImage<T1> &im1;
194  const GenericImage<T2> &im2;
195  const GenericImage<T3> &im3;
196  const GenericImage<T4> &im4;
197  const GenericImage<T5> &im5;
198  const GenericImage<T6> &im6;
199 
200  /// Constructor
202  const GenericImage<T2> &im2,
203  const GenericImage<T3> &im3,
204  const GenericImage<T4> &im4,
205  const GenericImage<T5> &im5,
206  const GenericImage<T6> &im6,
207  VoxelFunc &vf, OutsideFunc &of)
208  :
209  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
210  {}
211 
212  /// Copy constructor
214  :
215  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
216  {}
217 
218  /// Split constructor
220  :
221  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
222  {}
223 
224  /// Process entire image
225  void operator ()(const ImageAttributes &attr) const
226  {
227  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
228  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
229  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
230  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
231  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
232  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
233 
234  const int T = (attr._dt ? attr._t : 1);
235 
236  for (int l = 0; l < T; ++l)
237  for (int k = 0; k < attr._z; ++k)
238  for (int j = 0; j < attr._y; ++j)
239  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
240  if (Domain::IsInside(im6, i, j, k, l, p6)) {
241  // const_cast such that voxel functions need only implement
242  // non-const operator() which is required for parallel_reduce
243  const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
244  } else const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
245  }
246  }
247 
248  /// Process image region using linear index
249  void operator ()(const blocked_range<int> &re) const
250  {
251  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
252  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
253  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
254  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
255  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
256  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
257 
258  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
259  if (Domain::IsInside(im6, idx, p6)) {
260  // const_cast such that voxel functions need only implement
261  // non-const operator() which is required for parallel_reduce
262  const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
263  } else const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
264  }
265  }
266 
267  /// Process 2D image region
268  void operator ()(const blocked_range2d<int> &re) const
269  {
270  const int bi = re.cols().begin();
271  const int bj = re.rows().begin();
272  const int ei = re.cols().end();
273  const int ej = re.rows().end();
274 
275  const int s1 = im6.GetX() - (ei - bi);
276 
277  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
278  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
279  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
280  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
281  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
282  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
283 
284  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
285  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
286  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
287  // const_cast such that voxel functions need only implement
288  // non-const operator() which is required for parallel_reduce
289  const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
290  } else const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
291  }
292  }
293 
294  /// Process 3D image region
295  void operator ()(const blocked_range3d<int> &re) const
296  {
297  const int bi = re.cols ().begin();
298  const int bj = re.rows ().begin();
299  const int bk = re.pages().begin();
300  const int ei = re.cols ().end();
301  const int ej = re.rows ().end();
302  const int ek = re.pages().end();
303 
304  const int s1 = im6.GetX() - (ei - bi);
305  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
306 
307  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
308  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
309  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
310  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
311  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
312  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
313 
314  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
315  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
316  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
317  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
318  // const_cast such that voxel functions need only implement
319  // non-const operator() which is required for parallel_reduce
320  const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
321  } else const_cast<SenaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
322  }
323  }
324 };
325 
326 // -----------------------------------------------------------------------------
327 // ForEachVoxel
328 // -----------------------------------------------------------------------------
329 
330 //
331 // Image arguments by pointer
332 //
333 
334 // -----------------------------------------------------------------------------
335 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
336 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
337 {
338  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
340  body(re);
341  vf.join(body._VoxelFunc);
342 }
343 
344 // -----------------------------------------------------------------------------
345 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
346 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
347 {
348  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
349  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
350 }
351 
352 // -----------------------------------------------------------------------------
353 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
354 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
355 {
356  if (im6->GetTSize()) {
357  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
358  } else {
359  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
360  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
361  body(re);
362  vf.join(body._VoxelFunc);
363  }
364 }
365 
366 // -----------------------------------------------------------------------------
367 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
368 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
369 {
370  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
371  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
372 }
373 
374 // -----------------------------------------------------------------------------
375 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
376 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
377 {
378  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
379  body(attr);
380  vf.join(body._VoxelFunc);
381 }
382 
383 // -----------------------------------------------------------------------------
384 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
385 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
386 {
387  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
388  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
389 }
390 
391 // -----------------------------------------------------------------------------
392 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
393 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
394 {
395  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
396  body(re);
397  vf.join(body._VoxelFunc);
398 }
399 
400 // -----------------------------------------------------------------------------
401 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
402 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
403 {
404  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
405  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
406 }
407 
408 // -----------------------------------------------------------------------------
409 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
410 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
411 {
412  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
413  body(re);
414  vf.join(body._VoxelFunc);
415 }
416 
417 // -----------------------------------------------------------------------------
418 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
419 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
420 {
421  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
422  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
423 }
424 
425 // -----------------------------------------------------------------------------
426 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
427 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
428 {
429  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
430  body(re);
431  vf.join(body._VoxelFunc);
432 }
433 
434 // -----------------------------------------------------------------------------
435 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
436 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
437 {
438  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
439  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
440 }
441 
442 //
443 // Image arguments by reference
444 //
445 
446 // -----------------------------------------------------------------------------
447 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
448 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
449 {
450  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
452  body(re);
453  vf.join(body._VoxelFunc);
454 }
455 
456 // -----------------------------------------------------------------------------
457 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
458 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
459 {
460  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
461  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
462 }
463 
464 // -----------------------------------------------------------------------------
465 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
466 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
467 {
468  if (im6.GetTSize()) {
469  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
470  } else {
471  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
472  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
473  body(re);
474  vf.join(body._VoxelFunc);
475  }
476 }
477 
478 // -----------------------------------------------------------------------------
479 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
480 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
481 {
482  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
483  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
484 }
485 
486 // -----------------------------------------------------------------------------
487 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
488 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
489 {
490  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
491  body(attr);
492  vf.join(body._VoxelFunc);
493 }
494 
495 // -----------------------------------------------------------------------------
496 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
497 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
498 {
499  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
500  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
501 }
502 
503 // -----------------------------------------------------------------------------
504 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
505 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
506 {
507  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
508  body(re);
509  vf.join(body._VoxelFunc);
510 }
511 
512 // -----------------------------------------------------------------------------
513 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
514 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
515 {
516  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
517  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
518 }
519 
520 // -----------------------------------------------------------------------------
521 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
522 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
523 {
524  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
525  body(re);
526  vf.join(body._VoxelFunc);
527 }
528 
529 // -----------------------------------------------------------------------------
530 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
531 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
532 {
533  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
534  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
535 }
536 
537 // -----------------------------------------------------------------------------
538 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
539 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
540 {
541  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
542  body(re);
543  vf.join(body._VoxelFunc);
544 }
545 
546 // -----------------------------------------------------------------------------
547 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
548 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
549 {
550  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
551  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
552 }
553 
554 // -----------------------------------------------------------------------------
555 // ForEachVoxelIf
556 // -----------------------------------------------------------------------------
557 
558 //
559 // Image arguments by pointer
560 //
561 
562 // -----------------------------------------------------------------------------
563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
564 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
565 {
568  body(re);
569  vf.join(body._VoxelFunc);
570  of.join(body._OutsideFunc);
571 }
572 
573 // -----------------------------------------------------------------------------
574 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
575 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
576 {
577  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
578  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
579 }
580 
581 // -----------------------------------------------------------------------------
582 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
583 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
584 {
586  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
587 }
588 
589 // -----------------------------------------------------------------------------
590 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
591 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
592 {
593  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
594  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
595 }
596 
597 // -----------------------------------------------------------------------------
598 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
599 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
600 {
601  if (im6->GetTSize()) {
602  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
603  } else {
605  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
606  body(re);
607  vf.join(body._VoxelFunc);
608  of.join(body._OutsideFunc);
609  }
610 }
611 
612 // -----------------------------------------------------------------------------
613 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
614 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
615 {
616  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
617  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
618 }
619 
620 // -----------------------------------------------------------------------------
621 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
622 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
623 {
625  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
626 }
627 
628 // -----------------------------------------------------------------------------
629 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
630 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
631 {
632  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
633  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
634 }
635 
636 // -----------------------------------------------------------------------------
637 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
638 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
639 {
641  body(attr);
642  vf.join(body._VoxelFunc);
643  of.join(body._OutsideFunc);
644 }
645 
646 // -----------------------------------------------------------------------------
647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
648 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
649 {
650  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
651  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
652 }
653 
654 // -----------------------------------------------------------------------------
655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
656 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
657 {
659  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
660 }
661 
662 // -----------------------------------------------------------------------------
663 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
664 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
665 {
666  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
667  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
668 }
669 
670 // -----------------------------------------------------------------------------
671 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
672 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
673 {
675  body(re);
676  vf.join(body._VoxelFunc);
677  of.join(body._OutsideFunc);
678 }
679 
680 // -----------------------------------------------------------------------------
681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
682 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
683 {
684  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
685  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
686 }
687 
688 // -----------------------------------------------------------------------------
689 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
690 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
691 {
693  body(re);
694  vf.join(body._VoxelFunc);
695  of.join(body._OutsideFunc);
696 }
697 
698 // -----------------------------------------------------------------------------
699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
700 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
701 {
702  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
703  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
704 }
705 
706 // -----------------------------------------------------------------------------
707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
708 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
709 {
711  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
712 }
713 
714 // -----------------------------------------------------------------------------
715 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
716 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
717 {
718  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
719  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
720 }
721 
722 // -----------------------------------------------------------------------------
723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
724 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
725 {
727  body(re);
728  vf.join(body._VoxelFunc);
729  of.join(body._OutsideFunc);
730 }
731 
732 // -----------------------------------------------------------------------------
733 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
734 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
735 {
736  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
737  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
738 }
739 
740 // -----------------------------------------------------------------------------
741 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
742 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
743 {
745  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
746 }
747 
748 // -----------------------------------------------------------------------------
749 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
750 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
751 {
752  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
753  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
754 }
755 
756 //
757 // Image arguments by reference
758 //
759 
760 // -----------------------------------------------------------------------------
761 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
762 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
763 {
766  body(re);
767  vf.join(body._VoxelFunc);
768  of.join(body._OutsideFunc);
769 }
770 
771 // -----------------------------------------------------------------------------
772 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
773 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
774 {
775  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
776  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
777 }
778 
779 // -----------------------------------------------------------------------------
780 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
781 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
782 {
784  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
785 }
786 
787 // -----------------------------------------------------------------------------
788 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
789 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
790 {
791  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
792  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
793 }
794 
795 // -----------------------------------------------------------------------------
796 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
797 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
798 {
799  if (im6.GetTSize()) {
800  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
801  } else {
803  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
804  body(re);
805  vf.join(body._VoxelFunc);
806  of.join(body._OutsideFunc);
807  }
808 }
809 
810 // -----------------------------------------------------------------------------
811 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
812 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
813 {
814  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
815  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
816 }
817 
818 // -----------------------------------------------------------------------------
819 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
820 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
821 {
823  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
824 }
825 
826 // -----------------------------------------------------------------------------
827 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
828 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
829 {
830  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
831  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
832 }
833 
834 // -----------------------------------------------------------------------------
835 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
836 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
837 {
839  body(attr);
840  vf.join(body._VoxelFunc);
841  of.join(body._OutsideFunc);
842 }
843 
844 // -----------------------------------------------------------------------------
845 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
846 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
847 {
848  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
849  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
850 }
851 
852 // -----------------------------------------------------------------------------
853 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
854 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
855 {
857  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
858 }
859 
860 // -----------------------------------------------------------------------------
861 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
862 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
863 {
864  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
865  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
866 }
867 
868 // -----------------------------------------------------------------------------
869 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
870 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
871 {
873  body(re);
874  vf.join(body._VoxelFunc);
875  of.join(body._OutsideFunc);
876 }
877 
878 // -----------------------------------------------------------------------------
879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
880 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
881 {
882  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
883  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
884 }
885 
886 // -----------------------------------------------------------------------------
887 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
888 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
889 {
891  body(re);
892  vf.join(body._VoxelFunc);
893  of.join(body._OutsideFunc);
894 }
895 
896 // -----------------------------------------------------------------------------
897 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
898 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
899 {
900  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
901  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
902 }
903 
904 // -----------------------------------------------------------------------------
905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
906 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
907 {
909  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
910 }
911 
912 // -----------------------------------------------------------------------------
913 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
914 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
915 {
916  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
917  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
918 }
919 
920 // -----------------------------------------------------------------------------
921 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
922 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
923 {
925  body(re);
926  vf.join(body._VoxelFunc);
927  of.join(body._OutsideFunc);
928 }
929 
930 // -----------------------------------------------------------------------------
931 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
932 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
933 {
934  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
935  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
936 }
937 
938 // -----------------------------------------------------------------------------
939 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
940 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
941 {
943  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
944 }
945 
946 // -----------------------------------------------------------------------------
947 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
948 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
949 {
950  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
951  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
952 }
953 
954 // -----------------------------------------------------------------------------
955 // ParallelForEachVoxel
956 // -----------------------------------------------------------------------------
957 
958 //
959 // Image arguments by pointer
960 //
961 
962 // -----------------------------------------------------------------------------
963 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
964 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
965 {
966  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
968  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
969  else parallel_for (re, body);
970 }
971 
972 // -----------------------------------------------------------------------------
973 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
974 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
975 {
976  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
977  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
978 }
979 
980 // -----------------------------------------------------------------------------
981 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
982 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
983 {
984  if (im6->GetTSize()) {
985  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
986  } else {
987  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
988  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
989  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
990  else parallel_for (re, body);
991  }
992 }
993 
994 // -----------------------------------------------------------------------------
995 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
996 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
997 {
998  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
999  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1000 }
1001 
1002 // -----------------------------------------------------------------------------
1003 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1004 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1005 {
1006  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1007  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1008  if (VoxelFunc::IsReduction()) {
1009  if (attr._dt) {
1010  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1011  } else {
1012  parallel_reduce(re, body);
1013  }
1014  vf.join(body._VoxelFunc);
1015  } else {
1016  if (attr._dt) {
1017  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1018  } else {
1019  parallel_for(re, body);
1020  }
1021  }
1022 }
1023 
1024 // -----------------------------------------------------------------------------
1025 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1026 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1027 {
1028  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1029  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1030 }
1031 
1032 // -----------------------------------------------------------------------------
1033 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1034 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1035 {
1036  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1037  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1038  else parallel_for (re, body);
1039 }
1040 
1041 // -----------------------------------------------------------------------------
1042 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1043 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1044 {
1045  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1046  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1047 }
1048 
1049 // -----------------------------------------------------------------------------
1050 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1051 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1052 {
1053  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1054  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1055  else parallel_for (re, body);
1056 }
1057 
1058 // -----------------------------------------------------------------------------
1059 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1060 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1061 {
1062  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1063  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1064 }
1065 
1066 // -----------------------------------------------------------------------------
1067 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1068 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1069 {
1070  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1071  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1072  else parallel_for (re, body);
1073 }
1074 
1075 // -----------------------------------------------------------------------------
1076 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1077 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1078 {
1079  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1080  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1081 }
1082 
1083 //
1084 // Image arguments by reference
1085 //
1086 
1087 // -----------------------------------------------------------------------------
1088 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1089 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1090 {
1091  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1093  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1094  else parallel_for (re, body);
1095 }
1096 
1097 // -----------------------------------------------------------------------------
1098 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1099 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1100 {
1101  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1102  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
1103 }
1104 
1105 // -----------------------------------------------------------------------------
1106 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1107 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1108 {
1109  if (im6.GetTSize()) {
1110  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
1111  } else {
1112  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1113  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
1114  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1115  else parallel_for (re, body);
1116  }
1117 }
1118 
1119 // -----------------------------------------------------------------------------
1120 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1121 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1122 {
1123  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1124  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
1125 }
1126 
1127 // -----------------------------------------------------------------------------
1128 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1129 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1130 {
1131  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1132  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1133  if (VoxelFunc::IsReduction()) {
1134  if (attr._dt) {
1135  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1136  } else {
1137  parallel_reduce(re, body);
1138  }
1139  vf.join(body._VoxelFunc);
1140  } else {
1141  if (attr._dt) {
1142  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1143  } else {
1144  parallel_for(re, body);
1145  }
1146  }
1147 }
1148 
1149 // -----------------------------------------------------------------------------
1150 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1151 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1152 {
1153  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1154  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
1155 }
1156 
1157 // -----------------------------------------------------------------------------
1158 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1159 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1160 {
1161  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1162  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1163  else parallel_for (re, body);
1164 }
1165 
1166 // -----------------------------------------------------------------------------
1167 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1168 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1169 {
1170  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1171  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
1172 }
1173 
1174 // -----------------------------------------------------------------------------
1175 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1176 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1177 {
1178  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1179  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1180  else parallel_for (re, body);
1181 }
1182 
1183 // -----------------------------------------------------------------------------
1184 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1185 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1186 {
1187  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1188  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
1189 }
1190 
1191 // -----------------------------------------------------------------------------
1192 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1193 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1194 {
1195  SenaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
1196  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1197  else parallel_for (re, body);
1198 }
1199 
1200 // -----------------------------------------------------------------------------
1201 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1202 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1203 {
1204  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1205  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
1206 }
1207 
1208 // -----------------------------------------------------------------------------
1209 // ParallelForEachVoxelIf
1210 // -----------------------------------------------------------------------------
1211 
1212 //
1213 // Image arguments by pointer
1214 //
1215 
1216 // -----------------------------------------------------------------------------
1217 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1218 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1219 {
1220  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1221  blocked_range<int> re(0, im6->GetNumberOfVoxels());
1222  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1223  parallel_reduce(re, body);
1224  vf.join(body._VoxelFunc);
1225  of.join(body._OutsideFunc);
1226  } else {
1227  parallel_for(re, body);
1228  }
1229 }
1230 
1231 // -----------------------------------------------------------------------------
1232 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1233 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1234 {
1235  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1236  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1237 }
1238 
1239 // -----------------------------------------------------------------------------
1240 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1241 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1242 {
1244  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1245 }
1246 
1247 // -----------------------------------------------------------------------------
1248 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1249 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1250 {
1251  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1252  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1253 }
1254 
1255 // -----------------------------------------------------------------------------
1256 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1257 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1258 {
1259  if (im6->GetTSize()) {
1260  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1261  } else {
1262  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1263  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
1264  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1265  parallel_reduce(re, body);
1266  vf.join(body._VoxelFunc);
1267  of.join(body._OutsideFunc);
1268  } else {
1269  parallel_for(re, body);
1270  }
1271  }
1272 }
1273 
1274 // -----------------------------------------------------------------------------
1275 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1276 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1277 {
1278  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1279  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1280 }
1281 
1282 // -----------------------------------------------------------------------------
1283 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1284 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1285 {
1287  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1288 }
1289 
1290 // -----------------------------------------------------------------------------
1291 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1292 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1293 {
1294  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1295  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1296 }
1297 
1298 // -----------------------------------------------------------------------------
1299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1300 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1301 {
1302  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1303  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1304  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1305  if (attr._dt) {
1306  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1307  } else {
1308  parallel_reduce(re, body);
1309  }
1310  vf.join(body._VoxelFunc);
1311  of.join(body._OutsideFunc);
1312  } else {
1313  if (attr._dt) {
1314  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1315  } else {
1316  parallel_for(re, body);
1317  }
1318  }
1319 }
1320 
1321 // -----------------------------------------------------------------------------
1322 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1323 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1324 {
1325  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1326  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1327 }
1328 
1329 // -----------------------------------------------------------------------------
1330 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1331 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1332 {
1334  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1335 }
1336 
1337 // -----------------------------------------------------------------------------
1338 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1339 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1340 {
1341  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1342  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1343 }
1344 
1345 // -----------------------------------------------------------------------------
1346 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1347 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1348 {
1349  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1350  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1351  parallel_reduce(re, body);
1352  vf.join(body._VoxelFunc);
1353  of.join(body._OutsideFunc);
1354  } else {
1355  parallel_for(re, body);
1356  }
1357 }
1358 
1359 // -----------------------------------------------------------------------------
1360 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1361 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1362 {
1363  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1364  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1365 }
1366 
1367 // -----------------------------------------------------------------------------
1368 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1369 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1370 {
1372  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1373 }
1374 
1375 // -----------------------------------------------------------------------------
1376 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1377 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1378 {
1379  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1380  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1381 }
1382 
1383 // -----------------------------------------------------------------------------
1384 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1385 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1386 {
1387  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1388  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1389  parallel_reduce(re, body);
1390  vf.join(body._VoxelFunc);
1391  of.join(body._OutsideFunc);
1392  } else {
1393  parallel_for(re, body);
1394  }
1395 }
1396 
1397 // -----------------------------------------------------------------------------
1398 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1399 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1400 {
1401  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1402  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1403 }
1404 
1405 // -----------------------------------------------------------------------------
1406 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1407 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1408 {
1410  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1411 }
1412 
1413 // -----------------------------------------------------------------------------
1414 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1415 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1416 {
1417  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1418  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1419 }
1420 
1421 // -----------------------------------------------------------------------------
1422 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1423 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
1424 {
1425  SenaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1426  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1427  parallel_reduce(re, body);
1428  vf.join(body._VoxelFunc);
1429  of.join(body._OutsideFunc);
1430  } else {
1431  parallel_for(re, body);
1432  }
1433 }
1434 
1435 // -----------------------------------------------------------------------------
1436 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1437 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1438 {
1439  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1440  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1441 }
1442 
1443 // -----------------------------------------------------------------------------
1444 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1445 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6, VoxelFunc &vf)
1446 {
1448  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
1449 }
1450 
1451 // -----------------------------------------------------------------------------
1452 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1453 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, const GenericImage<T6> *im6)
1454 {
1455  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1456  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
1457 }
1458 
1459 //
1460 // Image arguments by reference
1461 //
1462 
1463 // -----------------------------------------------------------------------------
1464 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1465 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1466 {
1469  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1470  parallel_reduce(re, body);
1471  vf.join(body._VoxelFunc);
1472  of.join(body._OutsideFunc);
1473  } else {
1474  parallel_for(re, body);
1475  }
1476 }
1477 
1478 // -----------------------------------------------------------------------------
1479 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1480 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1481 {
1482  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1483  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
1484 }
1485 
1486 // -----------------------------------------------------------------------------
1487 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1488 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1489 {
1491  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
1492 }
1493 
1494 // -----------------------------------------------------------------------------
1495 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1496 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1497 {
1498  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1499  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
1500 }
1501 
1502 // -----------------------------------------------------------------------------
1503 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1504 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1505 {
1506  if (im6.GetTSize()) {
1507  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
1508  } else {
1510  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
1511  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1512  parallel_reduce(re, body);
1513  vf.join(body._VoxelFunc);
1514  of.join(body._OutsideFunc);
1515  } else {
1516  parallel_for(re, body);
1517  }
1518  }
1519 }
1520 
1521 // -----------------------------------------------------------------------------
1522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1523 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1524 {
1525  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1526  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
1527 }
1528 
1529 // -----------------------------------------------------------------------------
1530 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1531 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1532 {
1534  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
1535 }
1536 
1537 // -----------------------------------------------------------------------------
1538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1539 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1540 {
1541  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1542  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
1543 }
1544 
1545 // -----------------------------------------------------------------------------
1546 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1547 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1548 {
1550  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1551  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1552  if (attr._dt) {
1553  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1554  } else {
1555  parallel_reduce(re, body);
1556  }
1557  vf.join(body._VoxelFunc);
1558  of.join(body._OutsideFunc);
1559  } else {
1560  if (attr._dt) {
1561  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1562  } else {
1563  parallel_for(re, body);
1564  }
1565  }
1566 }
1567 
1568 // -----------------------------------------------------------------------------
1569 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1570 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1571 {
1572  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1573  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
1574 }
1575 
1576 // -----------------------------------------------------------------------------
1577 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1578 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1579 {
1581  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
1582 }
1583 
1584 // -----------------------------------------------------------------------------
1585 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1586 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1587 {
1588  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1589  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
1590 }
1591 
1592 // -----------------------------------------------------------------------------
1593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1594 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1595 {
1597  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1598  parallel_reduce(re, body);
1599  vf.join(body._VoxelFunc);
1600  of.join(body._OutsideFunc);
1601  } else {
1602  parallel_for(re, body);
1603  }
1604 }
1605 
1606 // -----------------------------------------------------------------------------
1607 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1608 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1609 {
1610  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1611  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1612 }
1613 
1614 // -----------------------------------------------------------------------------
1615 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1616 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1617 {
1619  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1620 }
1621 
1622 // -----------------------------------------------------------------------------
1623 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1624 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1625 {
1626  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1627  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
1628 }
1629 
1630 // -----------------------------------------------------------------------------
1631 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1632 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1633 {
1635  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1636  parallel_reduce(re, body);
1637  vf.join(body._VoxelFunc);
1638  of.join(body._OutsideFunc);
1639  } else {
1640  parallel_for(re, body);
1641  }
1642 }
1643 
1644 // -----------------------------------------------------------------------------
1645 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1646 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1647 {
1648  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1649  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1650 }
1651 
1652 // -----------------------------------------------------------------------------
1653 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1654 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1655 {
1657  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1658 }
1659 
1660 // -----------------------------------------------------------------------------
1661 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1662 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1663 {
1664  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1665  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
1666 }
1667 
1668 // -----------------------------------------------------------------------------
1669 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1670 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
1671 {
1673  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1674  parallel_reduce(re, body);
1675  vf.join(body._VoxelFunc);
1676  of.join(body._OutsideFunc);
1677  } else {
1678  parallel_for(re, body);
1679  }
1680 }
1681 
1682 // -----------------------------------------------------------------------------
1683 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
1684 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1685 {
1686  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1687  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1688 }
1689 
1690 // -----------------------------------------------------------------------------
1691 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1692 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6, VoxelFunc &vf)
1693 {
1695  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
1696 }
1697 
1698 // -----------------------------------------------------------------------------
1699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1700 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, const GenericImage<T6> &im6)
1701 {
1702  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
1703  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
1704 }
1705 
1706 // =============================================================================
1707 // 5 const, 1 non-const images
1708 // =============================================================================
1709 
1710 // -----------------------------------------------------------------------------
1711 /**
1712  * ForEachVoxel body for voxel function of 5 const, 1 non-const images
1713  */
1714 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1716 {
1717  const GenericImage<T1> &im1;
1718  const GenericImage<T2> &im2;
1719  const GenericImage<T3> &im3;
1720  const GenericImage<T4> &im4;
1721  const GenericImage<T5> &im5;
1722  GenericImage<T6> &im6;
1723 
1724  /// Constructor
1726  const GenericImage<T2> &im2,
1727  const GenericImage<T3> &im3,
1728  const GenericImage<T4> &im4,
1729  const GenericImage<T5> &im5,
1730  GenericImage<T6> &im6,
1731  VoxelFunc &vf)
1732  :
1733  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
1734  {}
1735 
1736  /// Copy constructor
1738  :
1739  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
1740  {}
1741 
1742  /// Split constructor
1744  :
1745  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
1746  {}
1747 
1748  /// Process entire image
1749  void operator ()(const ImageAttributes &attr) const
1750  {
1751  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1752  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1753  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1754  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1755  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1756  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1757 
1758  const int T = (attr._dt ? attr._t : 1);
1759 
1760  for (int l = 0; l < T; ++l)
1761  for (int k = 0; k < attr._z; ++k)
1762  for (int j = 0; j < attr._y; ++j)
1763  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
1764  // const_cast such that voxel functions need only implement
1765  // non-const operator() which is required for parallel_reduce
1766  const_cast<SenaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
1767  }
1768  }
1769 
1770  /// Process image region using linear index
1771  void operator ()(const blocked_range<int> &re) const
1772  {
1773  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1774  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1775  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1776  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1777  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1778  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1779 
1780  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1781  // const_cast such that voxel functions need only implement
1782  // non-const operator() which is required for parallel_reduce
1783  const_cast<SenaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
1784  }
1785  }
1786 
1787  /// Process 2D image region
1788  void operator ()(const blocked_range2d<int> &re) const
1789  {
1790  const int bi = re.cols().begin();
1791  const int bj = re.rows().begin();
1792  const int ei = re.cols().end();
1793  const int ej = re.rows().end();
1794 
1795  const int s1 = im6.GetX() - (ei - bi);
1796 
1797  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1798  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1799  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1800  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1801  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1802  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1803 
1804  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
1805  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1806  // const_cast such that voxel functions need only implement
1807  // non-const operator() which is required for parallel_reduce
1808  const_cast<SenaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
1809  }
1810  }
1811 
1812  /// Process 3D image region
1813  void operator ()(const blocked_range3d<int> &re) const
1814  {
1815  const int bi = re.cols ().begin();
1816  const int bj = re.rows ().begin();
1817  const int bk = re.pages().begin();
1818  const int ei = re.cols ().end();
1819  const int ej = re.rows ().end();
1820  const int ek = re.pages().end();
1821 
1822  const int s1 = im6.GetX() - (ei - bi);
1823  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
1824 
1825  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
1826  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
1827  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
1828  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
1829  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
1830  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
1831 
1832  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
1833  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
1834  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1835  // const_cast such that voxel functions need only implement
1836  // non-const operator() which is required for parallel_reduce
1837  const_cast<SenaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
1838  }
1839  }
1840 };
1841 
1842 // -----------------------------------------------------------------------------
1843 /**
1844  * ForEachVoxel body for inside and outside unary voxel function of 5 const, 1 non-const images
1845  */
1846 template <class T1, class T2, class T3, class T4, class T5, class T6,
1847  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
1848  class Domain = ForEachVoxelDomain::Foreground>
1849 struct SenaryForEachVoxelIfBody_5Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
1850 {
1851  const GenericImage<T1> &im1;
1852  const GenericImage<T2> &im2;
1853  const GenericImage<T3> &im3;
1854  const GenericImage<T4> &im4;
1855  const GenericImage<T5> &im5;
1856  GenericImage<T6> &im6;
1857 
1858  /// Constructor
1860  const GenericImage<T2> &im2,
1861  const GenericImage<T3> &im3,
1862  const GenericImage<T4> &im4,
1863  const GenericImage<T5> &im5,
1864  GenericImage<T6> &im6,
1865  VoxelFunc &vf, OutsideFunc &of)
1866  :
1867  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
1868  {}
1869 
1870  /// Copy constructor
1872  :
1873  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
1874  {}
1875 
1876  /// Split constructor
1878  :
1879  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
1880  {}
1881 
1882  /// Process entire image
1883  void operator ()(const ImageAttributes &attr) const
1884  {
1885  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1886  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1887  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1888  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1889  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1890  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1891 
1892  const int T = (attr._dt ? attr._t : 1);
1893 
1894  for (int l = 0; l < T; ++l)
1895  for (int k = 0; k < attr._z; ++k)
1896  for (int j = 0; j < attr._y; ++j)
1897  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
1898  if (Domain::IsInside(im6, i, j, k, l, p6)) {
1899  // const_cast such that voxel functions need only implement
1900  // non-const operator() which is required for parallel_reduce
1901  const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
1902  } else const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
1903  }
1904  }
1905 
1906  /// Process image region using linear index
1907  void operator ()(const blocked_range<int> &re) const
1908  {
1909  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1910  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1911  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1912  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1913  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1914  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1915 
1916  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1917  if (Domain::IsInside(im6, idx, p6)) {
1918  // const_cast such that voxel functions need only implement
1919  // non-const operator() which is required for parallel_reduce
1920  const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
1921  } else const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
1922  }
1923  }
1924 
1925  /// Process 2D image region
1926  void operator ()(const blocked_range2d<int> &re) const
1927  {
1928  const int bi = re.cols().begin();
1929  const int bj = re.rows().begin();
1930  const int ei = re.cols().end();
1931  const int ej = re.rows().end();
1932 
1933  const int s1 = im6.GetX() - (ei - bi);
1934 
1935  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1936  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1937  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1938  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1939  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1940  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1941 
1942  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
1943  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1944  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
1945  // const_cast such that voxel functions need only implement
1946  // non-const operator() which is required for parallel_reduce
1947  const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
1948  } else const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
1949  }
1950  }
1951 
1952  /// Process 3D image region
1953  void operator ()(const blocked_range3d<int> &re) const
1954  {
1955  const int bi = re.cols ().begin();
1956  const int bj = re.rows ().begin();
1957  const int bk = re.pages().begin();
1958  const int ei = re.cols ().end();
1959  const int ej = re.rows ().end();
1960  const int ek = re.pages().end();
1961 
1962  const int s1 = im6.GetX() - (ei - bi);
1963  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
1964 
1965  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
1966  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
1967  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
1968  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
1969  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
1970  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
1971 
1972  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
1973  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
1974  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
1975  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
1976  // const_cast such that voxel functions need only implement
1977  // non-const operator() which is required for parallel_reduce
1978  const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
1979  } else const_cast<SenaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
1980  }
1981  }
1982 };
1983 
1984 // -----------------------------------------------------------------------------
1985 // ForEachVoxel
1986 // -----------------------------------------------------------------------------
1987 
1988 //
1989 // Image arguments by pointer
1990 //
1991 
1992 // -----------------------------------------------------------------------------
1993 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
1994 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
1995 {
1996  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
1997  blocked_range<int> re(0, im6->GetNumberOfVoxels());
1998  body(re);
1999  vf.join(body._VoxelFunc);
2000 }
2001 
2002 // -----------------------------------------------------------------------------
2003 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2004 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2005 {
2006  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2007  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2008 }
2009 
2010 // -----------------------------------------------------------------------------
2011 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2012 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2013 {
2014  if (im6->GetTSize()) {
2015  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2016  } else {
2017  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2018  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
2019  body(re);
2020  vf.join(body._VoxelFunc);
2021  }
2022 }
2023 
2024 // -----------------------------------------------------------------------------
2025 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2026 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2027 {
2028  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2029  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2030 }
2031 
2032 // -----------------------------------------------------------------------------
2033 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2034 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2035 {
2036  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2037  body(attr);
2038  vf.join(body._VoxelFunc);
2039 }
2040 
2041 // -----------------------------------------------------------------------------
2042 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2043 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2044 {
2045  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2046  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2047 }
2048 
2049 // -----------------------------------------------------------------------------
2050 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2051 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2052 {
2053  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2054  body(re);
2055  vf.join(body._VoxelFunc);
2056 }
2057 
2058 // -----------------------------------------------------------------------------
2059 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2060 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2061 {
2062  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2063  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2064 }
2065 
2066 // -----------------------------------------------------------------------------
2067 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2068 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2069 {
2070  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2071  body(re);
2072  vf.join(body._VoxelFunc);
2073 }
2074 
2075 // -----------------------------------------------------------------------------
2076 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2077 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2078 {
2079  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2080  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2081 }
2082 
2083 // -----------------------------------------------------------------------------
2084 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2085 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2086 {
2087  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2088  body(re);
2089  vf.join(body._VoxelFunc);
2090 }
2091 
2092 // -----------------------------------------------------------------------------
2093 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2094 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2095 {
2096  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2097  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2098 }
2099 
2100 //
2101 // Image arguments by reference
2102 //
2103 
2104 // -----------------------------------------------------------------------------
2105 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2106 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2107 {
2108  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2110  body(re);
2111  vf.join(body._VoxelFunc);
2112 }
2113 
2114 // -----------------------------------------------------------------------------
2115 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2116 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2117 {
2118  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2119  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
2120 }
2121 
2122 // -----------------------------------------------------------------------------
2123 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2124 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2125 {
2126  if (im6.GetTSize()) {
2127  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
2128  } else {
2129  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2130  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
2131  body(re);
2132  vf.join(body._VoxelFunc);
2133  }
2134 }
2135 
2136 // -----------------------------------------------------------------------------
2137 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2138 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2139 {
2140  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2141  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
2142 }
2143 
2144 // -----------------------------------------------------------------------------
2145 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2146 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2147 {
2148  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2149  body(attr);
2150  vf.join(body._VoxelFunc);
2151 }
2152 
2153 // -----------------------------------------------------------------------------
2154 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2155 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2156 {
2157  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2158  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
2159 }
2160 
2161 // -----------------------------------------------------------------------------
2162 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2163 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2164 {
2165  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2166  body(re);
2167  vf.join(body._VoxelFunc);
2168 }
2169 
2170 // -----------------------------------------------------------------------------
2171 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2172 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2173 {
2174  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2175  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2176 }
2177 
2178 // -----------------------------------------------------------------------------
2179 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2180 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2181 {
2182  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2183  body(re);
2184  vf.join(body._VoxelFunc);
2185 }
2186 
2187 // -----------------------------------------------------------------------------
2188 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2189 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2190 {
2191  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2192  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2193 }
2194 
2195 // -----------------------------------------------------------------------------
2196 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2197 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2198 {
2199  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2200  body(re);
2201  vf.join(body._VoxelFunc);
2202 }
2203 
2204 // -----------------------------------------------------------------------------
2205 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2206 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2207 {
2208  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2209  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2210 }
2211 
2212 // -----------------------------------------------------------------------------
2213 // ForEachVoxelIf
2214 // -----------------------------------------------------------------------------
2215 
2216 //
2217 // Image arguments by pointer
2218 //
2219 
2220 // -----------------------------------------------------------------------------
2221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2222 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2223 {
2224  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2225  blocked_range<int> re(0, im6->GetNumberOfVoxels());
2226  body(re);
2227  vf.join(body._VoxelFunc);
2228  of.join(body._OutsideFunc);
2229 }
2230 
2231 // -----------------------------------------------------------------------------
2232 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2233 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2234 {
2235  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2236  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2237 }
2238 
2239 // -----------------------------------------------------------------------------
2240 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2241 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2242 {
2244  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2245 }
2246 
2247 // -----------------------------------------------------------------------------
2248 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2249 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2250 {
2251  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2252  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2253 }
2254 
2255 // -----------------------------------------------------------------------------
2256 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2257 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2258 {
2259  if (im6->GetTSize()) {
2260  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2261  } else {
2262  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2263  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
2264  body(re);
2265  vf.join(body._VoxelFunc);
2266  of.join(body._OutsideFunc);
2267  }
2268 }
2269 
2270 // -----------------------------------------------------------------------------
2271 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2272 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2273 {
2274  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2275  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2276 }
2277 
2278 // -----------------------------------------------------------------------------
2279 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2280 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2281 {
2283  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2284 }
2285 
2286 // -----------------------------------------------------------------------------
2287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2288 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2289 {
2290  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2291  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2292 }
2293 
2294 // -----------------------------------------------------------------------------
2295 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2296 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2297 {
2298  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2299  body(attr);
2300  vf.join(body._VoxelFunc);
2301  of.join(body._OutsideFunc);
2302 }
2303 
2304 // -----------------------------------------------------------------------------
2305 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2306 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2307 {
2308  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2309  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2310 }
2311 
2312 // -----------------------------------------------------------------------------
2313 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2314 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2315 {
2317  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2318 }
2319 
2320 // -----------------------------------------------------------------------------
2321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2322 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2323 {
2324  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2325  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2326 }
2327 
2328 // -----------------------------------------------------------------------------
2329 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2330 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2331 {
2332  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2333  body(re);
2334  vf.join(body._VoxelFunc);
2335  of.join(body._OutsideFunc);
2336 }
2337 
2338 // -----------------------------------------------------------------------------
2339 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2340 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2341 {
2342  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2343  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2344 }
2345 
2346 // -----------------------------------------------------------------------------
2347 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2348 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2349 {
2350  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2351  body(re);
2352  vf.join(body._VoxelFunc);
2353  of.join(body._OutsideFunc);
2354 }
2355 
2356 // -----------------------------------------------------------------------------
2357 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2358 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2359 {
2360  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2361  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2362 }
2363 
2364 // -----------------------------------------------------------------------------
2365 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2366 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2367 {
2369  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2370 }
2371 
2372 // -----------------------------------------------------------------------------
2373 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2374 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2375 {
2376  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2377  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2378 }
2379 
2380 // -----------------------------------------------------------------------------
2381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2382 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2383 {
2384  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2385  body(re);
2386  vf.join(body._VoxelFunc);
2387  of.join(body._OutsideFunc);
2388 }
2389 
2390 // -----------------------------------------------------------------------------
2391 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2392 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2393 {
2394  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2395  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2396 }
2397 
2398 // -----------------------------------------------------------------------------
2399 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2400 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2401 {
2403  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2404 }
2405 
2406 // -----------------------------------------------------------------------------
2407 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2408 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2409 {
2410  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2411  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2412 }
2413 
2414 //
2415 // Image arguments by reference
2416 //
2417 
2418 // -----------------------------------------------------------------------------
2419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2420 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2421 {
2424  body(re);
2425  vf.join(body._VoxelFunc);
2426  of.join(body._OutsideFunc);
2427 }
2428 
2429 // -----------------------------------------------------------------------------
2430 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2431 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2432 {
2433  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2434  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
2435 }
2436 
2437 // -----------------------------------------------------------------------------
2438 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2439 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2440 {
2442  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
2443 }
2444 
2445 // -----------------------------------------------------------------------------
2446 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2447 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2448 {
2449  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2450  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
2451 }
2452 
2453 // -----------------------------------------------------------------------------
2454 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2455 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2456 {
2457  if (im6.GetTSize()) {
2458  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
2459  } else {
2461  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
2462  body(re);
2463  vf.join(body._VoxelFunc);
2464  of.join(body._OutsideFunc);
2465  }
2466 }
2467 
2468 // -----------------------------------------------------------------------------
2469 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2470 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2471 {
2472  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2473  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
2474 }
2475 
2476 // -----------------------------------------------------------------------------
2477 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2478 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2479 {
2481  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
2482 }
2483 
2484 // -----------------------------------------------------------------------------
2485 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2486 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2487 {
2488  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2489  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
2490 }
2491 
2492 // -----------------------------------------------------------------------------
2493 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2494 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2495 {
2497  body(attr);
2498  vf.join(body._VoxelFunc);
2499  of.join(body._OutsideFunc);
2500 }
2501 
2502 // -----------------------------------------------------------------------------
2503 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2504 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2505 {
2506  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2507  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
2508 }
2509 
2510 // -----------------------------------------------------------------------------
2511 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2512 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2513 {
2515  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
2516 }
2517 
2518 // -----------------------------------------------------------------------------
2519 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2520 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2521 {
2522  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2523  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
2524 }
2525 
2526 // -----------------------------------------------------------------------------
2527 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2528 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2529 {
2531  body(re);
2532  vf.join(body._VoxelFunc);
2533  of.join(body._OutsideFunc);
2534 }
2535 
2536 // -----------------------------------------------------------------------------
2537 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2538 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2539 {
2540  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2541  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
2542 }
2543 
2544 // -----------------------------------------------------------------------------
2545 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2546 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2547 {
2549  body(re);
2550  vf.join(body._VoxelFunc);
2551  of.join(body._OutsideFunc);
2552 }
2553 
2554 // -----------------------------------------------------------------------------
2555 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2556 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2557 {
2558  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2559  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
2560 }
2561 
2562 // -----------------------------------------------------------------------------
2563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2564 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2565 {
2567  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
2568 }
2569 
2570 // -----------------------------------------------------------------------------
2571 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2572 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2573 {
2574  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2575  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
2576 }
2577 
2578 // -----------------------------------------------------------------------------
2579 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2580 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
2581 {
2583  body(re);
2584  vf.join(body._VoxelFunc);
2585  of.join(body._OutsideFunc);
2586 }
2587 
2588 // -----------------------------------------------------------------------------
2589 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2590 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2591 {
2592  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2593  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
2594 }
2595 
2596 // -----------------------------------------------------------------------------
2597 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2598 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2599 {
2601  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
2602 }
2603 
2604 // -----------------------------------------------------------------------------
2605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2606 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2607 {
2608  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2609  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
2610 }
2611 
2612 // -----------------------------------------------------------------------------
2613 // ParallelForEachVoxel
2614 // -----------------------------------------------------------------------------
2615 
2616 //
2617 // Image arguments by pointer
2618 //
2619 
2620 // -----------------------------------------------------------------------------
2621 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2622 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2623 {
2624  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2625  blocked_range<int> re(0, im6->GetNumberOfVoxels());
2626  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2627  else parallel_for (re, body);
2628 }
2629 
2630 // -----------------------------------------------------------------------------
2631 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2632 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2633 {
2634  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2635  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2636 }
2637 
2638 // -----------------------------------------------------------------------------
2639 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2640 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2641 {
2642  if (im6->GetTSize()) {
2643  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2644  } else {
2645  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2646  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
2647  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2648  else parallel_for (re, body);
2649  }
2650 }
2651 
2652 // -----------------------------------------------------------------------------
2653 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2654 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2655 {
2656  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2657  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2658 }
2659 
2660 // -----------------------------------------------------------------------------
2661 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2662 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2663 {
2664  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2665  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2666  if (VoxelFunc::IsReduction()) {
2667  if (attr._dt) {
2668  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2669  } else {
2670  parallel_reduce(re, body);
2671  }
2672  vf.join(body._VoxelFunc);
2673  } else {
2674  if (attr._dt) {
2675  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2676  } else {
2677  parallel_for(re, body);
2678  }
2679  }
2680 }
2681 
2682 // -----------------------------------------------------------------------------
2683 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2684 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2685 {
2686  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2687  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2688 }
2689 
2690 // -----------------------------------------------------------------------------
2691 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2692 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2693 {
2694  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2695  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2696  else parallel_for (re, body);
2697 }
2698 
2699 // -----------------------------------------------------------------------------
2700 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2701 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2702 {
2703  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2704  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2705 }
2706 
2707 // -----------------------------------------------------------------------------
2708 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2709 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2710 {
2711  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2712  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2713  else parallel_for (re, body);
2714 }
2715 
2716 // -----------------------------------------------------------------------------
2717 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2718 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2719 {
2720  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2721  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2722 }
2723 
2724 // -----------------------------------------------------------------------------
2725 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2726 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2727 {
2728  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2729  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2730  else parallel_for (re, body);
2731 }
2732 
2733 // -----------------------------------------------------------------------------
2734 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2735 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2736 {
2737  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2738  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
2739 }
2740 
2741 //
2742 // Image arguments by reference
2743 //
2744 
2745 // -----------------------------------------------------------------------------
2746 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2747 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2748 {
2749  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2751  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2752  else parallel_for (re, body);
2753 }
2754 
2755 // -----------------------------------------------------------------------------
2756 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2757 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2758 {
2759  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2760  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
2761 }
2762 
2763 // -----------------------------------------------------------------------------
2764 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2765 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2766 {
2767  if (im6.GetTSize()) {
2768  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
2769  } else {
2770  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2771  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
2772  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2773  else parallel_for (re, body);
2774  }
2775 }
2776 
2777 // -----------------------------------------------------------------------------
2778 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2779 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2780 {
2781  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2782  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
2783 }
2784 
2785 // -----------------------------------------------------------------------------
2786 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2787 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2788 {
2789  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2790  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2791  if (VoxelFunc::IsReduction()) {
2792  if (attr._dt) {
2793  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2794  } else {
2795  parallel_reduce(re, body);
2796  }
2797  vf.join(body._VoxelFunc);
2798  } else {
2799  if (attr._dt) {
2800  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2801  } else {
2802  parallel_for(re, body);
2803  }
2804  }
2805 }
2806 
2807 // -----------------------------------------------------------------------------
2808 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2809 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2810 {
2811  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2812  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
2813 }
2814 
2815 // -----------------------------------------------------------------------------
2816 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2817 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2818 {
2819  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2820  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2821  else parallel_for (re, body);
2822 }
2823 
2824 // -----------------------------------------------------------------------------
2825 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2826 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2827 {
2828  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2829  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2830 }
2831 
2832 // -----------------------------------------------------------------------------
2833 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2834 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2835 {
2836  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2837  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2838  else parallel_for (re, body);
2839 }
2840 
2841 // -----------------------------------------------------------------------------
2842 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2843 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2844 {
2845  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2846  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2847 }
2848 
2849 // -----------------------------------------------------------------------------
2850 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2851 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
2852 {
2853  SenaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
2854  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2855  else parallel_for (re, body);
2856 }
2857 
2858 // -----------------------------------------------------------------------------
2859 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2860 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
2861 {
2862  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2863  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
2864 }
2865 
2866 // -----------------------------------------------------------------------------
2867 // ParallelForEachVoxelIf
2868 // -----------------------------------------------------------------------------
2869 
2870 //
2871 // Image arguments by pointer
2872 //
2873 
2874 // -----------------------------------------------------------------------------
2875 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2876 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2877 {
2878  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2879  blocked_range<int> re(0, im6->GetNumberOfVoxels());
2880  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2881  parallel_reduce(re, body);
2882  vf.join(body._VoxelFunc);
2883  of.join(body._OutsideFunc);
2884  } else {
2885  parallel_for(re, body);
2886  }
2887 }
2888 
2889 // -----------------------------------------------------------------------------
2890 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2891 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2892 {
2893  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2894  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2895 }
2896 
2897 // -----------------------------------------------------------------------------
2898 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2899 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2900 {
2902  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2903 }
2904 
2905 // -----------------------------------------------------------------------------
2906 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2907 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2908 {
2909  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2910  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2911 }
2912 
2913 // -----------------------------------------------------------------------------
2914 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2915 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2916 {
2917  if (im6->GetTSize()) {
2918  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2919  } else {
2920  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2921  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
2922  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2923  parallel_reduce(re, body);
2924  vf.join(body._VoxelFunc);
2925  of.join(body._OutsideFunc);
2926  } else {
2927  parallel_for(re, body);
2928  }
2929  }
2930 }
2931 
2932 // -----------------------------------------------------------------------------
2933 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2934 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2935 {
2936  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2937  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2938 }
2939 
2940 // -----------------------------------------------------------------------------
2941 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2942 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2943 {
2945  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2946 }
2947 
2948 // -----------------------------------------------------------------------------
2949 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2950 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2951 {
2952  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2953  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
2954 }
2955 
2956 // -----------------------------------------------------------------------------
2957 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2958 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
2959 {
2960  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2961  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2962  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2963  if (attr._dt) {
2964  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2965  } else {
2966  parallel_reduce(re, body);
2967  }
2968  vf.join(body._VoxelFunc);
2969  of.join(body._OutsideFunc);
2970  } else {
2971  if (attr._dt) {
2972  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2973  } else {
2974  parallel_for(re, body);
2975  }
2976  }
2977 }
2978 
2979 // -----------------------------------------------------------------------------
2980 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
2981 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2982 {
2983  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
2984  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2985 }
2986 
2987 // -----------------------------------------------------------------------------
2988 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2989 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
2990 {
2992  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
2993 }
2994 
2995 // -----------------------------------------------------------------------------
2996 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
2997 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
2998 {
2999  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3000  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3001 }
3002 
3003 // -----------------------------------------------------------------------------
3004 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3005 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3006 {
3007  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3008  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3009  parallel_reduce(re, body);
3010  vf.join(body._VoxelFunc);
3011  of.join(body._OutsideFunc);
3012  } else {
3013  parallel_for(re, body);
3014  }
3015 }
3016 
3017 // -----------------------------------------------------------------------------
3018 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3019 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3020 {
3021  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3022  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3023 }
3024 
3025 // -----------------------------------------------------------------------------
3026 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3027 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3028 {
3030  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3031 }
3032 
3033 // -----------------------------------------------------------------------------
3034 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3035 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3036 {
3037  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3038  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3039 }
3040 
3041 // -----------------------------------------------------------------------------
3042 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3043 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3044 {
3045  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3046  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3047  parallel_reduce(re, body);
3048  vf.join(body._VoxelFunc);
3049  of.join(body._OutsideFunc);
3050  } else {
3051  parallel_for(re, body);
3052  }
3053 }
3054 
3055 // -----------------------------------------------------------------------------
3056 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3057 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3058 {
3059  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3060  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3061 }
3062 
3063 // -----------------------------------------------------------------------------
3064 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3065 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3066 {
3068  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3069 }
3070 
3071 // -----------------------------------------------------------------------------
3072 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3073 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3074 {
3075  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3076  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3077 }
3078 
3079 // -----------------------------------------------------------------------------
3080 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3081 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3082 {
3083  SenaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3084  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3085  parallel_reduce(re, body);
3086  vf.join(body._VoxelFunc);
3087  of.join(body._OutsideFunc);
3088  } else {
3089  parallel_for(re, body);
3090  }
3091 }
3092 
3093 // -----------------------------------------------------------------------------
3094 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3095 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3096 {
3097  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3098  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3099 }
3100 
3101 // -----------------------------------------------------------------------------
3102 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3103 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3104 {
3106  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3107 }
3108 
3109 // -----------------------------------------------------------------------------
3110 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3111 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, const GenericImage<T5> *im5, GenericImage<T6> *im6)
3112 {
3113  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3114  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3115 }
3116 
3117 //
3118 // Image arguments by reference
3119 //
3120 
3121 // -----------------------------------------------------------------------------
3122 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3123 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3124 {
3127  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3128  parallel_reduce(re, body);
3129  vf.join(body._VoxelFunc);
3130  of.join(body._OutsideFunc);
3131  } else {
3132  parallel_for(re, body);
3133  }
3134 }
3135 
3136 // -----------------------------------------------------------------------------
3137 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3138 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3139 {
3140  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3141  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
3142 }
3143 
3144 // -----------------------------------------------------------------------------
3145 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3146 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3147 {
3149  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
3150 }
3151 
3152 // -----------------------------------------------------------------------------
3153 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3154 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3155 {
3156  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3157  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
3158 }
3159 
3160 // -----------------------------------------------------------------------------
3161 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3162 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3163 {
3164  if (im6.GetTSize()) {
3165  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
3166  } else {
3168  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
3169  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3170  parallel_reduce(re, body);
3171  vf.join(body._VoxelFunc);
3172  of.join(body._OutsideFunc);
3173  } else {
3174  parallel_for(re, body);
3175  }
3176  }
3177 }
3178 
3179 // -----------------------------------------------------------------------------
3180 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3181 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3182 {
3183  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3184  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
3185 }
3186 
3187 // -----------------------------------------------------------------------------
3188 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3189 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3190 {
3192  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
3193 }
3194 
3195 // -----------------------------------------------------------------------------
3196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3197 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3198 {
3199  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3200  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
3201 }
3202 
3203 // -----------------------------------------------------------------------------
3204 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3205 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3206 {
3208  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
3209  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3210  if (attr._dt) {
3211  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
3212  } else {
3213  parallel_reduce(re, body);
3214  }
3215  vf.join(body._VoxelFunc);
3216  of.join(body._OutsideFunc);
3217  } else {
3218  if (attr._dt) {
3219  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
3220  } else {
3221  parallel_for(re, body);
3222  }
3223  }
3224 }
3225 
3226 // -----------------------------------------------------------------------------
3227 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3228 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3229 {
3230  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3231  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
3232 }
3233 
3234 // -----------------------------------------------------------------------------
3235 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3236 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3237 {
3239  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
3240 }
3241 
3242 // -----------------------------------------------------------------------------
3243 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3244 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3245 {
3246  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3247  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
3248 }
3249 
3250 // -----------------------------------------------------------------------------
3251 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3252 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3253 {
3255  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3256  parallel_reduce(re, body);
3257  vf.join(body._VoxelFunc);
3258  of.join(body._OutsideFunc);
3259  } else {
3260  parallel_for(re, body);
3261  }
3262 }
3263 
3264 // -----------------------------------------------------------------------------
3265 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3266 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3267 {
3268  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3269  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3270 }
3271 
3272 // -----------------------------------------------------------------------------
3273 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3274 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3275 {
3277  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3278 }
3279 
3280 // -----------------------------------------------------------------------------
3281 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3282 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3283 {
3284  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3285  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
3286 }
3287 
3288 // -----------------------------------------------------------------------------
3289 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3290 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3291 {
3293  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3294  parallel_reduce(re, body);
3295  vf.join(body._VoxelFunc);
3296  of.join(body._OutsideFunc);
3297  } else {
3298  parallel_for(re, body);
3299  }
3300 }
3301 
3302 // -----------------------------------------------------------------------------
3303 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3304 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3305 {
3306  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3307  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3308 }
3309 
3310 // -----------------------------------------------------------------------------
3311 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3312 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3313 {
3315  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3316 }
3317 
3318 // -----------------------------------------------------------------------------
3319 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3320 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3321 {
3322  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3323  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
3324 }
3325 
3326 // -----------------------------------------------------------------------------
3327 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3328 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
3329 {
3331  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3332  parallel_reduce(re, body);
3333  vf.join(body._VoxelFunc);
3334  of.join(body._OutsideFunc);
3335  } else {
3336  parallel_for(re, body);
3337  }
3338 }
3339 
3340 // -----------------------------------------------------------------------------
3341 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3342 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3343 {
3344  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3345  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3346 }
3347 
3348 // -----------------------------------------------------------------------------
3349 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3350 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3351 {
3353  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
3354 }
3355 
3356 // -----------------------------------------------------------------------------
3357 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3358 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, const GenericImage<T5> &im5, GenericImage<T6> &im6)
3359 {
3360  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3361  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
3362 }
3363 
3364 // =============================================================================
3365 // 4 const, 2 non-const images
3366 // =============================================================================
3367 
3368 // -----------------------------------------------------------------------------
3369 /**
3370  * ForEachVoxel body for voxel function of 4 const, 2 non-const images
3371  */
3372 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3374 {
3375  const GenericImage<T1> &im1;
3376  const GenericImage<T2> &im2;
3377  const GenericImage<T3> &im3;
3378  const GenericImage<T4> &im4;
3379  GenericImage<T5> &im5;
3380  GenericImage<T6> &im6;
3381 
3382  /// Constructor
3384  const GenericImage<T2> &im2,
3385  const GenericImage<T3> &im3,
3386  const GenericImage<T4> &im4,
3387  GenericImage<T5> &im5,
3388  GenericImage<T6> &im6,
3389  VoxelFunc &vf)
3390  :
3391  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
3392  {}
3393 
3394  /// Copy constructor
3396  :
3397  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
3398  {}
3399 
3400  /// Split constructor
3402  :
3403  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
3404  {}
3405 
3406  /// Process entire image
3407  void operator ()(const ImageAttributes &attr) const
3408  {
3409  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3410  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3411  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3412  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3413  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3414  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3415 
3416  const int T = (attr._dt ? attr._t : 1);
3417 
3418  for (int l = 0; l < T; ++l)
3419  for (int k = 0; k < attr._z; ++k)
3420  for (int j = 0; j < attr._y; ++j)
3421  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
3422  // const_cast such that voxel functions need only implement
3423  // non-const operator() which is required for parallel_reduce
3424  const_cast<SenaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
3425  }
3426  }
3427 
3428  /// Process image region using linear index
3429  void operator ()(const blocked_range<int> &re) const
3430  {
3431  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3432  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3433  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3434  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3435  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3436  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3437 
3438  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3439  // const_cast such that voxel functions need only implement
3440  // non-const operator() which is required for parallel_reduce
3441  const_cast<SenaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
3442  }
3443  }
3444 
3445  /// Process 2D image region
3446  void operator ()(const blocked_range2d<int> &re) const
3447  {
3448  const int bi = re.cols().begin();
3449  const int bj = re.rows().begin();
3450  const int ei = re.cols().end();
3451  const int ej = re.rows().end();
3452 
3453  const int s1 = im6.GetX() - (ei - bi);
3454 
3455  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3456  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3457  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3458  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3459  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3460  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3461 
3462  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
3463  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3464  // const_cast such that voxel functions need only implement
3465  // non-const operator() which is required for parallel_reduce
3466  const_cast<SenaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
3467  }
3468  }
3469 
3470  /// Process 3D image region
3471  void operator ()(const blocked_range3d<int> &re) const
3472  {
3473  const int bi = re.cols ().begin();
3474  const int bj = re.rows ().begin();
3475  const int bk = re.pages().begin();
3476  const int ei = re.cols ().end();
3477  const int ej = re.rows ().end();
3478  const int ek = re.pages().end();
3479 
3480  const int s1 = im6.GetX() - (ei - bi);
3481  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
3482 
3483  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3484  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3485  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3486  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3487  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3488  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3489 
3490  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
3491  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
3492  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3493  // const_cast such that voxel functions need only implement
3494  // non-const operator() which is required for parallel_reduce
3495  const_cast<SenaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
3496  }
3497  }
3498 };
3499 
3500 // -----------------------------------------------------------------------------
3501 /**
3502  * ForEachVoxel body for inside and outside unary voxel function of 4 const, 2 non-const images
3503  */
3504 template <class T1, class T2, class T3, class T4, class T5, class T6,
3505  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
3506  class Domain = ForEachVoxelDomain::Foreground>
3507 struct SenaryForEachVoxelIfBody_4Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
3508 {
3509  const GenericImage<T1> &im1;
3510  const GenericImage<T2> &im2;
3511  const GenericImage<T3> &im3;
3512  const GenericImage<T4> &im4;
3513  GenericImage<T5> &im5;
3514  GenericImage<T6> &im6;
3515 
3516  /// Constructor
3518  const GenericImage<T2> &im2,
3519  const GenericImage<T3> &im3,
3520  const GenericImage<T4> &im4,
3521  GenericImage<T5> &im5,
3522  GenericImage<T6> &im6,
3523  VoxelFunc &vf, OutsideFunc &of)
3524  :
3525  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
3526  {}
3527 
3528  /// Copy constructor
3530  :
3531  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
3532  {}
3533 
3534  /// Split constructor
3536  :
3537  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
3538  {}
3539 
3540  /// Process entire image
3541  void operator ()(const ImageAttributes &attr) const
3542  {
3543  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3544  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3545  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3546  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3547  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3548  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3549 
3550  const int T = (attr._dt ? attr._t : 1);
3551 
3552  for (int l = 0; l < T; ++l)
3553  for (int k = 0; k < attr._z; ++k)
3554  for (int j = 0; j < attr._y; ++j)
3555  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
3556  if (Domain::IsInside(im6, i, j, k, l, p6)) {
3557  // const_cast such that voxel functions need only implement
3558  // non-const operator() which is required for parallel_reduce
3559  const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
3560  } else const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
3561  }
3562  }
3563 
3564  /// Process image region using linear index
3565  void operator ()(const blocked_range<int> &re) const
3566  {
3567  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3568  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3569  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3570  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3571  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3572  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3573 
3574  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3575  if (Domain::IsInside(im6, idx, p6)) {
3576  // const_cast such that voxel functions need only implement
3577  // non-const operator() which is required for parallel_reduce
3578  const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
3579  } else const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
3580  }
3581  }
3582 
3583  /// Process 2D image region
3584  void operator ()(const blocked_range2d<int> &re) const
3585  {
3586  const int bi = re.cols().begin();
3587  const int bj = re.rows().begin();
3588  const int ei = re.cols().end();
3589  const int ej = re.rows().end();
3590 
3591  const int s1 = im6.GetX() - (ei - bi);
3592 
3593  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3594  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3595  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3596  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3597  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3598  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3599 
3600  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
3601  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3602  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
3603  // const_cast such that voxel functions need only implement
3604  // non-const operator() which is required for parallel_reduce
3605  const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
3606  } else const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
3607  }
3608  }
3609 
3610  /// Process 3D image region
3611  void operator ()(const blocked_range3d<int> &re) const
3612  {
3613  const int bi = re.cols ().begin();
3614  const int bj = re.rows ().begin();
3615  const int bk = re.pages().begin();
3616  const int ei = re.cols ().end();
3617  const int ej = re.rows ().end();
3618  const int ek = re.pages().end();
3619 
3620  const int s1 = im6.GetX() - (ei - bi);
3621  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
3622 
3623  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3624  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3625  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3626  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3627  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3628  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3629 
3630  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
3631  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
3632  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
3633  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
3634  // const_cast such that voxel functions need only implement
3635  // non-const operator() which is required for parallel_reduce
3636  const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
3637  } else const_cast<SenaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
3638  }
3639  }
3640 };
3641 
3642 // -----------------------------------------------------------------------------
3643 // ForEachVoxel
3644 // -----------------------------------------------------------------------------
3645 
3646 //
3647 // Image arguments by pointer
3648 //
3649 
3650 // -----------------------------------------------------------------------------
3651 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3652 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3653 {
3654  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3655  blocked_range<int> re(0, im6->GetNumberOfVoxels());
3656  body(re);
3657  vf.join(body._VoxelFunc);
3658 }
3659 
3660 // -----------------------------------------------------------------------------
3661 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3662 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3663 {
3664  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3665  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3666 }
3667 
3668 // -----------------------------------------------------------------------------
3669 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3670 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3671 {
3672  if (im6->GetTSize()) {
3673  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3674  } else {
3675  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3676  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
3677  body(re);
3678  vf.join(body._VoxelFunc);
3679  }
3680 }
3681 
3682 // -----------------------------------------------------------------------------
3683 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3684 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3685 {
3686  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3687  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3688 }
3689 
3690 // -----------------------------------------------------------------------------
3691 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3692 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3693 {
3694  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3695  body(attr);
3696  vf.join(body._VoxelFunc);
3697 }
3698 
3699 // -----------------------------------------------------------------------------
3700 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3701 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3702 {
3703  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3704  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3705 }
3706 
3707 // -----------------------------------------------------------------------------
3708 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3709 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3710 {
3711  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3712  body(re);
3713  vf.join(body._VoxelFunc);
3714 }
3715 
3716 // -----------------------------------------------------------------------------
3717 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3718 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3719 {
3720  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3721  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3722 }
3723 
3724 // -----------------------------------------------------------------------------
3725 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3726 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3727 {
3728  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3729  body(re);
3730  vf.join(body._VoxelFunc);
3731 }
3732 
3733 // -----------------------------------------------------------------------------
3734 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3735 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3736 {
3737  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3738  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3739 }
3740 
3741 // -----------------------------------------------------------------------------
3742 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3743 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3744 {
3745  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3746  body(re);
3747  vf.join(body._VoxelFunc);
3748 }
3749 
3750 // -----------------------------------------------------------------------------
3751 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3752 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3753 {
3754  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3755  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3756 }
3757 
3758 //
3759 // Image arguments by reference
3760 //
3761 
3762 // -----------------------------------------------------------------------------
3763 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3764 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3765 {
3766  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3768  body(re);
3769  vf.join(body._VoxelFunc);
3770 }
3771 
3772 // -----------------------------------------------------------------------------
3773 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3774 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3775 {
3776  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3777  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
3778 }
3779 
3780 // -----------------------------------------------------------------------------
3781 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3782 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3783 {
3784  if (im6.GetTSize()) {
3785  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
3786  } else {
3787  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3788  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
3789  body(re);
3790  vf.join(body._VoxelFunc);
3791  }
3792 }
3793 
3794 // -----------------------------------------------------------------------------
3795 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3796 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3797 {
3798  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3799  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
3800 }
3801 
3802 // -----------------------------------------------------------------------------
3803 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3804 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3805 {
3806  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3807  body(attr);
3808  vf.join(body._VoxelFunc);
3809 }
3810 
3811 // -----------------------------------------------------------------------------
3812 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3813 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3814 {
3815  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3816  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
3817 }
3818 
3819 // -----------------------------------------------------------------------------
3820 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3821 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3822 {
3823  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3824  body(re);
3825  vf.join(body._VoxelFunc);
3826 }
3827 
3828 // -----------------------------------------------------------------------------
3829 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3830 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3831 {
3832  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3833  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
3834 }
3835 
3836 // -----------------------------------------------------------------------------
3837 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3838 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3839 {
3840  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3841  body(re);
3842  vf.join(body._VoxelFunc);
3843 }
3844 
3845 // -----------------------------------------------------------------------------
3846 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3847 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3848 {
3849  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3850  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
3851 }
3852 
3853 // -----------------------------------------------------------------------------
3854 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3855 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
3856 {
3857  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
3858  body(re);
3859  vf.join(body._VoxelFunc);
3860 }
3861 
3862 // -----------------------------------------------------------------------------
3863 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3864 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
3865 {
3866  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3867  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
3868 }
3869 
3870 // -----------------------------------------------------------------------------
3871 // ForEachVoxelIf
3872 // -----------------------------------------------------------------------------
3873 
3874 //
3875 // Image arguments by pointer
3876 //
3877 
3878 // -----------------------------------------------------------------------------
3879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3880 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3881 {
3882  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3883  blocked_range<int> re(0, im6->GetNumberOfVoxels());
3884  body(re);
3885  vf.join(body._VoxelFunc);
3886  of.join(body._OutsideFunc);
3887 }
3888 
3889 // -----------------------------------------------------------------------------
3890 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3891 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3892 {
3893  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3894  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3895 }
3896 
3897 // -----------------------------------------------------------------------------
3898 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3899 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3900 {
3902  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3903 }
3904 
3905 // -----------------------------------------------------------------------------
3906 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3907 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3908 {
3909  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3910  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3911 }
3912 
3913 // -----------------------------------------------------------------------------
3914 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3915 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3916 {
3917  if (im6->GetTSize()) {
3918  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3919  } else {
3920  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3921  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
3922  body(re);
3923  vf.join(body._VoxelFunc);
3924  of.join(body._OutsideFunc);
3925  }
3926 }
3927 
3928 // -----------------------------------------------------------------------------
3929 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3930 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3931 {
3932  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3933  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3934 }
3935 
3936 // -----------------------------------------------------------------------------
3937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3938 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3939 {
3941  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3942 }
3943 
3944 // -----------------------------------------------------------------------------
3945 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3946 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3947 {
3948  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3949  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
3950 }
3951 
3952 // -----------------------------------------------------------------------------
3953 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3954 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3955 {
3956  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3957  body(attr);
3958  vf.join(body._VoxelFunc);
3959  of.join(body._OutsideFunc);
3960 }
3961 
3962 // -----------------------------------------------------------------------------
3963 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3964 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3965 {
3966  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3967  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3968 }
3969 
3970 // -----------------------------------------------------------------------------
3971 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3972 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
3973 {
3975  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3976 }
3977 
3978 // -----------------------------------------------------------------------------
3979 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
3980 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3981 {
3982  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
3983  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
3984 }
3985 
3986 // -----------------------------------------------------------------------------
3987 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3988 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
3989 {
3990  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
3991  body(re);
3992  vf.join(body._VoxelFunc);
3993  of.join(body._OutsideFunc);
3994 }
3995 
3996 // -----------------------------------------------------------------------------
3997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
3998 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
3999 {
4000  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4001  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4002 }
4003 
4004 // -----------------------------------------------------------------------------
4005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4006 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4007 {
4008  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4009  body(re);
4010  vf.join(body._VoxelFunc);
4011  of.join(body._OutsideFunc);
4012 }
4013 
4014 // -----------------------------------------------------------------------------
4015 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4016 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4017 {
4018  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4019  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4020 }
4021 
4022 // -----------------------------------------------------------------------------
4023 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4024 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4025 {
4027  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4028 }
4029 
4030 // -----------------------------------------------------------------------------
4031 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4032 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4033 {
4034  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4035  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4036 }
4037 
4038 // -----------------------------------------------------------------------------
4039 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4040 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4041 {
4042  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4043  body(re);
4044  vf.join(body._VoxelFunc);
4045  of.join(body._OutsideFunc);
4046 }
4047 
4048 // -----------------------------------------------------------------------------
4049 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4050 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4051 {
4052  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4053  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4054 }
4055 
4056 // -----------------------------------------------------------------------------
4057 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4058 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4059 {
4061  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4062 }
4063 
4064 // -----------------------------------------------------------------------------
4065 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4066 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4067 {
4068  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4069  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4070 }
4071 
4072 //
4073 // Image arguments by reference
4074 //
4075 
4076 // -----------------------------------------------------------------------------
4077 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4078 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4079 {
4082  body(re);
4083  vf.join(body._VoxelFunc);
4084  of.join(body._OutsideFunc);
4085 }
4086 
4087 // -----------------------------------------------------------------------------
4088 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4089 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4090 {
4091  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4092  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4093 }
4094 
4095 // -----------------------------------------------------------------------------
4096 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4097 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4098 {
4100  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4101 }
4102 
4103 // -----------------------------------------------------------------------------
4104 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4105 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4106 {
4107  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4108  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
4109 }
4110 
4111 // -----------------------------------------------------------------------------
4112 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4113 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4114 {
4115  if (im6.GetTSize()) {
4116  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4117  } else {
4119  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
4120  body(re);
4121  vf.join(body._VoxelFunc);
4122  of.join(body._OutsideFunc);
4123  }
4124 }
4125 
4126 // -----------------------------------------------------------------------------
4127 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4128 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4129 {
4130  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4131  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4132 }
4133 
4134 // -----------------------------------------------------------------------------
4135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4136 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4137 {
4139  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4140 }
4141 
4142 // -----------------------------------------------------------------------------
4143 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4144 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4145 {
4146  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4147  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
4148 }
4149 
4150 // -----------------------------------------------------------------------------
4151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4152 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4153 {
4155  body(attr);
4156  vf.join(body._VoxelFunc);
4157  of.join(body._OutsideFunc);
4158 }
4159 
4160 // -----------------------------------------------------------------------------
4161 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4162 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4163 {
4164  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4165  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
4166 }
4167 
4168 // -----------------------------------------------------------------------------
4169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4170 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4171 {
4173  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
4174 }
4175 
4176 // -----------------------------------------------------------------------------
4177 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4178 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4179 {
4180  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4181  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
4182 }
4183 
4184 // -----------------------------------------------------------------------------
4185 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4186 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4187 {
4189  body(re);
4190  vf.join(body._VoxelFunc);
4191  of.join(body._OutsideFunc);
4192 }
4193 
4194 // -----------------------------------------------------------------------------
4195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4196 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4197 {
4198  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4199  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4200 }
4201 
4202 // -----------------------------------------------------------------------------
4203 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4204 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4205 {
4207  body(re);
4208  vf.join(body._VoxelFunc);
4209  of.join(body._OutsideFunc);
4210 }
4211 
4212 // -----------------------------------------------------------------------------
4213 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4214 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4215 {
4216  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4217  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4218 }
4219 
4220 // -----------------------------------------------------------------------------
4221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4222 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4223 {
4225  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4226 }
4227 
4228 // -----------------------------------------------------------------------------
4229 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4230 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4231 {
4232  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4233  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
4234 }
4235 
4236 // -----------------------------------------------------------------------------
4237 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4238 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4239 {
4241  body(re);
4242  vf.join(body._VoxelFunc);
4243  of.join(body._OutsideFunc);
4244 }
4245 
4246 // -----------------------------------------------------------------------------
4247 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4248 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4249 {
4250  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4251  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4252 }
4253 
4254 // -----------------------------------------------------------------------------
4255 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4256 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4257 {
4259  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4260 }
4261 
4262 // -----------------------------------------------------------------------------
4263 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4264 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4265 {
4266  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4267  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
4268 }
4269 
4270 // -----------------------------------------------------------------------------
4271 // ParallelForEachVoxel
4272 // -----------------------------------------------------------------------------
4273 
4274 //
4275 // Image arguments by pointer
4276 //
4277 
4278 // -----------------------------------------------------------------------------
4279 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4280 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4281 {
4282  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4283  blocked_range<int> re(0, im6->GetNumberOfVoxels());
4284  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4285  else parallel_for (re, body);
4286 }
4287 
4288 // -----------------------------------------------------------------------------
4289 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4290 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4291 {
4292  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4293  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4294 }
4295 
4296 // -----------------------------------------------------------------------------
4297 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4298 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4299 {
4300  if (im6->GetTSize()) {
4301  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4302  } else {
4303  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4304  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
4305  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4306  else parallel_for (re, body);
4307  }
4308 }
4309 
4310 // -----------------------------------------------------------------------------
4311 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4312 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4313 {
4314  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4315  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4316 }
4317 
4318 // -----------------------------------------------------------------------------
4319 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4320 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4321 {
4322  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4323  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4324  if (VoxelFunc::IsReduction()) {
4325  if (attr._dt) {
4326  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4327  } else {
4328  parallel_reduce(re, body);
4329  }
4330  vf.join(body._VoxelFunc);
4331  } else {
4332  if (attr._dt) {
4333  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4334  } else {
4335  parallel_for(re, body);
4336  }
4337  }
4338 }
4339 
4340 // -----------------------------------------------------------------------------
4341 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4342 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4343 {
4344  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4345  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4346 }
4347 
4348 // -----------------------------------------------------------------------------
4349 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4350 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4351 {
4352  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4353  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4354  else parallel_for (re, body);
4355 }
4356 
4357 // -----------------------------------------------------------------------------
4358 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4359 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4360 {
4361  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4362  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4363 }
4364 
4365 // -----------------------------------------------------------------------------
4366 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4367 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4368 {
4369  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4370  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4371  else parallel_for (re, body);
4372 }
4373 
4374 // -----------------------------------------------------------------------------
4375 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4376 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4377 {
4378  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4379  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4380 }
4381 
4382 // -----------------------------------------------------------------------------
4383 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4384 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4385 {
4386  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4387  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4388  else parallel_for (re, body);
4389 }
4390 
4391 // -----------------------------------------------------------------------------
4392 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4393 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4394 {
4395  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4396  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4397 }
4398 
4399 //
4400 // Image arguments by reference
4401 //
4402 
4403 // -----------------------------------------------------------------------------
4404 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4405 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4406 {
4407  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4409  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4410  else parallel_for (re, body);
4411 }
4412 
4413 // -----------------------------------------------------------------------------
4414 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4415 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4416 {
4417  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4418  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
4419 }
4420 
4421 // -----------------------------------------------------------------------------
4422 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4423 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4424 {
4425  if (im6.GetTSize()) {
4426  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
4427  } else {
4428  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4429  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
4430  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4431  else parallel_for (re, body);
4432  }
4433 }
4434 
4435 // -----------------------------------------------------------------------------
4436 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4437 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4438 {
4439  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4440  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
4441 }
4442 
4443 // -----------------------------------------------------------------------------
4444 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4445 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4446 {
4447  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4448  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4449  if (VoxelFunc::IsReduction()) {
4450  if (attr._dt) {
4451  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4452  } else {
4453  parallel_reduce(re, body);
4454  }
4455  vf.join(body._VoxelFunc);
4456  } else {
4457  if (attr._dt) {
4458  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4459  } else {
4460  parallel_for(re, body);
4461  }
4462  }
4463 }
4464 
4465 // -----------------------------------------------------------------------------
4466 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4467 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4468 {
4469  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4470  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
4471 }
4472 
4473 // -----------------------------------------------------------------------------
4474 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4475 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4476 {
4477  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4478  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4479  else parallel_for (re, body);
4480 }
4481 
4482 // -----------------------------------------------------------------------------
4483 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4484 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4485 {
4486  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4487  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
4488 }
4489 
4490 // -----------------------------------------------------------------------------
4491 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4492 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4493 {
4494  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4495  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4496  else parallel_for (re, body);
4497 }
4498 
4499 // -----------------------------------------------------------------------------
4500 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4501 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4502 {
4503  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4504  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
4505 }
4506 
4507 // -----------------------------------------------------------------------------
4508 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4509 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4510 {
4511  SenaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
4512  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4513  else parallel_for (re, body);
4514 }
4515 
4516 // -----------------------------------------------------------------------------
4517 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4518 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4519 {
4520  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4521  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
4522 }
4523 
4524 // -----------------------------------------------------------------------------
4525 // ParallelForEachVoxelIf
4526 // -----------------------------------------------------------------------------
4527 
4528 //
4529 // Image arguments by pointer
4530 //
4531 
4532 // -----------------------------------------------------------------------------
4533 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4534 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4535 {
4536  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4537  blocked_range<int> re(0, im6->GetNumberOfVoxels());
4538  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4539  parallel_reduce(re, body);
4540  vf.join(body._VoxelFunc);
4541  of.join(body._OutsideFunc);
4542  } else {
4543  parallel_for(re, body);
4544  }
4545 }
4546 
4547 // -----------------------------------------------------------------------------
4548 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4549 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4550 {
4551  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4552  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4553 }
4554 
4555 // -----------------------------------------------------------------------------
4556 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4557 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4558 {
4560  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4561 }
4562 
4563 // -----------------------------------------------------------------------------
4564 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4565 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4566 {
4567  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4568  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4569 }
4570 
4571 // -----------------------------------------------------------------------------
4572 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4573 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4574 {
4575  if (im6->GetTSize()) {
4576  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4577  } else {
4578  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4579  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
4580  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4581  parallel_reduce(re, body);
4582  vf.join(body._VoxelFunc);
4583  of.join(body._OutsideFunc);
4584  } else {
4585  parallel_for(re, body);
4586  }
4587  }
4588 }
4589 
4590 // -----------------------------------------------------------------------------
4591 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4592 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4593 {
4594  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4595  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4596 }
4597 
4598 // -----------------------------------------------------------------------------
4599 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4600 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4601 {
4603  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4604 }
4605 
4606 // -----------------------------------------------------------------------------
4607 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4608 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4609 {
4610  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4611  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
4612 }
4613 
4614 // -----------------------------------------------------------------------------
4615 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4616 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4617 {
4618  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4619  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4620  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4621  if (attr._dt) {
4622  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4623  } else {
4624  parallel_reduce(re, body);
4625  }
4626  vf.join(body._VoxelFunc);
4627  of.join(body._OutsideFunc);
4628  } else {
4629  if (attr._dt) {
4630  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4631  } else {
4632  parallel_for(re, body);
4633  }
4634  }
4635 }
4636 
4637 // -----------------------------------------------------------------------------
4638 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4639 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4640 {
4641  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4642  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4643 }
4644 
4645 // -----------------------------------------------------------------------------
4646 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4647 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4648 {
4650  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4651 }
4652 
4653 // -----------------------------------------------------------------------------
4654 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4655 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4656 {
4657  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4658  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4659 }
4660 
4661 // -----------------------------------------------------------------------------
4662 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4663 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4664 {
4665  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4666  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4667  parallel_reduce(re, body);
4668  vf.join(body._VoxelFunc);
4669  of.join(body._OutsideFunc);
4670  } else {
4671  parallel_for(re, body);
4672  }
4673 }
4674 
4675 // -----------------------------------------------------------------------------
4676 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4677 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4678 {
4679  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4680  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4681 }
4682 
4683 // -----------------------------------------------------------------------------
4684 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4685 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4686 {
4688  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4689 }
4690 
4691 // -----------------------------------------------------------------------------
4692 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4693 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4694 {
4695  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4696  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4697 }
4698 
4699 // -----------------------------------------------------------------------------
4700 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4701 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4702 {
4703  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4704  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4705  parallel_reduce(re, body);
4706  vf.join(body._VoxelFunc);
4707  of.join(body._OutsideFunc);
4708  } else {
4709  parallel_for(re, body);
4710  }
4711 }
4712 
4713 // -----------------------------------------------------------------------------
4714 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4715 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4716 {
4717  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4718  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4719 }
4720 
4721 // -----------------------------------------------------------------------------
4722 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4723 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4724 {
4726  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4727 }
4728 
4729 // -----------------------------------------------------------------------------
4730 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4731 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4732 {
4733  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4734  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4735 }
4736 
4737 // -----------------------------------------------------------------------------
4738 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4739 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
4740 {
4741  SenaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4742  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4743  parallel_reduce(re, body);
4744  vf.join(body._VoxelFunc);
4745  of.join(body._OutsideFunc);
4746  } else {
4747  parallel_for(re, body);
4748  }
4749 }
4750 
4751 // -----------------------------------------------------------------------------
4752 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4753 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4754 {
4755  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4756  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4757 }
4758 
4759 // -----------------------------------------------------------------------------
4760 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4761 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
4762 {
4764  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
4765 }
4766 
4767 // -----------------------------------------------------------------------------
4768 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4769 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
4770 {
4771  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4772  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
4773 }
4774 
4775 //
4776 // Image arguments by reference
4777 //
4778 
4779 // -----------------------------------------------------------------------------
4780 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4781 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4782 {
4785  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4786  parallel_reduce(re, body);
4787  vf.join(body._VoxelFunc);
4788  of.join(body._OutsideFunc);
4789  } else {
4790  parallel_for(re, body);
4791  }
4792 }
4793 
4794 // -----------------------------------------------------------------------------
4795 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4796 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4797 {
4798  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4799  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4800 }
4801 
4802 // -----------------------------------------------------------------------------
4803 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4804 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4805 {
4807  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4808 }
4809 
4810 // -----------------------------------------------------------------------------
4811 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4812 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4813 {
4814  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4815  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
4816 }
4817 
4818 // -----------------------------------------------------------------------------
4819 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4820 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4821 {
4822  if (im6.GetTSize()) {
4823  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4824  } else {
4826  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
4827  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4828  parallel_reduce(re, body);
4829  vf.join(body._VoxelFunc);
4830  of.join(body._OutsideFunc);
4831  } else {
4832  parallel_for(re, body);
4833  }
4834  }
4835 }
4836 
4837 // -----------------------------------------------------------------------------
4838 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4839 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4840 {
4841  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4842  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4843 }
4844 
4845 // -----------------------------------------------------------------------------
4846 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4847 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4848 {
4850  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
4851 }
4852 
4853 // -----------------------------------------------------------------------------
4854 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4855 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4856 {
4857  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4858  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
4859 }
4860 
4861 // -----------------------------------------------------------------------------
4862 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4863 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4864 {
4866  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4867  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4868  if (attr._dt) {
4869  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4870  } else {
4871  parallel_reduce(re, body);
4872  }
4873  vf.join(body._VoxelFunc);
4874  of.join(body._OutsideFunc);
4875  } else {
4876  if (attr._dt) {
4877  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4878  } else {
4879  parallel_for(re, body);
4880  }
4881  }
4882 }
4883 
4884 // -----------------------------------------------------------------------------
4885 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4886 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4887 {
4888  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4889  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
4890 }
4891 
4892 // -----------------------------------------------------------------------------
4893 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4894 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4895 {
4897  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
4898 }
4899 
4900 // -----------------------------------------------------------------------------
4901 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4902 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4903 {
4904  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4905  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
4906 }
4907 
4908 // -----------------------------------------------------------------------------
4909 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4910 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4911 {
4913  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4914  parallel_reduce(re, body);
4915  vf.join(body._VoxelFunc);
4916  of.join(body._OutsideFunc);
4917  } else {
4918  parallel_for(re, body);
4919  }
4920 }
4921 
4922 // -----------------------------------------------------------------------------
4923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4924 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4925 {
4926  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4927  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4928 }
4929 
4930 // -----------------------------------------------------------------------------
4931 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4932 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4933 {
4935  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4936 }
4937 
4938 // -----------------------------------------------------------------------------
4939 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4940 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4941 {
4942  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4943  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
4944 }
4945 
4946 // -----------------------------------------------------------------------------
4947 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4948 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4949 {
4951  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4952  parallel_reduce(re, body);
4953  vf.join(body._VoxelFunc);
4954  of.join(body._OutsideFunc);
4955  } else {
4956  parallel_for(re, body);
4957  }
4958 }
4959 
4960 // -----------------------------------------------------------------------------
4961 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4962 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4963 {
4964  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4965  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4966 }
4967 
4968 // -----------------------------------------------------------------------------
4969 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4970 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
4971 {
4973  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
4974 }
4975 
4976 // -----------------------------------------------------------------------------
4977 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
4978 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
4979 {
4980  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
4981  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
4982 }
4983 
4984 // -----------------------------------------------------------------------------
4985 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
4986 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
4987 {
4989  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4990  parallel_reduce(re, body);
4991  vf.join(body._VoxelFunc);
4992  of.join(body._OutsideFunc);
4993  } else {
4994  parallel_for(re, body);
4995  }
4996 }
4997 
4998 // -----------------------------------------------------------------------------
4999 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5000 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5001 {
5002  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5003  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5004 }
5005 
5006 // -----------------------------------------------------------------------------
5007 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5008 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5009 {
5011  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5012 }
5013 
5014 // -----------------------------------------------------------------------------
5015 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5016 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5017 {
5018  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5019  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
5020 }
5021 
5022 // =============================================================================
5023 // 3 const, 3 non-const images
5024 // =============================================================================
5025 
5026 // -----------------------------------------------------------------------------
5027 /**
5028  * ForEachVoxel body for voxel function of 3 const, 3 non-const images
5029  */
5030 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5032 {
5033  const GenericImage<T1> &im1;
5034  const GenericImage<T2> &im2;
5035  const GenericImage<T3> &im3;
5036  GenericImage<T4> &im4;
5037  GenericImage<T5> &im5;
5038  GenericImage<T6> &im6;
5039 
5040  /// Constructor
5042  const GenericImage<T2> &im2,
5043  const GenericImage<T3> &im3,
5044  GenericImage<T4> &im4,
5045  GenericImage<T5> &im5,
5046  GenericImage<T6> &im6,
5047  VoxelFunc &vf)
5048  :
5049  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
5050  {}
5051 
5052  /// Copy constructor
5054  :
5055  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
5056  {}
5057 
5058  /// Split constructor
5060  :
5061  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
5062  {}
5063 
5064  /// Process entire image
5065  void operator ()(const ImageAttributes &attr) const
5066  {
5067  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5068  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5069  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5070  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5071  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5072  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5073 
5074  const int T = (attr._dt ? attr._t : 1);
5075 
5076  for (int l = 0; l < T; ++l)
5077  for (int k = 0; k < attr._z; ++k)
5078  for (int j = 0; j < attr._y; ++j)
5079  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
5080  // const_cast such that voxel functions need only implement
5081  // non-const operator() which is required for parallel_reduce
5082  const_cast<SenaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
5083  }
5084  }
5085 
5086  /// Process image region using linear index
5087  void operator ()(const blocked_range<int> &re) const
5088  {
5089  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5090  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5091  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5092  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5093  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5094  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5095 
5096  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5097  // const_cast such that voxel functions need only implement
5098  // non-const operator() which is required for parallel_reduce
5099  const_cast<SenaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
5100  }
5101  }
5102 
5103  /// Process 2D image region
5104  void operator ()(const blocked_range2d<int> &re) const
5105  {
5106  const int bi = re.cols().begin();
5107  const int bj = re.rows().begin();
5108  const int ei = re.cols().end();
5109  const int ej = re.rows().end();
5110 
5111  const int s1 = im6.GetX() - (ei - bi);
5112 
5113  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5114  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5115  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5116  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5117  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5118  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5119 
5120  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
5121  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5122  // const_cast such that voxel functions need only implement
5123  // non-const operator() which is required for parallel_reduce
5124  const_cast<SenaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
5125  }
5126  }
5127 
5128  /// Process 3D image region
5129  void operator ()(const blocked_range3d<int> &re) const
5130  {
5131  const int bi = re.cols ().begin();
5132  const int bj = re.rows ().begin();
5133  const int bk = re.pages().begin();
5134  const int ei = re.cols ().end();
5135  const int ej = re.rows ().end();
5136  const int ek = re.pages().end();
5137 
5138  const int s1 = im6.GetX() - (ei - bi);
5139  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
5140 
5141  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5142  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5143  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5144  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5145  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5146  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5147 
5148  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
5149  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
5150  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5151  // const_cast such that voxel functions need only implement
5152  // non-const operator() which is required for parallel_reduce
5153  const_cast<SenaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
5154  }
5155  }
5156 };
5157 
5158 // -----------------------------------------------------------------------------
5159 /**
5160  * ForEachVoxel body for inside and outside unary voxel function of 3 const, 3 non-const images
5161  */
5162 template <class T1, class T2, class T3, class T4, class T5, class T6,
5163  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
5164  class Domain = ForEachVoxelDomain::Foreground>
5165 struct SenaryForEachVoxelIfBody_3Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
5166 {
5167  const GenericImage<T1> &im1;
5168  const GenericImage<T2> &im2;
5169  const GenericImage<T3> &im3;
5170  GenericImage<T4> &im4;
5171  GenericImage<T5> &im5;
5172  GenericImage<T6> &im6;
5173 
5174  /// Constructor
5176  const GenericImage<T2> &im2,
5177  const GenericImage<T3> &im3,
5178  GenericImage<T4> &im4,
5179  GenericImage<T5> &im5,
5180  GenericImage<T6> &im6,
5181  VoxelFunc &vf, OutsideFunc &of)
5182  :
5183  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
5184  {}
5185 
5186  /// Copy constructor
5188  :
5189  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
5190  {}
5191 
5192  /// Split constructor
5194  :
5195  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
5196  {}
5197 
5198  /// Process entire image
5199  void operator ()(const ImageAttributes &attr) const
5200  {
5201  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5202  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5203  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5204  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5205  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5206  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5207 
5208  const int T = (attr._dt ? attr._t : 1);
5209 
5210  for (int l = 0; l < T; ++l)
5211  for (int k = 0; k < attr._z; ++k)
5212  for (int j = 0; j < attr._y; ++j)
5213  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
5214  if (Domain::IsInside(im6, i, j, k, l, p6)) {
5215  // const_cast such that voxel functions need only implement
5216  // non-const operator() which is required for parallel_reduce
5217  const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
5218  } else const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
5219  }
5220  }
5221 
5222  /// Process image region using linear index
5223  void operator ()(const blocked_range<int> &re) const
5224  {
5225  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5226  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5227  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5228  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5229  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5230  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5231 
5232  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5233  if (Domain::IsInside(im6, idx, p6)) {
5234  // const_cast such that voxel functions need only implement
5235  // non-const operator() which is required for parallel_reduce
5236  const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
5237  } else const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
5238  }
5239  }
5240 
5241  /// Process 2D image region
5242  void operator ()(const blocked_range2d<int> &re) const
5243  {
5244  const int bi = re.cols().begin();
5245  const int bj = re.rows().begin();
5246  const int ei = re.cols().end();
5247  const int ej = re.rows().end();
5248 
5249  const int s1 = im6.GetX() - (ei - bi);
5250 
5251  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5252  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5253  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5254  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5255  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5256  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5257 
5258  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
5259  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5260  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
5261  // const_cast such that voxel functions need only implement
5262  // non-const operator() which is required for parallel_reduce
5263  const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
5264  } else const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
5265  }
5266  }
5267 
5268  /// Process 3D image region
5269  void operator ()(const blocked_range3d<int> &re) const
5270  {
5271  const int bi = re.cols ().begin();
5272  const int bj = re.rows ().begin();
5273  const int bk = re.pages().begin();
5274  const int ei = re.cols ().end();
5275  const int ej = re.rows ().end();
5276  const int ek = re.pages().end();
5277 
5278  const int s1 = im6.GetX() - (ei - bi);
5279  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
5280 
5281  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5282  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5283  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5284  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5285  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5286  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5287 
5288  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
5289  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
5290  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
5291  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
5292  // const_cast such that voxel functions need only implement
5293  // non-const operator() which is required for parallel_reduce
5294  const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
5295  } else const_cast<SenaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
5296  }
5297  }
5298 };
5299 
5300 // -----------------------------------------------------------------------------
5301 // ForEachVoxel
5302 // -----------------------------------------------------------------------------
5303 
5304 //
5305 // Image arguments by pointer
5306 //
5307 
5308 // -----------------------------------------------------------------------------
5309 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5310 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5311 {
5312  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5313  blocked_range<int> re(0, im6->GetNumberOfVoxels());
5314  body(re);
5315  vf.join(body._VoxelFunc);
5316 }
5317 
5318 // -----------------------------------------------------------------------------
5319 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5320 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5321 {
5322  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5323  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5324 }
5325 
5326 // -----------------------------------------------------------------------------
5327 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5328 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5329 {
5330  if (im6->GetTSize()) {
5331  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5332  } else {
5333  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5334  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
5335  body(re);
5336  vf.join(body._VoxelFunc);
5337  }
5338 }
5339 
5340 // -----------------------------------------------------------------------------
5341 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5342 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5343 {
5344  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5345  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5346 }
5347 
5348 // -----------------------------------------------------------------------------
5349 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5350 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5351 {
5352  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5353  body(attr);
5354  vf.join(body._VoxelFunc);
5355 }
5356 
5357 // -----------------------------------------------------------------------------
5358 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5359 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5360 {
5361  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5362  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5363 }
5364 
5365 // -----------------------------------------------------------------------------
5366 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5367 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5368 {
5369  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5370  body(re);
5371  vf.join(body._VoxelFunc);
5372 }
5373 
5374 // -----------------------------------------------------------------------------
5375 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5376 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5377 {
5378  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5379  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5380 }
5381 
5382 // -----------------------------------------------------------------------------
5383 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5384 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5385 {
5386  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5387  body(re);
5388  vf.join(body._VoxelFunc);
5389 }
5390 
5391 // -----------------------------------------------------------------------------
5392 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5393 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5394 {
5395  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5396  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5397 }
5398 
5399 // -----------------------------------------------------------------------------
5400 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5401 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5402 {
5403  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5404  body(re);
5405  vf.join(body._VoxelFunc);
5406 }
5407 
5408 // -----------------------------------------------------------------------------
5409 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5410 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5411 {
5412  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5413  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5414 }
5415 
5416 //
5417 // Image arguments by reference
5418 //
5419 
5420 // -----------------------------------------------------------------------------
5421 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5422 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5423 {
5424  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5426  body(re);
5427  vf.join(body._VoxelFunc);
5428 }
5429 
5430 // -----------------------------------------------------------------------------
5431 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5432 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5433 {
5434  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5435  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
5436 }
5437 
5438 // -----------------------------------------------------------------------------
5439 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5440 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5441 {
5442  if (im6.GetTSize()) {
5443  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
5444  } else {
5445  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5446  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
5447  body(re);
5448  vf.join(body._VoxelFunc);
5449  }
5450 }
5451 
5452 // -----------------------------------------------------------------------------
5453 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5454 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5455 {
5456  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5457  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
5458 }
5459 
5460 // -----------------------------------------------------------------------------
5461 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5462 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5463 {
5464  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5465  body(attr);
5466  vf.join(body._VoxelFunc);
5467 }
5468 
5469 // -----------------------------------------------------------------------------
5470 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5471 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5472 {
5473  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5474  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
5475 }
5476 
5477 // -----------------------------------------------------------------------------
5478 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5479 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5480 {
5481  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5482  body(re);
5483  vf.join(body._VoxelFunc);
5484 }
5485 
5486 // -----------------------------------------------------------------------------
5487 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5488 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5489 {
5490  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5491  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
5492 }
5493 
5494 // -----------------------------------------------------------------------------
5495 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5496 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5497 {
5498  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5499  body(re);
5500  vf.join(body._VoxelFunc);
5501 }
5502 
5503 // -----------------------------------------------------------------------------
5504 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5505 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5506 {
5507  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5508  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
5509 }
5510 
5511 // -----------------------------------------------------------------------------
5512 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5513 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5514 {
5515  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
5516  body(re);
5517  vf.join(body._VoxelFunc);
5518 }
5519 
5520 // -----------------------------------------------------------------------------
5521 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5522 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5523 {
5524  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5525  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
5526 }
5527 
5528 // -----------------------------------------------------------------------------
5529 // ForEachVoxelIf
5530 // -----------------------------------------------------------------------------
5531 
5532 //
5533 // Image arguments by pointer
5534 //
5535 
5536 // -----------------------------------------------------------------------------
5537 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5538 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5539 {
5540  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5541  blocked_range<int> re(0, im6->GetNumberOfVoxels());
5542  body(re);
5543  vf.join(body._VoxelFunc);
5544  of.join(body._OutsideFunc);
5545 }
5546 
5547 // -----------------------------------------------------------------------------
5548 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5549 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5550 {
5551  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5552  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5553 }
5554 
5555 // -----------------------------------------------------------------------------
5556 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5557 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5558 {
5560  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5561 }
5562 
5563 // -----------------------------------------------------------------------------
5564 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5565 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5566 {
5567  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5568  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5569 }
5570 
5571 // -----------------------------------------------------------------------------
5572 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5573 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5574 {
5575  if (im6->GetTSize()) {
5576  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5577  } else {
5578  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5579  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
5580  body(re);
5581  vf.join(body._VoxelFunc);
5582  of.join(body._OutsideFunc);
5583  }
5584 }
5585 
5586 // -----------------------------------------------------------------------------
5587 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5588 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5589 {
5590  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5591  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5592 }
5593 
5594 // -----------------------------------------------------------------------------
5595 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5596 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5597 {
5599  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5600 }
5601 
5602 // -----------------------------------------------------------------------------
5603 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5604 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5605 {
5606  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5607  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5608 }
5609 
5610 // -----------------------------------------------------------------------------
5611 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5612 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5613 {
5614  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5615  body(attr);
5616  vf.join(body._VoxelFunc);
5617  of.join(body._OutsideFunc);
5618 }
5619 
5620 // -----------------------------------------------------------------------------
5621 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5622 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5623 {
5624  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5625  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5626 }
5627 
5628 // -----------------------------------------------------------------------------
5629 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5630 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5631 {
5633  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5634 }
5635 
5636 // -----------------------------------------------------------------------------
5637 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5638 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5639 {
5640  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5641  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5642 }
5643 
5644 // -----------------------------------------------------------------------------
5645 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5646 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5647 {
5648  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5649  body(re);
5650  vf.join(body._VoxelFunc);
5651  of.join(body._OutsideFunc);
5652 }
5653 
5654 // -----------------------------------------------------------------------------
5655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5656 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5657 {
5658  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5659  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5660 }
5661 
5662 // -----------------------------------------------------------------------------
5663 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5664 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5665 {
5666  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5667  body(re);
5668  vf.join(body._VoxelFunc);
5669  of.join(body._OutsideFunc);
5670 }
5671 
5672 // -----------------------------------------------------------------------------
5673 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5674 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5675 {
5676  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5677  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5678 }
5679 
5680 // -----------------------------------------------------------------------------
5681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5682 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5683 {
5685  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5686 }
5687 
5688 // -----------------------------------------------------------------------------
5689 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5690 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5691 {
5692  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5693  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5694 }
5695 
5696 // -----------------------------------------------------------------------------
5697 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5698 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
5699 {
5700  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5701  body(re);
5702  vf.join(body._VoxelFunc);
5703  of.join(body._OutsideFunc);
5704 }
5705 
5706 // -----------------------------------------------------------------------------
5707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5708 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5709 {
5710  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5711  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5712 }
5713 
5714 // -----------------------------------------------------------------------------
5715 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5716 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5717 {
5719  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
5720 }
5721 
5722 // -----------------------------------------------------------------------------
5723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5724 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5725 {
5726  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5727  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
5728 }
5729 
5730 //
5731 // Image arguments by reference
5732 //
5733 
5734 // -----------------------------------------------------------------------------
5735 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5736 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5737 {
5740  body(re);
5741  vf.join(body._VoxelFunc);
5742  of.join(body._OutsideFunc);
5743 }
5744 
5745 // -----------------------------------------------------------------------------
5746 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5747 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5748 {
5749  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5750  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
5751 }
5752 
5753 // -----------------------------------------------------------------------------
5754 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5755 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5756 {
5758  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
5759 }
5760 
5761 // -----------------------------------------------------------------------------
5762 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5763 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5764 {
5765  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5766  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
5767 }
5768 
5769 // -----------------------------------------------------------------------------
5770 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5771 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5772 {
5773  if (im6.GetTSize()) {
5774  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
5775  } else {
5777  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
5778  body(re);
5779  vf.join(body._VoxelFunc);
5780  of.join(body._OutsideFunc);
5781  }
5782 }
5783 
5784 // -----------------------------------------------------------------------------
5785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5786 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5787 {
5788  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5789  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
5790 }
5791 
5792 // -----------------------------------------------------------------------------
5793 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5794 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5795 {
5797  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
5798 }
5799 
5800 // -----------------------------------------------------------------------------
5801 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5802 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5803 {
5804  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5805  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
5806 }
5807 
5808 // -----------------------------------------------------------------------------
5809 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5810 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5811 {
5813  body(attr);
5814  vf.join(body._VoxelFunc);
5815  of.join(body._OutsideFunc);
5816 }
5817 
5818 // -----------------------------------------------------------------------------
5819 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5820 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5821 {
5822  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5823  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
5824 }
5825 
5826 // -----------------------------------------------------------------------------
5827 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5828 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5829 {
5831  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
5832 }
5833 
5834 // -----------------------------------------------------------------------------
5835 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5836 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5837 {
5838  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5839  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
5840 }
5841 
5842 // -----------------------------------------------------------------------------
5843 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5844 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5845 {
5847  body(re);
5848  vf.join(body._VoxelFunc);
5849  of.join(body._OutsideFunc);
5850 }
5851 
5852 // -----------------------------------------------------------------------------
5853 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5854 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5855 {
5856  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5857  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5858 }
5859 
5860 // -----------------------------------------------------------------------------
5861 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5862 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5863 {
5865  body(re);
5866  vf.join(body._VoxelFunc);
5867  of.join(body._OutsideFunc);
5868 }
5869 
5870 // -----------------------------------------------------------------------------
5871 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5872 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5873 {
5874  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5875  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5876 }
5877 
5878 // -----------------------------------------------------------------------------
5879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5880 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5881 {
5883  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5884 }
5885 
5886 // -----------------------------------------------------------------------------
5887 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5888 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5889 {
5890  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5891  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
5892 }
5893 
5894 // -----------------------------------------------------------------------------
5895 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5896 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
5897 {
5899  body(re);
5900  vf.join(body._VoxelFunc);
5901  of.join(body._OutsideFunc);
5902 }
5903 
5904 // -----------------------------------------------------------------------------
5905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
5906 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5907 {
5908  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5909  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5910 }
5911 
5912 // -----------------------------------------------------------------------------
5913 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5914 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
5915 {
5917  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
5918 }
5919 
5920 // -----------------------------------------------------------------------------
5921 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5922 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
5923 {
5924  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5925  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
5926 }
5927 
5928 // -----------------------------------------------------------------------------
5929 // ParallelForEachVoxel
5930 // -----------------------------------------------------------------------------
5931 
5932 //
5933 // Image arguments by pointer
5934 //
5935 
5936 // -----------------------------------------------------------------------------
5937 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5938 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5939 {
5940  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5941  blocked_range<int> re(0, im6->GetNumberOfVoxels());
5942  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
5943  else parallel_for (re, body);
5944 }
5945 
5946 // -----------------------------------------------------------------------------
5947 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5948 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5949 {
5950  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5951  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5952 }
5953 
5954 // -----------------------------------------------------------------------------
5955 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5956 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5957 {
5958  if (im6->GetTSize()) {
5959  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5960  } else {
5961  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5962  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
5963  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
5964  else parallel_for (re, body);
5965  }
5966 }
5967 
5968 // -----------------------------------------------------------------------------
5969 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5970 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
5971 {
5972  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
5973  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5974 }
5975 
5976 // -----------------------------------------------------------------------------
5977 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
5978 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
5979 {
5980  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
5981  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
5982  if (VoxelFunc::IsReduction()) {
5983  if (attr._dt) {
5984  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
5985  } else {
5986  parallel_reduce(re, body);
5987  }
5988  vf.join(body._VoxelFunc);
5989  } else {
5990  if (attr._dt) {
5991  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
5992  } else {
5993  parallel_for(re, body);
5994  }
5995  }
5996 }
5997 
5998 // -----------------------------------------------------------------------------
5999 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6000 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6001 {
6002  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6003  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6004 }
6005 
6006 // -----------------------------------------------------------------------------
6007 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6008 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6009 {
6010  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6011  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6012  else parallel_for (re, body);
6013 }
6014 
6015 // -----------------------------------------------------------------------------
6016 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6017 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6018 {
6019  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6020  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6021 }
6022 
6023 // -----------------------------------------------------------------------------
6024 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6025 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6026 {
6027  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6028  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6029  else parallel_for (re, body);
6030 }
6031 
6032 // -----------------------------------------------------------------------------
6033 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6034 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6035 {
6036  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6037  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6038 }
6039 
6040 // -----------------------------------------------------------------------------
6041 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6042 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6043 {
6044  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6045  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6046  else parallel_for (re, body);
6047 }
6048 
6049 // -----------------------------------------------------------------------------
6050 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6051 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6052 {
6053  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6054  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6055 }
6056 
6057 //
6058 // Image arguments by reference
6059 //
6060 
6061 // -----------------------------------------------------------------------------
6062 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6063 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6064 {
6065  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6067  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6068  else parallel_for (re, body);
6069 }
6070 
6071 // -----------------------------------------------------------------------------
6072 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6073 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6074 {
6075  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6076  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
6077 }
6078 
6079 // -----------------------------------------------------------------------------
6080 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6081 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6082 {
6083  if (im6.GetTSize()) {
6084  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
6085  } else {
6086  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6087  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
6088  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6089  else parallel_for (re, body);
6090  }
6091 }
6092 
6093 // -----------------------------------------------------------------------------
6094 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6095 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6096 {
6097  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6098  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
6099 }
6100 
6101 // -----------------------------------------------------------------------------
6102 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6103 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6104 {
6105  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6106  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6107  if (VoxelFunc::IsReduction()) {
6108  if (attr._dt) {
6109  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6110  } else {
6111  parallel_reduce(re, body);
6112  }
6113  vf.join(body._VoxelFunc);
6114  } else {
6115  if (attr._dt) {
6116  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6117  } else {
6118  parallel_for(re, body);
6119  }
6120  }
6121 }
6122 
6123 // -----------------------------------------------------------------------------
6124 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6125 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6126 {
6127  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6128  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
6129 }
6130 
6131 // -----------------------------------------------------------------------------
6132 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6133 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6134 {
6135  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6136  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6137  else parallel_for (re, body);
6138 }
6139 
6140 // -----------------------------------------------------------------------------
6141 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6142 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6143 {
6144  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6145  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
6146 }
6147 
6148 // -----------------------------------------------------------------------------
6149 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6150 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6151 {
6152  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6153  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6154  else parallel_for (re, body);
6155 }
6156 
6157 // -----------------------------------------------------------------------------
6158 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6159 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6160 {
6161  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6162  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
6163 }
6164 
6165 // -----------------------------------------------------------------------------
6166 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6167 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6168 {
6169  SenaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
6170  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6171  else parallel_for (re, body);
6172 }
6173 
6174 // -----------------------------------------------------------------------------
6175 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6176 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6177 {
6178  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6179  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
6180 }
6181 
6182 // -----------------------------------------------------------------------------
6183 // ParallelForEachVoxelIf
6184 // -----------------------------------------------------------------------------
6185 
6186 //
6187 // Image arguments by pointer
6188 //
6189 
6190 // -----------------------------------------------------------------------------
6191 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6192 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6193 {
6194  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6195  blocked_range<int> re(0, im6->GetNumberOfVoxels());
6196  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6197  parallel_reduce(re, body);
6198  vf.join(body._VoxelFunc);
6199  of.join(body._OutsideFunc);
6200  } else {
6201  parallel_for(re, body);
6202  }
6203 }
6204 
6205 // -----------------------------------------------------------------------------
6206 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6207 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6208 {
6209  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6210  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6211 }
6212 
6213 // -----------------------------------------------------------------------------
6214 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6215 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6216 {
6218  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6219 }
6220 
6221 // -----------------------------------------------------------------------------
6222 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6223 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6224 {
6225  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6226  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6227 }
6228 
6229 // -----------------------------------------------------------------------------
6230 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6231 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6232 {
6233  if (im6->GetTSize()) {
6234  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6235  } else {
6236  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6237  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
6238  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6239  parallel_reduce(re, body);
6240  vf.join(body._VoxelFunc);
6241  of.join(body._OutsideFunc);
6242  } else {
6243  parallel_for(re, body);
6244  }
6245  }
6246 }
6247 
6248 // -----------------------------------------------------------------------------
6249 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6250 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6251 {
6252  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6253  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6254 }
6255 
6256 // -----------------------------------------------------------------------------
6257 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6258 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6259 {
6261  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6262 }
6263 
6264 // -----------------------------------------------------------------------------
6265 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6266 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6267 {
6268  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6269  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6270 }
6271 
6272 // -----------------------------------------------------------------------------
6273 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6274 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6275 {
6276  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6277  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6278  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6279  if (attr._dt) {
6280  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6281  } else {
6282  parallel_reduce(re, body);
6283  }
6284  vf.join(body._VoxelFunc);
6285  of.join(body._OutsideFunc);
6286  } else {
6287  if (attr._dt) {
6288  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6289  } else {
6290  parallel_for(re, body);
6291  }
6292  }
6293 }
6294 
6295 // -----------------------------------------------------------------------------
6296 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6297 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6298 {
6299  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6300  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6301 }
6302 
6303 // -----------------------------------------------------------------------------
6304 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6305 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6306 {
6308  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6309 }
6310 
6311 // -----------------------------------------------------------------------------
6312 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6313 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6314 {
6315  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6316  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6317 }
6318 
6319 // -----------------------------------------------------------------------------
6320 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6321 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6322 {
6323  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6324  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6325  parallel_reduce(re, body);
6326  vf.join(body._VoxelFunc);
6327  of.join(body._OutsideFunc);
6328  } else {
6329  parallel_for(re, body);
6330  }
6331 }
6332 
6333 // -----------------------------------------------------------------------------
6334 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6335 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6336 {
6337  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6338  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6339 }
6340 
6341 // -----------------------------------------------------------------------------
6342 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6343 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6344 {
6346  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6347 }
6348 
6349 // -----------------------------------------------------------------------------
6350 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6351 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6352 {
6353  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6354  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6355 }
6356 
6357 // -----------------------------------------------------------------------------
6358 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6359 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6360 {
6361  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6362  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6363  parallel_reduce(re, body);
6364  vf.join(body._VoxelFunc);
6365  of.join(body._OutsideFunc);
6366  } else {
6367  parallel_for(re, body);
6368  }
6369 }
6370 
6371 // -----------------------------------------------------------------------------
6372 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6373 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6374 {
6375  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6376  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6377 }
6378 
6379 // -----------------------------------------------------------------------------
6380 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6381 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6382 {
6384  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6385 }
6386 
6387 // -----------------------------------------------------------------------------
6388 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6389 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6390 {
6391  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6392  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6393 }
6394 
6395 // -----------------------------------------------------------------------------
6396 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6397 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
6398 {
6399  SenaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6400  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6401  parallel_reduce(re, body);
6402  vf.join(body._VoxelFunc);
6403  of.join(body._OutsideFunc);
6404  } else {
6405  parallel_for(re, body);
6406  }
6407 }
6408 
6409 // -----------------------------------------------------------------------------
6410 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6411 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6412 {
6413  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6414  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6415 }
6416 
6417 // -----------------------------------------------------------------------------
6418 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6419 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6420 {
6422  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
6423 }
6424 
6425 // -----------------------------------------------------------------------------
6426 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6427 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6428 {
6429  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6430  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
6431 }
6432 
6433 //
6434 // Image arguments by reference
6435 //
6436 
6437 // -----------------------------------------------------------------------------
6438 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6439 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6440 {
6443  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6444  parallel_reduce(re, body);
6445  vf.join(body._VoxelFunc);
6446  of.join(body._OutsideFunc);
6447  } else {
6448  parallel_for(re, body);
6449  }
6450 }
6451 
6452 // -----------------------------------------------------------------------------
6453 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6454 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6455 {
6456  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6457  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
6458 }
6459 
6460 // -----------------------------------------------------------------------------
6461 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6462 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6463 {
6465  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
6466 }
6467 
6468 // -----------------------------------------------------------------------------
6469 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6470 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6471 {
6472  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6473  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
6474 }
6475 
6476 // -----------------------------------------------------------------------------
6477 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6478 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6479 {
6480  if (im6.GetTSize()) {
6481  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
6482  } else {
6484  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
6485  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6486  parallel_reduce(re, body);
6487  vf.join(body._VoxelFunc);
6488  of.join(body._OutsideFunc);
6489  } else {
6490  parallel_for(re, body);
6491  }
6492  }
6493 }
6494 
6495 // -----------------------------------------------------------------------------
6496 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6497 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6498 {
6499  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6500  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
6501 }
6502 
6503 // -----------------------------------------------------------------------------
6504 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6505 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6506 {
6508  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
6509 }
6510 
6511 // -----------------------------------------------------------------------------
6512 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6513 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6514 {
6515  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6516  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
6517 }
6518 
6519 // -----------------------------------------------------------------------------
6520 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6521 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6522 {
6524  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6525  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6526  if (attr._dt) {
6527  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6528  } else {
6529  parallel_reduce(re, body);
6530  }
6531  vf.join(body._VoxelFunc);
6532  of.join(body._OutsideFunc);
6533  } else {
6534  if (attr._dt) {
6535  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6536  } else {
6537  parallel_for(re, body);
6538  }
6539  }
6540 }
6541 
6542 // -----------------------------------------------------------------------------
6543 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6544 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6545 {
6546  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6547  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
6548 }
6549 
6550 // -----------------------------------------------------------------------------
6551 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6552 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6553 {
6555  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
6556 }
6557 
6558 // -----------------------------------------------------------------------------
6559 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6560 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6561 {
6562  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6563  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
6564 }
6565 
6566 // -----------------------------------------------------------------------------
6567 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6568 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6569 {
6571  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6572  parallel_reduce(re, body);
6573  vf.join(body._VoxelFunc);
6574  of.join(body._OutsideFunc);
6575  } else {
6576  parallel_for(re, body);
6577  }
6578 }
6579 
6580 // -----------------------------------------------------------------------------
6581 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6582 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6583 {
6584  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6585  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6586 }
6587 
6588 // -----------------------------------------------------------------------------
6589 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6590 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6591 {
6593  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6594 }
6595 
6596 // -----------------------------------------------------------------------------
6597 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6598 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6599 {
6600  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6601  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
6602 }
6603 
6604 // -----------------------------------------------------------------------------
6605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6606 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6607 {
6609  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6610  parallel_reduce(re, body);
6611  vf.join(body._VoxelFunc);
6612  of.join(body._OutsideFunc);
6613  } else {
6614  parallel_for(re, body);
6615  }
6616 }
6617 
6618 // -----------------------------------------------------------------------------
6619 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6620 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6621 {
6622  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6623  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6624 }
6625 
6626 // -----------------------------------------------------------------------------
6627 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6628 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6629 {
6631  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6632 }
6633 
6634 // -----------------------------------------------------------------------------
6635 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6636 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6637 {
6638  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6639  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
6640 }
6641 
6642 // -----------------------------------------------------------------------------
6643 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6644 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
6645 {
6647  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6648  parallel_reduce(re, body);
6649  vf.join(body._VoxelFunc);
6650  of.join(body._OutsideFunc);
6651  } else {
6652  parallel_for(re, body);
6653  }
6654 }
6655 
6656 // -----------------------------------------------------------------------------
6657 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
6658 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6659 {
6660  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6661  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6662 }
6663 
6664 // -----------------------------------------------------------------------------
6665 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6666 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
6667 {
6669  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
6670 }
6671 
6672 // -----------------------------------------------------------------------------
6673 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6674 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
6675 {
6676  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6677  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
6678 }
6679 
6680 // =============================================================================
6681 // 2 const, 4 non-const images
6682 // =============================================================================
6683 
6684 // -----------------------------------------------------------------------------
6685 /**
6686  * ForEachVoxel body for voxel function of 2 const, 4 non-const images
6687  */
6688 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6690 {
6691  const GenericImage<T1> &im1;
6692  const GenericImage<T2> &im2;
6693  GenericImage<T3> &im3;
6694  GenericImage<T4> &im4;
6695  GenericImage<T5> &im5;
6696  GenericImage<T6> &im6;
6697 
6698  /// Constructor
6700  const GenericImage<T2> &im2,
6701  GenericImage<T3> &im3,
6702  GenericImage<T4> &im4,
6703  GenericImage<T5> &im5,
6704  GenericImage<T6> &im6,
6705  VoxelFunc &vf)
6706  :
6707  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
6708  {}
6709 
6710  /// Copy constructor
6712  :
6713  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
6714  {}
6715 
6716  /// Split constructor
6718  :
6719  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
6720  {}
6721 
6722  /// Process entire image
6723  void operator ()(const ImageAttributes &attr) const
6724  {
6725  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
6726  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
6727  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
6728  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
6729  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
6730  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
6731 
6732  const int T = (attr._dt ? attr._t : 1);
6733 
6734  for (int l = 0; l < T; ++l)
6735  for (int k = 0; k < attr._z; ++k)
6736  for (int j = 0; j < attr._y; ++j)
6737  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
6738  // const_cast such that voxel functions need only implement
6739  // non-const operator() which is required for parallel_reduce
6740  const_cast<SenaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
6741  }
6742  }
6743 
6744  /// Process image region using linear index
6745  void operator ()(const blocked_range<int> &re) const
6746  {
6747  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
6748  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
6749  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
6750  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
6751  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
6752  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
6753 
6754  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6755  // const_cast such that voxel functions need only implement
6756  // non-const operator() which is required for parallel_reduce
6757  const_cast<SenaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
6758  }
6759  }
6760 
6761  /// Process 2D image region
6762  void operator ()(const blocked_range2d<int> &re) const
6763  {
6764  const int bi = re.cols().begin();
6765  const int bj = re.rows().begin();
6766  const int ei = re.cols().end();
6767  const int ej = re.rows().end();
6768 
6769  const int s1 = im6.GetX() - (ei - bi);
6770 
6771  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6772  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6773  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6774  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6775  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6776  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6777 
6778  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
6779  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6780  // const_cast such that voxel functions need only implement
6781  // non-const operator() which is required for parallel_reduce
6782  const_cast<SenaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
6783  }
6784  }
6785 
6786  /// Process 3D image region
6787  void operator ()(const blocked_range3d<int> &re) const
6788  {
6789  const int bi = re.cols ().begin();
6790  const int bj = re.rows ().begin();
6791  const int bk = re.pages().begin();
6792  const int ei = re.cols ().end();
6793  const int ej = re.rows ().end();
6794  const int ek = re.pages().end();
6795 
6796  const int s1 = im6.GetX() - (ei - bi);
6797  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
6798 
6799  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
6800  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
6801  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
6802  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
6803  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
6804  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
6805 
6806  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
6807  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
6808  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6809  // const_cast such that voxel functions need only implement
6810  // non-const operator() which is required for parallel_reduce
6811  const_cast<SenaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
6812  }
6813  }
6814 };
6815 
6816 // -----------------------------------------------------------------------------
6817 /**
6818  * ForEachVoxel body for inside and outside unary voxel function of 2 const, 4 non-const images
6819  */
6820 template <class T1, class T2, class T3, class T4, class T5, class T6,
6821  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
6822  class Domain = ForEachVoxelDomain::Foreground>
6823 struct SenaryForEachVoxelIfBody_2Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
6824 {
6825  const GenericImage<T1> &im1;
6826  const GenericImage<T2> &im2;
6827  GenericImage<T3> &im3;
6828  GenericImage<T4> &im4;
6829  GenericImage<T5> &im5;
6830  GenericImage<T6> &im6;
6831 
6832  /// Constructor
6834  const GenericImage<T2> &im2,
6835  GenericImage<T3> &im3,
6836  GenericImage<T4> &im4,
6837  GenericImage<T5> &im5,
6838  GenericImage<T6> &im6,
6839  VoxelFunc &vf, OutsideFunc &of)
6840  :
6841  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
6842  {}
6843 
6844  /// Copy constructor
6846  :
6847  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
6848  {}
6849 
6850  /// Split constructor
6852  :
6853  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
6854  {}
6855 
6856  /// Process entire image
6857  void operator ()(const ImageAttributes &attr) const
6858  {
6859  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
6860  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
6861  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
6862  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
6863  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
6864  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
6865 
6866  const int T = (attr._dt ? attr._t : 1);
6867 
6868  for (int l = 0; l < T; ++l)
6869  for (int k = 0; k < attr._z; ++k)
6870  for (int j = 0; j < attr._y; ++j)
6871  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
6872  if (Domain::IsInside(im6, i, j, k, l, p6)) {
6873  // const_cast such that voxel functions need only implement
6874  // non-const operator() which is required for parallel_reduce
6875  const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
6876  } else const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
6877  }
6878  }
6879 
6880  /// Process image region using linear index
6881  void operator ()(const blocked_range<int> &re) const
6882  {
6883  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
6884  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
6885  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
6886  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
6887  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
6888  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
6889 
6890  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6891  if (Domain::IsInside(im6, idx, p6)) {
6892  // const_cast such that voxel functions need only implement
6893  // non-const operator() which is required for parallel_reduce
6894  const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
6895  } else const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
6896  }
6897  }
6898 
6899  /// Process 2D image region
6900  void operator ()(const blocked_range2d<int> &re) const
6901  {
6902  const int bi = re.cols().begin();
6903  const int bj = re.rows().begin();
6904  const int ei = re.cols().end();
6905  const int ej = re.rows().end();
6906 
6907  const int s1 = im6.GetX() - (ei - bi);
6908 
6909  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6910  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6911  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6912  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6913  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6914  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6915 
6916  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
6917  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6918  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
6919  // const_cast such that voxel functions need only implement
6920  // non-const operator() which is required for parallel_reduce
6921  const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
6922  } else const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
6923  }
6924  }
6925 
6926  /// Process 3D image region
6927  void operator ()(const blocked_range3d<int> &re) const
6928  {
6929  const int bi = re.cols ().begin();
6930  const int bj = re.rows ().begin();
6931  const int bk = re.pages().begin();
6932  const int ei = re.cols ().end();
6933  const int ej = re.rows ().end();
6934  const int ek = re.pages().end();
6935 
6936  const int s1 = im6.GetX() - (ei - bi);
6937  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
6938 
6939  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
6940  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
6941  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
6942  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
6943  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
6944  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
6945 
6946  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
6947  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
6948  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
6949  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
6950  // const_cast such that voxel functions need only implement
6951  // non-const operator() which is required for parallel_reduce
6952  const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
6953  } else const_cast<SenaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
6954  }
6955  }
6956 };
6957 
6958 // -----------------------------------------------------------------------------
6959 // ForEachVoxel
6960 // -----------------------------------------------------------------------------
6961 
6962 //
6963 // Image arguments by pointer
6964 //
6965 
6966 // -----------------------------------------------------------------------------
6967 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6968 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6969 {
6970  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6971  blocked_range<int> re(0, im6->GetNumberOfVoxels());
6972  body(re);
6973  vf.join(body._VoxelFunc);
6974 }
6975 
6976 // -----------------------------------------------------------------------------
6977 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6978 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
6979 {
6980  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
6981  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6982 }
6983 
6984 // -----------------------------------------------------------------------------
6985 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
6986 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
6987 {
6988  if (im6->GetTSize()) {
6989  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6990  } else {
6991  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
6992  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
6993  body(re);
6994  vf.join(body._VoxelFunc);
6995  }
6996 }
6997 
6998 // -----------------------------------------------------------------------------
6999 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7000 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7001 {
7002  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7003  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7004 }
7005 
7006 // -----------------------------------------------------------------------------
7007 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7008 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7009 {
7010  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7011  body(attr);
7012  vf.join(body._VoxelFunc);
7013 }
7014 
7015 // -----------------------------------------------------------------------------
7016 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7017 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7018 {
7019  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7020  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7021 }
7022 
7023 // -----------------------------------------------------------------------------
7024 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7025 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7026 {
7027  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7028  body(re);
7029  vf.join(body._VoxelFunc);
7030 }
7031 
7032 // -----------------------------------------------------------------------------
7033 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7034 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7035 {
7036  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7037  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7038 }
7039 
7040 // -----------------------------------------------------------------------------
7041 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7042 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7043 {
7044  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7045  body(re);
7046  vf.join(body._VoxelFunc);
7047 }
7048 
7049 // -----------------------------------------------------------------------------
7050 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7051 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7052 {
7053  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7054  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7055 }
7056 
7057 // -----------------------------------------------------------------------------
7058 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7059 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7060 {
7061  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7062  body(re);
7063  vf.join(body._VoxelFunc);
7064 }
7065 
7066 // -----------------------------------------------------------------------------
7067 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7068 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7069 {
7070  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7071  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7072 }
7073 
7074 //
7075 // Image arguments by reference
7076 //
7077 
7078 // -----------------------------------------------------------------------------
7079 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7080 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7081 {
7082  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7084  body(re);
7085  vf.join(body._VoxelFunc);
7086 }
7087 
7088 // -----------------------------------------------------------------------------
7089 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7090 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7091 {
7092  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7093  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
7094 }
7095 
7096 // -----------------------------------------------------------------------------
7097 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7098 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7099 {
7100  if (im6.GetTSize()) {
7101  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
7102  } else {
7103  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7104  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
7105  body(re);
7106  vf.join(body._VoxelFunc);
7107  }
7108 }
7109 
7110 // -----------------------------------------------------------------------------
7111 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7112 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7113 {
7114  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7115  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
7116 }
7117 
7118 // -----------------------------------------------------------------------------
7119 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7120 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7121 {
7122  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7123  body(attr);
7124  vf.join(body._VoxelFunc);
7125 }
7126 
7127 // -----------------------------------------------------------------------------
7128 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7129 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7130 {
7131  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7132  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
7133 }
7134 
7135 // -----------------------------------------------------------------------------
7136 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7137 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7138 {
7139  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7140  body(re);
7141  vf.join(body._VoxelFunc);
7142 }
7143 
7144 // -----------------------------------------------------------------------------
7145 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7146 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7147 {
7148  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7149  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7150 }
7151 
7152 // -----------------------------------------------------------------------------
7153 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7154 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7155 {
7156  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7157  body(re);
7158  vf.join(body._VoxelFunc);
7159 }
7160 
7161 // -----------------------------------------------------------------------------
7162 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7163 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7164 {
7165  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7166  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7167 }
7168 
7169 // -----------------------------------------------------------------------------
7170 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7171 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7172 {
7173  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7174  body(re);
7175  vf.join(body._VoxelFunc);
7176 }
7177 
7178 // -----------------------------------------------------------------------------
7179 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7180 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7181 {
7182  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7183  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7184 }
7185 
7186 // -----------------------------------------------------------------------------
7187 // ForEachVoxelIf
7188 // -----------------------------------------------------------------------------
7189 
7190 //
7191 // Image arguments by pointer
7192 //
7193 
7194 // -----------------------------------------------------------------------------
7195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7196 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7197 {
7198  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7199  blocked_range<int> re(0, im6->GetNumberOfVoxels());
7200  body(re);
7201  vf.join(body._VoxelFunc);
7202  of.join(body._OutsideFunc);
7203 }
7204 
7205 // -----------------------------------------------------------------------------
7206 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7207 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7208 {
7209  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7210  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7211 }
7212 
7213 // -----------------------------------------------------------------------------
7214 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7215 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7216 {
7218  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7219 }
7220 
7221 // -----------------------------------------------------------------------------
7222 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7223 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7224 {
7225  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7226  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7227 }
7228 
7229 // -----------------------------------------------------------------------------
7230 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7231 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7232 {
7233  if (im6->GetTSize()) {
7234  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7235  } else {
7236  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7237  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
7238  body(re);
7239  vf.join(body._VoxelFunc);
7240  of.join(body._OutsideFunc);
7241  }
7242 }
7243 
7244 // -----------------------------------------------------------------------------
7245 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7246 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7247 {
7248  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7249  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7250 }
7251 
7252 // -----------------------------------------------------------------------------
7253 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7254 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7255 {
7257  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7258 }
7259 
7260 // -----------------------------------------------------------------------------
7261 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7262 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7263 {
7264  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7265  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7266 }
7267 
7268 // -----------------------------------------------------------------------------
7269 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7270 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7271 {
7272  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7273  body(attr);
7274  vf.join(body._VoxelFunc);
7275  of.join(body._OutsideFunc);
7276 }
7277 
7278 // -----------------------------------------------------------------------------
7279 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7280 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7281 {
7282  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7283  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7284 }
7285 
7286 // -----------------------------------------------------------------------------
7287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7288 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7289 {
7291  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7292 }
7293 
7294 // -----------------------------------------------------------------------------
7295 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7296 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7297 {
7298  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7299  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7300 }
7301 
7302 // -----------------------------------------------------------------------------
7303 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7304 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7305 {
7306  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7307  body(re);
7308  vf.join(body._VoxelFunc);
7309  of.join(body._OutsideFunc);
7310 }
7311 
7312 // -----------------------------------------------------------------------------
7313 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7314 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7315 {
7316  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7317  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7318 }
7319 
7320 // -----------------------------------------------------------------------------
7321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7322 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7323 {
7324  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7325  body(re);
7326  vf.join(body._VoxelFunc);
7327  of.join(body._OutsideFunc);
7328 }
7329 
7330 // -----------------------------------------------------------------------------
7331 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7332 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7333 {
7334  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7335  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7336 }
7337 
7338 // -----------------------------------------------------------------------------
7339 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7340 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7341 {
7343  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7344 }
7345 
7346 // -----------------------------------------------------------------------------
7347 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7348 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7349 {
7350  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7351  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7352 }
7353 
7354 // -----------------------------------------------------------------------------
7355 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7356 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7357 {
7358  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7359  body(re);
7360  vf.join(body._VoxelFunc);
7361  of.join(body._OutsideFunc);
7362 }
7363 
7364 // -----------------------------------------------------------------------------
7365 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7366 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7367 {
7368  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7369  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7370 }
7371 
7372 // -----------------------------------------------------------------------------
7373 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7374 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7375 {
7377  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7378 }
7379 
7380 // -----------------------------------------------------------------------------
7381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7382 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7383 {
7384  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7385  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7386 }
7387 
7388 //
7389 // Image arguments by reference
7390 //
7391 
7392 // -----------------------------------------------------------------------------
7393 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7394 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7395 {
7398  body(re);
7399  vf.join(body._VoxelFunc);
7400  of.join(body._OutsideFunc);
7401 }
7402 
7403 // -----------------------------------------------------------------------------
7404 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7405 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7406 {
7407  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7408  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
7409 }
7410 
7411 // -----------------------------------------------------------------------------
7412 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7413 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7414 {
7416  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
7417 }
7418 
7419 // -----------------------------------------------------------------------------
7420 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7421 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7422 {
7423  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7424  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
7425 }
7426 
7427 // -----------------------------------------------------------------------------
7428 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7429 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7430 {
7431  if (im6.GetTSize()) {
7432  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
7433  } else {
7435  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
7436  body(re);
7437  vf.join(body._VoxelFunc);
7438  of.join(body._OutsideFunc);
7439  }
7440 }
7441 
7442 // -----------------------------------------------------------------------------
7443 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7444 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7445 {
7446  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7447  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
7448 }
7449 
7450 // -----------------------------------------------------------------------------
7451 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7452 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7453 {
7455  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
7456 }
7457 
7458 // -----------------------------------------------------------------------------
7459 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7460 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7461 {
7462  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7463  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
7464 }
7465 
7466 // -----------------------------------------------------------------------------
7467 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7468 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7469 {
7471  body(attr);
7472  vf.join(body._VoxelFunc);
7473  of.join(body._OutsideFunc);
7474 }
7475 
7476 // -----------------------------------------------------------------------------
7477 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7478 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7479 {
7480  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7481  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
7482 }
7483 
7484 // -----------------------------------------------------------------------------
7485 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7486 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7487 {
7489  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
7490 }
7491 
7492 // -----------------------------------------------------------------------------
7493 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7494 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7495 {
7496  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7497  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
7498 }
7499 
7500 // -----------------------------------------------------------------------------
7501 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7502 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7503 {
7505  body(re);
7506  vf.join(body._VoxelFunc);
7507  of.join(body._OutsideFunc);
7508 }
7509 
7510 // -----------------------------------------------------------------------------
7511 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7512 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7513 {
7514  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7515  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
7516 }
7517 
7518 // -----------------------------------------------------------------------------
7519 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7520 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7521 {
7523  body(re);
7524  vf.join(body._VoxelFunc);
7525  of.join(body._OutsideFunc);
7526 }
7527 
7528 // -----------------------------------------------------------------------------
7529 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7530 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7531 {
7532  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7533  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
7534 }
7535 
7536 // -----------------------------------------------------------------------------
7537 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7538 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7539 {
7541  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
7542 }
7543 
7544 // -----------------------------------------------------------------------------
7545 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7546 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7547 {
7548  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7549  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
7550 }
7551 
7552 // -----------------------------------------------------------------------------
7553 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7554 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
7555 {
7557  body(re);
7558  vf.join(body._VoxelFunc);
7559  of.join(body._OutsideFunc);
7560 }
7561 
7562 // -----------------------------------------------------------------------------
7563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7564 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7565 {
7566  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7567  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
7568 }
7569 
7570 // -----------------------------------------------------------------------------
7571 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7572 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7573 {
7575  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
7576 }
7577 
7578 // -----------------------------------------------------------------------------
7579 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7580 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7581 {
7582  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7583  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
7584 }
7585 
7586 // -----------------------------------------------------------------------------
7587 // ParallelForEachVoxel
7588 // -----------------------------------------------------------------------------
7589 
7590 //
7591 // Image arguments by pointer
7592 //
7593 
7594 // -----------------------------------------------------------------------------
7595 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7596 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7597 {
7598  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7599  blocked_range<int> re(0, im6->GetNumberOfVoxels());
7600  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7601  else parallel_for (re, body);
7602 }
7603 
7604 // -----------------------------------------------------------------------------
7605 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7606 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7607 {
7608  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7609  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7610 }
7611 
7612 // -----------------------------------------------------------------------------
7613 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7614 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7615 {
7616  if (im6->GetTSize()) {
7617  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7618  } else {
7619  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7620  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
7621  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7622  else parallel_for (re, body);
7623  }
7624 }
7625 
7626 // -----------------------------------------------------------------------------
7627 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7628 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7629 {
7630  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7631  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7632 }
7633 
7634 // -----------------------------------------------------------------------------
7635 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7636 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7637 {
7638  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7639  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7640  if (VoxelFunc::IsReduction()) {
7641  if (attr._dt) {
7642  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7643  } else {
7644  parallel_reduce(re, body);
7645  }
7646  vf.join(body._VoxelFunc);
7647  } else {
7648  if (attr._dt) {
7649  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7650  } else {
7651  parallel_for(re, body);
7652  }
7653  }
7654 }
7655 
7656 // -----------------------------------------------------------------------------
7657 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7658 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7659 {
7660  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7661  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7662 }
7663 
7664 // -----------------------------------------------------------------------------
7665 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7666 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7667 {
7668  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7669  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7670  else parallel_for (re, body);
7671 }
7672 
7673 // -----------------------------------------------------------------------------
7674 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7675 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7676 {
7677  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7678  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7679 }
7680 
7681 // -----------------------------------------------------------------------------
7682 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7683 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7684 {
7685  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7686  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7687  else parallel_for (re, body);
7688 }
7689 
7690 // -----------------------------------------------------------------------------
7691 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7692 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7693 {
7694  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7695  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7696 }
7697 
7698 // -----------------------------------------------------------------------------
7699 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7700 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7701 {
7702  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7703  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7704  else parallel_for (re, body);
7705 }
7706 
7707 // -----------------------------------------------------------------------------
7708 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7709 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7710 {
7711  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7712  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7713 }
7714 
7715 //
7716 // Image arguments by reference
7717 //
7718 
7719 // -----------------------------------------------------------------------------
7720 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7721 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7722 {
7723  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7725  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7726  else parallel_for (re, body);
7727 }
7728 
7729 // -----------------------------------------------------------------------------
7730 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7731 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7732 {
7733  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7734  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
7735 }
7736 
7737 // -----------------------------------------------------------------------------
7738 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7739 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7740 {
7741  if (im6.GetTSize()) {
7742  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
7743  } else {
7744  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7745  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
7746  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7747  else parallel_for (re, body);
7748  }
7749 }
7750 
7751 // -----------------------------------------------------------------------------
7752 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7753 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7754 {
7755  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7756  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
7757 }
7758 
7759 // -----------------------------------------------------------------------------
7760 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7761 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7762 {
7763  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7764  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7765  if (VoxelFunc::IsReduction()) {
7766  if (attr._dt) {
7767  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7768  } else {
7769  parallel_reduce(re, body);
7770  }
7771  vf.join(body._VoxelFunc);
7772  } else {
7773  if (attr._dt) {
7774  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7775  } else {
7776  parallel_for(re, body);
7777  }
7778  }
7779 }
7780 
7781 // -----------------------------------------------------------------------------
7782 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7783 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7784 {
7785  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7786  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
7787 }
7788 
7789 // -----------------------------------------------------------------------------
7790 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7791 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7792 {
7793  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7794  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7795  else parallel_for (re, body);
7796 }
7797 
7798 // -----------------------------------------------------------------------------
7799 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7800 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7801 {
7802  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7803  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7804 }
7805 
7806 // -----------------------------------------------------------------------------
7807 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7808 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7809 {
7810  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7811  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7812  else parallel_for (re, body);
7813 }
7814 
7815 // -----------------------------------------------------------------------------
7816 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7817 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7818 {
7819  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7820  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7821 }
7822 
7823 // -----------------------------------------------------------------------------
7824 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7825 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
7826 {
7827  SenaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
7828  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7829  else parallel_for (re, body);
7830 }
7831 
7832 // -----------------------------------------------------------------------------
7833 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7834 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
7835 {
7836  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7837  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
7838 }
7839 
7840 // -----------------------------------------------------------------------------
7841 // ParallelForEachVoxelIf
7842 // -----------------------------------------------------------------------------
7843 
7844 //
7845 // Image arguments by pointer
7846 //
7847 
7848 // -----------------------------------------------------------------------------
7849 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7850 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7851 {
7852  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7853  blocked_range<int> re(0, im6->GetNumberOfVoxels());
7854  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
7855  parallel_reduce(re, body);
7856  vf.join(body._VoxelFunc);
7857  of.join(body._OutsideFunc);
7858  } else {
7859  parallel_for(re, body);
7860  }
7861 }
7862 
7863 // -----------------------------------------------------------------------------
7864 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7865 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7866 {
7867  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7868  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7869 }
7870 
7871 // -----------------------------------------------------------------------------
7872 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7873 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7874 {
7876  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7877 }
7878 
7879 // -----------------------------------------------------------------------------
7880 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7881 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7882 {
7883  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7884  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7885 }
7886 
7887 // -----------------------------------------------------------------------------
7888 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7889 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7890 {
7891  if (im6->GetTSize()) {
7892  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7893  } else {
7894  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7895  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
7896  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
7897  parallel_reduce(re, body);
7898  vf.join(body._VoxelFunc);
7899  of.join(body._OutsideFunc);
7900  } else {
7901  parallel_for(re, body);
7902  }
7903  }
7904 }
7905 
7906 // -----------------------------------------------------------------------------
7907 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7908 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7909 {
7910  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7911  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7912 }
7913 
7914 // -----------------------------------------------------------------------------
7915 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7916 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7917 {
7919  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7920 }
7921 
7922 // -----------------------------------------------------------------------------
7923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7924 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7925 {
7926  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7927  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
7928 }
7929 
7930 // -----------------------------------------------------------------------------
7931 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7932 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7933 {
7934  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7935  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7936  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
7937  if (attr._dt) {
7938  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7939  } else {
7940  parallel_reduce(re, body);
7941  }
7942  vf.join(body._VoxelFunc);
7943  of.join(body._OutsideFunc);
7944  } else {
7945  if (attr._dt) {
7946  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7947  } else {
7948  parallel_for(re, body);
7949  }
7950  }
7951 }
7952 
7953 // -----------------------------------------------------------------------------
7954 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7955 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7956 {
7957  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7958  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7959 }
7960 
7961 // -----------------------------------------------------------------------------
7962 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7963 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
7964 {
7966  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7967 }
7968 
7969 // -----------------------------------------------------------------------------
7970 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
7971 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7972 {
7973  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7974  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
7975 }
7976 
7977 // -----------------------------------------------------------------------------
7978 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7979 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
7980 {
7981  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7982  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
7983  parallel_reduce(re, body);
7984  vf.join(body._VoxelFunc);
7985  of.join(body._OutsideFunc);
7986  } else {
7987  parallel_for(re, body);
7988  }
7989 }
7990 
7991 // -----------------------------------------------------------------------------
7992 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
7993 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
7994 {
7995  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
7996  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
7997 }
7998 
7999 // -----------------------------------------------------------------------------
8000 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8001 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8002 {
8004  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8005 }
8006 
8007 // -----------------------------------------------------------------------------
8008 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8009 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8010 {
8011  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8012  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8013 }
8014 
8015 // -----------------------------------------------------------------------------
8016 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8017 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8018 {
8019  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8020  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8021  parallel_reduce(re, body);
8022  vf.join(body._VoxelFunc);
8023  of.join(body._OutsideFunc);
8024  } else {
8025  parallel_for(re, body);
8026  }
8027 }
8028 
8029 // -----------------------------------------------------------------------------
8030 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8031 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8032 {
8033  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8034  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8035 }
8036 
8037 // -----------------------------------------------------------------------------
8038 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8039 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8040 {
8042  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8043 }
8044 
8045 // -----------------------------------------------------------------------------
8046 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8047 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8048 {
8049  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8050  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8051 }
8052 
8053 // -----------------------------------------------------------------------------
8054 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8055 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8056 {
8057  SenaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8058  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8059  parallel_reduce(re, body);
8060  vf.join(body._VoxelFunc);
8061  of.join(body._OutsideFunc);
8062  } else {
8063  parallel_for(re, body);
8064  }
8065 }
8066 
8067 // -----------------------------------------------------------------------------
8068 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8069 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8070 {
8071  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8072  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8073 }
8074 
8075 // -----------------------------------------------------------------------------
8076 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8077 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8078 {
8080  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8081 }
8082 
8083 // -----------------------------------------------------------------------------
8084 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8085 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8086 {
8087  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8088  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8089 }
8090 
8091 //
8092 // Image arguments by reference
8093 //
8094 
8095 // -----------------------------------------------------------------------------
8096 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8097 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8098 {
8101  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8102  parallel_reduce(re, body);
8103  vf.join(body._VoxelFunc);
8104  of.join(body._OutsideFunc);
8105  } else {
8106  parallel_for(re, body);
8107  }
8108 }
8109 
8110 // -----------------------------------------------------------------------------
8111 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8112 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8113 {
8114  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8115  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
8116 }
8117 
8118 // -----------------------------------------------------------------------------
8119 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8120 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8121 {
8123  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
8124 }
8125 
8126 // -----------------------------------------------------------------------------
8127 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8128 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8129 {
8130  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8131  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
8132 }
8133 
8134 // -----------------------------------------------------------------------------
8135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8136 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8137 {
8138  if (im6.GetTSize()) {
8139  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
8140  } else {
8142  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
8143  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8144  parallel_reduce(re, body);
8145  vf.join(body._VoxelFunc);
8146  of.join(body._OutsideFunc);
8147  } else {
8148  parallel_for(re, body);
8149  }
8150  }
8151 }
8152 
8153 // -----------------------------------------------------------------------------
8154 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8155 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8156 {
8157  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8158  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
8159 }
8160 
8161 // -----------------------------------------------------------------------------
8162 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8163 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8164 {
8166  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
8167 }
8168 
8169 // -----------------------------------------------------------------------------
8170 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8171 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8172 {
8173  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8174  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
8175 }
8176 
8177 // -----------------------------------------------------------------------------
8178 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8179 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8180 {
8182  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
8183  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8184  if (attr._dt) {
8185  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
8186  } else {
8187  parallel_reduce(re, body);
8188  }
8189  vf.join(body._VoxelFunc);
8190  of.join(body._OutsideFunc);
8191  } else {
8192  if (attr._dt) {
8193  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
8194  } else {
8195  parallel_for(re, body);
8196  }
8197  }
8198 }
8199 
8200 // -----------------------------------------------------------------------------
8201 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8202 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8203 {
8204  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8205  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
8206 }
8207 
8208 // -----------------------------------------------------------------------------
8209 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8210 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8211 {
8213  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
8214 }
8215 
8216 // -----------------------------------------------------------------------------
8217 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8218 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8219 {
8220  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8221  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
8222 }
8223 
8224 // -----------------------------------------------------------------------------
8225 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8226 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8227 {
8229  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8230  parallel_reduce(re, body);
8231  vf.join(body._VoxelFunc);
8232  of.join(body._OutsideFunc);
8233  } else {
8234  parallel_for(re, body);
8235  }
8236 }
8237 
8238 // -----------------------------------------------------------------------------
8239 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8240 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8241 {
8242  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8243  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8244 }
8245 
8246 // -----------------------------------------------------------------------------
8247 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8248 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8249 {
8251  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8252 }
8253 
8254 // -----------------------------------------------------------------------------
8255 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8256 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8257 {
8258  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8259  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
8260 }
8261 
8262 // -----------------------------------------------------------------------------
8263 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8264 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8265 {
8267  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8268  parallel_reduce(re, body);
8269  vf.join(body._VoxelFunc);
8270  of.join(body._OutsideFunc);
8271  } else {
8272  parallel_for(re, body);
8273  }
8274 }
8275 
8276 // -----------------------------------------------------------------------------
8277 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8278 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8279 {
8280  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8281  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8282 }
8283 
8284 // -----------------------------------------------------------------------------
8285 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8286 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8287 {
8289  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8290 }
8291 
8292 // -----------------------------------------------------------------------------
8293 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8294 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8295 {
8296  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8297  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
8298 }
8299 
8300 // -----------------------------------------------------------------------------
8301 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8302 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
8303 {
8305  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8306  parallel_reduce(re, body);
8307  vf.join(body._VoxelFunc);
8308  of.join(body._OutsideFunc);
8309  } else {
8310  parallel_for(re, body);
8311  }
8312 }
8313 
8314 // -----------------------------------------------------------------------------
8315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8316 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8317 {
8318  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8319  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8320 }
8321 
8322 // -----------------------------------------------------------------------------
8323 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8324 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8325 {
8327  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
8328 }
8329 
8330 // -----------------------------------------------------------------------------
8331 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8332 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8333 {
8334  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8335  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
8336 }
8337 
8338 // =============================================================================
8339 // 1 const, 5 non-const images
8340 // =============================================================================
8341 
8342 // -----------------------------------------------------------------------------
8343 /**
8344  * ForEachVoxel body for voxel function of 1 const, 5 non-const images
8345  */
8346 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8348 {
8349  const GenericImage<T1> &im1;
8350  GenericImage<T2> &im2;
8351  GenericImage<T3> &im3;
8352  GenericImage<T4> &im4;
8353  GenericImage<T5> &im5;
8354  GenericImage<T6> &im6;
8355 
8356  /// Constructor
8358  GenericImage<T2> &im2,
8359  GenericImage<T3> &im3,
8360  GenericImage<T4> &im4,
8361  GenericImage<T5> &im5,
8362  GenericImage<T6> &im6,
8363  VoxelFunc &vf)
8364  :
8365  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
8366  {}
8367 
8368  /// Copy constructor
8370  :
8371  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
8372  {}
8373 
8374  /// Split constructor
8376  :
8377  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
8378  {}
8379 
8380  /// Process entire image
8381  void operator ()(const ImageAttributes &attr) const
8382  {
8383  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8384  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8385  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8386  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8387  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8388  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8389 
8390  const int T = (attr._dt ? attr._t : 1);
8391 
8392  for (int l = 0; l < T; ++l)
8393  for (int k = 0; k < attr._z; ++k)
8394  for (int j = 0; j < attr._y; ++j)
8395  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
8396  // const_cast such that voxel functions need only implement
8397  // non-const operator() which is required for parallel_reduce
8398  const_cast<SenaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
8399  }
8400  }
8401 
8402  /// Process image region using linear index
8403  void operator ()(const blocked_range<int> &re) const
8404  {
8405  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8406  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8407  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8408  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8409  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8410  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8411 
8412  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8413  // const_cast such that voxel functions need only implement
8414  // non-const operator() which is required for parallel_reduce
8415  const_cast<SenaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
8416  }
8417  }
8418 
8419  /// Process 2D image region
8420  void operator ()(const blocked_range2d<int> &re) const
8421  {
8422  const int bi = re.cols().begin();
8423  const int bj = re.rows().begin();
8424  const int ei = re.cols().end();
8425  const int ej = re.rows().end();
8426 
8427  const int s1 = im6.GetX() - (ei - bi);
8428 
8429  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8430  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8431  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8432  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8433  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8434  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8435 
8436  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
8437  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8438  // const_cast such that voxel functions need only implement
8439  // non-const operator() which is required for parallel_reduce
8440  const_cast<SenaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
8441  }
8442  }
8443 
8444  /// Process 3D image region
8445  void operator ()(const blocked_range3d<int> &re) const
8446  {
8447  const int bi = re.cols ().begin();
8448  const int bj = re.rows ().begin();
8449  const int bk = re.pages().begin();
8450  const int ei = re.cols ().end();
8451  const int ej = re.rows ().end();
8452  const int ek = re.pages().end();
8453 
8454  const int s1 = im6.GetX() - (ei - bi);
8455  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
8456 
8457  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8458  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8459  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8460  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8461  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8462  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8463 
8464  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
8465  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
8466  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8467  // const_cast such that voxel functions need only implement
8468  // non-const operator() which is required for parallel_reduce
8469  const_cast<SenaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
8470  }
8471  }
8472 };
8473 
8474 // -----------------------------------------------------------------------------
8475 /**
8476  * ForEachVoxel body for inside and outside unary voxel function of 1 const, 5 non-const images
8477  */
8478 template <class T1, class T2, class T3, class T4, class T5, class T6,
8479  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
8480  class Domain = ForEachVoxelDomain::Foreground>
8481 struct SenaryForEachVoxelIfBody_1Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
8482 {
8483  const GenericImage<T1> &im1;
8484  GenericImage<T2> &im2;
8485  GenericImage<T3> &im3;
8486  GenericImage<T4> &im4;
8487  GenericImage<T5> &im5;
8488  GenericImage<T6> &im6;
8489 
8490  /// Constructor
8492  GenericImage<T2> &im2,
8493  GenericImage<T3> &im3,
8494  GenericImage<T4> &im4,
8495  GenericImage<T5> &im5,
8496  GenericImage<T6> &im6,
8497  VoxelFunc &vf, OutsideFunc &of)
8498  :
8499  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
8500  {}
8501 
8502  /// Copy constructor
8504  :
8505  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
8506  {}
8507 
8508  /// Split constructor
8510  :
8511  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
8512  {}
8513 
8514  /// Process entire image
8515  void operator ()(const ImageAttributes &attr) const
8516  {
8517  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8518  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8519  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8520  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8521  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8522  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8523 
8524  const int T = (attr._dt ? attr._t : 1);
8525 
8526  for (int l = 0; l < T; ++l)
8527  for (int k = 0; k < attr._z; ++k)
8528  for (int j = 0; j < attr._y; ++j)
8529  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
8530  if (Domain::IsInside(im6, i, j, k, l, p6)) {
8531  // const_cast such that voxel functions need only implement
8532  // non-const operator() which is required for parallel_reduce
8533  const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
8534  } else const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
8535  }
8536  }
8537 
8538  /// Process image region using linear index
8539  void operator ()(const blocked_range<int> &re) const
8540  {
8541  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8542  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8543  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8544  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8545  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8546  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8547 
8548  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8549  if (Domain::IsInside(im6, idx, p6)) {
8550  // const_cast such that voxel functions need only implement
8551  // non-const operator() which is required for parallel_reduce
8552  const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
8553  } else const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
8554  }
8555  }
8556 
8557  /// Process 2D image region
8558  void operator ()(const blocked_range2d<int> &re) const
8559  {
8560  const int bi = re.cols().begin();
8561  const int bj = re.rows().begin();
8562  const int ei = re.cols().end();
8563  const int ej = re.rows().end();
8564 
8565  const int s1 = im6.GetX() - (ei - bi);
8566 
8567  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8568  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8569  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8570  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8571  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8572  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8573 
8574  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
8575  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8576  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
8577  // const_cast such that voxel functions need only implement
8578  // non-const operator() which is required for parallel_reduce
8579  const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
8580  } else const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
8581  }
8582  }
8583 
8584  /// Process 3D image region
8585  void operator ()(const blocked_range3d<int> &re) const
8586  {
8587  const int bi = re.cols ().begin();
8588  const int bj = re.rows ().begin();
8589  const int bk = re.pages().begin();
8590  const int ei = re.cols ().end();
8591  const int ej = re.rows ().end();
8592  const int ek = re.pages().end();
8593 
8594  const int s1 = im6.GetX() - (ei - bi);
8595  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
8596 
8597  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8598  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8599  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8600  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8601  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8602  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8603 
8604  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
8605  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
8606  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
8607  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
8608  // const_cast such that voxel functions need only implement
8609  // non-const operator() which is required for parallel_reduce
8610  const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
8611  } else const_cast<SenaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
8612  }
8613  }
8614 };
8615 
8616 // -----------------------------------------------------------------------------
8617 // ForEachVoxel
8618 // -----------------------------------------------------------------------------
8619 
8620 //
8621 // Image arguments by pointer
8622 //
8623 
8624 // -----------------------------------------------------------------------------
8625 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8626 void ForEachScalar(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8627 {
8628  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8629  blocked_range<int> re(0, im6->GetNumberOfVoxels());
8630  body(re);
8631  vf.join(body._VoxelFunc);
8632 }
8633 
8634 // -----------------------------------------------------------------------------
8635 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8636 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8637 {
8638  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8639  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8640 }
8641 
8642 // -----------------------------------------------------------------------------
8643 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8644 void ForEachVoxel(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8645 {
8646  if (im6->GetTSize()) {
8647  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8648  } else {
8649  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8650  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
8651  body(re);
8652  vf.join(body._VoxelFunc);
8653  }
8654 }
8655 
8656 // -----------------------------------------------------------------------------
8657 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8658 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8659 {
8660  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8661  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8662 }
8663 
8664 // -----------------------------------------------------------------------------
8665 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8666 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8667 {
8668  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8669  body(attr);
8670  vf.join(body._VoxelFunc);
8671 }
8672 
8673 // -----------------------------------------------------------------------------
8674 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8675 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8676 {
8677  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8678  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8679 }
8680 
8681 // -----------------------------------------------------------------------------
8682 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8683 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8684 {
8685  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8686  body(re);
8687  vf.join(body._VoxelFunc);
8688 }
8689 
8690 // -----------------------------------------------------------------------------
8691 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8692 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8693 {
8694  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8695  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8696 }
8697 
8698 // -----------------------------------------------------------------------------
8699 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8700 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8701 {
8702  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8703  body(re);
8704  vf.join(body._VoxelFunc);
8705 }
8706 
8707 // -----------------------------------------------------------------------------
8708 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8709 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8710 {
8711  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8712  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8713 }
8714 
8715 // -----------------------------------------------------------------------------
8716 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8717 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8718 {
8719  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8720  body(re);
8721  vf.join(body._VoxelFunc);
8722 }
8723 
8724 // -----------------------------------------------------------------------------
8725 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8726 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8727 {
8728  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8729  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8730 }
8731 
8732 //
8733 // Image arguments by reference
8734 //
8735 
8736 // -----------------------------------------------------------------------------
8737 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8738 void ForEachScalar(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8739 {
8740  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8742  body(re);
8743  vf.join(body._VoxelFunc);
8744 }
8745 
8746 // -----------------------------------------------------------------------------
8747 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8748 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8749 {
8750  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8751  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
8752 }
8753 
8754 // -----------------------------------------------------------------------------
8755 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8756 void ForEachVoxel(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8757 {
8758  if (im6.GetTSize()) {
8759  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
8760  } else {
8761  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8762  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
8763  body(re);
8764  vf.join(body._VoxelFunc);
8765  }
8766 }
8767 
8768 // -----------------------------------------------------------------------------
8769 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8770 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8771 {
8772  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8773  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
8774 }
8775 
8776 // -----------------------------------------------------------------------------
8777 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8778 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8779 {
8780  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8781  body(attr);
8782  vf.join(body._VoxelFunc);
8783 }
8784 
8785 // -----------------------------------------------------------------------------
8786 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8787 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8788 {
8789  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8790  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
8791 }
8792 
8793 // -----------------------------------------------------------------------------
8794 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8795 void ForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8796 {
8797  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8798  body(re);
8799  vf.join(body._VoxelFunc);
8800 }
8801 
8802 // -----------------------------------------------------------------------------
8803 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8804 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8805 {
8806  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8807  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
8808 }
8809 
8810 // -----------------------------------------------------------------------------
8811 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8812 void ForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8813 {
8814  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8815  body(re);
8816  vf.join(body._VoxelFunc);
8817 }
8818 
8819 // -----------------------------------------------------------------------------
8820 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8821 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8822 {
8823  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8824  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
8825 }
8826 
8827 // -----------------------------------------------------------------------------
8828 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8829 void ForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
8830 {
8831  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
8832  body(re);
8833  vf.join(body._VoxelFunc);
8834 }
8835 
8836 // -----------------------------------------------------------------------------
8837 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8838 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
8839 {
8840  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8841  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
8842 }
8843 
8844 // -----------------------------------------------------------------------------
8845 // ForEachVoxelIf
8846 // -----------------------------------------------------------------------------
8847 
8848 //
8849 // Image arguments by pointer
8850 //
8851 
8852 // -----------------------------------------------------------------------------
8853 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8854 void ForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8855 {
8856  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8857  blocked_range<int> re(0, im6->GetNumberOfVoxels());
8858  body(re);
8859  vf.join(body._VoxelFunc);
8860  of.join(body._OutsideFunc);
8861 }
8862 
8863 // -----------------------------------------------------------------------------
8864 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8865 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8866 {
8867  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8868  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8869 }
8870 
8871 // -----------------------------------------------------------------------------
8872 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8873 void ForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8874 {
8876  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8877 }
8878 
8879 // -----------------------------------------------------------------------------
8880 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8881 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8882 {
8883  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8884  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8885 }
8886 
8887 // -----------------------------------------------------------------------------
8888 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8889 void ForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8890 {
8891  if (im6->GetTSize()) {
8892  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8893  } else {
8894  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8895  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
8896  body(re);
8897  vf.join(body._VoxelFunc);
8898  of.join(body._OutsideFunc);
8899  }
8900 }
8901 
8902 // -----------------------------------------------------------------------------
8903 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8904 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8905 {
8906  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8907  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8908 }
8909 
8910 // -----------------------------------------------------------------------------
8911 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8912 void ForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8913 {
8915  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8916 }
8917 
8918 // -----------------------------------------------------------------------------
8919 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8920 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8921 {
8922  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8923  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
8924 }
8925 
8926 // -----------------------------------------------------------------------------
8927 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8928 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8929 {
8930  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8931  body(attr);
8932  vf.join(body._VoxelFunc);
8933  of.join(body._OutsideFunc);
8934 }
8935 
8936 // -----------------------------------------------------------------------------
8937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8938 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8939 {
8940  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8941  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8942 }
8943 
8944 // -----------------------------------------------------------------------------
8945 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8946 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8947 {
8949  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8950 }
8951 
8952 // -----------------------------------------------------------------------------
8953 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8954 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8955 {
8956  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8957  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
8958 }
8959 
8960 // -----------------------------------------------------------------------------
8961 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8962 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8963 {
8964  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8965  body(re);
8966  vf.join(body._VoxelFunc);
8967  of.join(body._OutsideFunc);
8968 }
8969 
8970 // -----------------------------------------------------------------------------
8971 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8972 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8973 {
8974  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8975  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8976 }
8977 
8978 // -----------------------------------------------------------------------------
8979 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8980 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
8981 {
8982  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8983  body(re);
8984  vf.join(body._VoxelFunc);
8985  of.join(body._OutsideFunc);
8986 }
8987 
8988 // -----------------------------------------------------------------------------
8989 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
8990 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
8991 {
8992  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
8993  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
8994 }
8995 
8996 // -----------------------------------------------------------------------------
8997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
8998 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
8999 {
9001  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9002 }
9003 
9004 // -----------------------------------------------------------------------------
9005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9006 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9007 {
9008  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9009  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9010 }
9011 
9012 // -----------------------------------------------------------------------------
9013 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9014 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9015 {
9016  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9017  body(re);
9018  vf.join(body._VoxelFunc);
9019  of.join(body._OutsideFunc);
9020 }
9021 
9022 // -----------------------------------------------------------------------------
9023 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9024 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9025 {
9026  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9027  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9028 }
9029 
9030 // -----------------------------------------------------------------------------
9031 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9032 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9033 {
9035  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9036 }
9037 
9038 // -----------------------------------------------------------------------------
9039 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9040 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9041 {
9042  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9043  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9044 }
9045 
9046 //
9047 // Image arguments by reference
9048 //
9049 
9050 // -----------------------------------------------------------------------------
9051 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9052 void ForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9053 {
9056  body(re);
9057  vf.join(body._VoxelFunc);
9058  of.join(body._OutsideFunc);
9059 }
9060 
9061 // -----------------------------------------------------------------------------
9062 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9063 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9064 {
9065  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9066  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9067 }
9068 
9069 // -----------------------------------------------------------------------------
9070 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9071 void ForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9072 {
9074  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9075 }
9076 
9077 // -----------------------------------------------------------------------------
9078 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9079 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9080 {
9081  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9082  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
9083 }
9084 
9085 // -----------------------------------------------------------------------------
9086 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9087 void ForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9088 {
9089  if (im6.GetTSize()) {
9090  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9091  } else {
9093  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
9094  body(re);
9095  vf.join(body._VoxelFunc);
9096  of.join(body._OutsideFunc);
9097  }
9098 }
9099 
9100 // -----------------------------------------------------------------------------
9101 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9102 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9103 {
9104  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9105  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9106 }
9107 
9108 // -----------------------------------------------------------------------------
9109 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9110 void ForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9111 {
9113  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9114 }
9115 
9116 // -----------------------------------------------------------------------------
9117 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9118 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9119 {
9120  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9121  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
9122 }
9123 
9124 // -----------------------------------------------------------------------------
9125 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9126 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9127 {
9129  body(attr);
9130  vf.join(body._VoxelFunc);
9131  of.join(body._OutsideFunc);
9132 }
9133 
9134 // -----------------------------------------------------------------------------
9135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9136 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9137 {
9138  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9139  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
9140 }
9141 
9142 // -----------------------------------------------------------------------------
9143 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9144 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9145 {
9147  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
9148 }
9149 
9150 // -----------------------------------------------------------------------------
9151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9152 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9153 {
9154  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9155  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
9156 }
9157 
9158 // -----------------------------------------------------------------------------
9159 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9160 void ForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9161 {
9163  body(re);
9164  vf.join(body._VoxelFunc);
9165  of.join(body._OutsideFunc);
9166 }
9167 
9168 // -----------------------------------------------------------------------------
9169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9170 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9171 {
9172  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9173  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9174 }
9175 
9176 // -----------------------------------------------------------------------------
9177 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9178 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9179 {
9181  body(re);
9182  vf.join(body._VoxelFunc);
9183  of.join(body._OutsideFunc);
9184 }
9185 
9186 // -----------------------------------------------------------------------------
9187 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9188 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9189 {
9190  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9191  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9192 }
9193 
9194 // -----------------------------------------------------------------------------
9195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9196 void ForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9197 {
9199  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9200 }
9201 
9202 // -----------------------------------------------------------------------------
9203 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9204 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9205 {
9206  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9207  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
9208 }
9209 
9210 // -----------------------------------------------------------------------------
9211 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9212 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9213 {
9215  body(re);
9216  vf.join(body._VoxelFunc);
9217  of.join(body._OutsideFunc);
9218 }
9219 
9220 // -----------------------------------------------------------------------------
9221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9222 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9223 {
9224  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9225  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9226 }
9227 
9228 // -----------------------------------------------------------------------------
9229 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9230 void ForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9231 {
9233  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9234 }
9235 
9236 // -----------------------------------------------------------------------------
9237 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9238 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9239 {
9240  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9241  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
9242 }
9243 
9244 // -----------------------------------------------------------------------------
9245 // ParallelForEachVoxel
9246 // -----------------------------------------------------------------------------
9247 
9248 //
9249 // Image arguments by pointer
9250 //
9251 
9252 // -----------------------------------------------------------------------------
9253 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9254 void ParallelForEachScalar(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9255 {
9256  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9257  blocked_range<int> re(0, im6->GetNumberOfVoxels());
9258  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9259  else parallel_for (re, body);
9260 }
9261 
9262 // -----------------------------------------------------------------------------
9263 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9264 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9265 {
9266  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9267  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9268 }
9269 
9270 // -----------------------------------------------------------------------------
9271 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9272 void ParallelForEachVoxel(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9273 {
9274  if (im6->GetTSize()) {
9275  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9276  } else {
9277  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9278  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
9279  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9280  else parallel_for (re, body);
9281  }
9282 }
9283 
9284 // -----------------------------------------------------------------------------
9285 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9286 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9287 {
9288  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9289  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9290 }
9291 
9292 // -----------------------------------------------------------------------------
9293 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9294 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9295 {
9296  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9297  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9298  if (VoxelFunc::IsReduction()) {
9299  if (attr._dt) {
9300  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9301  } else {
9302  parallel_reduce(re, body);
9303  }
9304  vf.join(body._VoxelFunc);
9305  } else {
9306  if (attr._dt) {
9307  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9308  } else {
9309  parallel_for(re, body);
9310  }
9311  }
9312 }
9313 
9314 // -----------------------------------------------------------------------------
9315 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9316 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9317 {
9318  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9319  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9320 }
9321 
9322 // -----------------------------------------------------------------------------
9323 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9324 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9325 {
9326  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9327  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9328  else parallel_for (re, body);
9329 }
9330 
9331 // -----------------------------------------------------------------------------
9332 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9333 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9334 {
9335  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9336  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9337 }
9338 
9339 // -----------------------------------------------------------------------------
9340 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9341 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9342 {
9343  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9344  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9345  else parallel_for (re, body);
9346 }
9347 
9348 // -----------------------------------------------------------------------------
9349 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9350 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9351 {
9352  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9353  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9354 }
9355 
9356 // -----------------------------------------------------------------------------
9357 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9358 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9359 {
9360  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9361  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9362  else parallel_for (re, body);
9363 }
9364 
9365 // -----------------------------------------------------------------------------
9366 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9367 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9368 {
9369  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9370  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9371 }
9372 
9373 //
9374 // Image arguments by reference
9375 //
9376 
9377 // -----------------------------------------------------------------------------
9378 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9379 void ParallelForEachScalar(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9380 {
9381  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9383  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9384  else parallel_for (re, body);
9385 }
9386 
9387 // -----------------------------------------------------------------------------
9388 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9389 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9390 {
9391  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9392  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
9393 }
9394 
9395 // -----------------------------------------------------------------------------
9396 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9397 void ParallelForEachVoxel(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9398 {
9399  if (im6.GetTSize()) {
9400  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
9401  } else {
9402  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9403  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
9404  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9405  else parallel_for (re, body);
9406  }
9407 }
9408 
9409 // -----------------------------------------------------------------------------
9410 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9411 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9412 {
9413  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9414  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
9415 }
9416 
9417 // -----------------------------------------------------------------------------
9418 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9419 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9420 {
9421  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9422  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9423  if (VoxelFunc::IsReduction()) {
9424  if (attr._dt) {
9425  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9426  } else {
9427  parallel_reduce(re, body);
9428  }
9429  vf.join(body._VoxelFunc);
9430  } else {
9431  if (attr._dt) {
9432  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9433  } else {
9434  parallel_for(re, body);
9435  }
9436  }
9437 }
9438 
9439 // -----------------------------------------------------------------------------
9440 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9441 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9442 {
9443  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9444  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
9445 }
9446 
9447 // -----------------------------------------------------------------------------
9448 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9449 void ParallelForEachVoxel(const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9450 {
9451  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9452  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9453  else parallel_for (re, body);
9454 }
9455 
9456 // -----------------------------------------------------------------------------
9457 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9458 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9459 {
9460  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9461  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
9462 }
9463 
9464 // -----------------------------------------------------------------------------
9465 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9466 void ParallelForEachVoxel(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9467 {
9468  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9469  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9470  else parallel_for (re, body);
9471 }
9472 
9473 // -----------------------------------------------------------------------------
9474 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9475 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9476 {
9477  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9478  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
9479 }
9480 
9481 // -----------------------------------------------------------------------------
9482 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9483 void ParallelForEachVoxel(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9484 {
9485  SenaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
9486  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9487  else parallel_for (re, body);
9488 }
9489 
9490 // -----------------------------------------------------------------------------
9491 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9492 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9493 {
9494  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9495  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
9496 }
9497 
9498 // -----------------------------------------------------------------------------
9499 // ParallelForEachVoxelIf
9500 // -----------------------------------------------------------------------------
9501 
9502 //
9503 // Image arguments by pointer
9504 //
9505 
9506 // -----------------------------------------------------------------------------
9507 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9508 void ParallelForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9509 {
9510  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9511  blocked_range<int> re(0, im6->GetNumberOfVoxels());
9512  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9513  parallel_reduce(re, body);
9514  vf.join(body._VoxelFunc);
9515  of.join(body._OutsideFunc);
9516  } else {
9517  parallel_for(re, body);
9518  }
9519 }
9520 
9521 // -----------------------------------------------------------------------------
9522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9523 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9524 {
9525  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9526  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9527 }
9528 
9529 // -----------------------------------------------------------------------------
9530 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9531 void ParallelForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9532 {
9534  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9535 }
9536 
9537 // -----------------------------------------------------------------------------
9538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9539 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9540 {
9541  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9542  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9543 }
9544 
9545 // -----------------------------------------------------------------------------
9546 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9547 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9548 {
9549  if (im6->GetTSize()) {
9550  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9551  } else {
9552  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9553  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
9554  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9555  parallel_reduce(re, body);
9556  vf.join(body._VoxelFunc);
9557  of.join(body._OutsideFunc);
9558  } else {
9559  parallel_for(re, body);
9560  }
9561  }
9562 }
9563 
9564 // -----------------------------------------------------------------------------
9565 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9566 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9567 {
9568  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9569  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9570 }
9571 
9572 // -----------------------------------------------------------------------------
9573 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9574 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9575 {
9577  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9578 }
9579 
9580 // -----------------------------------------------------------------------------
9581 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9582 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9583 {
9584  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9585  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
9586 }
9587 
9588 // -----------------------------------------------------------------------------
9589 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9590 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9591 {
9592  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9593  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9594  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9595  if (attr._dt) {
9596  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9597  } else {
9598  parallel_reduce(re, body);
9599  }
9600  vf.join(body._VoxelFunc);
9601  of.join(body._OutsideFunc);
9602  } else {
9603  if (attr._dt) {
9604  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9605  } else {
9606  parallel_for(re, body);
9607  }
9608  }
9609 }
9610 
9611 // -----------------------------------------------------------------------------
9612 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9613 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9614 {
9615  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9616  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9617 }
9618 
9619 // -----------------------------------------------------------------------------
9620 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9621 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9622 {
9624  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9625 }
9626 
9627 // -----------------------------------------------------------------------------
9628 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9629 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9630 {
9631  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9632  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9633 }
9634 
9635 // -----------------------------------------------------------------------------
9636 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9637 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9638 {
9639  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9640  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9641  parallel_reduce(re, body);
9642  vf.join(body._VoxelFunc);
9643  of.join(body._OutsideFunc);
9644  } else {
9645  parallel_for(re, body);
9646  }
9647 }
9648 
9649 // -----------------------------------------------------------------------------
9650 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9651 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9652 {
9653  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9654  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9655 }
9656 
9657 // -----------------------------------------------------------------------------
9658 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9659 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9660 {
9662  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9663 }
9664 
9665 // -----------------------------------------------------------------------------
9666 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9667 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9668 {
9669  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9670  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9671 }
9672 
9673 // -----------------------------------------------------------------------------
9674 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9675 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9676 {
9677  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9678  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9679  parallel_reduce(re, body);
9680  vf.join(body._VoxelFunc);
9681  of.join(body._OutsideFunc);
9682  } else {
9683  parallel_for(re, body);
9684  }
9685 }
9686 
9687 // -----------------------------------------------------------------------------
9688 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9689 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9690 {
9691  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9692  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9693 }
9694 
9695 // -----------------------------------------------------------------------------
9696 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9697 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9698 {
9700  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9701 }
9702 
9703 // -----------------------------------------------------------------------------
9704 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9705 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9706 {
9707  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9708  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9709 }
9710 
9711 // -----------------------------------------------------------------------------
9712 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9713 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
9714 {
9715  SenaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9716  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9717  parallel_reduce(re, body);
9718  vf.join(body._VoxelFunc);
9719  of.join(body._OutsideFunc);
9720  } else {
9721  parallel_for(re, body);
9722  }
9723 }
9724 
9725 // -----------------------------------------------------------------------------
9726 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9727 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9728 {
9729  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9730  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9731 }
9732 
9733 // -----------------------------------------------------------------------------
9734 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9735 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
9736 {
9738  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
9739 }
9740 
9741 // -----------------------------------------------------------------------------
9742 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9743 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
9744 {
9745  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9746  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
9747 }
9748 
9749 //
9750 // Image arguments by reference
9751 //
9752 
9753 // -----------------------------------------------------------------------------
9754 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9755 void ParallelForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9756 {
9759  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9760  parallel_reduce(re, body);
9761  vf.join(body._VoxelFunc);
9762  of.join(body._OutsideFunc);
9763  } else {
9764  parallel_for(re, body);
9765  }
9766 }
9767 
9768 // -----------------------------------------------------------------------------
9769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9770 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9771 {
9772  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9773  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9774 }
9775 
9776 // -----------------------------------------------------------------------------
9777 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9778 void ParallelForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9779 {
9781  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9782 }
9783 
9784 // -----------------------------------------------------------------------------
9785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9786 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9787 {
9788  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9789  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
9790 }
9791 
9792 // -----------------------------------------------------------------------------
9793 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9794 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9795 {
9796  if (im6.GetTSize()) {
9797  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9798  } else {
9800  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
9801  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9802  parallel_reduce(re, body);
9803  vf.join(body._VoxelFunc);
9804  of.join(body._OutsideFunc);
9805  } else {
9806  parallel_for(re, body);
9807  }
9808  }
9809 }
9810 
9811 // -----------------------------------------------------------------------------
9812 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9813 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9814 {
9815  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9816  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9817 }
9818 
9819 // -----------------------------------------------------------------------------
9820 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9821 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9822 {
9824  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
9825 }
9826 
9827 // -----------------------------------------------------------------------------
9828 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9829 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9830 {
9831  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9832  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
9833 }
9834 
9835 // -----------------------------------------------------------------------------
9836 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9837 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9838 {
9840  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9841  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9842  if (attr._dt) {
9843  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9844  } else {
9845  parallel_reduce(re, body);
9846  }
9847  vf.join(body._VoxelFunc);
9848  of.join(body._OutsideFunc);
9849  } else {
9850  if (attr._dt) {
9851  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9852  } else {
9853  parallel_for(re, body);
9854  }
9855  }
9856 }
9857 
9858 // -----------------------------------------------------------------------------
9859 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9860 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9861 {
9862  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9863  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
9864 }
9865 
9866 // -----------------------------------------------------------------------------
9867 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9868 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9869 {
9871  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
9872 }
9873 
9874 // -----------------------------------------------------------------------------
9875 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9876 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9877 {
9878  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9879  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
9880 }
9881 
9882 // -----------------------------------------------------------------------------
9883 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9884 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9885 {
9887  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9888  parallel_reduce(re, body);
9889  vf.join(body._VoxelFunc);
9890  of.join(body._OutsideFunc);
9891  } else {
9892  parallel_for(re, body);
9893  }
9894 }
9895 
9896 // -----------------------------------------------------------------------------
9897 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9898 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9899 {
9900  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9901  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9902 }
9903 
9904 // -----------------------------------------------------------------------------
9905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9906 void ParallelForEachVoxelIf(const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9907 {
9909  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9910 }
9911 
9912 // -----------------------------------------------------------------------------
9913 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9914 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9915 {
9916  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9917  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
9918 }
9919 
9920 // -----------------------------------------------------------------------------
9921 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9922 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9923 {
9925  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9926  parallel_reduce(re, body);
9927  vf.join(body._VoxelFunc);
9928  of.join(body._OutsideFunc);
9929  } else {
9930  parallel_for(re, body);
9931  }
9932 }
9933 
9934 // -----------------------------------------------------------------------------
9935 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9936 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9937 {
9938  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9939  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9940 }
9941 
9942 // -----------------------------------------------------------------------------
9943 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9944 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9945 {
9947  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9948 }
9949 
9950 // -----------------------------------------------------------------------------
9951 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9952 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9953 {
9954  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9955  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
9956 }
9957 
9958 // -----------------------------------------------------------------------------
9959 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9960 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
9961 {
9963  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9964  parallel_reduce(re, body);
9965  vf.join(body._VoxelFunc);
9966  of.join(body._OutsideFunc);
9967  } else {
9968  parallel_for(re, body);
9969  }
9970 }
9971 
9972 // -----------------------------------------------------------------------------
9973 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
9974 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9975 {
9976  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9977  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9978 }
9979 
9980 // -----------------------------------------------------------------------------
9981 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9982 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
9983 {
9985  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
9986 }
9987 
9988 // -----------------------------------------------------------------------------
9989 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
9990 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
9991 {
9992  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
9993  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
9994 }
9995 
9996 // =============================================================================
9997 // 6 non-const images
9998 // =============================================================================
9999 
10000 // -----------------------------------------------------------------------------
10001 /**
10002  * ForEachVoxel body for voxel function of 6 non-const images
10003  */
10004 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10005 struct SenaryForEachVoxelBody : public ForEachVoxelBody<VoxelFunc>
10006 {
10007  GenericImage<T1> &im1;
10008  GenericImage<T2> &im2;
10009  GenericImage<T3> &im3;
10010  GenericImage<T4> &im4;
10011  GenericImage<T5> &im5;
10012  GenericImage<T6> &im6;
10013 
10014  /// Constructor
10016  GenericImage<T2> &im2,
10017  GenericImage<T3> &im3,
10018  GenericImage<T4> &im4,
10019  GenericImage<T5> &im5,
10020  GenericImage<T6> &im6,
10021  VoxelFunc &vf)
10022  :
10023  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
10024  {}
10025 
10026  /// Copy constructor
10028  :
10029  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
10030  {}
10031 
10032  /// Split constructor
10034  :
10035  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
10036  {}
10037 
10038  /// Process entire image
10039  void operator ()(const ImageAttributes &attr) const
10040  {
10041  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10042  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10043  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10044  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10045  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10046  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10047 
10048  const int T = (attr._dt ? attr._t : 1);
10049 
10050  for (int l = 0; l < T; ++l)
10051  for (int k = 0; k < attr._z; ++k)
10052  for (int j = 0; j < attr._y; ++j)
10053  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
10054  // const_cast such that voxel functions need only implement
10055  // non-const operator() which is required for parallel_reduce
10056  const_cast<SenaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
10057  }
10058  }
10059 
10060  /// Process image region using linear index
10061  void operator ()(const blocked_range<int> &re) const
10062  {
10063  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10064  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10065  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10066  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10067  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10068  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10069 
10070  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10071  // const_cast such that voxel functions need only implement
10072  // non-const operator() which is required for parallel_reduce
10073  const_cast<SenaryForEachVoxelBody *>(this)->_VoxelFunc(im6, idx, p1, p2, p3, p4, p5, p6);
10074  }
10075  }
10076 
10077  /// Process 2D image region
10078  void operator ()(const blocked_range2d<int> &re) const
10079  {
10080  const int bi = re.cols().begin();
10081  const int bj = re.rows().begin();
10082  const int ei = re.cols().end();
10083  const int ej = re.rows().end();
10084 
10085  const int s1 = im6.GetX() - (ei - bi);
10086 
10087  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10088  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10089  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10090  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10091  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10092  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10093 
10094  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
10095  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10096  // const_cast such that voxel functions need only implement
10097  // non-const operator() which is required for parallel_reduce
10098  const_cast<SenaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
10099  }
10100  }
10101 
10102  /// Process 3D image region
10103  void operator ()(const blocked_range3d<int> &re) const
10104  {
10105  const int bi = re.cols ().begin();
10106  const int bj = re.rows ().begin();
10107  const int bk = re.pages().begin();
10108  const int ei = re.cols ().end();
10109  const int ej = re.rows ().end();
10110  const int ek = re.pages().end();
10111 
10112  const int s1 = im6.GetX() - (ei - bi);
10113  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
10114 
10115  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10116  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10117  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10118  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10119  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10120  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10121 
10122  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
10123  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
10124  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10125  // const_cast such that voxel functions need only implement
10126  // non-const operator() which is required for parallel_reduce
10127  const_cast<SenaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
10128  }
10129  }
10130 };
10131 
10132 // -----------------------------------------------------------------------------
10133 /**
10134  * ForEachVoxel body for inside and outside unary voxel function of 6 non-const images
10135  */
10136 template <class T1, class T2, class T3, class T4, class T5, class T6,
10137  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
10138  class Domain = ForEachVoxelDomain::Foreground>
10139 struct SenaryForEachVoxelIfBody : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
10140 {
10141  GenericImage<T1> &im1;
10142  GenericImage<T2> &im2;
10143  GenericImage<T3> &im3;
10144  GenericImage<T4> &im4;
10145  GenericImage<T5> &im5;
10146  GenericImage<T6> &im6;
10147 
10148  /// Constructor
10150  GenericImage<T2> &im2,
10151  GenericImage<T3> &im3,
10152  GenericImage<T4> &im4,
10153  GenericImage<T5> &im5,
10154  GenericImage<T6> &im6,
10155  VoxelFunc &vf, OutsideFunc &of)
10156  :
10157  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6)
10158  {}
10159 
10160  /// Copy constructor
10162  :
10163  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
10164  {}
10165 
10166  /// Split constructor
10168  :
10169  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6)
10170  {}
10171 
10172  /// Process entire image
10173  void operator ()(const ImageAttributes &attr) const
10174  {
10175  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10176  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10177  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10178  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10179  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10180  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10181 
10182  const int T = (attr._dt ? attr._t : 1);
10183 
10184  for (int l = 0; l < T; ++l)
10185  for (int k = 0; k < attr._z; ++k)
10186  for (int j = 0; j < attr._y; ++j)
10187  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6) {
10188  if (Domain::IsInside(im6, i, j, k, l, p6)) {
10189  // const_cast such that voxel functions need only implement
10190  // non-const operator() which is required for parallel_reduce
10191  const_cast<SenaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6);
10192  } else const_cast<SenaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6);
10193  }
10194  }
10195 
10196  /// Process image region using linear index
10197  void operator ()(const blocked_range<int> &re) const
10198  {
10199  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10200  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10201  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10202  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10203  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10204  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10205 
10206  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10207  if (Domain::IsInside(im6, idx, p6)) {
10208  // const_cast such that voxel functions need only implement
10209  // non-const operator() which is required for parallel_reduce
10210  const_cast<SenaryForEachVoxelIfBody *>(this)->_VoxelFunc (im6, idx, p1, p2, p3, p4, p5, p6);
10211  } else const_cast<SenaryForEachVoxelIfBody *>(this)->_OutsideFunc(im6, idx, p1, p2, p3, p4, p5, p6);
10212  }
10213  }
10214 
10215  /// Process 2D image region
10216  void operator ()(const blocked_range2d<int> &re) const
10217  {
10218  const int bi = re.cols().begin();
10219  const int bj = re.rows().begin();
10220  const int ei = re.cols().end();
10221  const int ej = re.rows().end();
10222 
10223  const int s1 = im6.GetX() - (ei - bi);
10224 
10225  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10226  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10227  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10228  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10229  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10230  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10231 
10232  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
10233  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10234  if (Domain::IsInside(im6, i, j, this->_k, this->_l, p6)) {
10235  // const_cast such that voxel functions need only implement
10236  // non-const operator() which is required for parallel_reduce
10237  const_cast<SenaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
10238  } else const_cast<SenaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6);
10239  }
10240  }
10241 
10242  /// Process 3D image region
10243  void operator ()(const blocked_range3d<int> &re) const
10244  {
10245  const int bi = re.cols ().begin();
10246  const int bj = re.rows ().begin();
10247  const int bk = re.pages().begin();
10248  const int ei = re.cols ().end();
10249  const int ej = re.rows ().end();
10250  const int ek = re.pages().end();
10251 
10252  const int s1 = im6.GetX() - (ei - bi);
10253  const int s2 = (im6.GetY() - (ej - bj)) * im6.GetX();
10254 
10255  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10256  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10257  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10258  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10259  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10260  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10261 
10262  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2)
10263  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1)
10264  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1) {
10265  if (Domain::IsInside(im6, i, j, k, this->_l, p6)) {
10266  // const_cast such that voxel functions need only implement
10267  // non-const operator() which is required for parallel_reduce
10268  const_cast<SenaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
10269  } else const_cast<SenaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6);
10270  }
10271  }
10272 };
10273 
10274 // -----------------------------------------------------------------------------
10275 // ForEachVoxel
10276 // -----------------------------------------------------------------------------
10277 
10278 //
10279 // Image arguments by pointer
10280 //
10281 
10282 // -----------------------------------------------------------------------------
10283 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10284 void ForEachScalar(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10285 {
10286  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10287  blocked_range<int> re(0, im6->GetNumberOfVoxels());
10288  body(re);
10289  vf.join(body._VoxelFunc);
10290 }
10291 
10292 // -----------------------------------------------------------------------------
10293 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10294 void ForEachScalar(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10295 {
10296  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10297  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10298 }
10299 
10300 // -----------------------------------------------------------------------------
10301 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10302 void ForEachVoxel(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10303 {
10304  if (im6->GetTSize()) {
10305  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10306  } else {
10307  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10308  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
10309  body(re);
10310  vf.join(body._VoxelFunc);
10311  }
10312 }
10313 
10314 // -----------------------------------------------------------------------------
10315 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10316 void ForEachVoxel(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10317 {
10318  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10319  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10320 }
10321 
10322 // -----------------------------------------------------------------------------
10323 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10324 void ForEachVoxel(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10325 {
10326  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10327  body(attr);
10328  vf.join(body._VoxelFunc);
10329 }
10330 
10331 // -----------------------------------------------------------------------------
10332 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10333 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10334 {
10335  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10336  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10337 }
10338 
10339 // -----------------------------------------------------------------------------
10340 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10341 void ForEachVoxel(const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10342 {
10343  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10344  body(re);
10345  vf.join(body._VoxelFunc);
10346 }
10347 
10348 // -----------------------------------------------------------------------------
10349 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10350 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10351 {
10352  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10353  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10354 }
10355 
10356 // -----------------------------------------------------------------------------
10357 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10358 void ForEachVoxel(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10359 {
10360  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10361  body(re);
10362  vf.join(body._VoxelFunc);
10363 }
10364 
10365 // -----------------------------------------------------------------------------
10366 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10367 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10368 {
10369  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10370  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10371 }
10372 
10373 // -----------------------------------------------------------------------------
10374 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10375 void ForEachVoxel(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10376 {
10377  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10378  body(re);
10379  vf.join(body._VoxelFunc);
10380 }
10381 
10382 // -----------------------------------------------------------------------------
10383 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10384 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10385 {
10386  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10387  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10388 }
10389 
10390 //
10391 // Image arguments by reference
10392 //
10393 
10394 // -----------------------------------------------------------------------------
10395 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10396 void ForEachScalar(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10397 {
10398  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10400  body(re);
10401  vf.join(body._VoxelFunc);
10402 }
10403 
10404 // -----------------------------------------------------------------------------
10405 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10406 void ForEachScalar(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10407 {
10408  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10409  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
10410 }
10411 
10412 // -----------------------------------------------------------------------------
10413 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10414 void ForEachVoxel(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10415 {
10416  if (im6.GetTSize()) {
10417  ForEachScalar(im1, im2, im3, im4, im5, im6, vf);
10418  } else {
10419  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10420  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
10421  body(re);
10422  vf.join(body._VoxelFunc);
10423  }
10424 }
10425 
10426 // -----------------------------------------------------------------------------
10427 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10428 void ForEachVoxel(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10429 {
10430  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10431  ForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
10432 }
10433 
10434 // -----------------------------------------------------------------------------
10435 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10436 void ForEachVoxel(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10437 {
10438  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10439  body(attr);
10440  vf.join(body._VoxelFunc);
10441 }
10442 
10443 // -----------------------------------------------------------------------------
10444 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10445 void ForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10446 {
10447  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10448  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
10449 }
10450 
10451 // -----------------------------------------------------------------------------
10452 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10453 void ForEachVoxel(const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10454 {
10455  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10456  body(re);
10457  vf.join(body._VoxelFunc);
10458 }
10459 
10460 // -----------------------------------------------------------------------------
10461 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10462 void ForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10463 {
10464  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10465  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
10466 }
10467 
10468 // -----------------------------------------------------------------------------
10469 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10470 void ForEachVoxel(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10471 {
10472  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10473  body(re);
10474  vf.join(body._VoxelFunc);
10475 }
10476 
10477 // -----------------------------------------------------------------------------
10478 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10479 void ForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10480 {
10481  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10482  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
10483 }
10484 
10485 // -----------------------------------------------------------------------------
10486 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10487 void ForEachVoxel(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10488 {
10489  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
10490  body(re);
10491  vf.join(body._VoxelFunc);
10492 }
10493 
10494 // -----------------------------------------------------------------------------
10495 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10496 void ForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10497 {
10498  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10499  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
10500 }
10501 
10502 // -----------------------------------------------------------------------------
10503 // ForEachVoxelIf
10504 // -----------------------------------------------------------------------------
10505 
10506 //
10507 // Image arguments by pointer
10508 //
10509 
10510 // -----------------------------------------------------------------------------
10511 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10512 void ForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10513 {
10514  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10515  blocked_range<int> re(0, im6->GetNumberOfVoxels());
10516  body(re);
10517  vf.join(body._VoxelFunc);
10518  of.join(body._OutsideFunc);
10519 }
10520 
10521 // -----------------------------------------------------------------------------
10522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10523 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10524 {
10525  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10526  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10527 }
10528 
10529 // -----------------------------------------------------------------------------
10530 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10531 void ForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10532 {
10534  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10535 }
10536 
10537 // -----------------------------------------------------------------------------
10538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10539 void ForEachScalarIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10540 {
10541  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10542  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10543 }
10544 
10545 // -----------------------------------------------------------------------------
10546 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10547 void ForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10548 {
10549  if (im6->GetTSize()) {
10550  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10551  } else {
10552  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10553  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
10554  body(re);
10555  vf.join(body._VoxelFunc);
10556  of.join(body._OutsideFunc);
10557  }
10558 }
10559 
10560 // -----------------------------------------------------------------------------
10561 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10562 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10563 {
10564  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10565  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10566 }
10567 
10568 // -----------------------------------------------------------------------------
10569 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10570 void ForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10571 {
10573  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10574 }
10575 
10576 // -----------------------------------------------------------------------------
10577 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10578 void ForEachVoxelIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10579 {
10580  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10581  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10582 }
10583 
10584 // -----------------------------------------------------------------------------
10585 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10586 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10587 {
10588  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10589  body(attr);
10590  vf.join(body._VoxelFunc);
10591  of.join(body._OutsideFunc);
10592 }
10593 
10594 // -----------------------------------------------------------------------------
10595 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10596 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10597 {
10598  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10599  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10600 }
10601 
10602 // -----------------------------------------------------------------------------
10603 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10604 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10605 {
10607  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10608 }
10609 
10610 // -----------------------------------------------------------------------------
10611 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10612 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10613 {
10614  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10615  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10616 }
10617 
10618 // -----------------------------------------------------------------------------
10619 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10620 void ForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10621 {
10622  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10623  body(re);
10624  vf.join(body._VoxelFunc);
10625  of.join(body._OutsideFunc);
10626 }
10627 
10628 // -----------------------------------------------------------------------------
10629 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10630 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10631 {
10632  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10633  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10634 }
10635 
10636 // -----------------------------------------------------------------------------
10637 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10638 void ForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10639 {
10640  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10641  body(re);
10642  vf.join(body._VoxelFunc);
10643  of.join(body._OutsideFunc);
10644 }
10645 
10646 // -----------------------------------------------------------------------------
10647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10648 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10649 {
10650  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10651  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10652 }
10653 
10654 // -----------------------------------------------------------------------------
10655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10656 void ForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10657 {
10659  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10660 }
10661 
10662 // -----------------------------------------------------------------------------
10663 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10664 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10665 {
10666  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10667  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10668 }
10669 
10670 // -----------------------------------------------------------------------------
10671 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10672 void ForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
10673 {
10674  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10675  body(re);
10676  vf.join(body._VoxelFunc);
10677  of.join(body._OutsideFunc);
10678 }
10679 
10680 // -----------------------------------------------------------------------------
10681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10682 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10683 {
10684  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10685  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10686 }
10687 
10688 // -----------------------------------------------------------------------------
10689 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10690 void ForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10691 {
10693  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
10694 }
10695 
10696 // -----------------------------------------------------------------------------
10697 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10698 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10699 {
10700  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10701  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10702 }
10703 
10704 //
10705 // Image arguments by reference
10706 //
10707 
10708 // -----------------------------------------------------------------------------
10709 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10710 void ForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10711 {
10714  body(re);
10715  vf.join(body._VoxelFunc);
10716  of.join(body._OutsideFunc);
10717 }
10718 
10719 // -----------------------------------------------------------------------------
10720 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10721 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10722 {
10723  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10724  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
10725 }
10726 
10727 // -----------------------------------------------------------------------------
10728 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10729 void ForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10730 {
10732  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
10733 }
10734 
10735 // -----------------------------------------------------------------------------
10736 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10737 void ForEachScalarIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10738 {
10739  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10740  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
10741 }
10742 
10743 // -----------------------------------------------------------------------------
10744 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10745 void ForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10746 {
10747  if (im6.GetTSize()) {
10748  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
10749  } else {
10751  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
10752  body(re);
10753  vf.join(body._VoxelFunc);
10754  of.join(body._OutsideFunc);
10755  }
10756 }
10757 
10758 // -----------------------------------------------------------------------------
10759 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10760 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10761 {
10762  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10763  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
10764 }
10765 
10766 // -----------------------------------------------------------------------------
10767 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10768 void ForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10769 {
10771  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
10772 }
10773 
10774 // -----------------------------------------------------------------------------
10775 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10776 void ForEachVoxelIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10777 {
10778  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10779  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
10780 }
10781 
10782 // -----------------------------------------------------------------------------
10783 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10784 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10785 {
10787  body(attr);
10788  vf.join(body._VoxelFunc);
10789  of.join(body._OutsideFunc);
10790 }
10791 
10792 // -----------------------------------------------------------------------------
10793 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10794 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10795 {
10796  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10797  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
10798 }
10799 
10800 // -----------------------------------------------------------------------------
10801 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10802 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10803 {
10805  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
10806 }
10807 
10808 // -----------------------------------------------------------------------------
10809 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10810 void ForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10811 {
10812  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10813  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
10814 }
10815 
10816 // -----------------------------------------------------------------------------
10817 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10818 void ForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10819 {
10821  body(re);
10822  vf.join(body._VoxelFunc);
10823  of.join(body._OutsideFunc);
10824 }
10825 
10826 // -----------------------------------------------------------------------------
10827 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10828 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10829 {
10830  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10831  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
10832 }
10833 
10834 // -----------------------------------------------------------------------------
10835 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10836 void ForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10837 {
10839  body(re);
10840  vf.join(body._VoxelFunc);
10841  of.join(body._OutsideFunc);
10842 }
10843 
10844 // -----------------------------------------------------------------------------
10845 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10846 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10847 {
10848  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10849  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
10850 }
10851 
10852 // -----------------------------------------------------------------------------
10853 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10854 void ForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10855 {
10857  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
10858 }
10859 
10860 // -----------------------------------------------------------------------------
10861 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10862 void ForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10863 {
10864  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10865  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
10866 }
10867 
10868 // -----------------------------------------------------------------------------
10869 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10870 void ForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
10871 {
10873  body(re);
10874  vf.join(body._VoxelFunc);
10875  of.join(body._OutsideFunc);
10876 }
10877 
10878 // -----------------------------------------------------------------------------
10879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
10880 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10881 {
10882  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10883  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
10884 }
10885 
10886 // -----------------------------------------------------------------------------
10887 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10888 void ForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
10889 {
10891  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
10892 }
10893 
10894 // -----------------------------------------------------------------------------
10895 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10896 void ForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
10897 {
10898  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10899  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
10900 }
10901 
10902 // -----------------------------------------------------------------------------
10903 // ParallelForEachVoxel
10904 // -----------------------------------------------------------------------------
10905 
10906 //
10907 // Image arguments by pointer
10908 //
10909 
10910 // -----------------------------------------------------------------------------
10911 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10912 void ParallelForEachScalar(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10913 {
10914  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10915  blocked_range<int> re(0, im6->GetNumberOfVoxels());
10916  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
10917  else parallel_for (re, body);
10918 }
10919 
10920 // -----------------------------------------------------------------------------
10921 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10922 void ParallelForEachScalar(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10923 {
10924  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10925  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10926 }
10927 
10928 // -----------------------------------------------------------------------------
10929 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10930 void ParallelForEachVoxel(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10931 {
10932  if (im6->GetTSize()) {
10933  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10934  } else {
10935  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10936  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
10937  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
10938  else parallel_for (re, body);
10939  }
10940 }
10941 
10942 // -----------------------------------------------------------------------------
10943 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10944 void ParallelForEachVoxel(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10945 {
10946  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10947  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10948 }
10949 
10950 // -----------------------------------------------------------------------------
10951 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10952 void ParallelForEachVoxel(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10953 {
10954  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10955  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
10956  if (VoxelFunc::IsReduction()) {
10957  if (attr._dt) {
10958  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
10959  } else {
10960  parallel_reduce(re, body);
10961  }
10962  vf.join(body._VoxelFunc);
10963  } else {
10964  if (attr._dt) {
10965  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
10966  } else {
10967  parallel_for(re, body);
10968  }
10969  }
10970 }
10971 
10972 // -----------------------------------------------------------------------------
10973 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10974 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10975 {
10976  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10977  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10978 }
10979 
10980 // -----------------------------------------------------------------------------
10981 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10982 void ParallelForEachVoxel(const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
10983 {
10984  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
10985  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
10986  else parallel_for (re, body);
10987 }
10988 
10989 // -----------------------------------------------------------------------------
10990 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10991 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
10992 {
10993  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
10994  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
10995 }
10996 
10997 // -----------------------------------------------------------------------------
10998 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
10999 void ParallelForEachVoxel(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11000 {
11001  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
11002  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11003  else parallel_for (re, body);
11004 }
11005 
11006 // -----------------------------------------------------------------------------
11007 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11008 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11009 {
11010  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11011  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11012 }
11013 
11014 // -----------------------------------------------------------------------------
11015 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11016 void ParallelForEachVoxel(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11017 {
11018  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, vf);
11019  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11020  else parallel_for (re, body);
11021 }
11022 
11023 // -----------------------------------------------------------------------------
11024 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11025 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11026 {
11027  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11028  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11029 }
11030 
11031 //
11032 // Image arguments by reference
11033 //
11034 
11035 // -----------------------------------------------------------------------------
11036 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11037 void ParallelForEachScalar(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11038 {
11039  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11041  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11042  else parallel_for (re, body);
11043 }
11044 
11045 // -----------------------------------------------------------------------------
11046 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11047 void ParallelForEachScalar(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11048 {
11049  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11050  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
11051 }
11052 
11053 // -----------------------------------------------------------------------------
11054 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11055 void ParallelForEachVoxel(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11056 {
11057  if (im6.GetTSize()) {
11058  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, vf);
11059  } else {
11060  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11061  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
11062  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11063  else parallel_for (re, body);
11064  }
11065 }
11066 
11067 // -----------------------------------------------------------------------------
11068 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11069 void ParallelForEachVoxel(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11070 {
11071  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11072  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, vf);
11073 }
11074 
11075 // -----------------------------------------------------------------------------
11076 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11077 void ParallelForEachVoxel(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11078 {
11079  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11080  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11081  if (VoxelFunc::IsReduction()) {
11082  if (attr._dt) {
11083  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11084  } else {
11085  parallel_reduce(re, body);
11086  }
11087  vf.join(body._VoxelFunc);
11088  } else {
11089  if (attr._dt) {
11090  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11091  } else {
11092  parallel_for(re, body);
11093  }
11094  }
11095 }
11096 
11097 // -----------------------------------------------------------------------------
11098 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11099 void ParallelForEachVoxel(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11100 {
11101  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11102  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, vf);
11103 }
11104 
11105 // -----------------------------------------------------------------------------
11106 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11107 void ParallelForEachVoxel(const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11108 {
11109  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11110  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11111  else parallel_for (re, body);
11112 }
11113 
11114 // -----------------------------------------------------------------------------
11115 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11116 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11117 {
11118  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11119  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
11120 }
11121 
11122 // -----------------------------------------------------------------------------
11123 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11124 void ParallelForEachVoxel(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11125 {
11126  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11127  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11128  else parallel_for (re, body);
11129 }
11130 
11131 // -----------------------------------------------------------------------------
11132 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11133 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11134 {
11135  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11136  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
11137 }
11138 
11139 // -----------------------------------------------------------------------------
11140 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11141 void ParallelForEachVoxel(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11142 {
11143  SenaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, VoxelFunc> body(im1, im2, im3, im4, im5, im6, vf);
11144  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11145  else parallel_for (re, body);
11146 }
11147 
11148 // -----------------------------------------------------------------------------
11149 template <class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11150 void ParallelForEachVoxel(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11151 {
11152  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11153  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, vf);
11154 }
11155 
11156 // -----------------------------------------------------------------------------
11157 // ParallelForEachVoxelIf
11158 // -----------------------------------------------------------------------------
11159 
11160 //
11161 // Image arguments by pointer
11162 //
11163 
11164 // -----------------------------------------------------------------------------
11165 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11166 void ParallelForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11167 {
11168  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11169  blocked_range<int> re(0, im6->GetNumberOfVoxels());
11170  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11171  parallel_reduce(re, body);
11172  vf.join(body._VoxelFunc);
11173  of.join(body._OutsideFunc);
11174  } else {
11175  parallel_for(re, body);
11176  }
11177 }
11178 
11179 // -----------------------------------------------------------------------------
11180 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11181 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11182 {
11183  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11184  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11185 }
11186 
11187 // -----------------------------------------------------------------------------
11188 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11189 void ParallelForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11190 {
11192  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11193 }
11194 
11195 // -----------------------------------------------------------------------------
11196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11197 void ParallelForEachScalarIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11198 {
11199  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11200  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
11201 }
11202 
11203 // -----------------------------------------------------------------------------
11204 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11205 void ParallelForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11206 {
11207  if (im6->GetTSize()) {
11208  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11209  } else {
11210  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11211  blocked_range<int> re(0, im6->GetNumberOfVoxels() / im6->GetT());
11212  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11213  parallel_reduce(re, body);
11214  vf.join(body._VoxelFunc);
11215  of.join(body._OutsideFunc);
11216  } else {
11217  parallel_for(re, body);
11218  }
11219  }
11220 }
11221 
11222 // -----------------------------------------------------------------------------
11223 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11224 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11225 {
11226  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11227  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11228 }
11229 
11230 // -----------------------------------------------------------------------------
11231 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11232 void ParallelForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11233 {
11235  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11236 }
11237 
11238 // -----------------------------------------------------------------------------
11239 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11240 void ParallelForEachVoxelIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11241 {
11242  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11243  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, vf);
11244 }
11245 
11246 // -----------------------------------------------------------------------------
11247 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11248 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11249 {
11250  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11251  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11252  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11253  if (attr._dt) {
11254  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11255  } else {
11256  parallel_reduce(re, body);
11257  }
11258  vf.join(body._VoxelFunc);
11259  of.join(body._OutsideFunc);
11260  } else {
11261  if (attr._dt) {
11262  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11263  } else {
11264  parallel_for(re, body);
11265  }
11266  }
11267 }
11268 
11269 // -----------------------------------------------------------------------------
11270 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11271 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11272 {
11273  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11274  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11275 }
11276 
11277 // -----------------------------------------------------------------------------
11278 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11279 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11280 {
11282  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11283 }
11284 
11285 // -----------------------------------------------------------------------------
11286 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11287 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11288 {
11289  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11290  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11291 }
11292 
11293 // -----------------------------------------------------------------------------
11294 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11295 void ParallelForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11296 {
11297  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11298  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11299  parallel_reduce(re, body);
11300  vf.join(body._VoxelFunc);
11301  of.join(body._OutsideFunc);
11302  } else {
11303  parallel_for(re, body);
11304  }
11305 }
11306 
11307 // -----------------------------------------------------------------------------
11308 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11309 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11310 {
11311  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11312  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11313 }
11314 
11315 // -----------------------------------------------------------------------------
11316 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11317 void ParallelForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11318 {
11320  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11321 }
11322 
11323 // -----------------------------------------------------------------------------
11324 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11325 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11326 {
11327  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11328  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11329 }
11330 
11331 // -----------------------------------------------------------------------------
11332 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11333 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11334 {
11335  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11336  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11337  parallel_reduce(re, body);
11338  vf.join(body._VoxelFunc);
11339  of.join(body._OutsideFunc);
11340  } else {
11341  parallel_for(re, body);
11342  }
11343 }
11344 
11345 // -----------------------------------------------------------------------------
11346 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11347 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11348 {
11349  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11350  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11351 }
11352 
11353 // -----------------------------------------------------------------------------
11354 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11355 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11356 {
11358  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11359 }
11360 
11361 // -----------------------------------------------------------------------------
11362 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11363 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11364 {
11365  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11366  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11367 }
11368 
11369 // -----------------------------------------------------------------------------
11370 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11371 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf, OutsideFunc &of)
11372 {
11373  SenaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11374  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11375  parallel_reduce(re, body);
11376  vf.join(body._VoxelFunc);
11377  of.join(body._OutsideFunc);
11378  } else {
11379  parallel_for(re, body);
11380  }
11381 }
11382 
11383 // -----------------------------------------------------------------------------
11384 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11385 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11386 {
11387  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11388  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11389 }
11390 
11391 // -----------------------------------------------------------------------------
11392 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11393 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, VoxelFunc &vf)
11394 {
11396  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf, of);
11397 }
11398 
11399 // -----------------------------------------------------------------------------
11400 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11401 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6)
11402 {
11403  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11404  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, vf);
11405 }
11406 
11407 //
11408 // Image arguments by reference
11409 //
11410 
11411 // -----------------------------------------------------------------------------
11412 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11413 void ParallelForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11414 {
11417  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11418  parallel_reduce(re, body);
11419  vf.join(body._VoxelFunc);
11420  of.join(body._OutsideFunc);
11421  } else {
11422  parallel_for(re, body);
11423  }
11424 }
11425 
11426 // -----------------------------------------------------------------------------
11427 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11428 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11429 {
11430  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11431  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
11432 }
11433 
11434 // -----------------------------------------------------------------------------
11435 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11436 void ParallelForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11437 {
11439  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
11440 }
11441 
11442 // -----------------------------------------------------------------------------
11443 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11444 void ParallelForEachScalarIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11445 {
11446  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11447  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
11448 }
11449 
11450 // -----------------------------------------------------------------------------
11451 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11452 void ParallelForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11453 {
11454  if (im6.GetTSize()) {
11455  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
11456  } else {
11458  blocked_range<int> re(0, im6.GetNumberOfVoxels() / im6.GetT());
11459  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11460  parallel_reduce(re, body);
11461  vf.join(body._VoxelFunc);
11462  of.join(body._OutsideFunc);
11463  } else {
11464  parallel_for(re, body);
11465  }
11466  }
11467 }
11468 
11469 // -----------------------------------------------------------------------------
11470 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11471 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11472 {
11473  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11474  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
11475 }
11476 
11477 // -----------------------------------------------------------------------------
11478 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11479 void ParallelForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11480 {
11482  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf, of);
11483 }
11484 
11485 // -----------------------------------------------------------------------------
11486 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11487 void ParallelForEachVoxelIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11488 {
11489  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11490  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, vf);
11491 }
11492 
11493 // -----------------------------------------------------------------------------
11494 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11495 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11496 {
11498  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11499  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11500  if (attr._dt) {
11501  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11502  } else {
11503  parallel_reduce(re, body);
11504  }
11505  vf.join(body._VoxelFunc);
11506  of.join(body._OutsideFunc);
11507  } else {
11508  if (attr._dt) {
11509  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11510  } else {
11511  parallel_for(re, body);
11512  }
11513  }
11514 }
11515 
11516 // -----------------------------------------------------------------------------
11517 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11518 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11519 {
11520  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11521  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
11522 }
11523 
11524 // -----------------------------------------------------------------------------
11525 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11526 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11527 {
11529  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf, of);
11530 }
11531 
11532 // -----------------------------------------------------------------------------
11533 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11534 void ParallelForEachVoxelIf(VoxelFunc vf, const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11535 {
11536  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11537  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, vf);
11538 }
11539 
11540 // -----------------------------------------------------------------------------
11541 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11542 void ParallelForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11543 {
11545  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11546  parallel_reduce(re, body);
11547  vf.join(body._VoxelFunc);
11548  of.join(body._OutsideFunc);
11549  } else {
11550  parallel_for(re, body);
11551  }
11552 }
11553 
11554 // -----------------------------------------------------------------------------
11555 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11556 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11557 {
11558  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11559  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11560 }
11561 
11562 // -----------------------------------------------------------------------------
11563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11564 void ParallelForEachVoxelIf(const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11565 {
11567  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11568 }
11569 
11570 // -----------------------------------------------------------------------------
11571 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11572 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11573 {
11574  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11575  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
11576 }
11577 
11578 // -----------------------------------------------------------------------------
11579 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11580 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11581 {
11583  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11584  parallel_reduce(re, body);
11585  vf.join(body._VoxelFunc);
11586  of.join(body._OutsideFunc);
11587  } else {
11588  parallel_for(re, body);
11589  }
11590 }
11591 
11592 // -----------------------------------------------------------------------------
11593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11594 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11595 {
11596  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11597  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11598 }
11599 
11600 // -----------------------------------------------------------------------------
11601 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11602 void ParallelForEachVoxelIf(const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11603 {
11605  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11606 }
11607 
11608 // -----------------------------------------------------------------------------
11609 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11610 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range2d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11611 {
11612  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11613  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
11614 }
11615 
11616 // -----------------------------------------------------------------------------
11617 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11618 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf, OutsideFunc &of)
11619 {
11621  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11622  parallel_reduce(re, body);
11623  vf.join(body._VoxelFunc);
11624  of.join(body._OutsideFunc);
11625  } else {
11626  parallel_for(re, body);
11627  }
11628 }
11629 
11630 // -----------------------------------------------------------------------------
11631 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc, class OutsideFunc>
11632 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11633 {
11634  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11635  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11636 }
11637 
11638 // -----------------------------------------------------------------------------
11639 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11640 void ParallelForEachVoxelIf(const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, VoxelFunc &vf)
11641 {
11643  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf, of);
11644 }
11645 
11646 // -----------------------------------------------------------------------------
11647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class VoxelFunc>
11648 void ParallelForEachVoxelIf(VoxelFunc vf, const blocked_range3d<int> &re, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6)
11649 {
11650  if (VoxelFunc::IsReduction()) _foreachsenaryvoxelfunction_must_not_be_reduction();
11651  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, vf);
11652 }
11653 
11654 
11655 } // namespace mirtk
11656 
11657 #endif
double _dt
Voxel t-dimensions (in ms)
Dummy type used to distinguish split constructor from copy constructor.
Definition: Parallel.h:143
SenaryForEachVoxelBody_Const(const SenaryForEachVoxelBody_Const &o)
Copy constructor.
SenaryForEachVoxelBody_Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
SenaryForEachVoxelIfBody_1Const(const SenaryForEachVoxelIfBody_1Const &o)
Copy constructor.
SenaryForEachVoxelBody_4Const(const SenaryForEachVoxelBody_4Const &o)
Copy constructor.
Two-dimensional range.
Definition: Parallel.h:168
SenaryForEachVoxelIfBody_5Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
bool IsEmpty() const
Whether image is uninitialized.
Definition: BaseImage.h:1283
SenaryForEachVoxelIfBody_3Const(SenaryForEachVoxelIfBody_3Const &o, split s)
Split constructor.
SenaryForEachVoxelIfBody_Const(const SenaryForEachVoxelIfBody_Const &o)
Copy constructor.
SenaryForEachVoxelBody_2Const(const SenaryForEachVoxelBody_2Const &o)
Copy constructor.
SenaryForEachVoxelBody_1Const(const GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
SenaryForEachVoxelBody_4Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
int _y
Image y-dimension (in voxels)
SenaryForEachVoxelIfBody_3Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
SenaryForEachVoxelBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
SenaryForEachVoxelBody_3Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
SenaryForEachVoxelBody_5Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
One-dimensional range.
Definition: Parallel.h:155
VoxelFunc _VoxelFunc
Functor executed for each voxel.
SenaryForEachVoxelIfBody_Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
SenaryForEachVoxelIfBody_2Const(SenaryForEachVoxelIfBody_2Const &o, split s)
Split constructor.
SenaryForEachVoxelBody_5Const(const SenaryForEachVoxelBody_5Const &o)
Copy constructor.
SenaryForEachVoxelBody(const SenaryForEachVoxelBody &o)
Copy constructor.
SenaryForEachVoxelIfBody_2Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
SenaryForEachVoxelBody_2Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf)
Constructor.
void operator()(const ImageAttributes &attr) const
Process entire image.
SenaryForEachVoxelBody_Const(SenaryForEachVoxelBody_Const &o, split s)
Split constructor.
Definition: IOConfig.h:41
SenaryForEachVoxelIfBody_1Const(SenaryForEachVoxelIfBody_1Const &o, split s)
Split constructor.
VoxelType * GetPointerToVoxels(int=0, int=0, int=0, int=0)
Definition: GenericImage.h:849
int GetX() const
Returns the number of voxels in the x-direction.
Definition: BaseImage.h:904
int _z
Image z-dimension (in voxels)
SenaryForEachVoxelBody(SenaryForEachVoxelBody &o, split s)
Split constructor.
int _l
Indices for fixed dimensions.
int _t
Image t-dimension (in voxels)
int GetT() const
Returns the number of voxels in the t-direction.
Definition: BaseImage.h:922
SenaryForEachVoxelIfBody_1Const(const GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
SenaryForEachVoxelIfBody(SenaryForEachVoxelIfBody &o, split s)
Split constructor.
int GetY() const
Returns the number of voxels in the y-direction.
Definition: BaseImage.h:910
SenaryForEachVoxelBody_1Const(const SenaryForEachVoxelBody_1Const &o)
Copy constructor.
SenaryForEachVoxelBody_5Const(SenaryForEachVoxelBody_5Const &o, split s)
Split constructor.
Three-dimensional range.
Definition: Parallel.h:197
int GetNumberOfVoxels() const
Definition: BaseImage.h:1741
SenaryForEachVoxelIfBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OutsideFunc _OutsideFunc
Functor executed for each background voxel.
SenaryForEachVoxelIfBody_Const(SenaryForEachVoxelIfBody_Const &o, split s)
Split constructor.
SenaryForEachVoxelIfBody_4Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, VoxelFunc &vf, OutsideFunc &of)
Constructor.
SenaryForEachVoxelIfBody_4Const(const SenaryForEachVoxelIfBody_4Const &o)
Copy constructor.
SenaryForEachVoxelBody_1Const(SenaryForEachVoxelBody_1Const &o, split s)
Split constructor.
SenaryForEachVoxelBody_3Const(const SenaryForEachVoxelBody_3Const &o)
Copy constructor.
double GetTSize() const
Returns the size of a voxel in the t-direction.
Definition: BaseImage.h:970
SenaryForEachVoxelIfBody_2Const(const SenaryForEachVoxelIfBody_2Const &o)
Copy constructor.
SenaryForEachVoxelBody_2Const(SenaryForEachVoxelBody_2Const &o, split s)
Split constructor.
SenaryForEachVoxelIfBody(const SenaryForEachVoxelIfBody &o)
Copy constructor.
SenaryForEachVoxelIfBody_4Const(SenaryForEachVoxelIfBody_4Const &o, split s)
Split constructor.
SenaryForEachVoxelIfBody_5Const(SenaryForEachVoxelIfBody_5Const &o, split s)
Split constructor.
int _x
Image x-dimension (in voxels)
SenaryForEachVoxelIfBody_3Const(const SenaryForEachVoxelIfBody_3Const &o)
Copy constructor.
void parallel_reduce(const Range &range, Body &body)
parallel_reduce dummy template function which executes the body serially
Definition: Parallel.h:238
SenaryForEachVoxelIfBody_5Const(const SenaryForEachVoxelIfBody_5Const &o)
Copy constructor.
void parallel_for(const Range &range, const Body &body)
parallel_for dummy template function which executes the body serially
Definition: Parallel.h:232
SenaryForEachVoxelBody_3Const(SenaryForEachVoxelBody_3Const &o, split s)
Split constructor.
SenaryForEachVoxelBody_4Const(SenaryForEachVoxelBody_4Const &o, split s)
Split constructor.