ForEachNonaryVoxelFunction.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_ForEachNonaryVoxelFunction_H
31 #define MIRTK_ForEachNonaryVoxelFunction_H
32 
33 #include "mirtk/Stream.h"
34 #include "mirtk/VoxelFunction.h"
35 
36 
37 namespace mirtk {
38 
39 
40 inline void _foreachnonaryvoxelfunction_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 // 9 const images
50 // =============================================================================
51 
52 // -----------------------------------------------------------------------------
53 /**
54  * ForEachVoxel body for voxel function of 9 const images
55  */
56 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, 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  const GenericImage<T7> &im7;
66  const GenericImage<T8> &im8;
67  const GenericImage<T9> &im9;
68 
69  /// Constructor
71  const GenericImage<T2> &im2,
72  const GenericImage<T3> &im3,
73  const GenericImage<T4> &im4,
74  const GenericImage<T5> &im5,
75  const GenericImage<T6> &im6,
76  const GenericImage<T7> &im7,
77  const GenericImage<T8> &im8,
78  const GenericImage<T9> &im9,
79  VoxelFunc &vf)
80  :
81  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
82  {}
83 
84  /// Copy constructor
86  :
87  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
88  {}
89 
90  /// Split constructor
92  :
93  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
94  {}
95 
96  /// Process entire image
97  void operator ()(const ImageAttributes &attr) const
98  {
99  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
100  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
101  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
102  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
103  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
104  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
105  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
106  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
107  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
108 
109  const int T = (attr._dt ? attr._t : 1);
110 
111  for (int l = 0; l < T; ++l)
112  for (int k = 0; k < attr._z; ++k)
113  for (int j = 0; j < attr._y; ++j)
114  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
115  // const_cast such that voxel functions need only implement
116  // non-const operator() which is required for parallel_reduce
117  const_cast<NonaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
118  }
119  }
120 
121  /// Process image region using linear index
122  void operator ()(const blocked_range<int> &re) const
123  {
124  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
125  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
126  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
127  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
128  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
129  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
130  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
131  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
132  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
133 
134  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
135  // const_cast such that voxel functions need only implement
136  // non-const operator() which is required for parallel_reduce
137  const_cast<NonaryForEachVoxelBody_Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
138  }
139  }
140 
141  /// Process 2D image region
142  void operator ()(const blocked_range2d<int> &re) const
143  {
144  const int bi = re.cols().begin();
145  const int bj = re.rows().begin();
146  const int ei = re.cols().end();
147  const int ej = re.rows().end();
148 
149  const int s1 = im9.GetX() - (ei - bi);
150 
151  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
152  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
153  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
154  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
155  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
156  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
157  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
158  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
159  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
160 
161  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
162  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
163  // const_cast such that voxel functions need only implement
164  // non-const operator() which is required for parallel_reduce
165  const_cast<NonaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
166  }
167  }
168 
169  /// Process 3D image region
170  void operator ()(const blocked_range3d<int> &re) const
171  {
172  const int bi = re.cols ().begin();
173  const int bj = re.rows ().begin();
174  const int bk = re.pages().begin();
175  const int ei = re.cols ().end();
176  const int ej = re.rows ().end();
177  const int ek = re.pages().end();
178 
179  const int s1 = im9.GetX() - (ei - bi);
180  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
181 
182  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
183  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
184  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
185  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
186  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
187  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
188  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
189  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
190  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
191 
192  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
193  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
194  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
195  // const_cast such that voxel functions need only implement
196  // non-const operator() which is required for parallel_reduce
197  const_cast<NonaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
198  }
199  }
200 };
201 
202 // -----------------------------------------------------------------------------
203 /**
204  * ForEachVoxel body for inside and outside unary voxel function of 9 const images
205  */
206 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
207  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
208  class Domain = ForEachVoxelDomain::Foreground>
209 struct NonaryForEachVoxelIfBody_Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
210 {
211  const GenericImage<T1> &im1;
212  const GenericImage<T2> &im2;
213  const GenericImage<T3> &im3;
214  const GenericImage<T4> &im4;
215  const GenericImage<T5> &im5;
216  const GenericImage<T6> &im6;
217  const GenericImage<T7> &im7;
218  const GenericImage<T8> &im8;
219  const GenericImage<T9> &im9;
220 
221  /// Constructor
223  const GenericImage<T2> &im2,
224  const GenericImage<T3> &im3,
225  const GenericImage<T4> &im4,
226  const GenericImage<T5> &im5,
227  const GenericImage<T6> &im6,
228  const GenericImage<T7> &im7,
229  const GenericImage<T8> &im8,
230  const GenericImage<T9> &im9,
231  VoxelFunc &vf, OutsideFunc &of)
232  :
233  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
234  {}
235 
236  /// Copy constructor
238  :
239  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
240  {}
241 
242  /// Split constructor
244  :
245  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
246  {}
247 
248  /// Process entire image
249  void operator ()(const ImageAttributes &attr) const
250  {
251  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
252  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
253  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
254  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
255  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
256  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
257  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
258  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
259  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
260 
261  const int T = (attr._dt ? attr._t : 1);
262 
263  for (int l = 0; l < T; ++l)
264  for (int k = 0; k < attr._z; ++k)
265  for (int j = 0; j < attr._y; ++j)
266  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
267  if (Domain::IsInside(im9, i, j, k, l, p9)) {
268  // const_cast such that voxel functions need only implement
269  // non-const operator() which is required for parallel_reduce
270  const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
271  } else const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
272  }
273  }
274 
275  /// Process image region using linear index
276  void operator ()(const blocked_range<int> &re) const
277  {
278  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
279  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
280  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
281  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
282  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
283  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
284  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
285  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
286  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
287 
288  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
289  if (Domain::IsInside(im9, idx, p9)) {
290  // const_cast such that voxel functions need only implement
291  // non-const operator() which is required for parallel_reduce
292  const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
293  } else const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
294  }
295  }
296 
297  /// Process 2D image region
298  void operator ()(const blocked_range2d<int> &re) const
299  {
300  const int bi = re.cols().begin();
301  const int bj = re.rows().begin();
302  const int ei = re.cols().end();
303  const int ej = re.rows().end();
304 
305  const int s1 = im9.GetX() - (ei - bi);
306 
307  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
308  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
309  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
310  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
311  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
312  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
313  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
314  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
315  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
316 
317  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
318  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
319  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
320  // const_cast such that voxel functions need only implement
321  // non-const operator() which is required for parallel_reduce
322  const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
323  } else const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
324  }
325  }
326 
327  /// Process 3D image region
328  void operator ()(const blocked_range3d<int> &re) const
329  {
330  const int bi = re.cols ().begin();
331  const int bj = re.rows ().begin();
332  const int bk = re.pages().begin();
333  const int ei = re.cols ().end();
334  const int ej = re.rows ().end();
335  const int ek = re.pages().end();
336 
337  const int s1 = im9.GetX() - (ei - bi);
338  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
339 
340  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
341  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
342  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
343  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
344  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
345  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
346  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
347  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
348  const T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
349 
350  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
351  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
352  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
353  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
354  // const_cast such that voxel functions need only implement
355  // non-const operator() which is required for parallel_reduce
356  const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
357  } else const_cast<NonaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
358  }
359  }
360 };
361 
362 // -----------------------------------------------------------------------------
363 // ForEachVoxel
364 // -----------------------------------------------------------------------------
365 
366 //
367 // Image arguments by pointer
368 //
369 
370 // -----------------------------------------------------------------------------
371 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
372 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
373 {
374  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
376  body(re);
377  vf.join(body._VoxelFunc);
378 }
379 
380 // -----------------------------------------------------------------------------
381 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
382 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
383 {
384  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
385  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
386 }
387 
388 // -----------------------------------------------------------------------------
389 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
390 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
391 {
392  if (im9->GetTSize()) {
393  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
394  } else {
395  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
396  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
397  body(re);
398  vf.join(body._VoxelFunc);
399  }
400 }
401 
402 // -----------------------------------------------------------------------------
403 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
404 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
405 {
406  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
407  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
408 }
409 
410 // -----------------------------------------------------------------------------
411 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
412 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
413 {
414  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
415  body(attr);
416  vf.join(body._VoxelFunc);
417 }
418 
419 // -----------------------------------------------------------------------------
420 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
421 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
422 {
423  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
424  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
425 }
426 
427 // -----------------------------------------------------------------------------
428 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
429 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
430 {
431  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
432  body(re);
433  vf.join(body._VoxelFunc);
434 }
435 
436 // -----------------------------------------------------------------------------
437 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
438 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
439 {
440  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
441  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
442 }
443 
444 // -----------------------------------------------------------------------------
445 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
446 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
447 {
448  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
449  body(re);
450  vf.join(body._VoxelFunc);
451 }
452 
453 // -----------------------------------------------------------------------------
454 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
455 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
456 {
457  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
458  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
459 }
460 
461 // -----------------------------------------------------------------------------
462 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
463 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
464 {
465  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
466  body(re);
467  vf.join(body._VoxelFunc);
468 }
469 
470 // -----------------------------------------------------------------------------
471 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
472 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
473 {
474  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
475  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
476 }
477 
478 //
479 // Image arguments by reference
480 //
481 
482 // -----------------------------------------------------------------------------
483 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
484 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
485 {
486  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
488  body(re);
489  vf.join(body._VoxelFunc);
490 }
491 
492 // -----------------------------------------------------------------------------
493 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
494 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
495 {
496  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
497  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
498 }
499 
500 // -----------------------------------------------------------------------------
501 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
502 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
503 {
504  if (im9.GetTSize()) {
505  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
506  } else {
507  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
508  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
509  body(re);
510  vf.join(body._VoxelFunc);
511  }
512 }
513 
514 // -----------------------------------------------------------------------------
515 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
516 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
517 {
518  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
519  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
520 }
521 
522 // -----------------------------------------------------------------------------
523 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
524 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
525 {
526  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
527  body(attr);
528  vf.join(body._VoxelFunc);
529 }
530 
531 // -----------------------------------------------------------------------------
532 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
533 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
534 {
535  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
536  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
537 }
538 
539 // -----------------------------------------------------------------------------
540 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
541 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
542 {
543  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
544  body(re);
545  vf.join(body._VoxelFunc);
546 }
547 
548 // -----------------------------------------------------------------------------
549 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
550 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
551 {
552  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
553  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
554 }
555 
556 // -----------------------------------------------------------------------------
557 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
558 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
559 {
560  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
561  body(re);
562  vf.join(body._VoxelFunc);
563 }
564 
565 // -----------------------------------------------------------------------------
566 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
567 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
568 {
569  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
570  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
571 }
572 
573 // -----------------------------------------------------------------------------
574 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
575 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
576 {
577  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
578  body(re);
579  vf.join(body._VoxelFunc);
580 }
581 
582 // -----------------------------------------------------------------------------
583 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
584 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
585 {
586  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
587  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
588 }
589 
590 // -----------------------------------------------------------------------------
591 // ForEachVoxelIf
592 // -----------------------------------------------------------------------------
593 
594 //
595 // Image arguments by pointer
596 //
597 
598 // -----------------------------------------------------------------------------
599 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
600 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
601 {
602  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
604  body(re);
605  vf.join(body._VoxelFunc);
606  of.join(body._OutsideFunc);
607 }
608 
609 // -----------------------------------------------------------------------------
610 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
611 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
612 {
613  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
614  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
615 }
616 
617 // -----------------------------------------------------------------------------
618 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
619 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
620 {
622  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
623 }
624 
625 // -----------------------------------------------------------------------------
626 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
627 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
628 {
629  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
630  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
631 }
632 
633 // -----------------------------------------------------------------------------
634 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
635 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
636 {
637  if (im9->GetTSize()) {
638  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
639  } else {
640  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
641  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
642  body(re);
643  vf.join(body._VoxelFunc);
644  of.join(body._OutsideFunc);
645  }
646 }
647 
648 // -----------------------------------------------------------------------------
649 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
650 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
651 {
652  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
653  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
654 }
655 
656 // -----------------------------------------------------------------------------
657 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
658 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
659 {
661  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
662 }
663 
664 // -----------------------------------------------------------------------------
665 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
666 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
667 {
668  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
669  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
670 }
671 
672 // -----------------------------------------------------------------------------
673 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
674 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
675 {
676  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
677  body(attr);
678  vf.join(body._VoxelFunc);
679  of.join(body._OutsideFunc);
680 }
681 
682 // -----------------------------------------------------------------------------
683 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
684 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
685 {
686  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
687  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
688 }
689 
690 // -----------------------------------------------------------------------------
691 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
692 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
693 {
695  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
696 }
697 
698 // -----------------------------------------------------------------------------
699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
700 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
701 {
702  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
703  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
704 }
705 
706 // -----------------------------------------------------------------------------
707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
708 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
709 {
710  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
711  body(re);
712  vf.join(body._VoxelFunc);
713  of.join(body._OutsideFunc);
714 }
715 
716 // -----------------------------------------------------------------------------
717 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
718 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
719 {
720  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
721  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
722 }
723 
724 // -----------------------------------------------------------------------------
725 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
726 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
727 {
728  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
729  body(re);
730  vf.join(body._VoxelFunc);
731  of.join(body._OutsideFunc);
732 }
733 
734 // -----------------------------------------------------------------------------
735 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
736 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
737 {
738  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
739  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
740 }
741 
742 // -----------------------------------------------------------------------------
743 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
744 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
745 {
747  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
748 }
749 
750 // -----------------------------------------------------------------------------
751 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
752 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
753 {
754  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
755  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
756 }
757 
758 // -----------------------------------------------------------------------------
759 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
760 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
761 {
762  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
763  body(re);
764  vf.join(body._VoxelFunc);
765  of.join(body._OutsideFunc);
766 }
767 
768 // -----------------------------------------------------------------------------
769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
770 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
771 {
772  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
773  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
774 }
775 
776 // -----------------------------------------------------------------------------
777 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
778 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
779 {
781  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
782 }
783 
784 // -----------------------------------------------------------------------------
785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
786 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
787 {
788  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
789  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
790 }
791 
792 //
793 // Image arguments by reference
794 //
795 
796 // -----------------------------------------------------------------------------
797 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
798 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
799 {
800  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
802  body(re);
803  vf.join(body._VoxelFunc);
804  of.join(body._OutsideFunc);
805 }
806 
807 // -----------------------------------------------------------------------------
808 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
809 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
810 {
811  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
812  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
813 }
814 
815 // -----------------------------------------------------------------------------
816 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
817 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
818 {
820  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
821 }
822 
823 // -----------------------------------------------------------------------------
824 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
825 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
826 {
827  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
828  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
829 }
830 
831 // -----------------------------------------------------------------------------
832 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
833 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
834 {
835  if (im9.GetTSize()) {
836  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
837  } else {
838  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
839  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
840  body(re);
841  vf.join(body._VoxelFunc);
842  of.join(body._OutsideFunc);
843  }
844 }
845 
846 // -----------------------------------------------------------------------------
847 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
848 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
849 {
850  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
851  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
852 }
853 
854 // -----------------------------------------------------------------------------
855 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
856 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
857 {
859  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
860 }
861 
862 // -----------------------------------------------------------------------------
863 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
864 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
865 {
866  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
867  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
868 }
869 
870 // -----------------------------------------------------------------------------
871 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
872 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
873 {
874  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
875  body(attr);
876  vf.join(body._VoxelFunc);
877  of.join(body._OutsideFunc);
878 }
879 
880 // -----------------------------------------------------------------------------
881 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
882 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
883 {
884  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
885  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
886 }
887 
888 // -----------------------------------------------------------------------------
889 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
890 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
891 {
893  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
894 }
895 
896 // -----------------------------------------------------------------------------
897 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
898 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
899 {
900  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
901  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
902 }
903 
904 // -----------------------------------------------------------------------------
905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
906 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
907 {
908  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
909  body(re);
910  vf.join(body._VoxelFunc);
911  of.join(body._OutsideFunc);
912 }
913 
914 // -----------------------------------------------------------------------------
915 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
916 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
917 {
918  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
919  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
920 }
921 
922 // -----------------------------------------------------------------------------
923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
924 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
925 {
926  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
927  body(re);
928  vf.join(body._VoxelFunc);
929  of.join(body._OutsideFunc);
930 }
931 
932 // -----------------------------------------------------------------------------
933 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
934 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
935 {
936  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
937  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
938 }
939 
940 // -----------------------------------------------------------------------------
941 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
942 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
943 {
945  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
946 }
947 
948 // -----------------------------------------------------------------------------
949 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
950 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
951 {
952  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
953  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
954 }
955 
956 // -----------------------------------------------------------------------------
957 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
958 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
959 {
960  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
961  body(re);
962  vf.join(body._VoxelFunc);
963  of.join(body._OutsideFunc);
964 }
965 
966 // -----------------------------------------------------------------------------
967 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
968 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
969 {
970  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
971  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
972 }
973 
974 // -----------------------------------------------------------------------------
975 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
976 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
977 {
979  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
980 }
981 
982 // -----------------------------------------------------------------------------
983 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
984 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
985 {
986  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
987  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
988 }
989 
990 // -----------------------------------------------------------------------------
991 // ParallelForEachVoxel
992 // -----------------------------------------------------------------------------
993 
994 //
995 // Image arguments by pointer
996 //
997 
998 // -----------------------------------------------------------------------------
999 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1000 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1001 {
1002  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1003  blocked_range<int> re(0, im9->GetNumberOfVoxels());
1004  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1005  else parallel_for (re, body);
1006 }
1007 
1008 // -----------------------------------------------------------------------------
1009 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1010 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1011 {
1012  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1013  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1014 }
1015 
1016 // -----------------------------------------------------------------------------
1017 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1018 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1019 {
1020  if (im9->GetTSize()) {
1021  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1022  } else {
1023  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1024  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
1025  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1026  else parallel_for (re, body);
1027  }
1028 }
1029 
1030 // -----------------------------------------------------------------------------
1031 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1032 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1033 {
1034  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1035  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1036 }
1037 
1038 // -----------------------------------------------------------------------------
1039 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1040 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1041 {
1042  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1043  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1044  if (VoxelFunc::IsReduction()) {
1045  if (attr._dt) {
1046  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1047  } else {
1048  parallel_reduce(re, body);
1049  }
1050  vf.join(body._VoxelFunc);
1051  } else {
1052  if (attr._dt) {
1053  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1054  } else {
1055  parallel_for(re, body);
1056  }
1057  }
1058 }
1059 
1060 // -----------------------------------------------------------------------------
1061 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1062 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1063 {
1064  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1065  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1066 }
1067 
1068 // -----------------------------------------------------------------------------
1069 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1070 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1071 {
1072  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1073  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1074  else parallel_for (re, body);
1075 }
1076 
1077 // -----------------------------------------------------------------------------
1078 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1079 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1080 {
1081  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1082  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1083 }
1084 
1085 // -----------------------------------------------------------------------------
1086 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1087 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1088 {
1089  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1090  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1091  else parallel_for (re, body);
1092 }
1093 
1094 // -----------------------------------------------------------------------------
1095 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1096 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1097 {
1098  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1099  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1100 }
1101 
1102 // -----------------------------------------------------------------------------
1103 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1104 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1105 {
1106  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1107  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1108  else parallel_for (re, body);
1109 }
1110 
1111 // -----------------------------------------------------------------------------
1112 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1113 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1114 {
1115  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1116  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1117 }
1118 
1119 //
1120 // Image arguments by reference
1121 //
1122 
1123 // -----------------------------------------------------------------------------
1124 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1125 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1126 {
1127  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1129  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1130  else parallel_for (re, body);
1131 }
1132 
1133 // -----------------------------------------------------------------------------
1134 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1135 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1136 {
1137  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1138  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1139 }
1140 
1141 // -----------------------------------------------------------------------------
1142 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1143 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1144 {
1145  if (im9.GetTSize()) {
1146  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1147  } else {
1148  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1149  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
1150  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1151  else parallel_for (re, body);
1152  }
1153 }
1154 
1155 // -----------------------------------------------------------------------------
1156 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1157 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1158 {
1159  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1160  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1161 }
1162 
1163 // -----------------------------------------------------------------------------
1164 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1165 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1166 {
1167  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1168  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1169  if (VoxelFunc::IsReduction()) {
1170  if (attr._dt) {
1171  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1172  } else {
1173  parallel_reduce(re, body);
1174  }
1175  vf.join(body._VoxelFunc);
1176  } else {
1177  if (attr._dt) {
1178  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1179  } else {
1180  parallel_for(re, body);
1181  }
1182  }
1183 }
1184 
1185 // -----------------------------------------------------------------------------
1186 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1187 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1188 {
1189  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1190  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1191 }
1192 
1193 // -----------------------------------------------------------------------------
1194 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1195 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1196 {
1197  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1198  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1199  else parallel_for (re, body);
1200 }
1201 
1202 // -----------------------------------------------------------------------------
1203 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1204 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1205 {
1206  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1207  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1208 }
1209 
1210 // -----------------------------------------------------------------------------
1211 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1212 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1213 {
1214  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1215  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1216  else parallel_for (re, body);
1217 }
1218 
1219 // -----------------------------------------------------------------------------
1220 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1221 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1222 {
1223  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1224  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1225 }
1226 
1227 // -----------------------------------------------------------------------------
1228 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1229 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1230 {
1231  NonaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1232  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1233  else parallel_for (re, body);
1234 }
1235 
1236 // -----------------------------------------------------------------------------
1237 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1238 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1239 {
1240  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1241  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1242 }
1243 
1244 // -----------------------------------------------------------------------------
1245 // ParallelForEachVoxelIf
1246 // -----------------------------------------------------------------------------
1247 
1248 //
1249 // Image arguments by pointer
1250 //
1251 
1252 // -----------------------------------------------------------------------------
1253 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1254 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1255 {
1256  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1257  blocked_range<int> re(0, im9->GetNumberOfVoxels());
1258  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1259  parallel_reduce(re, body);
1260  vf.join(body._VoxelFunc);
1261  of.join(body._OutsideFunc);
1262  } else {
1263  parallel_for(re, body);
1264  }
1265 }
1266 
1267 // -----------------------------------------------------------------------------
1268 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1269 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1270 {
1271  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1272  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1273 }
1274 
1275 // -----------------------------------------------------------------------------
1276 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1277 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1278 {
1280  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1281 }
1282 
1283 // -----------------------------------------------------------------------------
1284 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1285 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1286 {
1287  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1288  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1289 }
1290 
1291 // -----------------------------------------------------------------------------
1292 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1293 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1294 {
1295  if (im9->GetTSize()) {
1296  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1297  } else {
1298  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1299  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
1300  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1301  parallel_reduce(re, body);
1302  vf.join(body._VoxelFunc);
1303  of.join(body._OutsideFunc);
1304  } else {
1305  parallel_for(re, body);
1306  }
1307  }
1308 }
1309 
1310 // -----------------------------------------------------------------------------
1311 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1312 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1313 {
1314  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1315  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1316 }
1317 
1318 // -----------------------------------------------------------------------------
1319 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1320 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1321 {
1323  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1324 }
1325 
1326 // -----------------------------------------------------------------------------
1327 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1328 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1329 {
1330  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1331  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1332 }
1333 
1334 // -----------------------------------------------------------------------------
1335 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1336 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1337 {
1338  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1339  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1340  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1341  if (attr._dt) {
1342  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1343  } else {
1344  parallel_reduce(re, body);
1345  }
1346  vf.join(body._VoxelFunc);
1347  of.join(body._OutsideFunc);
1348  } else {
1349  if (attr._dt) {
1350  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1351  } else {
1352  parallel_for(re, body);
1353  }
1354  }
1355 }
1356 
1357 // -----------------------------------------------------------------------------
1358 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1359 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1360 {
1361  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1362  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1363 }
1364 
1365 // -----------------------------------------------------------------------------
1366 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1367 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1368 {
1370  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1371 }
1372 
1373 // -----------------------------------------------------------------------------
1374 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1375 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1376 {
1377  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1378  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1379 }
1380 
1381 // -----------------------------------------------------------------------------
1382 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1383 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1384 {
1385  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1386  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1387  parallel_reduce(re, body);
1388  vf.join(body._VoxelFunc);
1389  of.join(body._OutsideFunc);
1390  } else {
1391  parallel_for(re, body);
1392  }
1393 }
1394 
1395 // -----------------------------------------------------------------------------
1396 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1397 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1398 {
1399  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1400  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1401 }
1402 
1403 // -----------------------------------------------------------------------------
1404 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1405 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1406 {
1408  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1409 }
1410 
1411 // -----------------------------------------------------------------------------
1412 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1413 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1414 {
1415  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1416  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1417 }
1418 
1419 // -----------------------------------------------------------------------------
1420 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1421 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1422 {
1423  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1424  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1425  parallel_reduce(re, body);
1426  vf.join(body._VoxelFunc);
1427  of.join(body._OutsideFunc);
1428  } else {
1429  parallel_for(re, body);
1430  }
1431 }
1432 
1433 // -----------------------------------------------------------------------------
1434 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1435 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1436 {
1437  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1438  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1439 }
1440 
1441 // -----------------------------------------------------------------------------
1442 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1443 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1444 {
1446  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1447 }
1448 
1449 // -----------------------------------------------------------------------------
1450 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1451 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1452 {
1453  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1454  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1455 }
1456 
1457 // -----------------------------------------------------------------------------
1458 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1459 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
1460 {
1461  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1462  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1463  parallel_reduce(re, body);
1464  vf.join(body._VoxelFunc);
1465  of.join(body._OutsideFunc);
1466  } else {
1467  parallel_for(re, body);
1468  }
1469 }
1470 
1471 // -----------------------------------------------------------------------------
1472 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1473 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1474 {
1475  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1476  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1477 }
1478 
1479 // -----------------------------------------------------------------------------
1480 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1481 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9, VoxelFunc &vf)
1482 {
1484  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
1485 }
1486 
1487 // -----------------------------------------------------------------------------
1488 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1489 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, const GenericImage<T9> *im9)
1490 {
1491  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1492  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
1493 }
1494 
1495 //
1496 // Image arguments by reference
1497 //
1498 
1499 // -----------------------------------------------------------------------------
1500 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1501 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1502 {
1503  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1505  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1506  parallel_reduce(re, body);
1507  vf.join(body._VoxelFunc);
1508  of.join(body._OutsideFunc);
1509  } else {
1510  parallel_for(re, body);
1511  }
1512 }
1513 
1514 // -----------------------------------------------------------------------------
1515 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1516 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1517 {
1518  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1519  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1520 }
1521 
1522 // -----------------------------------------------------------------------------
1523 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1524 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1525 {
1527  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1528 }
1529 
1530 // -----------------------------------------------------------------------------
1531 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1532 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1533 {
1534  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1535  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1536 }
1537 
1538 // -----------------------------------------------------------------------------
1539 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1540 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1541 {
1542  if (im9.GetTSize()) {
1543  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1544  } else {
1545  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1546  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
1547  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1548  parallel_reduce(re, body);
1549  vf.join(body._VoxelFunc);
1550  of.join(body._OutsideFunc);
1551  } else {
1552  parallel_for(re, body);
1553  }
1554  }
1555 }
1556 
1557 // -----------------------------------------------------------------------------
1558 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1559 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1560 {
1561  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1562  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1563 }
1564 
1565 // -----------------------------------------------------------------------------
1566 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1567 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1568 {
1570  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1571 }
1572 
1573 // -----------------------------------------------------------------------------
1574 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1575 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1576 {
1577  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1578  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1579 }
1580 
1581 // -----------------------------------------------------------------------------
1582 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1583 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1584 {
1585  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1586  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1587  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1588  if (attr._dt) {
1589  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1590  } else {
1591  parallel_reduce(re, body);
1592  }
1593  vf.join(body._VoxelFunc);
1594  of.join(body._OutsideFunc);
1595  } else {
1596  if (attr._dt) {
1597  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1598  } else {
1599  parallel_for(re, body);
1600  }
1601  }
1602 }
1603 
1604 // -----------------------------------------------------------------------------
1605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1606 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1607 {
1608  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1609  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1610 }
1611 
1612 // -----------------------------------------------------------------------------
1613 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1614 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1615 {
1617  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1618 }
1619 
1620 // -----------------------------------------------------------------------------
1621 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1622 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1623 {
1624  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1625  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1626 }
1627 
1628 // -----------------------------------------------------------------------------
1629 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1630 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1631 {
1632  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1633  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1634  parallel_reduce(re, body);
1635  vf.join(body._VoxelFunc);
1636  of.join(body._OutsideFunc);
1637  } else {
1638  parallel_for(re, body);
1639  }
1640 }
1641 
1642 // -----------------------------------------------------------------------------
1643 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1644 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1645 {
1646  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1647  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1648 }
1649 
1650 // -----------------------------------------------------------------------------
1651 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1652 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1653 {
1655  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1656 }
1657 
1658 // -----------------------------------------------------------------------------
1659 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1660 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1661 {
1662  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1663  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1664 }
1665 
1666 // -----------------------------------------------------------------------------
1667 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1668 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1669 {
1670  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1671  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1672  parallel_reduce(re, body);
1673  vf.join(body._VoxelFunc);
1674  of.join(body._OutsideFunc);
1675  } else {
1676  parallel_for(re, body);
1677  }
1678 }
1679 
1680 // -----------------------------------------------------------------------------
1681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1682 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1683 {
1684  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1685  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1686 }
1687 
1688 // -----------------------------------------------------------------------------
1689 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1690 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1691 {
1693  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1694 }
1695 
1696 // -----------------------------------------------------------------------------
1697 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1698 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1699 {
1700  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1701  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1702 }
1703 
1704 // -----------------------------------------------------------------------------
1705 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1706 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
1707 {
1708  NonaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1709  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1710  parallel_reduce(re, body);
1711  vf.join(body._VoxelFunc);
1712  of.join(body._OutsideFunc);
1713  } else {
1714  parallel_for(re, body);
1715  }
1716 }
1717 
1718 // -----------------------------------------------------------------------------
1719 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
1720 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1721 {
1722  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1723  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1724 }
1725 
1726 // -----------------------------------------------------------------------------
1727 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1728 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9, VoxelFunc &vf)
1729 {
1731  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
1732 }
1733 
1734 // -----------------------------------------------------------------------------
1735 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1736 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, const GenericImage<T9> &im9)
1737 {
1738  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
1739  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
1740 }
1741 
1742 // =============================================================================
1743 // 8 const, 1 non-const images
1744 // =============================================================================
1745 
1746 // -----------------------------------------------------------------------------
1747 /**
1748  * ForEachVoxel body for voxel function of 8 const, 1 non-const images
1749  */
1750 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
1752 {
1753  const GenericImage<T1> &im1;
1754  const GenericImage<T2> &im2;
1755  const GenericImage<T3> &im3;
1756  const GenericImage<T4> &im4;
1757  const GenericImage<T5> &im5;
1758  const GenericImage<T6> &im6;
1759  const GenericImage<T7> &im7;
1760  const GenericImage<T8> &im8;
1761  GenericImage<T9> &im9;
1762 
1763  /// Constructor
1765  const GenericImage<T2> &im2,
1766  const GenericImage<T3> &im3,
1767  const GenericImage<T4> &im4,
1768  const GenericImage<T5> &im5,
1769  const GenericImage<T6> &im6,
1770  const GenericImage<T7> &im7,
1771  const GenericImage<T8> &im8,
1772  GenericImage<T9> &im9,
1773  VoxelFunc &vf)
1774  :
1775  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
1776  {}
1777 
1778  /// Copy constructor
1780  :
1781  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
1782  {}
1783 
1784  /// Split constructor
1786  :
1787  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
1788  {}
1789 
1790  /// Process entire image
1791  void operator ()(const ImageAttributes &attr) const
1792  {
1793  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1794  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1795  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1796  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1797  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1798  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1799  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
1800  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
1801  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
1802 
1803  const int T = (attr._dt ? attr._t : 1);
1804 
1805  for (int l = 0; l < T; ++l)
1806  for (int k = 0; k < attr._z; ++k)
1807  for (int j = 0; j < attr._y; ++j)
1808  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
1809  // const_cast such that voxel functions need only implement
1810  // non-const operator() which is required for parallel_reduce
1811  const_cast<NonaryForEachVoxelBody_8Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1812  }
1813  }
1814 
1815  /// Process image region using linear index
1816  void operator ()(const blocked_range<int> &re) const
1817  {
1818  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1819  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1820  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1821  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1822  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1823  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1824  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
1825  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
1826  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
1827 
1828  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
1829  // const_cast such that voxel functions need only implement
1830  // non-const operator() which is required for parallel_reduce
1831  const_cast<NonaryForEachVoxelBody_8Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1832  }
1833  }
1834 
1835  /// Process 2D image region
1836  void operator ()(const blocked_range2d<int> &re) const
1837  {
1838  const int bi = re.cols().begin();
1839  const int bj = re.rows().begin();
1840  const int ei = re.cols().end();
1841  const int ej = re.rows().end();
1842 
1843  const int s1 = im9.GetX() - (ei - bi);
1844 
1845  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1846  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1847  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1848  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1849  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1850  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1851  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1852  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1853  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1854 
1855  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
1856  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
1857  // const_cast such that voxel functions need only implement
1858  // non-const operator() which is required for parallel_reduce
1859  const_cast<NonaryForEachVoxelBody_8Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1860  }
1861  }
1862 
1863  /// Process 3D image region
1864  void operator ()(const blocked_range3d<int> &re) const
1865  {
1866  const int bi = re.cols ().begin();
1867  const int bj = re.rows ().begin();
1868  const int bk = re.pages().begin();
1869  const int ei = re.cols ().end();
1870  const int ej = re.rows ().end();
1871  const int ek = re.pages().end();
1872 
1873  const int s1 = im9.GetX() - (ei - bi);
1874  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
1875 
1876  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
1877  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
1878  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
1879  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
1880  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
1881  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
1882  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
1883  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
1884  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
1885 
1886  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
1887  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
1888  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
1889  // const_cast such that voxel functions need only implement
1890  // non-const operator() which is required for parallel_reduce
1891  const_cast<NonaryForEachVoxelBody_8Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1892  }
1893  }
1894 };
1895 
1896 // -----------------------------------------------------------------------------
1897 /**
1898  * ForEachVoxel body for inside and outside unary voxel function of 8 const, 1 non-const images
1899  */
1900 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
1901  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
1902  class Domain = ForEachVoxelDomain::Foreground>
1903 struct NonaryForEachVoxelIfBody_8Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
1904 {
1905  const GenericImage<T1> &im1;
1906  const GenericImage<T2> &im2;
1907  const GenericImage<T3> &im3;
1908  const GenericImage<T4> &im4;
1909  const GenericImage<T5> &im5;
1910  const GenericImage<T6> &im6;
1911  const GenericImage<T7> &im7;
1912  const GenericImage<T8> &im8;
1913  GenericImage<T9> &im9;
1914 
1915  /// Constructor
1917  const GenericImage<T2> &im2,
1918  const GenericImage<T3> &im3,
1919  const GenericImage<T4> &im4,
1920  const GenericImage<T5> &im5,
1921  const GenericImage<T6> &im6,
1922  const GenericImage<T7> &im7,
1923  const GenericImage<T8> &im8,
1924  GenericImage<T9> &im9,
1925  VoxelFunc &vf, OutsideFunc &of)
1926  :
1927  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
1928  {}
1929 
1930  /// Copy constructor
1932  :
1933  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
1934  {}
1935 
1936  /// Split constructor
1938  :
1939  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
1940  {}
1941 
1942  /// Process entire image
1943  void operator ()(const ImageAttributes &attr) const
1944  {
1945  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1946  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1947  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1948  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1949  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1950  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1951  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
1952  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
1953  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
1954 
1955  const int T = (attr._dt ? attr._t : 1);
1956 
1957  for (int l = 0; l < T; ++l)
1958  for (int k = 0; k < attr._z; ++k)
1959  for (int j = 0; j < attr._y; ++j)
1960  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
1961  if (Domain::IsInside(im9, i, j, k, l, p9)) {
1962  // const_cast such that voxel functions need only implement
1963  // non-const operator() which is required for parallel_reduce
1964  const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1965  } else const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1966  }
1967  }
1968 
1969  /// Process image region using linear index
1970  void operator ()(const blocked_range<int> &re) const
1971  {
1972  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1973  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1974  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1975  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1976  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1977  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1978  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
1979  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
1980  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
1981 
1982  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
1983  if (Domain::IsInside(im9, idx, p9)) {
1984  // const_cast such that voxel functions need only implement
1985  // non-const operator() which is required for parallel_reduce
1986  const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1987  } else const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
1988  }
1989  }
1990 
1991  /// Process 2D image region
1992  void operator ()(const blocked_range2d<int> &re) const
1993  {
1994  const int bi = re.cols().begin();
1995  const int bj = re.rows().begin();
1996  const int ei = re.cols().end();
1997  const int ej = re.rows().end();
1998 
1999  const int s1 = im9.GetX() - (ei - bi);
2000 
2001  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2002  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2003  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2004  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2005  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2006  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2007  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2008  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2009  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
2010 
2011  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
2012  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
2013  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
2014  // const_cast such that voxel functions need only implement
2015  // non-const operator() which is required for parallel_reduce
2016  const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2017  } else const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2018  }
2019  }
2020 
2021  /// Process 3D image region
2022  void operator ()(const blocked_range3d<int> &re) const
2023  {
2024  const int bi = re.cols ().begin();
2025  const int bj = re.rows ().begin();
2026  const int bk = re.pages().begin();
2027  const int ei = re.cols ().end();
2028  const int ej = re.rows ().end();
2029  const int ek = re.pages().end();
2030 
2031  const int s1 = im9.GetX() - (ei - bi);
2032  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
2033 
2034  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
2035  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
2036  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
2037  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
2038  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
2039  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
2040  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
2041  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
2042  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
2043 
2044  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
2045  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
2046  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
2047  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
2048  // const_cast such that voxel functions need only implement
2049  // non-const operator() which is required for parallel_reduce
2050  const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2051  } else const_cast<NonaryForEachVoxelIfBody_8Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
2052  }
2053  }
2054 };
2055 
2056 // -----------------------------------------------------------------------------
2057 // ForEachVoxel
2058 // -----------------------------------------------------------------------------
2059 
2060 //
2061 // Image arguments by pointer
2062 //
2063 
2064 // -----------------------------------------------------------------------------
2065 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2066 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2067 {
2068  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2069  blocked_range<int> re(0, im9->GetNumberOfVoxels());
2070  body(re);
2071  vf.join(body._VoxelFunc);
2072 }
2073 
2074 // -----------------------------------------------------------------------------
2075 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2076 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2077 {
2078  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2079  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2080 }
2081 
2082 // -----------------------------------------------------------------------------
2083 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2084 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2085 {
2086  if (im9->GetTSize()) {
2087  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2088  } else {
2089  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2090  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
2091  body(re);
2092  vf.join(body._VoxelFunc);
2093  }
2094 }
2095 
2096 // -----------------------------------------------------------------------------
2097 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2098 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2099 {
2100  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2101  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2102 }
2103 
2104 // -----------------------------------------------------------------------------
2105 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2106 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2107 {
2108  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2109  body(attr);
2110  vf.join(body._VoxelFunc);
2111 }
2112 
2113 // -----------------------------------------------------------------------------
2114 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2115 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2116 {
2117  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2118  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2119 }
2120 
2121 // -----------------------------------------------------------------------------
2122 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2123 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2124 {
2125  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2126  body(re);
2127  vf.join(body._VoxelFunc);
2128 }
2129 
2130 // -----------------------------------------------------------------------------
2131 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2132 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2133 {
2134  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2135  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2136 }
2137 
2138 // -----------------------------------------------------------------------------
2139 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2140 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2141 {
2142  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2143  body(re);
2144  vf.join(body._VoxelFunc);
2145 }
2146 
2147 // -----------------------------------------------------------------------------
2148 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2149 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2150 {
2151  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2152  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2153 }
2154 
2155 // -----------------------------------------------------------------------------
2156 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2157 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2158 {
2159  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2160  body(re);
2161  vf.join(body._VoxelFunc);
2162 }
2163 
2164 // -----------------------------------------------------------------------------
2165 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2166 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2167 {
2168  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2169  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2170 }
2171 
2172 //
2173 // Image arguments by reference
2174 //
2175 
2176 // -----------------------------------------------------------------------------
2177 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2178 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2179 {
2180  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2182  body(re);
2183  vf.join(body._VoxelFunc);
2184 }
2185 
2186 // -----------------------------------------------------------------------------
2187 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2188 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2189 {
2190  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2191  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2192 }
2193 
2194 // -----------------------------------------------------------------------------
2195 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2196 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2197 {
2198  if (im9.GetTSize()) {
2199  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2200  } else {
2201  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2202  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
2203  body(re);
2204  vf.join(body._VoxelFunc);
2205  }
2206 }
2207 
2208 // -----------------------------------------------------------------------------
2209 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2210 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2211 {
2212  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2213  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2214 }
2215 
2216 // -----------------------------------------------------------------------------
2217 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2218 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2219 {
2220  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2221  body(attr);
2222  vf.join(body._VoxelFunc);
2223 }
2224 
2225 // -----------------------------------------------------------------------------
2226 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2227 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2228 {
2229  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2230  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2231 }
2232 
2233 // -----------------------------------------------------------------------------
2234 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2235 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2236 {
2237  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2238  body(re);
2239  vf.join(body._VoxelFunc);
2240 }
2241 
2242 // -----------------------------------------------------------------------------
2243 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2244 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2245 {
2246  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2247  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2248 }
2249 
2250 // -----------------------------------------------------------------------------
2251 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2252 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2253 {
2254  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2255  body(re);
2256  vf.join(body._VoxelFunc);
2257 }
2258 
2259 // -----------------------------------------------------------------------------
2260 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2261 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2262 {
2263  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2264  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2265 }
2266 
2267 // -----------------------------------------------------------------------------
2268 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2269 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2270 {
2271  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2272  body(re);
2273  vf.join(body._VoxelFunc);
2274 }
2275 
2276 // -----------------------------------------------------------------------------
2277 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2278 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2279 {
2280  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2281  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2282 }
2283 
2284 // -----------------------------------------------------------------------------
2285 // ForEachVoxelIf
2286 // -----------------------------------------------------------------------------
2287 
2288 //
2289 // Image arguments by pointer
2290 //
2291 
2292 // -----------------------------------------------------------------------------
2293 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2294 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2295 {
2296  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2297  blocked_range<int> re(0, im9->GetNumberOfVoxels());
2298  body(re);
2299  vf.join(body._VoxelFunc);
2300  of.join(body._OutsideFunc);
2301 }
2302 
2303 // -----------------------------------------------------------------------------
2304 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2305 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2306 {
2307  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2308  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2309 }
2310 
2311 // -----------------------------------------------------------------------------
2312 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2313 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2314 {
2316  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2317 }
2318 
2319 // -----------------------------------------------------------------------------
2320 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2321 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2322 {
2323  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2324  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2325 }
2326 
2327 // -----------------------------------------------------------------------------
2328 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2329 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2330 {
2331  if (im9->GetTSize()) {
2332  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2333  } else {
2334  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2335  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
2336  body(re);
2337  vf.join(body._VoxelFunc);
2338  of.join(body._OutsideFunc);
2339  }
2340 }
2341 
2342 // -----------------------------------------------------------------------------
2343 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2344 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2345 {
2346  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2347  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2348 }
2349 
2350 // -----------------------------------------------------------------------------
2351 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2352 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2353 {
2355  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2356 }
2357 
2358 // -----------------------------------------------------------------------------
2359 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2360 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2361 {
2362  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2363  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2364 }
2365 
2366 // -----------------------------------------------------------------------------
2367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2368 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2369 {
2370  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2371  body(attr);
2372  vf.join(body._VoxelFunc);
2373  of.join(body._OutsideFunc);
2374 }
2375 
2376 // -----------------------------------------------------------------------------
2377 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2378 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2379 {
2380  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2381  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2382 }
2383 
2384 // -----------------------------------------------------------------------------
2385 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2386 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2387 {
2389  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2390 }
2391 
2392 // -----------------------------------------------------------------------------
2393 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2394 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2395 {
2396  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2397  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2398 }
2399 
2400 // -----------------------------------------------------------------------------
2401 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2402 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2403 {
2404  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2405  body(re);
2406  vf.join(body._VoxelFunc);
2407  of.join(body._OutsideFunc);
2408 }
2409 
2410 // -----------------------------------------------------------------------------
2411 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2412 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2413 {
2414  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2415  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2416 }
2417 
2418 // -----------------------------------------------------------------------------
2419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2420 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2421 {
2422  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2423  body(re);
2424  vf.join(body._VoxelFunc);
2425  of.join(body._OutsideFunc);
2426 }
2427 
2428 // -----------------------------------------------------------------------------
2429 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2430 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2431 {
2432  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2433  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2434 }
2435 
2436 // -----------------------------------------------------------------------------
2437 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2438 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2439 {
2441  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2442 }
2443 
2444 // -----------------------------------------------------------------------------
2445 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2446 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2447 {
2448  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2449  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2450 }
2451 
2452 // -----------------------------------------------------------------------------
2453 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2454 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2455 {
2456  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2457  body(re);
2458  vf.join(body._VoxelFunc);
2459  of.join(body._OutsideFunc);
2460 }
2461 
2462 // -----------------------------------------------------------------------------
2463 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2464 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2465 {
2466  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2467  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2468 }
2469 
2470 // -----------------------------------------------------------------------------
2471 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2472 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2473 {
2475  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2476 }
2477 
2478 // -----------------------------------------------------------------------------
2479 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2480 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2481 {
2482  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2483  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2484 }
2485 
2486 //
2487 // Image arguments by reference
2488 //
2489 
2490 // -----------------------------------------------------------------------------
2491 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2492 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2493 {
2494  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2496  body(re);
2497  vf.join(body._VoxelFunc);
2498  of.join(body._OutsideFunc);
2499 }
2500 
2501 // -----------------------------------------------------------------------------
2502 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2503 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2504 {
2505  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2506  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2507 }
2508 
2509 // -----------------------------------------------------------------------------
2510 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2511 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2512 {
2514  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2515 }
2516 
2517 // -----------------------------------------------------------------------------
2518 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2519 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2520 {
2521  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2522  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2523 }
2524 
2525 // -----------------------------------------------------------------------------
2526 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2527 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2528 {
2529  if (im9.GetTSize()) {
2530  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2531  } else {
2532  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2533  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
2534  body(re);
2535  vf.join(body._VoxelFunc);
2536  of.join(body._OutsideFunc);
2537  }
2538 }
2539 
2540 // -----------------------------------------------------------------------------
2541 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2542 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2543 {
2544  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2545  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2546 }
2547 
2548 // -----------------------------------------------------------------------------
2549 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2550 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2551 {
2553  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2554 }
2555 
2556 // -----------------------------------------------------------------------------
2557 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2558 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2559 {
2560  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2561  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2562 }
2563 
2564 // -----------------------------------------------------------------------------
2565 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2566 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2567 {
2568  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2569  body(attr);
2570  vf.join(body._VoxelFunc);
2571  of.join(body._OutsideFunc);
2572 }
2573 
2574 // -----------------------------------------------------------------------------
2575 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2576 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2577 {
2578  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2579  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2580 }
2581 
2582 // -----------------------------------------------------------------------------
2583 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2584 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2585 {
2587  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2588 }
2589 
2590 // -----------------------------------------------------------------------------
2591 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2592 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2593 {
2594  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2595  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2596 }
2597 
2598 // -----------------------------------------------------------------------------
2599 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2600 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2601 {
2602  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2603  body(re);
2604  vf.join(body._VoxelFunc);
2605  of.join(body._OutsideFunc);
2606 }
2607 
2608 // -----------------------------------------------------------------------------
2609 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2610 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2611 {
2612  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2613  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2614 }
2615 
2616 // -----------------------------------------------------------------------------
2617 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2618 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2619 {
2620  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2621  body(re);
2622  vf.join(body._VoxelFunc);
2623  of.join(body._OutsideFunc);
2624 }
2625 
2626 // -----------------------------------------------------------------------------
2627 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2628 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2629 {
2630  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2631  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2632 }
2633 
2634 // -----------------------------------------------------------------------------
2635 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2636 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2637 {
2639  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2640 }
2641 
2642 // -----------------------------------------------------------------------------
2643 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2644 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2645 {
2646  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2647  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2648 }
2649 
2650 // -----------------------------------------------------------------------------
2651 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2652 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
2653 {
2654  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2655  body(re);
2656  vf.join(body._VoxelFunc);
2657  of.join(body._OutsideFunc);
2658 }
2659 
2660 // -----------------------------------------------------------------------------
2661 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2662 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2663 {
2664  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2665  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2666 }
2667 
2668 // -----------------------------------------------------------------------------
2669 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2670 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2671 {
2673  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
2674 }
2675 
2676 // -----------------------------------------------------------------------------
2677 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2678 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2679 {
2680  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2681  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2682 }
2683 
2684 // -----------------------------------------------------------------------------
2685 // ParallelForEachVoxel
2686 // -----------------------------------------------------------------------------
2687 
2688 //
2689 // Image arguments by pointer
2690 //
2691 
2692 // -----------------------------------------------------------------------------
2693 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2694 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2695 {
2696  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2697  blocked_range<int> re(0, im9->GetNumberOfVoxels());
2698  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2699  else parallel_for (re, body);
2700 }
2701 
2702 // -----------------------------------------------------------------------------
2703 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2704 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2705 {
2706  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2707  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2708 }
2709 
2710 // -----------------------------------------------------------------------------
2711 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2712 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2713 {
2714  if (im9->GetTSize()) {
2715  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2716  } else {
2717  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2718  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
2719  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2720  else parallel_for (re, body);
2721  }
2722 }
2723 
2724 // -----------------------------------------------------------------------------
2725 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2726 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2727 {
2728  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2729  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2730 }
2731 
2732 // -----------------------------------------------------------------------------
2733 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2734 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2735 {
2736  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2737  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2738  if (VoxelFunc::IsReduction()) {
2739  if (attr._dt) {
2740  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2741  } else {
2742  parallel_reduce(re, body);
2743  }
2744  vf.join(body._VoxelFunc);
2745  } else {
2746  if (attr._dt) {
2747  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2748  } else {
2749  parallel_for(re, body);
2750  }
2751  }
2752 }
2753 
2754 // -----------------------------------------------------------------------------
2755 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2756 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2757 {
2758  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2759  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2760 }
2761 
2762 // -----------------------------------------------------------------------------
2763 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2764 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2765 {
2766  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2767  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2768  else parallel_for (re, body);
2769 }
2770 
2771 // -----------------------------------------------------------------------------
2772 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2773 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2774 {
2775  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2776  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2777 }
2778 
2779 // -----------------------------------------------------------------------------
2780 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2781 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2782 {
2783  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2784  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2785  else parallel_for (re, body);
2786 }
2787 
2788 // -----------------------------------------------------------------------------
2789 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2790 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2791 {
2792  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2793  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2794 }
2795 
2796 // -----------------------------------------------------------------------------
2797 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2798 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2799 {
2800  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2801  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2802  else parallel_for (re, body);
2803 }
2804 
2805 // -----------------------------------------------------------------------------
2806 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2807 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2808 {
2809  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2810  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2811 }
2812 
2813 //
2814 // Image arguments by reference
2815 //
2816 
2817 // -----------------------------------------------------------------------------
2818 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2819 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2820 {
2821  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2823  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2824  else parallel_for (re, body);
2825 }
2826 
2827 // -----------------------------------------------------------------------------
2828 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2829 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2830 {
2831  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2832  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2833 }
2834 
2835 // -----------------------------------------------------------------------------
2836 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2837 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2838 {
2839  if (im9.GetTSize()) {
2840  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2841  } else {
2842  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2843  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
2844  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2845  else parallel_for (re, body);
2846  }
2847 }
2848 
2849 // -----------------------------------------------------------------------------
2850 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2851 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2852 {
2853  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2854  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2855 }
2856 
2857 // -----------------------------------------------------------------------------
2858 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2859 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2860 {
2861  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2862  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2863  if (VoxelFunc::IsReduction()) {
2864  if (attr._dt) {
2865  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2866  } else {
2867  parallel_reduce(re, body);
2868  }
2869  vf.join(body._VoxelFunc);
2870  } else {
2871  if (attr._dt) {
2872  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2873  } else {
2874  parallel_for(re, body);
2875  }
2876  }
2877 }
2878 
2879 // -----------------------------------------------------------------------------
2880 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2881 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2882 {
2883  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2884  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2885 }
2886 
2887 // -----------------------------------------------------------------------------
2888 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2889 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2890 {
2891  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2892  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2893  else parallel_for (re, body);
2894 }
2895 
2896 // -----------------------------------------------------------------------------
2897 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2898 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2899 {
2900  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2901  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2902 }
2903 
2904 // -----------------------------------------------------------------------------
2905 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2906 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2907 {
2908  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2909  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2910  else parallel_for (re, body);
2911 }
2912 
2913 // -----------------------------------------------------------------------------
2914 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2915 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2916 {
2917  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2918  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2919 }
2920 
2921 // -----------------------------------------------------------------------------
2922 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2923 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
2924 {
2925  NonaryForEachVoxelBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2926  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2927  else parallel_for (re, body);
2928 }
2929 
2930 // -----------------------------------------------------------------------------
2931 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2932 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
2933 {
2934  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2935  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
2936 }
2937 
2938 // -----------------------------------------------------------------------------
2939 // ParallelForEachVoxelIf
2940 // -----------------------------------------------------------------------------
2941 
2942 //
2943 // Image arguments by pointer
2944 //
2945 
2946 // -----------------------------------------------------------------------------
2947 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2948 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2949 {
2950  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2951  blocked_range<int> re(0, im9->GetNumberOfVoxels());
2952  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2953  parallel_reduce(re, body);
2954  vf.join(body._VoxelFunc);
2955  of.join(body._OutsideFunc);
2956  } else {
2957  parallel_for(re, body);
2958  }
2959 }
2960 
2961 // -----------------------------------------------------------------------------
2962 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2963 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2964 {
2965  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2966  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2967 }
2968 
2969 // -----------------------------------------------------------------------------
2970 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2971 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
2972 {
2974  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2975 }
2976 
2977 // -----------------------------------------------------------------------------
2978 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
2979 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
2980 {
2981  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
2982  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
2983 }
2984 
2985 // -----------------------------------------------------------------------------
2986 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
2987 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
2988 {
2989  if (im9->GetTSize()) {
2990  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2991  } else {
2992  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
2993  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
2994  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2995  parallel_reduce(re, body);
2996  vf.join(body._VoxelFunc);
2997  of.join(body._OutsideFunc);
2998  } else {
2999  parallel_for(re, body);
3000  }
3001  }
3002 }
3003 
3004 // -----------------------------------------------------------------------------
3005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3006 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3007 {
3008  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3009  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3010 }
3011 
3012 // -----------------------------------------------------------------------------
3013 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3014 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3015 {
3017  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3018 }
3019 
3020 // -----------------------------------------------------------------------------
3021 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3022 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3023 {
3024  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3025  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3026 }
3027 
3028 // -----------------------------------------------------------------------------
3029 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3030 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
3031 {
3032  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3033  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
3034  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3035  if (attr._dt) {
3036  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
3037  } else {
3038  parallel_reduce(re, body);
3039  }
3040  vf.join(body._VoxelFunc);
3041  of.join(body._OutsideFunc);
3042  } else {
3043  if (attr._dt) {
3044  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
3045  } else {
3046  parallel_for(re, body);
3047  }
3048  }
3049 }
3050 
3051 // -----------------------------------------------------------------------------
3052 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3053 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3054 {
3055  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3056  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3057 }
3058 
3059 // -----------------------------------------------------------------------------
3060 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3061 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3062 {
3064  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3065 }
3066 
3067 // -----------------------------------------------------------------------------
3068 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3069 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3070 {
3071  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3072  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3073 }
3074 
3075 // -----------------------------------------------------------------------------
3076 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3077 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
3078 {
3079  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3080  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3081  parallel_reduce(re, body);
3082  vf.join(body._VoxelFunc);
3083  of.join(body._OutsideFunc);
3084  } else {
3085  parallel_for(re, body);
3086  }
3087 }
3088 
3089 // -----------------------------------------------------------------------------
3090 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3091 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3092 {
3093  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3094  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3095 }
3096 
3097 // -----------------------------------------------------------------------------
3098 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3099 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3100 {
3102  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3103 }
3104 
3105 // -----------------------------------------------------------------------------
3106 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3107 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3108 {
3109  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3110  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3111 }
3112 
3113 // -----------------------------------------------------------------------------
3114 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3115 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
3116 {
3117  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3118  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3119  parallel_reduce(re, body);
3120  vf.join(body._VoxelFunc);
3121  of.join(body._OutsideFunc);
3122  } else {
3123  parallel_for(re, body);
3124  }
3125 }
3126 
3127 // -----------------------------------------------------------------------------
3128 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3129 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3130 {
3131  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3132  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3133 }
3134 
3135 // -----------------------------------------------------------------------------
3136 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3137 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3138 {
3140  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3141 }
3142 
3143 // -----------------------------------------------------------------------------
3144 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3145 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3146 {
3147  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3148  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3149 }
3150 
3151 // -----------------------------------------------------------------------------
3152 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3153 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
3154 {
3155  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3156  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3157  parallel_reduce(re, body);
3158  vf.join(body._VoxelFunc);
3159  of.join(body._OutsideFunc);
3160  } else {
3161  parallel_for(re, body);
3162  }
3163 }
3164 
3165 // -----------------------------------------------------------------------------
3166 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3167 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3168 {
3169  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3170  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3171 }
3172 
3173 // -----------------------------------------------------------------------------
3174 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3175 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3176 {
3178  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3179 }
3180 
3181 // -----------------------------------------------------------------------------
3182 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3183 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, const GenericImage<T7> *im7, const GenericImage<T8> *im8, GenericImage<T9> *im9)
3184 {
3185  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3186  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3187 }
3188 
3189 //
3190 // Image arguments by reference
3191 //
3192 
3193 // -----------------------------------------------------------------------------
3194 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3195 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3196 {
3197  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3199  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3200  parallel_reduce(re, body);
3201  vf.join(body._VoxelFunc);
3202  of.join(body._OutsideFunc);
3203  } else {
3204  parallel_for(re, body);
3205  }
3206 }
3207 
3208 // -----------------------------------------------------------------------------
3209 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3210 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3211 {
3212  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3213  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3214 }
3215 
3216 // -----------------------------------------------------------------------------
3217 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3218 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3219 {
3221  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3222 }
3223 
3224 // -----------------------------------------------------------------------------
3225 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3226 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3227 {
3228  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3229  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3230 }
3231 
3232 // -----------------------------------------------------------------------------
3233 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3234 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3235 {
3236  if (im9.GetTSize()) {
3237  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3238  } else {
3239  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3240  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
3241  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3242  parallel_reduce(re, body);
3243  vf.join(body._VoxelFunc);
3244  of.join(body._OutsideFunc);
3245  } else {
3246  parallel_for(re, body);
3247  }
3248  }
3249 }
3250 
3251 // -----------------------------------------------------------------------------
3252 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3253 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3254 {
3255  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3256  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3257 }
3258 
3259 // -----------------------------------------------------------------------------
3260 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3261 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3262 {
3264  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3265 }
3266 
3267 // -----------------------------------------------------------------------------
3268 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3269 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3270 {
3271  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3272  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3273 }
3274 
3275 // -----------------------------------------------------------------------------
3276 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3277 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3278 {
3279  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3280  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
3281  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3282  if (attr._dt) {
3283  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
3284  } else {
3285  parallel_reduce(re, body);
3286  }
3287  vf.join(body._VoxelFunc);
3288  of.join(body._OutsideFunc);
3289  } else {
3290  if (attr._dt) {
3291  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
3292  } else {
3293  parallel_for(re, body);
3294  }
3295  }
3296 }
3297 
3298 // -----------------------------------------------------------------------------
3299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3300 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3301 {
3302  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3303  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3304 }
3305 
3306 // -----------------------------------------------------------------------------
3307 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3308 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3309 {
3311  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3312 }
3313 
3314 // -----------------------------------------------------------------------------
3315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3316 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3317 {
3318  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3319  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3320 }
3321 
3322 // -----------------------------------------------------------------------------
3323 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3324 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3325 {
3326  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3327  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3328  parallel_reduce(re, body);
3329  vf.join(body._VoxelFunc);
3330  of.join(body._OutsideFunc);
3331  } else {
3332  parallel_for(re, body);
3333  }
3334 }
3335 
3336 // -----------------------------------------------------------------------------
3337 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3338 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3339 {
3340  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3341  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3342 }
3343 
3344 // -----------------------------------------------------------------------------
3345 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3346 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3347 {
3349  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3350 }
3351 
3352 // -----------------------------------------------------------------------------
3353 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3354 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3355 {
3356  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3357  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3358 }
3359 
3360 // -----------------------------------------------------------------------------
3361 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3362 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3363 {
3364  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3365  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3366  parallel_reduce(re, body);
3367  vf.join(body._VoxelFunc);
3368  of.join(body._OutsideFunc);
3369  } else {
3370  parallel_for(re, body);
3371  }
3372 }
3373 
3374 // -----------------------------------------------------------------------------
3375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3376 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3377 {
3378  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3379  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3380 }
3381 
3382 // -----------------------------------------------------------------------------
3383 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3384 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3385 {
3387  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3388 }
3389 
3390 // -----------------------------------------------------------------------------
3391 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3392 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3393 {
3394  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3395  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3396 }
3397 
3398 // -----------------------------------------------------------------------------
3399 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3400 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
3401 {
3402  NonaryForEachVoxelIfBody_8Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3403  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3404  parallel_reduce(re, body);
3405  vf.join(body._VoxelFunc);
3406  of.join(body._OutsideFunc);
3407  } else {
3408  parallel_for(re, body);
3409  }
3410 }
3411 
3412 // -----------------------------------------------------------------------------
3413 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3414 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3415 {
3416  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3417  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3418 }
3419 
3420 // -----------------------------------------------------------------------------
3421 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3422 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3423 {
3425  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
3426 }
3427 
3428 // -----------------------------------------------------------------------------
3429 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3430 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, const GenericImage<T7> &im7, const GenericImage<T8> &im8, GenericImage<T9> &im9)
3431 {
3432  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3433  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3434 }
3435 
3436 // =============================================================================
3437 // 7 const, 2 non-const images
3438 // =============================================================================
3439 
3440 // -----------------------------------------------------------------------------
3441 /**
3442  * ForEachVoxel body for voxel function of 7 const, 2 non-const images
3443  */
3444 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3446 {
3447  const GenericImage<T1> &im1;
3448  const GenericImage<T2> &im2;
3449  const GenericImage<T3> &im3;
3450  const GenericImage<T4> &im4;
3451  const GenericImage<T5> &im5;
3452  const GenericImage<T6> &im6;
3453  const GenericImage<T7> &im7;
3454  GenericImage<T8> &im8;
3455  GenericImage<T9> &im9;
3456 
3457  /// Constructor
3459  const GenericImage<T2> &im2,
3460  const GenericImage<T3> &im3,
3461  const GenericImage<T4> &im4,
3462  const GenericImage<T5> &im5,
3463  const GenericImage<T6> &im6,
3464  const GenericImage<T7> &im7,
3465  GenericImage<T8> &im8,
3466  GenericImage<T9> &im9,
3467  VoxelFunc &vf)
3468  :
3469  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
3470  {}
3471 
3472  /// Copy constructor
3474  :
3475  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
3476  {}
3477 
3478  /// Split constructor
3480  :
3481  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
3482  {}
3483 
3484  /// Process entire image
3485  void operator ()(const ImageAttributes &attr) const
3486  {
3487  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3488  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3489  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3490  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3491  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3492  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3493  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
3494  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
3495  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
3496 
3497  const int T = (attr._dt ? attr._t : 1);
3498 
3499  for (int l = 0; l < T; ++l)
3500  for (int k = 0; k < attr._z; ++k)
3501  for (int j = 0; j < attr._y; ++j)
3502  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
3503  // const_cast such that voxel functions need only implement
3504  // non-const operator() which is required for parallel_reduce
3505  const_cast<NonaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3506  }
3507  }
3508 
3509  /// Process image region using linear index
3510  void operator ()(const blocked_range<int> &re) const
3511  {
3512  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3513  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3514  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3515  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3516  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3517  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3518  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
3519  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
3520  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
3521 
3522  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3523  // const_cast such that voxel functions need only implement
3524  // non-const operator() which is required for parallel_reduce
3525  const_cast<NonaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3526  }
3527  }
3528 
3529  /// Process 2D image region
3530  void operator ()(const blocked_range2d<int> &re) const
3531  {
3532  const int bi = re.cols().begin();
3533  const int bj = re.rows().begin();
3534  const int ei = re.cols().end();
3535  const int ej = re.rows().end();
3536 
3537  const int s1 = im9.GetX() - (ei - bi);
3538 
3539  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3540  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3541  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3542  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3543  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3544  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3545  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3546  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3547  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3548 
3549  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
3550  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3551  // const_cast such that voxel functions need only implement
3552  // non-const operator() which is required for parallel_reduce
3553  const_cast<NonaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3554  }
3555  }
3556 
3557  /// Process 3D image region
3558  void operator ()(const blocked_range3d<int> &re) const
3559  {
3560  const int bi = re.cols ().begin();
3561  const int bj = re.rows ().begin();
3562  const int bk = re.pages().begin();
3563  const int ei = re.cols ().end();
3564  const int ej = re.rows ().end();
3565  const int ek = re.pages().end();
3566 
3567  const int s1 = im9.GetX() - (ei - bi);
3568  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
3569 
3570  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3571  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3572  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3573  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3574  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3575  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3576  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
3577  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
3578  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
3579 
3580  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
3581  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
3582  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3583  // const_cast such that voxel functions need only implement
3584  // non-const operator() which is required for parallel_reduce
3585  const_cast<NonaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3586  }
3587  }
3588 };
3589 
3590 // -----------------------------------------------------------------------------
3591 /**
3592  * ForEachVoxel body for inside and outside unary voxel function of 7 const, 2 non-const images
3593  */
3594 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
3595  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
3596  class Domain = ForEachVoxelDomain::Foreground>
3597 struct NonaryForEachVoxelIfBody_7Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
3598 {
3599  const GenericImage<T1> &im1;
3600  const GenericImage<T2> &im2;
3601  const GenericImage<T3> &im3;
3602  const GenericImage<T4> &im4;
3603  const GenericImage<T5> &im5;
3604  const GenericImage<T6> &im6;
3605  const GenericImage<T7> &im7;
3606  GenericImage<T8> &im8;
3607  GenericImage<T9> &im9;
3608 
3609  /// Constructor
3611  const GenericImage<T2> &im2,
3612  const GenericImage<T3> &im3,
3613  const GenericImage<T4> &im4,
3614  const GenericImage<T5> &im5,
3615  const GenericImage<T6> &im6,
3616  const GenericImage<T7> &im7,
3617  GenericImage<T8> &im8,
3618  GenericImage<T9> &im9,
3619  VoxelFunc &vf, OutsideFunc &of)
3620  :
3621  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
3622  {}
3623 
3624  /// Copy constructor
3626  :
3627  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
3628  {}
3629 
3630  /// Split constructor
3632  :
3633  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
3634  {}
3635 
3636  /// Process entire image
3637  void operator ()(const ImageAttributes &attr) const
3638  {
3639  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3640  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3641  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3642  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3643  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3644  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3645  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
3646  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
3647  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
3648 
3649  const int T = (attr._dt ? attr._t : 1);
3650 
3651  for (int l = 0; l < T; ++l)
3652  for (int k = 0; k < attr._z; ++k)
3653  for (int j = 0; j < attr._y; ++j)
3654  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
3655  if (Domain::IsInside(im9, i, j, k, l, p9)) {
3656  // const_cast such that voxel functions need only implement
3657  // non-const operator() which is required for parallel_reduce
3658  const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3659  } else const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3660  }
3661  }
3662 
3663  /// Process image region using linear index
3664  void operator ()(const blocked_range<int> &re) const
3665  {
3666  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3667  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3668  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3669  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3670  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3671  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3672  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
3673  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
3674  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
3675 
3676  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3677  if (Domain::IsInside(im9, idx, p9)) {
3678  // const_cast such that voxel functions need only implement
3679  // non-const operator() which is required for parallel_reduce
3680  const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3681  } else const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3682  }
3683  }
3684 
3685  /// Process 2D image region
3686  void operator ()(const blocked_range2d<int> &re) const
3687  {
3688  const int bi = re.cols().begin();
3689  const int bj = re.rows().begin();
3690  const int ei = re.cols().end();
3691  const int ej = re.rows().end();
3692 
3693  const int s1 = im9.GetX() - (ei - bi);
3694 
3695  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3696  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3697  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3698  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3699  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3700  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3701  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3702  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3703  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3704 
3705  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
3706  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3707  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
3708  // const_cast such that voxel functions need only implement
3709  // non-const operator() which is required for parallel_reduce
3710  const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3711  } else const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3712  }
3713  }
3714 
3715  /// Process 3D image region
3716  void operator ()(const blocked_range3d<int> &re) const
3717  {
3718  const int bi = re.cols ().begin();
3719  const int bj = re.rows ().begin();
3720  const int bk = re.pages().begin();
3721  const int ei = re.cols ().end();
3722  const int ej = re.rows ().end();
3723  const int ek = re.pages().end();
3724 
3725  const int s1 = im9.GetX() - (ei - bi);
3726  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
3727 
3728  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3729  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3730  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3731  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3732  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3733  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3734  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
3735  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
3736  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
3737 
3738  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
3739  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
3740  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
3741  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
3742  // const_cast such that voxel functions need only implement
3743  // non-const operator() which is required for parallel_reduce
3744  const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3745  } else const_cast<NonaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
3746  }
3747  }
3748 };
3749 
3750 // -----------------------------------------------------------------------------
3751 // ForEachVoxel
3752 // -----------------------------------------------------------------------------
3753 
3754 //
3755 // Image arguments by pointer
3756 //
3757 
3758 // -----------------------------------------------------------------------------
3759 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3760 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3761 {
3762  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3763  blocked_range<int> re(0, im9->GetNumberOfVoxels());
3764  body(re);
3765  vf.join(body._VoxelFunc);
3766 }
3767 
3768 // -----------------------------------------------------------------------------
3769 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3770 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3771 {
3772  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3773  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3774 }
3775 
3776 // -----------------------------------------------------------------------------
3777 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3778 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3779 {
3780  if (im9->GetTSize()) {
3781  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3782  } else {
3783  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3784  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
3785  body(re);
3786  vf.join(body._VoxelFunc);
3787  }
3788 }
3789 
3790 // -----------------------------------------------------------------------------
3791 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3792 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3793 {
3794  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3795  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3796 }
3797 
3798 // -----------------------------------------------------------------------------
3799 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3800 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3801 {
3802  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3803  body(attr);
3804  vf.join(body._VoxelFunc);
3805 }
3806 
3807 // -----------------------------------------------------------------------------
3808 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3809 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3810 {
3811  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3812  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3813 }
3814 
3815 // -----------------------------------------------------------------------------
3816 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3817 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3818 {
3819  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3820  body(re);
3821  vf.join(body._VoxelFunc);
3822 }
3823 
3824 // -----------------------------------------------------------------------------
3825 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3826 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3827 {
3828  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3829  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3830 }
3831 
3832 // -----------------------------------------------------------------------------
3833 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3834 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3835 {
3836  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3837  body(re);
3838  vf.join(body._VoxelFunc);
3839 }
3840 
3841 // -----------------------------------------------------------------------------
3842 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3843 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3844 {
3845  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3846  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3847 }
3848 
3849 // -----------------------------------------------------------------------------
3850 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3851 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
3852 {
3853  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3854  body(re);
3855  vf.join(body._VoxelFunc);
3856 }
3857 
3858 // -----------------------------------------------------------------------------
3859 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3860 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
3861 {
3862  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3863  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
3864 }
3865 
3866 //
3867 // Image arguments by reference
3868 //
3869 
3870 // -----------------------------------------------------------------------------
3871 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3872 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3873 {
3874  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3876  body(re);
3877  vf.join(body._VoxelFunc);
3878 }
3879 
3880 // -----------------------------------------------------------------------------
3881 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3882 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3883 {
3884  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3885  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3886 }
3887 
3888 // -----------------------------------------------------------------------------
3889 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3890 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3891 {
3892  if (im9.GetTSize()) {
3893  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3894  } else {
3895  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3896  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
3897  body(re);
3898  vf.join(body._VoxelFunc);
3899  }
3900 }
3901 
3902 // -----------------------------------------------------------------------------
3903 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3904 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3905 {
3906  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3907  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3908 }
3909 
3910 // -----------------------------------------------------------------------------
3911 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3912 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3913 {
3914  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3915  body(attr);
3916  vf.join(body._VoxelFunc);
3917 }
3918 
3919 // -----------------------------------------------------------------------------
3920 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3921 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3922 {
3923  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3924  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3925 }
3926 
3927 // -----------------------------------------------------------------------------
3928 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3929 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3930 {
3931  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3932  body(re);
3933  vf.join(body._VoxelFunc);
3934 }
3935 
3936 // -----------------------------------------------------------------------------
3937 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3938 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3939 {
3940  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3941  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3942 }
3943 
3944 // -----------------------------------------------------------------------------
3945 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3946 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3947 {
3948  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3949  body(re);
3950  vf.join(body._VoxelFunc);
3951 }
3952 
3953 // -----------------------------------------------------------------------------
3954 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3955 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3956 {
3957  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3958  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3959 }
3960 
3961 // -----------------------------------------------------------------------------
3962 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3963 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
3964 {
3965  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3966  body(re);
3967  vf.join(body._VoxelFunc);
3968 }
3969 
3970 // -----------------------------------------------------------------------------
3971 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
3972 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
3973 {
3974  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
3975  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
3976 }
3977 
3978 // -----------------------------------------------------------------------------
3979 // ForEachVoxelIf
3980 // -----------------------------------------------------------------------------
3981 
3982 //
3983 // Image arguments by pointer
3984 //
3985 
3986 // -----------------------------------------------------------------------------
3987 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3988 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
3989 {
3990  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
3991  blocked_range<int> re(0, im9->GetNumberOfVoxels());
3992  body(re);
3993  vf.join(body._VoxelFunc);
3994  of.join(body._OutsideFunc);
3995 }
3996 
3997 // -----------------------------------------------------------------------------
3998 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
3999 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4000 {
4001  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4002  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4003 }
4004 
4005 // -----------------------------------------------------------------------------
4006 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4007 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4008 {
4010  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4011 }
4012 
4013 // -----------------------------------------------------------------------------
4014 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4015 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4016 {
4017  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4018  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4019 }
4020 
4021 // -----------------------------------------------------------------------------
4022 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4023 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4024 {
4025  if (im9->GetTSize()) {
4026  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4027  } else {
4028  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4029  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
4030  body(re);
4031  vf.join(body._VoxelFunc);
4032  of.join(body._OutsideFunc);
4033  }
4034 }
4035 
4036 // -----------------------------------------------------------------------------
4037 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4038 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4039 {
4040  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4041  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4042 }
4043 
4044 // -----------------------------------------------------------------------------
4045 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4046 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4047 {
4049  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4050 }
4051 
4052 // -----------------------------------------------------------------------------
4053 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4054 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4055 {
4056  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4057  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4058 }
4059 
4060 // -----------------------------------------------------------------------------
4061 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4062 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4063 {
4064  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4065  body(attr);
4066  vf.join(body._VoxelFunc);
4067  of.join(body._OutsideFunc);
4068 }
4069 
4070 // -----------------------------------------------------------------------------
4071 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4072 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4073 {
4074  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4075  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4076 }
4077 
4078 // -----------------------------------------------------------------------------
4079 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4080 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4081 {
4083  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4084 }
4085 
4086 // -----------------------------------------------------------------------------
4087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4088 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4089 {
4090  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4091  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4092 }
4093 
4094 // -----------------------------------------------------------------------------
4095 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4096 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4097 {
4098  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4099  body(re);
4100  vf.join(body._VoxelFunc);
4101  of.join(body._OutsideFunc);
4102 }
4103 
4104 // -----------------------------------------------------------------------------
4105 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4106 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4107 {
4108  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4109  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4110 }
4111 
4112 // -----------------------------------------------------------------------------
4113 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4114 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4115 {
4116  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4117  body(re);
4118  vf.join(body._VoxelFunc);
4119  of.join(body._OutsideFunc);
4120 }
4121 
4122 // -----------------------------------------------------------------------------
4123 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4124 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4125 {
4126  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4127  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4128 }
4129 
4130 // -----------------------------------------------------------------------------
4131 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4132 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4133 {
4135  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4136 }
4137 
4138 // -----------------------------------------------------------------------------
4139 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4140 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4141 {
4142  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4143  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4144 }
4145 
4146 // -----------------------------------------------------------------------------
4147 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4148 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4149 {
4150  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4151  body(re);
4152  vf.join(body._VoxelFunc);
4153  of.join(body._OutsideFunc);
4154 }
4155 
4156 // -----------------------------------------------------------------------------
4157 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4158 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4159 {
4160  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4161  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4162 }
4163 
4164 // -----------------------------------------------------------------------------
4165 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4166 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4167 {
4169  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4170 }
4171 
4172 // -----------------------------------------------------------------------------
4173 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4174 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4175 {
4176  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4177  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4178 }
4179 
4180 //
4181 // Image arguments by reference
4182 //
4183 
4184 // -----------------------------------------------------------------------------
4185 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4186 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4187 {
4188  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4190  body(re);
4191  vf.join(body._VoxelFunc);
4192  of.join(body._OutsideFunc);
4193 }
4194 
4195 // -----------------------------------------------------------------------------
4196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4197 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4198 {
4199  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4200  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4201 }
4202 
4203 // -----------------------------------------------------------------------------
4204 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4205 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4206 {
4208  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4209 }
4210 
4211 // -----------------------------------------------------------------------------
4212 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4213 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4214 {
4215  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4216  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4217 }
4218 
4219 // -----------------------------------------------------------------------------
4220 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4221 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4222 {
4223  if (im9.GetTSize()) {
4224  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4225  } else {
4226  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4227  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
4228  body(re);
4229  vf.join(body._VoxelFunc);
4230  of.join(body._OutsideFunc);
4231  }
4232 }
4233 
4234 // -----------------------------------------------------------------------------
4235 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4236 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4237 {
4238  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4239  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4240 }
4241 
4242 // -----------------------------------------------------------------------------
4243 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4244 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4245 {
4247  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4248 }
4249 
4250 // -----------------------------------------------------------------------------
4251 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4252 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4253 {
4254  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4255  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4256 }
4257 
4258 // -----------------------------------------------------------------------------
4259 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4260 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4261 {
4262  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4263  body(attr);
4264  vf.join(body._VoxelFunc);
4265  of.join(body._OutsideFunc);
4266 }
4267 
4268 // -----------------------------------------------------------------------------
4269 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4270 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4271 {
4272  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4273  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4274 }
4275 
4276 // -----------------------------------------------------------------------------
4277 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4278 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4279 {
4281  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4282 }
4283 
4284 // -----------------------------------------------------------------------------
4285 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4286 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4287 {
4288  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4289  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4290 }
4291 
4292 // -----------------------------------------------------------------------------
4293 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4294 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4295 {
4296  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4297  body(re);
4298  vf.join(body._VoxelFunc);
4299  of.join(body._OutsideFunc);
4300 }
4301 
4302 // -----------------------------------------------------------------------------
4303 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4304 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4305 {
4306  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4307  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4308 }
4309 
4310 // -----------------------------------------------------------------------------
4311 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4312 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4313 {
4314  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4315  body(re);
4316  vf.join(body._VoxelFunc);
4317  of.join(body._OutsideFunc);
4318 }
4319 
4320 // -----------------------------------------------------------------------------
4321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4322 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4323 {
4324  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4325  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4326 }
4327 
4328 // -----------------------------------------------------------------------------
4329 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4330 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4331 {
4333  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4334 }
4335 
4336 // -----------------------------------------------------------------------------
4337 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4338 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4339 {
4340  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4341  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4342 }
4343 
4344 // -----------------------------------------------------------------------------
4345 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4346 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4347 {
4348  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4349  body(re);
4350  vf.join(body._VoxelFunc);
4351  of.join(body._OutsideFunc);
4352 }
4353 
4354 // -----------------------------------------------------------------------------
4355 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4356 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4357 {
4358  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4359  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4360 }
4361 
4362 // -----------------------------------------------------------------------------
4363 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4364 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4365 {
4367  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4368 }
4369 
4370 // -----------------------------------------------------------------------------
4371 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4372 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4373 {
4374  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4375  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4376 }
4377 
4378 // -----------------------------------------------------------------------------
4379 // ParallelForEachVoxel
4380 // -----------------------------------------------------------------------------
4381 
4382 //
4383 // Image arguments by pointer
4384 //
4385 
4386 // -----------------------------------------------------------------------------
4387 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4388 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4389 {
4390  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4391  blocked_range<int> re(0, im9->GetNumberOfVoxels());
4392  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4393  else parallel_for (re, body);
4394 }
4395 
4396 // -----------------------------------------------------------------------------
4397 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4398 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4399 {
4400  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4401  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4402 }
4403 
4404 // -----------------------------------------------------------------------------
4405 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4406 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4407 {
4408  if (im9->GetTSize()) {
4409  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4410  } else {
4411  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4412  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
4413  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4414  else parallel_for (re, body);
4415  }
4416 }
4417 
4418 // -----------------------------------------------------------------------------
4419 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4420 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4421 {
4422  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4423  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4424 }
4425 
4426 // -----------------------------------------------------------------------------
4427 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4428 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4429 {
4430  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4431  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4432  if (VoxelFunc::IsReduction()) {
4433  if (attr._dt) {
4434  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4435  } else {
4436  parallel_reduce(re, body);
4437  }
4438  vf.join(body._VoxelFunc);
4439  } else {
4440  if (attr._dt) {
4441  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4442  } else {
4443  parallel_for(re, body);
4444  }
4445  }
4446 }
4447 
4448 // -----------------------------------------------------------------------------
4449 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4450 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4451 {
4452  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4453  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4454 }
4455 
4456 // -----------------------------------------------------------------------------
4457 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4458 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4459 {
4460  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4461  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4462  else parallel_for (re, body);
4463 }
4464 
4465 // -----------------------------------------------------------------------------
4466 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4467 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4468 {
4469  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4470  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4471 }
4472 
4473 // -----------------------------------------------------------------------------
4474 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4475 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4476 {
4477  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, 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 T7, class T8, class T9, class VoxelFunc>
4484 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4485 {
4486  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4487  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4488 }
4489 
4490 // -----------------------------------------------------------------------------
4491 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4492 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4493 {
4494  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, 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 T7, class T8, class T9, class VoxelFunc>
4501 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4502 {
4503  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4504  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4505 }
4506 
4507 //
4508 // Image arguments by reference
4509 //
4510 
4511 // -----------------------------------------------------------------------------
4512 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4513 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4514 {
4515  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4517  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4518  else parallel_for (re, body);
4519 }
4520 
4521 // -----------------------------------------------------------------------------
4522 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4523 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4524 {
4525  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4526  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4527 }
4528 
4529 // -----------------------------------------------------------------------------
4530 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4531 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4532 {
4533  if (im9.GetTSize()) {
4534  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4535  } else {
4536  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4537  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
4538  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4539  else parallel_for (re, body);
4540  }
4541 }
4542 
4543 // -----------------------------------------------------------------------------
4544 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4545 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4546 {
4547  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4548  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4549 }
4550 
4551 // -----------------------------------------------------------------------------
4552 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4553 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4554 {
4555  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4556  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4557  if (VoxelFunc::IsReduction()) {
4558  if (attr._dt) {
4559  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4560  } else {
4561  parallel_reduce(re, body);
4562  }
4563  vf.join(body._VoxelFunc);
4564  } else {
4565  if (attr._dt) {
4566  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4567  } else {
4568  parallel_for(re, body);
4569  }
4570  }
4571 }
4572 
4573 // -----------------------------------------------------------------------------
4574 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4575 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4576 {
4577  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4578  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4579 }
4580 
4581 // -----------------------------------------------------------------------------
4582 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4583 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4584 {
4585  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4586  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4587  else parallel_for (re, body);
4588 }
4589 
4590 // -----------------------------------------------------------------------------
4591 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4592 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4593 {
4594  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4595  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4596 }
4597 
4598 // -----------------------------------------------------------------------------
4599 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4600 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4601 {
4602  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4603  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4604  else parallel_for (re, body);
4605 }
4606 
4607 // -----------------------------------------------------------------------------
4608 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4609 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4610 {
4611  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4612  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4613 }
4614 
4615 // -----------------------------------------------------------------------------
4616 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4617 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4618 {
4619  NonaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4620  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4621  else parallel_for (re, body);
4622 }
4623 
4624 // -----------------------------------------------------------------------------
4625 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4626 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4627 {
4628  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4629  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4630 }
4631 
4632 // -----------------------------------------------------------------------------
4633 // ParallelForEachVoxelIf
4634 // -----------------------------------------------------------------------------
4635 
4636 //
4637 // Image arguments by pointer
4638 //
4639 
4640 // -----------------------------------------------------------------------------
4641 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4642 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4643 {
4644  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4645  blocked_range<int> re(0, im9->GetNumberOfVoxels());
4646  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4647  parallel_reduce(re, body);
4648  vf.join(body._VoxelFunc);
4649  of.join(body._OutsideFunc);
4650  } else {
4651  parallel_for(re, body);
4652  }
4653 }
4654 
4655 // -----------------------------------------------------------------------------
4656 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4657 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4658 {
4659  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4660  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4661 }
4662 
4663 // -----------------------------------------------------------------------------
4664 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4665 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4666 {
4668  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4669 }
4670 
4671 // -----------------------------------------------------------------------------
4672 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4673 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4674 {
4675  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4676  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4677 }
4678 
4679 // -----------------------------------------------------------------------------
4680 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4681 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4682 {
4683  if (im9->GetTSize()) {
4684  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4685  } else {
4686  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4687  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
4688  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4689  parallel_reduce(re, body);
4690  vf.join(body._VoxelFunc);
4691  of.join(body._OutsideFunc);
4692  } else {
4693  parallel_for(re, body);
4694  }
4695  }
4696 }
4697 
4698 // -----------------------------------------------------------------------------
4699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4700 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4701 {
4702  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4703  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4704 }
4705 
4706 // -----------------------------------------------------------------------------
4707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4708 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4709 {
4711  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4712 }
4713 
4714 // -----------------------------------------------------------------------------
4715 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4716 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4717 {
4718  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4719  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4720 }
4721 
4722 // -----------------------------------------------------------------------------
4723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4724 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4725 {
4726  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4727  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4728  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4729  if (attr._dt) {
4730  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4731  } else {
4732  parallel_reduce(re, body);
4733  }
4734  vf.join(body._VoxelFunc);
4735  of.join(body._OutsideFunc);
4736  } else {
4737  if (attr._dt) {
4738  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4739  } else {
4740  parallel_for(re, body);
4741  }
4742  }
4743 }
4744 
4745 // -----------------------------------------------------------------------------
4746 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4747 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4748 {
4749  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4750  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4751 }
4752 
4753 // -----------------------------------------------------------------------------
4754 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4755 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4756 {
4758  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4759 }
4760 
4761 // -----------------------------------------------------------------------------
4762 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4763 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4764 {
4765  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4766  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4767 }
4768 
4769 // -----------------------------------------------------------------------------
4770 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4771 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4772 {
4773  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4774  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4775  parallel_reduce(re, body);
4776  vf.join(body._VoxelFunc);
4777  of.join(body._OutsideFunc);
4778  } else {
4779  parallel_for(re, body);
4780  }
4781 }
4782 
4783 // -----------------------------------------------------------------------------
4784 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4785 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4786 {
4787  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4788  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4789 }
4790 
4791 // -----------------------------------------------------------------------------
4792 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4793 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4794 {
4796  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4797 }
4798 
4799 // -----------------------------------------------------------------------------
4800 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4801 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4802 {
4803  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4804  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4805 }
4806 
4807 // -----------------------------------------------------------------------------
4808 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4809 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4810 {
4811  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4812  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4813  parallel_reduce(re, body);
4814  vf.join(body._VoxelFunc);
4815  of.join(body._OutsideFunc);
4816  } else {
4817  parallel_for(re, body);
4818  }
4819 }
4820 
4821 // -----------------------------------------------------------------------------
4822 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4823 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4824 {
4825  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4826  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4827 }
4828 
4829 // -----------------------------------------------------------------------------
4830 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4831 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4832 {
4834  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4835 }
4836 
4837 // -----------------------------------------------------------------------------
4838 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4839 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4840 {
4841  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4842  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4843 }
4844 
4845 // -----------------------------------------------------------------------------
4846 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4847 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
4848 {
4849  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4850  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4851  parallel_reduce(re, body);
4852  vf.join(body._VoxelFunc);
4853  of.join(body._OutsideFunc);
4854  } else {
4855  parallel_for(re, body);
4856  }
4857 }
4858 
4859 // -----------------------------------------------------------------------------
4860 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4861 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4862 {
4863  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4864  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4865 }
4866 
4867 // -----------------------------------------------------------------------------
4868 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4869 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
4870 {
4872  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
4873 }
4874 
4875 // -----------------------------------------------------------------------------
4876 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4877 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, const GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
4878 {
4879  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4880  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
4881 }
4882 
4883 //
4884 // Image arguments by reference
4885 //
4886 
4887 // -----------------------------------------------------------------------------
4888 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4889 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4890 {
4891  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4893  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4894  parallel_reduce(re, body);
4895  vf.join(body._VoxelFunc);
4896  of.join(body._OutsideFunc);
4897  } else {
4898  parallel_for(re, body);
4899  }
4900 }
4901 
4902 // -----------------------------------------------------------------------------
4903 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4904 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4905 {
4906  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4907  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4908 }
4909 
4910 // -----------------------------------------------------------------------------
4911 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4912 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4913 {
4915  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4916 }
4917 
4918 // -----------------------------------------------------------------------------
4919 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4920 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4921 {
4922  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4923  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4924 }
4925 
4926 // -----------------------------------------------------------------------------
4927 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4928 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4929 {
4930  if (im9.GetTSize()) {
4931  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4932  } else {
4933  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4934  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
4935  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4936  parallel_reduce(re, body);
4937  vf.join(body._VoxelFunc);
4938  of.join(body._OutsideFunc);
4939  } else {
4940  parallel_for(re, body);
4941  }
4942  }
4943 }
4944 
4945 // -----------------------------------------------------------------------------
4946 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4947 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4948 {
4949  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4950  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4951 }
4952 
4953 // -----------------------------------------------------------------------------
4954 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4955 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
4956 {
4958  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4959 }
4960 
4961 // -----------------------------------------------------------------------------
4962 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
4963 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4964 {
4965  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4966  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
4967 }
4968 
4969 // -----------------------------------------------------------------------------
4970 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4971 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
4972 {
4973  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4974  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4975  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4976  if (attr._dt) {
4977  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4978  } else {
4979  parallel_reduce(re, body);
4980  }
4981  vf.join(body._VoxelFunc);
4982  of.join(body._OutsideFunc);
4983  } else {
4984  if (attr._dt) {
4985  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4986  } else {
4987  parallel_for(re, body);
4988  }
4989  }
4990 }
4991 
4992 // -----------------------------------------------------------------------------
4993 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
4994 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
4995 {
4996  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
4997  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
4998 }
4999 
5000 // -----------------------------------------------------------------------------
5001 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5002 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5003 {
5005  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5006 }
5007 
5008 // -----------------------------------------------------------------------------
5009 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5010 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5011 {
5012  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5013  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5014 }
5015 
5016 // -----------------------------------------------------------------------------
5017 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5018 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5019 {
5020  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5021  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
5022  parallel_reduce(re, body);
5023  vf.join(body._VoxelFunc);
5024  of.join(body._OutsideFunc);
5025  } else {
5026  parallel_for(re, body);
5027  }
5028 }
5029 
5030 // -----------------------------------------------------------------------------
5031 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5032 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5033 {
5034  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5035  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5036 }
5037 
5038 // -----------------------------------------------------------------------------
5039 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5040 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5041 {
5043  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5044 }
5045 
5046 // -----------------------------------------------------------------------------
5047 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5048 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5049 {
5050  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5051  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5052 }
5053 
5054 // -----------------------------------------------------------------------------
5055 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5056 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5057 {
5058  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5059  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
5060  parallel_reduce(re, body);
5061  vf.join(body._VoxelFunc);
5062  of.join(body._OutsideFunc);
5063  } else {
5064  parallel_for(re, body);
5065  }
5066 }
5067 
5068 // -----------------------------------------------------------------------------
5069 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5070 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5071 {
5072  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5073  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5074 }
5075 
5076 // -----------------------------------------------------------------------------
5077 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5078 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5079 {
5081  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5082 }
5083 
5084 // -----------------------------------------------------------------------------
5085 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5086 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5087 {
5088  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5089  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5090 }
5091 
5092 // -----------------------------------------------------------------------------
5093 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5094 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5095 {
5096  NonaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5097  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
5098  parallel_reduce(re, body);
5099  vf.join(body._VoxelFunc);
5100  of.join(body._OutsideFunc);
5101  } else {
5102  parallel_for(re, body);
5103  }
5104 }
5105 
5106 // -----------------------------------------------------------------------------
5107 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5108 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5109 {
5110  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5111  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5112 }
5113 
5114 // -----------------------------------------------------------------------------
5115 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5116 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5117 {
5119  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5120 }
5121 
5122 // -----------------------------------------------------------------------------
5123 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5124 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, const GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5125 {
5126  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5127  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5128 }
5129 
5130 // =============================================================================
5131 // 6 const, 3 non-const images
5132 // =============================================================================
5133 
5134 // -----------------------------------------------------------------------------
5135 /**
5136  * ForEachVoxel body for voxel function of 6 const, 3 non-const images
5137  */
5138 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5140 {
5141  const GenericImage<T1> &im1;
5142  const GenericImage<T2> &im2;
5143  const GenericImage<T3> &im3;
5144  const GenericImage<T4> &im4;
5145  const GenericImage<T5> &im5;
5146  const GenericImage<T6> &im6;
5147  GenericImage<T7> &im7;
5148  GenericImage<T8> &im8;
5149  GenericImage<T9> &im9;
5150 
5151  /// Constructor
5153  const GenericImage<T2> &im2,
5154  const GenericImage<T3> &im3,
5155  const GenericImage<T4> &im4,
5156  const GenericImage<T5> &im5,
5157  const GenericImage<T6> &im6,
5158  GenericImage<T7> &im7,
5159  GenericImage<T8> &im8,
5160  GenericImage<T9> &im9,
5161  VoxelFunc &vf)
5162  :
5163  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
5164  {}
5165 
5166  /// Copy constructor
5168  :
5169  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
5170  {}
5171 
5172  /// Split constructor
5174  :
5175  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
5176  {}
5177 
5178  /// Process entire image
5179  void operator ()(const ImageAttributes &attr) const
5180  {
5181  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5182  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5183  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5184  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5185  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5186  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5187  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
5188  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
5189  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
5190 
5191  const int T = (attr._dt ? attr._t : 1);
5192 
5193  for (int l = 0; l < T; ++l)
5194  for (int k = 0; k < attr._z; ++k)
5195  for (int j = 0; j < attr._y; ++j)
5196  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
5197  // const_cast such that voxel functions need only implement
5198  // non-const operator() which is required for parallel_reduce
5199  const_cast<NonaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5200  }
5201  }
5202 
5203  /// Process image region using linear index
5204  void operator ()(const blocked_range<int> &re) const
5205  {
5206  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5207  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5208  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5209  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5210  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5211  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5212  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
5213  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
5214  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
5215 
5216  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5217  // const_cast such that voxel functions need only implement
5218  // non-const operator() which is required for parallel_reduce
5219  const_cast<NonaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5220  }
5221  }
5222 
5223  /// Process 2D image region
5224  void operator ()(const blocked_range2d<int> &re) const
5225  {
5226  const int bi = re.cols().begin();
5227  const int bj = re.rows().begin();
5228  const int ei = re.cols().end();
5229  const int ej = re.rows().end();
5230 
5231  const int s1 = im9.GetX() - (ei - bi);
5232 
5233  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5234  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5235  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5236  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5237  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5238  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5239  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5240  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5241  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5242 
5243  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
5244  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5245  // const_cast such that voxel functions need only implement
5246  // non-const operator() which is required for parallel_reduce
5247  const_cast<NonaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5248  }
5249  }
5250 
5251  /// Process 3D image region
5252  void operator ()(const blocked_range3d<int> &re) const
5253  {
5254  const int bi = re.cols ().begin();
5255  const int bj = re.rows ().begin();
5256  const int bk = re.pages().begin();
5257  const int ei = re.cols ().end();
5258  const int ej = re.rows ().end();
5259  const int ek = re.pages().end();
5260 
5261  const int s1 = im9.GetX() - (ei - bi);
5262  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
5263 
5264  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5265  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5266  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5267  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5268  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5269  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5270  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
5271  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
5272  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
5273 
5274  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
5275  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
5276  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5277  // const_cast such that voxel functions need only implement
5278  // non-const operator() which is required for parallel_reduce
5279  const_cast<NonaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5280  }
5281  }
5282 };
5283 
5284 // -----------------------------------------------------------------------------
5285 /**
5286  * ForEachVoxel body for inside and outside unary voxel function of 6 const, 3 non-const images
5287  */
5288 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
5289  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
5290  class Domain = ForEachVoxelDomain::Foreground>
5291 struct NonaryForEachVoxelIfBody_6Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
5292 {
5293  const GenericImage<T1> &im1;
5294  const GenericImage<T2> &im2;
5295  const GenericImage<T3> &im3;
5296  const GenericImage<T4> &im4;
5297  const GenericImage<T5> &im5;
5298  const GenericImage<T6> &im6;
5299  GenericImage<T7> &im7;
5300  GenericImage<T8> &im8;
5301  GenericImage<T9> &im9;
5302 
5303  /// Constructor
5305  const GenericImage<T2> &im2,
5306  const GenericImage<T3> &im3,
5307  const GenericImage<T4> &im4,
5308  const GenericImage<T5> &im5,
5309  const GenericImage<T6> &im6,
5310  GenericImage<T7> &im7,
5311  GenericImage<T8> &im8,
5312  GenericImage<T9> &im9,
5313  VoxelFunc &vf, OutsideFunc &of)
5314  :
5315  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
5316  {}
5317 
5318  /// Copy constructor
5320  :
5321  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
5322  {}
5323 
5324  /// Split constructor
5326  :
5327  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
5328  {}
5329 
5330  /// Process entire image
5331  void operator ()(const ImageAttributes &attr) const
5332  {
5333  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5334  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5335  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5336  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5337  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5338  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5339  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
5340  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
5341  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
5342 
5343  const int T = (attr._dt ? attr._t : 1);
5344 
5345  for (int l = 0; l < T; ++l)
5346  for (int k = 0; k < attr._z; ++k)
5347  for (int j = 0; j < attr._y; ++j)
5348  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
5349  if (Domain::IsInside(im9, i, j, k, l, p9)) {
5350  // const_cast such that voxel functions need only implement
5351  // non-const operator() which is required for parallel_reduce
5352  const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5353  } else const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5354  }
5355  }
5356 
5357  /// Process image region using linear index
5358  void operator ()(const blocked_range<int> &re) const
5359  {
5360  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5361  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5362  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5363  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5364  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5365  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5366  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
5367  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
5368  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
5369 
5370  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5371  if (Domain::IsInside(im9, idx, p9)) {
5372  // const_cast such that voxel functions need only implement
5373  // non-const operator() which is required for parallel_reduce
5374  const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5375  } else const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5376  }
5377  }
5378 
5379  /// Process 2D image region
5380  void operator ()(const blocked_range2d<int> &re) const
5381  {
5382  const int bi = re.cols().begin();
5383  const int bj = re.rows().begin();
5384  const int ei = re.cols().end();
5385  const int ej = re.rows().end();
5386 
5387  const int s1 = im9.GetX() - (ei - bi);
5388 
5389  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5390  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5391  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5392  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5393  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5394  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5395  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5396  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5397  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5398 
5399  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
5400  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5401  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
5402  // const_cast such that voxel functions need only implement
5403  // non-const operator() which is required for parallel_reduce
5404  const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5405  } else const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5406  }
5407  }
5408 
5409  /// Process 3D image region
5410  void operator ()(const blocked_range3d<int> &re) const
5411  {
5412  const int bi = re.cols ().begin();
5413  const int bj = re.rows ().begin();
5414  const int bk = re.pages().begin();
5415  const int ei = re.cols ().end();
5416  const int ej = re.rows ().end();
5417  const int ek = re.pages().end();
5418 
5419  const int s1 = im9.GetX() - (ei - bi);
5420  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
5421 
5422  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5423  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5424  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5425  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5426  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5427  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5428  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
5429  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
5430  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
5431 
5432  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
5433  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
5434  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
5435  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
5436  // const_cast such that voxel functions need only implement
5437  // non-const operator() which is required for parallel_reduce
5438  const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5439  } else const_cast<NonaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
5440  }
5441  }
5442 };
5443 
5444 // -----------------------------------------------------------------------------
5445 // ForEachVoxel
5446 // -----------------------------------------------------------------------------
5447 
5448 //
5449 // Image arguments by pointer
5450 //
5451 
5452 // -----------------------------------------------------------------------------
5453 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5454 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5455 {
5456  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5457  blocked_range<int> re(0, im9->GetNumberOfVoxels());
5458  body(re);
5459  vf.join(body._VoxelFunc);
5460 }
5461 
5462 // -----------------------------------------------------------------------------
5463 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5464 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5465 {
5466  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5467  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5468 }
5469 
5470 // -----------------------------------------------------------------------------
5471 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5472 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5473 {
5474  if (im9->GetTSize()) {
5475  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5476  } else {
5477  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5478  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
5479  body(re);
5480  vf.join(body._VoxelFunc);
5481  }
5482 }
5483 
5484 // -----------------------------------------------------------------------------
5485 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5486 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5487 {
5488  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5489  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5490 }
5491 
5492 // -----------------------------------------------------------------------------
5493 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5494 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5495 {
5496  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5497  body(attr);
5498  vf.join(body._VoxelFunc);
5499 }
5500 
5501 // -----------------------------------------------------------------------------
5502 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5503 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5504 {
5505  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5506  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5507 }
5508 
5509 // -----------------------------------------------------------------------------
5510 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5511 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5512 {
5513  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5514  body(re);
5515  vf.join(body._VoxelFunc);
5516 }
5517 
5518 // -----------------------------------------------------------------------------
5519 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5520 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5521 {
5522  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5523  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5524 }
5525 
5526 // -----------------------------------------------------------------------------
5527 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5528 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5529 {
5530  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5531  body(re);
5532  vf.join(body._VoxelFunc);
5533 }
5534 
5535 // -----------------------------------------------------------------------------
5536 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5537 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5538 {
5539  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5540  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5541 }
5542 
5543 // -----------------------------------------------------------------------------
5544 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5545 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5546 {
5547  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5548  body(re);
5549  vf.join(body._VoxelFunc);
5550 }
5551 
5552 // -----------------------------------------------------------------------------
5553 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5554 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5555 {
5556  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5557  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5558 }
5559 
5560 //
5561 // Image arguments by reference
5562 //
5563 
5564 // -----------------------------------------------------------------------------
5565 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5566 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5567 {
5568  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5570  body(re);
5571  vf.join(body._VoxelFunc);
5572 }
5573 
5574 // -----------------------------------------------------------------------------
5575 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5576 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5577 {
5578  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5579  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5580 }
5581 
5582 // -----------------------------------------------------------------------------
5583 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5584 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5585 {
5586  if (im9.GetTSize()) {
5587  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5588  } else {
5589  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5590  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
5591  body(re);
5592  vf.join(body._VoxelFunc);
5593  }
5594 }
5595 
5596 // -----------------------------------------------------------------------------
5597 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5598 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5599 {
5600  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5601  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5602 }
5603 
5604 // -----------------------------------------------------------------------------
5605 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5606 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5607 {
5608  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5609  body(attr);
5610  vf.join(body._VoxelFunc);
5611 }
5612 
5613 // -----------------------------------------------------------------------------
5614 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5615 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5616 {
5617  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5618  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5619 }
5620 
5621 // -----------------------------------------------------------------------------
5622 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5623 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5624 {
5625  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5626  body(re);
5627  vf.join(body._VoxelFunc);
5628 }
5629 
5630 // -----------------------------------------------------------------------------
5631 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5632 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5633 {
5634  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5635  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5636 }
5637 
5638 // -----------------------------------------------------------------------------
5639 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5640 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5641 {
5642  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5643  body(re);
5644  vf.join(body._VoxelFunc);
5645 }
5646 
5647 // -----------------------------------------------------------------------------
5648 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5649 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5650 {
5651  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5652  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5653 }
5654 
5655 // -----------------------------------------------------------------------------
5656 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5657 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5658 {
5659  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5660  body(re);
5661  vf.join(body._VoxelFunc);
5662 }
5663 
5664 // -----------------------------------------------------------------------------
5665 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5666 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5667 {
5668  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5669  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5670 }
5671 
5672 // -----------------------------------------------------------------------------
5673 // ForEachVoxelIf
5674 // -----------------------------------------------------------------------------
5675 
5676 //
5677 // Image arguments by pointer
5678 //
5679 
5680 // -----------------------------------------------------------------------------
5681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5682 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5683 {
5684  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5685  blocked_range<int> re(0, im9->GetNumberOfVoxels());
5686  body(re);
5687  vf.join(body._VoxelFunc);
5688  of.join(body._OutsideFunc);
5689 }
5690 
5691 // -----------------------------------------------------------------------------
5692 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5693 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5694 {
5695  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5696  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5697 }
5698 
5699 // -----------------------------------------------------------------------------
5700 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5701 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5702 {
5704  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5705 }
5706 
5707 // -----------------------------------------------------------------------------
5708 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5709 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5710 {
5711  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5712  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5713 }
5714 
5715 // -----------------------------------------------------------------------------
5716 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5717 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5718 {
5719  if (im9->GetTSize()) {
5720  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5721  } else {
5722  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5723  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
5724  body(re);
5725  vf.join(body._VoxelFunc);
5726  of.join(body._OutsideFunc);
5727  }
5728 }
5729 
5730 // -----------------------------------------------------------------------------
5731 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5732 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5733 {
5734  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5735  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5736 }
5737 
5738 // -----------------------------------------------------------------------------
5739 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5740 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5741 {
5743  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5744 }
5745 
5746 // -----------------------------------------------------------------------------
5747 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5748 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5749 {
5750  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5751  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5752 }
5753 
5754 // -----------------------------------------------------------------------------
5755 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5756 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5757 {
5758  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5759  body(attr);
5760  vf.join(body._VoxelFunc);
5761  of.join(body._OutsideFunc);
5762 }
5763 
5764 // -----------------------------------------------------------------------------
5765 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5766 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5767 {
5768  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5769  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5770 }
5771 
5772 // -----------------------------------------------------------------------------
5773 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5774 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5775 {
5777  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5778 }
5779 
5780 // -----------------------------------------------------------------------------
5781 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5782 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5783 {
5784  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5785  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5786 }
5787 
5788 // -----------------------------------------------------------------------------
5789 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5790 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5791 {
5792  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5793  body(re);
5794  vf.join(body._VoxelFunc);
5795  of.join(body._OutsideFunc);
5796 }
5797 
5798 // -----------------------------------------------------------------------------
5799 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5800 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5801 {
5802  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5803  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5804 }
5805 
5806 // -----------------------------------------------------------------------------
5807 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5808 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5809 {
5810  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5811  body(re);
5812  vf.join(body._VoxelFunc);
5813  of.join(body._OutsideFunc);
5814 }
5815 
5816 // -----------------------------------------------------------------------------
5817 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5818 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5819 {
5820  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5821  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5822 }
5823 
5824 // -----------------------------------------------------------------------------
5825 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5826 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5827 {
5829  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5830 }
5831 
5832 // -----------------------------------------------------------------------------
5833 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5834 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5835 {
5836  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5837  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5838 }
5839 
5840 // -----------------------------------------------------------------------------
5841 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5842 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
5843 {
5844  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5845  body(re);
5846  vf.join(body._VoxelFunc);
5847  of.join(body._OutsideFunc);
5848 }
5849 
5850 // -----------------------------------------------------------------------------
5851 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5852 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5853 {
5854  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5855  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5856 }
5857 
5858 // -----------------------------------------------------------------------------
5859 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5860 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
5861 {
5863  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
5864 }
5865 
5866 // -----------------------------------------------------------------------------
5867 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5868 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
5869 {
5870  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5871  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
5872 }
5873 
5874 //
5875 // Image arguments by reference
5876 //
5877 
5878 // -----------------------------------------------------------------------------
5879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5880 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5881 {
5882  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5884  body(re);
5885  vf.join(body._VoxelFunc);
5886  of.join(body._OutsideFunc);
5887 }
5888 
5889 // -----------------------------------------------------------------------------
5890 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5891 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5892 {
5893  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5894  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5895 }
5896 
5897 // -----------------------------------------------------------------------------
5898 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5899 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5900 {
5902  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5903 }
5904 
5905 // -----------------------------------------------------------------------------
5906 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5907 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5908 {
5909  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5910  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5911 }
5912 
5913 // -----------------------------------------------------------------------------
5914 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5915 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5916 {
5917  if (im9.GetTSize()) {
5918  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5919  } else {
5920  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5921  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
5922  body(re);
5923  vf.join(body._VoxelFunc);
5924  of.join(body._OutsideFunc);
5925  }
5926 }
5927 
5928 // -----------------------------------------------------------------------------
5929 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5930 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5931 {
5932  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5933  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5934 }
5935 
5936 // -----------------------------------------------------------------------------
5937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5938 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5939 {
5941  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5942 }
5943 
5944 // -----------------------------------------------------------------------------
5945 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5946 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5947 {
5948  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5949  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5950 }
5951 
5952 // -----------------------------------------------------------------------------
5953 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5954 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5955 {
5956  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5957  body(attr);
5958  vf.join(body._VoxelFunc);
5959  of.join(body._OutsideFunc);
5960 }
5961 
5962 // -----------------------------------------------------------------------------
5963 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5964 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5965 {
5966  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5967  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5968 }
5969 
5970 // -----------------------------------------------------------------------------
5971 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5972 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
5973 {
5975  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5976 }
5977 
5978 // -----------------------------------------------------------------------------
5979 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
5980 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5981 {
5982  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
5983  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
5984 }
5985 
5986 // -----------------------------------------------------------------------------
5987 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5988 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
5989 {
5990  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
5991  body(re);
5992  vf.join(body._VoxelFunc);
5993  of.join(body._OutsideFunc);
5994 }
5995 
5996 // -----------------------------------------------------------------------------
5997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
5998 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
5999 {
6000  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6001  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6002 }
6003 
6004 // -----------------------------------------------------------------------------
6005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6006 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6007 {
6008  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6009  body(re);
6010  vf.join(body._VoxelFunc);
6011  of.join(body._OutsideFunc);
6012 }
6013 
6014 // -----------------------------------------------------------------------------
6015 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6016 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6017 {
6018  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6019  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6020 }
6021 
6022 // -----------------------------------------------------------------------------
6023 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6024 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6025 {
6027  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6028 }
6029 
6030 // -----------------------------------------------------------------------------
6031 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6032 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6033 {
6034  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6035  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6036 }
6037 
6038 // -----------------------------------------------------------------------------
6039 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6040 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6041 {
6042  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6043  body(re);
6044  vf.join(body._VoxelFunc);
6045  of.join(body._OutsideFunc);
6046 }
6047 
6048 // -----------------------------------------------------------------------------
6049 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6050 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6051 {
6052  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6053  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6054 }
6055 
6056 // -----------------------------------------------------------------------------
6057 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6058 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6059 {
6061  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6062 }
6063 
6064 // -----------------------------------------------------------------------------
6065 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6066 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6067 {
6068  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6069  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6070 }
6071 
6072 // -----------------------------------------------------------------------------
6073 // ParallelForEachVoxel
6074 // -----------------------------------------------------------------------------
6075 
6076 //
6077 // Image arguments by pointer
6078 //
6079 
6080 // -----------------------------------------------------------------------------
6081 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6082 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6083 {
6084  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6085  blocked_range<int> re(0, im9->GetNumberOfVoxels());
6086  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6087  else parallel_for (re, body);
6088 }
6089 
6090 // -----------------------------------------------------------------------------
6091 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6092 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6093 {
6094  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6095  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6096 }
6097 
6098 // -----------------------------------------------------------------------------
6099 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6100 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6101 {
6102  if (im9->GetTSize()) {
6103  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6104  } else {
6105  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6106  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
6107  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6108  else parallel_for (re, body);
6109  }
6110 }
6111 
6112 // -----------------------------------------------------------------------------
6113 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6114 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6115 {
6116  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6117  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6118 }
6119 
6120 // -----------------------------------------------------------------------------
6121 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6122 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6123 {
6124  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6125  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6126  if (VoxelFunc::IsReduction()) {
6127  if (attr._dt) {
6128  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6129  } else {
6130  parallel_reduce(re, body);
6131  }
6132  vf.join(body._VoxelFunc);
6133  } else {
6134  if (attr._dt) {
6135  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6136  } else {
6137  parallel_for(re, body);
6138  }
6139  }
6140 }
6141 
6142 // -----------------------------------------------------------------------------
6143 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6144 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6145 {
6146  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6147  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6148 }
6149 
6150 // -----------------------------------------------------------------------------
6151 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6152 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6153 {
6154  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6155  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6156  else parallel_for (re, body);
6157 }
6158 
6159 // -----------------------------------------------------------------------------
6160 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6161 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6162 {
6163  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6164  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6165 }
6166 
6167 // -----------------------------------------------------------------------------
6168 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6169 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6170 {
6171  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6172  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6173  else parallel_for (re, body);
6174 }
6175 
6176 // -----------------------------------------------------------------------------
6177 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6178 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6179 {
6180  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6181  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6182 }
6183 
6184 // -----------------------------------------------------------------------------
6185 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6186 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6187 {
6188  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6189  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6190  else parallel_for (re, body);
6191 }
6192 
6193 // -----------------------------------------------------------------------------
6194 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6195 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6196 {
6197  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6198  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6199 }
6200 
6201 //
6202 // Image arguments by reference
6203 //
6204 
6205 // -----------------------------------------------------------------------------
6206 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6207 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6208 {
6209  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6211  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6212  else parallel_for (re, body);
6213 }
6214 
6215 // -----------------------------------------------------------------------------
6216 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6217 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6218 {
6219  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6220  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6221 }
6222 
6223 // -----------------------------------------------------------------------------
6224 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6225 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6226 {
6227  if (im9.GetTSize()) {
6228  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6229  } else {
6230  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6231  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
6232  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6233  else parallel_for (re, body);
6234  }
6235 }
6236 
6237 // -----------------------------------------------------------------------------
6238 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6239 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6240 {
6241  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6242  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6243 }
6244 
6245 // -----------------------------------------------------------------------------
6246 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6247 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6248 {
6249  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6250  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6251  if (VoxelFunc::IsReduction()) {
6252  if (attr._dt) {
6253  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6254  } else {
6255  parallel_reduce(re, body);
6256  }
6257  vf.join(body._VoxelFunc);
6258  } else {
6259  if (attr._dt) {
6260  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6261  } else {
6262  parallel_for(re, body);
6263  }
6264  }
6265 }
6266 
6267 // -----------------------------------------------------------------------------
6268 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6269 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6270 {
6271  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6272  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6273 }
6274 
6275 // -----------------------------------------------------------------------------
6276 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6277 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6278 {
6279  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6280  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6281  else parallel_for (re, body);
6282 }
6283 
6284 // -----------------------------------------------------------------------------
6285 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6286 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6287 {
6288  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6289  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6290 }
6291 
6292 // -----------------------------------------------------------------------------
6293 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6294 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6295 {
6296  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6297  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6298  else parallel_for (re, body);
6299 }
6300 
6301 // -----------------------------------------------------------------------------
6302 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6303 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6304 {
6305  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6306  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6307 }
6308 
6309 // -----------------------------------------------------------------------------
6310 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6311 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6312 {
6313  NonaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6314  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6315  else parallel_for (re, body);
6316 }
6317 
6318 // -----------------------------------------------------------------------------
6319 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6320 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6321 {
6322  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6323  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6324 }
6325 
6326 // -----------------------------------------------------------------------------
6327 // ParallelForEachVoxelIf
6328 // -----------------------------------------------------------------------------
6329 
6330 //
6331 // Image arguments by pointer
6332 //
6333 
6334 // -----------------------------------------------------------------------------
6335 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6336 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6337 {
6338  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6339  blocked_range<int> re(0, im9->GetNumberOfVoxels());
6340  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6341  parallel_reduce(re, body);
6342  vf.join(body._VoxelFunc);
6343  of.join(body._OutsideFunc);
6344  } else {
6345  parallel_for(re, body);
6346  }
6347 }
6348 
6349 // -----------------------------------------------------------------------------
6350 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6351 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6352 {
6353  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6354  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6355 }
6356 
6357 // -----------------------------------------------------------------------------
6358 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6359 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6360 {
6362  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6363 }
6364 
6365 // -----------------------------------------------------------------------------
6366 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6367 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6368 {
6369  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6370  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6371 }
6372 
6373 // -----------------------------------------------------------------------------
6374 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6375 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6376 {
6377  if (im9->GetTSize()) {
6378  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6379  } else {
6380  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6381  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
6382  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6383  parallel_reduce(re, body);
6384  vf.join(body._VoxelFunc);
6385  of.join(body._OutsideFunc);
6386  } else {
6387  parallel_for(re, body);
6388  }
6389  }
6390 }
6391 
6392 // -----------------------------------------------------------------------------
6393 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6394 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6395 {
6396  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6397  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6398 }
6399 
6400 // -----------------------------------------------------------------------------
6401 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6402 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6403 {
6405  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6406 }
6407 
6408 // -----------------------------------------------------------------------------
6409 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6410 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6411 {
6412  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6413  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6414 }
6415 
6416 // -----------------------------------------------------------------------------
6417 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6418 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6419 {
6420  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6421  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6422  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6423  if (attr._dt) {
6424  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6425  } else {
6426  parallel_reduce(re, body);
6427  }
6428  vf.join(body._VoxelFunc);
6429  of.join(body._OutsideFunc);
6430  } else {
6431  if (attr._dt) {
6432  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6433  } else {
6434  parallel_for(re, body);
6435  }
6436  }
6437 }
6438 
6439 // -----------------------------------------------------------------------------
6440 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6441 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6442 {
6443  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6444  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6445 }
6446 
6447 // -----------------------------------------------------------------------------
6448 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6449 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6450 {
6452  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6453 }
6454 
6455 // -----------------------------------------------------------------------------
6456 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6457 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6458 {
6459  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6460  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6461 }
6462 
6463 // -----------------------------------------------------------------------------
6464 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6465 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6466 {
6467  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6468  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6469  parallel_reduce(re, body);
6470  vf.join(body._VoxelFunc);
6471  of.join(body._OutsideFunc);
6472  } else {
6473  parallel_for(re, body);
6474  }
6475 }
6476 
6477 // -----------------------------------------------------------------------------
6478 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6479 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6480 {
6481  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6482  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6483 }
6484 
6485 // -----------------------------------------------------------------------------
6486 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6487 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6488 {
6490  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6491 }
6492 
6493 // -----------------------------------------------------------------------------
6494 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6495 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6496 {
6497  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6498  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6499 }
6500 
6501 // -----------------------------------------------------------------------------
6502 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6503 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6504 {
6505  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6506  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6507  parallel_reduce(re, body);
6508  vf.join(body._VoxelFunc);
6509  of.join(body._OutsideFunc);
6510  } else {
6511  parallel_for(re, body);
6512  }
6513 }
6514 
6515 // -----------------------------------------------------------------------------
6516 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6517 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6518 {
6519  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6520  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6521 }
6522 
6523 // -----------------------------------------------------------------------------
6524 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6525 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6526 {
6528  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6529 }
6530 
6531 // -----------------------------------------------------------------------------
6532 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6533 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6534 {
6535  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6536  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6537 }
6538 
6539 // -----------------------------------------------------------------------------
6540 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6541 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
6542 {
6543  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6544  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6545  parallel_reduce(re, body);
6546  vf.join(body._VoxelFunc);
6547  of.join(body._OutsideFunc);
6548  } else {
6549  parallel_for(re, body);
6550  }
6551 }
6552 
6553 // -----------------------------------------------------------------------------
6554 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6555 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6556 {
6557  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6558  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6559 }
6560 
6561 // -----------------------------------------------------------------------------
6562 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6563 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
6564 {
6566  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
6567 }
6568 
6569 // -----------------------------------------------------------------------------
6570 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6571 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
6572 {
6573  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6574  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
6575 }
6576 
6577 //
6578 // Image arguments by reference
6579 //
6580 
6581 // -----------------------------------------------------------------------------
6582 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6583 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6584 {
6585  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6587  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6588  parallel_reduce(re, body);
6589  vf.join(body._VoxelFunc);
6590  of.join(body._OutsideFunc);
6591  } else {
6592  parallel_for(re, body);
6593  }
6594 }
6595 
6596 // -----------------------------------------------------------------------------
6597 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6598 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6599 {
6600  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6601  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6602 }
6603 
6604 // -----------------------------------------------------------------------------
6605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6606 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6607 {
6609  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6610 }
6611 
6612 // -----------------------------------------------------------------------------
6613 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6614 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6615 {
6616  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6617  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6618 }
6619 
6620 // -----------------------------------------------------------------------------
6621 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6622 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6623 {
6624  if (im9.GetTSize()) {
6625  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6626  } else {
6627  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6628  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
6629  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6630  parallel_reduce(re, body);
6631  vf.join(body._VoxelFunc);
6632  of.join(body._OutsideFunc);
6633  } else {
6634  parallel_for(re, body);
6635  }
6636  }
6637 }
6638 
6639 // -----------------------------------------------------------------------------
6640 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6641 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6642 {
6643  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6644  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6645 }
6646 
6647 // -----------------------------------------------------------------------------
6648 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6649 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6650 {
6652  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6653 }
6654 
6655 // -----------------------------------------------------------------------------
6656 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6657 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6658 {
6659  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6660  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6661 }
6662 
6663 // -----------------------------------------------------------------------------
6664 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6665 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6666 {
6667  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6668  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6669  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6670  if (attr._dt) {
6671  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6672  } else {
6673  parallel_reduce(re, body);
6674  }
6675  vf.join(body._VoxelFunc);
6676  of.join(body._OutsideFunc);
6677  } else {
6678  if (attr._dt) {
6679  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6680  } else {
6681  parallel_for(re, body);
6682  }
6683  }
6684 }
6685 
6686 // -----------------------------------------------------------------------------
6687 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6688 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6689 {
6690  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6691  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6692 }
6693 
6694 // -----------------------------------------------------------------------------
6695 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6696 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6697 {
6699  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6700 }
6701 
6702 // -----------------------------------------------------------------------------
6703 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6704 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6705 {
6706  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6707  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6708 }
6709 
6710 // -----------------------------------------------------------------------------
6711 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6712 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6713 {
6714  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6715  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6716  parallel_reduce(re, body);
6717  vf.join(body._VoxelFunc);
6718  of.join(body._OutsideFunc);
6719  } else {
6720  parallel_for(re, body);
6721  }
6722 }
6723 
6724 // -----------------------------------------------------------------------------
6725 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6726 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6727 {
6728  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6729  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6730 }
6731 
6732 // -----------------------------------------------------------------------------
6733 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6734 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6735 {
6737  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6738 }
6739 
6740 // -----------------------------------------------------------------------------
6741 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6742 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6743 {
6744  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6745  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6746 }
6747 
6748 // -----------------------------------------------------------------------------
6749 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6750 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6751 {
6752  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6753  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6754  parallel_reduce(re, body);
6755  vf.join(body._VoxelFunc);
6756  of.join(body._OutsideFunc);
6757  } else {
6758  parallel_for(re, body);
6759  }
6760 }
6761 
6762 // -----------------------------------------------------------------------------
6763 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6764 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6765 {
6766  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6767  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6768 }
6769 
6770 // -----------------------------------------------------------------------------
6771 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6772 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6773 {
6775  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6776 }
6777 
6778 // -----------------------------------------------------------------------------
6779 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6780 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6781 {
6782  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6783  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6784 }
6785 
6786 // -----------------------------------------------------------------------------
6787 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6788 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
6789 {
6790  NonaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6791  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6792  parallel_reduce(re, body);
6793  vf.join(body._VoxelFunc);
6794  of.join(body._OutsideFunc);
6795  } else {
6796  parallel_for(re, body);
6797  }
6798 }
6799 
6800 // -----------------------------------------------------------------------------
6801 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
6802 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6803 {
6804  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6805  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6806 }
6807 
6808 // -----------------------------------------------------------------------------
6809 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6810 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
6811 {
6813  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
6814 }
6815 
6816 // -----------------------------------------------------------------------------
6817 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6818 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
6819 {
6820  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
6821  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
6822 }
6823 
6824 // =============================================================================
6825 // 5 const, 4 non-const images
6826 // =============================================================================
6827 
6828 // -----------------------------------------------------------------------------
6829 /**
6830  * ForEachVoxel body for voxel function of 5 const, 4 non-const images
6831  */
6832 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
6834 {
6835  const GenericImage<T1> &im1;
6836  const GenericImage<T2> &im2;
6837  const GenericImage<T3> &im3;
6838  const GenericImage<T4> &im4;
6839  const GenericImage<T5> &im5;
6840  GenericImage<T6> &im6;
6841  GenericImage<T7> &im7;
6842  GenericImage<T8> &im8;
6843  GenericImage<T9> &im9;
6844 
6845  /// Constructor
6847  const GenericImage<T2> &im2,
6848  const GenericImage<T3> &im3,
6849  const GenericImage<T4> &im4,
6850  const GenericImage<T5> &im5,
6851  GenericImage<T6> &im6,
6852  GenericImage<T7> &im7,
6853  GenericImage<T8> &im8,
6854  GenericImage<T9> &im9,
6855  VoxelFunc &vf)
6856  :
6857  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
6858  {}
6859 
6860  /// Copy constructor
6862  :
6863  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
6864  {}
6865 
6866  /// Split constructor
6868  :
6869  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
6870  {}
6871 
6872  /// Process entire image
6873  void operator ()(const ImageAttributes &attr) const
6874  {
6875  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
6876  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
6877  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
6878  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
6879  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
6880  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
6881  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
6882  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
6883  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
6884 
6885  const int T = (attr._dt ? attr._t : 1);
6886 
6887  for (int l = 0; l < T; ++l)
6888  for (int k = 0; k < attr._z; ++k)
6889  for (int j = 0; j < attr._y; ++j)
6890  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
6891  // const_cast such that voxel functions need only implement
6892  // non-const operator() which is required for parallel_reduce
6893  const_cast<NonaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
6894  }
6895  }
6896 
6897  /// Process image region using linear index
6898  void operator ()(const blocked_range<int> &re) const
6899  {
6900  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
6901  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
6902  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
6903  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
6904  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
6905  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
6906  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
6907  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
6908  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
6909 
6910  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
6911  // const_cast such that voxel functions need only implement
6912  // non-const operator() which is required for parallel_reduce
6913  const_cast<NonaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
6914  }
6915  }
6916 
6917  /// Process 2D image region
6918  void operator ()(const blocked_range2d<int> &re) const
6919  {
6920  const int bi = re.cols().begin();
6921  const int bj = re.rows().begin();
6922  const int ei = re.cols().end();
6923  const int ej = re.rows().end();
6924 
6925  const int s1 = im9.GetX() - (ei - bi);
6926 
6927  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6928  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6929  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6930  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6931  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6932  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6933  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6934  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6935  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6936 
6937  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
6938  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
6939  // const_cast such that voxel functions need only implement
6940  // non-const operator() which is required for parallel_reduce
6941  const_cast<NonaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
6942  }
6943  }
6944 
6945  /// Process 3D image region
6946  void operator ()(const blocked_range3d<int> &re) const
6947  {
6948  const int bi = re.cols ().begin();
6949  const int bj = re.rows ().begin();
6950  const int bk = re.pages().begin();
6951  const int ei = re.cols ().end();
6952  const int ej = re.rows ().end();
6953  const int ek = re.pages().end();
6954 
6955  const int s1 = im9.GetX() - (ei - bi);
6956  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
6957 
6958  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
6959  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
6960  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
6961  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
6962  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
6963  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
6964  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
6965  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
6966  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
6967 
6968  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
6969  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
6970  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
6971  // const_cast such that voxel functions need only implement
6972  // non-const operator() which is required for parallel_reduce
6973  const_cast<NonaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
6974  }
6975  }
6976 };
6977 
6978 // -----------------------------------------------------------------------------
6979 /**
6980  * ForEachVoxel body for inside and outside unary voxel function of 5 const, 4 non-const images
6981  */
6982 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
6983  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
6984  class Domain = ForEachVoxelDomain::Foreground>
6985 struct NonaryForEachVoxelIfBody_5Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
6986 {
6987  const GenericImage<T1> &im1;
6988  const GenericImage<T2> &im2;
6989  const GenericImage<T3> &im3;
6990  const GenericImage<T4> &im4;
6991  const GenericImage<T5> &im5;
6992  GenericImage<T6> &im6;
6993  GenericImage<T7> &im7;
6994  GenericImage<T8> &im8;
6995  GenericImage<T9> &im9;
6996 
6997  /// Constructor
6999  const GenericImage<T2> &im2,
7000  const GenericImage<T3> &im3,
7001  const GenericImage<T4> &im4,
7002  const GenericImage<T5> &im5,
7003  GenericImage<T6> &im6,
7004  GenericImage<T7> &im7,
7005  GenericImage<T8> &im8,
7006  GenericImage<T9> &im9,
7007  VoxelFunc &vf, OutsideFunc &of)
7008  :
7009  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
7010  {}
7011 
7012  /// Copy constructor
7014  :
7015  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
7016  {}
7017 
7018  /// Split constructor
7020  :
7021  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
7022  {}
7023 
7024  /// Process entire image
7025  void operator ()(const ImageAttributes &attr) const
7026  {
7027  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
7028  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
7029  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
7030  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
7031  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
7032  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
7033  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
7034  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
7035  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
7036 
7037  const int T = (attr._dt ? attr._t : 1);
7038 
7039  for (int l = 0; l < T; ++l)
7040  for (int k = 0; k < attr._z; ++k)
7041  for (int j = 0; j < attr._y; ++j)
7042  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
7043  if (Domain::IsInside(im9, i, j, k, l, p9)) {
7044  // const_cast such that voxel functions need only implement
7045  // non-const operator() which is required for parallel_reduce
7046  const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7047  } else const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7048  }
7049  }
7050 
7051  /// Process image region using linear index
7052  void operator ()(const blocked_range<int> &re) const
7053  {
7054  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
7055  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
7056  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
7057  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
7058  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
7059  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
7060  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
7061  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
7062  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
7063 
7064  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
7065  if (Domain::IsInside(im9, idx, p9)) {
7066  // const_cast such that voxel functions need only implement
7067  // non-const operator() which is required for parallel_reduce
7068  const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7069  } else const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7070  }
7071  }
7072 
7073  /// Process 2D image region
7074  void operator ()(const blocked_range2d<int> &re) const
7075  {
7076  const int bi = re.cols().begin();
7077  const int bj = re.rows().begin();
7078  const int ei = re.cols().end();
7079  const int ej = re.rows().end();
7080 
7081  const int s1 = im9.GetX() - (ei - bi);
7082 
7083  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7084  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7085  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7086  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7087  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7088  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7089  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7090  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7091  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7092 
7093  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
7094  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
7095  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
7096  // const_cast such that voxel functions need only implement
7097  // non-const operator() which is required for parallel_reduce
7098  const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7099  } else const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7100  }
7101  }
7102 
7103  /// Process 3D image region
7104  void operator ()(const blocked_range3d<int> &re) const
7105  {
7106  const int bi = re.cols ().begin();
7107  const int bj = re.rows ().begin();
7108  const int bk = re.pages().begin();
7109  const int ei = re.cols ().end();
7110  const int ej = re.rows ().end();
7111  const int ek = re.pages().end();
7112 
7113  const int s1 = im9.GetX() - (ei - bi);
7114  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
7115 
7116  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
7117  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
7118  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
7119  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
7120  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
7121  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
7122  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
7123  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
7124  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
7125 
7126  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
7127  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
7128  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
7129  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
7130  // const_cast such that voxel functions need only implement
7131  // non-const operator() which is required for parallel_reduce
7132  const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7133  } else const_cast<NonaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
7134  }
7135  }
7136 };
7137 
7138 // -----------------------------------------------------------------------------
7139 // ForEachVoxel
7140 // -----------------------------------------------------------------------------
7141 
7142 //
7143 // Image arguments by pointer
7144 //
7145 
7146 // -----------------------------------------------------------------------------
7147 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7148 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7149 {
7150  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7151  blocked_range<int> re(0, im9->GetNumberOfVoxels());
7152  body(re);
7153  vf.join(body._VoxelFunc);
7154 }
7155 
7156 // -----------------------------------------------------------------------------
7157 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7158 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7159 {
7160  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7161  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7162 }
7163 
7164 // -----------------------------------------------------------------------------
7165 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7166 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7167 {
7168  if (im9->GetTSize()) {
7169  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7170  } else {
7171  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7172  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
7173  body(re);
7174  vf.join(body._VoxelFunc);
7175  }
7176 }
7177 
7178 // -----------------------------------------------------------------------------
7179 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7180 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7181 {
7182  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7183  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7184 }
7185 
7186 // -----------------------------------------------------------------------------
7187 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7188 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7189 {
7190  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7191  body(attr);
7192  vf.join(body._VoxelFunc);
7193 }
7194 
7195 // -----------------------------------------------------------------------------
7196 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7197 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7198 {
7199  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7200  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7201 }
7202 
7203 // -----------------------------------------------------------------------------
7204 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7205 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7206 {
7207  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7208  body(re);
7209  vf.join(body._VoxelFunc);
7210 }
7211 
7212 // -----------------------------------------------------------------------------
7213 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7214 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7215 {
7216  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7217  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7218 }
7219 
7220 // -----------------------------------------------------------------------------
7221 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7222 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7223 {
7224  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7225  body(re);
7226  vf.join(body._VoxelFunc);
7227 }
7228 
7229 // -----------------------------------------------------------------------------
7230 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7231 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7232 {
7233  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7234  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7235 }
7236 
7237 // -----------------------------------------------------------------------------
7238 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7239 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7240 {
7241  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7242  body(re);
7243  vf.join(body._VoxelFunc);
7244 }
7245 
7246 // -----------------------------------------------------------------------------
7247 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7248 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7249 {
7250  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7251  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7252 }
7253 
7254 //
7255 // Image arguments by reference
7256 //
7257 
7258 // -----------------------------------------------------------------------------
7259 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7260 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7261 {
7262  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7264  body(re);
7265  vf.join(body._VoxelFunc);
7266 }
7267 
7268 // -----------------------------------------------------------------------------
7269 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7270 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7271 {
7272  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7273  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7274 }
7275 
7276 // -----------------------------------------------------------------------------
7277 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7278 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7279 {
7280  if (im9.GetTSize()) {
7281  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7282  } else {
7283  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7284  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
7285  body(re);
7286  vf.join(body._VoxelFunc);
7287  }
7288 }
7289 
7290 // -----------------------------------------------------------------------------
7291 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7292 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7293 {
7294  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7295  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7296 }
7297 
7298 // -----------------------------------------------------------------------------
7299 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7300 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7301 {
7302  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7303  body(attr);
7304  vf.join(body._VoxelFunc);
7305 }
7306 
7307 // -----------------------------------------------------------------------------
7308 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7309 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7310 {
7311  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7312  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7313 }
7314 
7315 // -----------------------------------------------------------------------------
7316 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7317 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7318 {
7319  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7320  body(re);
7321  vf.join(body._VoxelFunc);
7322 }
7323 
7324 // -----------------------------------------------------------------------------
7325 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7326 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7327 {
7328  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7329  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7330 }
7331 
7332 // -----------------------------------------------------------------------------
7333 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7334 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7335 {
7336  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7337  body(re);
7338  vf.join(body._VoxelFunc);
7339 }
7340 
7341 // -----------------------------------------------------------------------------
7342 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7343 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7344 {
7345  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7346  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7347 }
7348 
7349 // -----------------------------------------------------------------------------
7350 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7351 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7352 {
7353  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7354  body(re);
7355  vf.join(body._VoxelFunc);
7356 }
7357 
7358 // -----------------------------------------------------------------------------
7359 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7360 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7361 {
7362  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7363  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7364 }
7365 
7366 // -----------------------------------------------------------------------------
7367 // ForEachVoxelIf
7368 // -----------------------------------------------------------------------------
7369 
7370 //
7371 // Image arguments by pointer
7372 //
7373 
7374 // -----------------------------------------------------------------------------
7375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7376 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7377 {
7378  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7379  blocked_range<int> re(0, im9->GetNumberOfVoxels());
7380  body(re);
7381  vf.join(body._VoxelFunc);
7382  of.join(body._OutsideFunc);
7383 }
7384 
7385 // -----------------------------------------------------------------------------
7386 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7387 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7388 {
7389  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7390  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7391 }
7392 
7393 // -----------------------------------------------------------------------------
7394 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7395 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7396 {
7398  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7399 }
7400 
7401 // -----------------------------------------------------------------------------
7402 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7403 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7404 {
7405  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7406  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7407 }
7408 
7409 // -----------------------------------------------------------------------------
7410 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7411 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7412 {
7413  if (im9->GetTSize()) {
7414  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7415  } else {
7416  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7417  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
7418  body(re);
7419  vf.join(body._VoxelFunc);
7420  of.join(body._OutsideFunc);
7421  }
7422 }
7423 
7424 // -----------------------------------------------------------------------------
7425 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7426 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7427 {
7428  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7429  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7430 }
7431 
7432 // -----------------------------------------------------------------------------
7433 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7434 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7435 {
7437  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7438 }
7439 
7440 // -----------------------------------------------------------------------------
7441 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7442 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7443 {
7444  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7445  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7446 }
7447 
7448 // -----------------------------------------------------------------------------
7449 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7450 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7451 {
7452  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7453  body(attr);
7454  vf.join(body._VoxelFunc);
7455  of.join(body._OutsideFunc);
7456 }
7457 
7458 // -----------------------------------------------------------------------------
7459 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7460 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7461 {
7462  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7463  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7464 }
7465 
7466 // -----------------------------------------------------------------------------
7467 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7468 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7469 {
7471  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7472 }
7473 
7474 // -----------------------------------------------------------------------------
7475 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7476 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7477 {
7478  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7479  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7480 }
7481 
7482 // -----------------------------------------------------------------------------
7483 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7484 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7485 {
7486  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7487  body(re);
7488  vf.join(body._VoxelFunc);
7489  of.join(body._OutsideFunc);
7490 }
7491 
7492 // -----------------------------------------------------------------------------
7493 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7494 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7495 {
7496  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7497  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7498 }
7499 
7500 // -----------------------------------------------------------------------------
7501 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7502 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7503 {
7504  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
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 T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7512 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7513 {
7514  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7515  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7516 }
7517 
7518 // -----------------------------------------------------------------------------
7519 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7520 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7521 {
7523  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7524 }
7525 
7526 // -----------------------------------------------------------------------------
7527 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7528 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7529 {
7530  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7531  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7532 }
7533 
7534 // -----------------------------------------------------------------------------
7535 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7536 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
7537 {
7538  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7539  body(re);
7540  vf.join(body._VoxelFunc);
7541  of.join(body._OutsideFunc);
7542 }
7543 
7544 // -----------------------------------------------------------------------------
7545 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7546 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7547 {
7548  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7549  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7550 }
7551 
7552 // -----------------------------------------------------------------------------
7553 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7554 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7555 {
7557  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
7558 }
7559 
7560 // -----------------------------------------------------------------------------
7561 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7562 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7563 {
7564  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7565  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7566 }
7567 
7568 //
7569 // Image arguments by reference
7570 //
7571 
7572 // -----------------------------------------------------------------------------
7573 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7574 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7575 {
7576  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7578  body(re);
7579  vf.join(body._VoxelFunc);
7580  of.join(body._OutsideFunc);
7581 }
7582 
7583 // -----------------------------------------------------------------------------
7584 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7585 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7586 {
7587  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7588  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7589 }
7590 
7591 // -----------------------------------------------------------------------------
7592 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7593 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7594 {
7596  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7597 }
7598 
7599 // -----------------------------------------------------------------------------
7600 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7601 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7602 {
7603  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7604  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7605 }
7606 
7607 // -----------------------------------------------------------------------------
7608 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7609 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7610 {
7611  if (im9.GetTSize()) {
7612  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7613  } else {
7614  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7615  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
7616  body(re);
7617  vf.join(body._VoxelFunc);
7618  of.join(body._OutsideFunc);
7619  }
7620 }
7621 
7622 // -----------------------------------------------------------------------------
7623 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7624 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7625 {
7626  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7627  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7628 }
7629 
7630 // -----------------------------------------------------------------------------
7631 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7632 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7633 {
7635  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7636 }
7637 
7638 // -----------------------------------------------------------------------------
7639 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7640 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7641 {
7642  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7643  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7644 }
7645 
7646 // -----------------------------------------------------------------------------
7647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7648 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7649 {
7650  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7651  body(attr);
7652  vf.join(body._VoxelFunc);
7653  of.join(body._OutsideFunc);
7654 }
7655 
7656 // -----------------------------------------------------------------------------
7657 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7658 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7659 {
7660  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7661  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7662 }
7663 
7664 // -----------------------------------------------------------------------------
7665 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7666 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7667 {
7669  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7670 }
7671 
7672 // -----------------------------------------------------------------------------
7673 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7674 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7675 {
7676  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7677  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7678 }
7679 
7680 // -----------------------------------------------------------------------------
7681 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7682 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7683 {
7684  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7685  body(re);
7686  vf.join(body._VoxelFunc);
7687  of.join(body._OutsideFunc);
7688 }
7689 
7690 // -----------------------------------------------------------------------------
7691 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7692 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7693 {
7694  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7695  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7696 }
7697 
7698 // -----------------------------------------------------------------------------
7699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7700 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7701 {
7702  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7703  body(re);
7704  vf.join(body._VoxelFunc);
7705  of.join(body._OutsideFunc);
7706 }
7707 
7708 // -----------------------------------------------------------------------------
7709 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7710 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7711 {
7712  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7713  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7714 }
7715 
7716 // -----------------------------------------------------------------------------
7717 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7718 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7719 {
7721  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7722 }
7723 
7724 // -----------------------------------------------------------------------------
7725 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7726 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7727 {
7728  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7729  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7730 }
7731 
7732 // -----------------------------------------------------------------------------
7733 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7734 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
7735 {
7736  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7737  body(re);
7738  vf.join(body._VoxelFunc);
7739  of.join(body._OutsideFunc);
7740 }
7741 
7742 // -----------------------------------------------------------------------------
7743 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
7744 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7745 {
7746  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7747  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7748 }
7749 
7750 // -----------------------------------------------------------------------------
7751 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7752 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7753 {
7755  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
7756 }
7757 
7758 // -----------------------------------------------------------------------------
7759 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7760 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7761 {
7762  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7763  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7764 }
7765 
7766 // -----------------------------------------------------------------------------
7767 // ParallelForEachVoxel
7768 // -----------------------------------------------------------------------------
7769 
7770 //
7771 // Image arguments by pointer
7772 //
7773 
7774 // -----------------------------------------------------------------------------
7775 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7776 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7777 {
7778  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7779  blocked_range<int> re(0, im9->GetNumberOfVoxels());
7780  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7781  else parallel_for (re, body);
7782 }
7783 
7784 // -----------------------------------------------------------------------------
7785 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7786 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7787 {
7788  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7789  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7790 }
7791 
7792 // -----------------------------------------------------------------------------
7793 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7794 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7795 {
7796  if (im9->GetTSize()) {
7797  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7798  } else {
7799  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7800  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
7801  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7802  else parallel_for (re, body);
7803  }
7804 }
7805 
7806 // -----------------------------------------------------------------------------
7807 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7808 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7809 {
7810  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7811  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7812 }
7813 
7814 // -----------------------------------------------------------------------------
7815 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7816 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7817 {
7818  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7819  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7820  if (VoxelFunc::IsReduction()) {
7821  if (attr._dt) {
7822  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7823  } else {
7824  parallel_reduce(re, body);
7825  }
7826  vf.join(body._VoxelFunc);
7827  } else {
7828  if (attr._dt) {
7829  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7830  } else {
7831  parallel_for(re, body);
7832  }
7833  }
7834 }
7835 
7836 // -----------------------------------------------------------------------------
7837 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7838 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7839 {
7840  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7841  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7842 }
7843 
7844 // -----------------------------------------------------------------------------
7845 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7846 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7847 {
7848  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7849  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7850  else parallel_for (re, body);
7851 }
7852 
7853 // -----------------------------------------------------------------------------
7854 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7855 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7856 {
7857  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7858  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7859 }
7860 
7861 // -----------------------------------------------------------------------------
7862 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7863 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7864 {
7865  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7866  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7867  else parallel_for (re, body);
7868 }
7869 
7870 // -----------------------------------------------------------------------------
7871 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7872 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7873 {
7874  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7875  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7876 }
7877 
7878 // -----------------------------------------------------------------------------
7879 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7880 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
7881 {
7882  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7883  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7884  else parallel_for (re, body);
7885 }
7886 
7887 // -----------------------------------------------------------------------------
7888 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7889 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
7890 {
7891  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7892  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
7893 }
7894 
7895 //
7896 // Image arguments by reference
7897 //
7898 
7899 // -----------------------------------------------------------------------------
7900 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7901 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7902 {
7903  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7905  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7906  else parallel_for (re, body);
7907 }
7908 
7909 // -----------------------------------------------------------------------------
7910 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7911 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7912 {
7913  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7914  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7915 }
7916 
7917 // -----------------------------------------------------------------------------
7918 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7919 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7920 {
7921  if (im9.GetTSize()) {
7922  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7923  } else {
7924  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7925  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
7926  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7927  else parallel_for (re, body);
7928  }
7929 }
7930 
7931 // -----------------------------------------------------------------------------
7932 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7933 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7934 {
7935  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7936  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7937 }
7938 
7939 // -----------------------------------------------------------------------------
7940 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7941 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7942 {
7943  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7944  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7945  if (VoxelFunc::IsReduction()) {
7946  if (attr._dt) {
7947  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7948  } else {
7949  parallel_reduce(re, body);
7950  }
7951  vf.join(body._VoxelFunc);
7952  } else {
7953  if (attr._dt) {
7954  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7955  } else {
7956  parallel_for(re, body);
7957  }
7958  }
7959 }
7960 
7961 // -----------------------------------------------------------------------------
7962 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7963 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7964 {
7965  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7966  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7967 }
7968 
7969 // -----------------------------------------------------------------------------
7970 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7971 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7972 {
7973  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7974  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7975  else parallel_for (re, body);
7976 }
7977 
7978 // -----------------------------------------------------------------------------
7979 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7980 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7981 {
7982  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
7983  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7984 }
7985 
7986 // -----------------------------------------------------------------------------
7987 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7988 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
7989 {
7990  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
7991  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7992  else parallel_for (re, body);
7993 }
7994 
7995 // -----------------------------------------------------------------------------
7996 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
7997 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
7998 {
7999  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8000  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8001 }
8002 
8003 // -----------------------------------------------------------------------------
8004 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8005 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8006 {
8007  NonaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8008  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
8009  else parallel_for (re, body);
8010 }
8011 
8012 // -----------------------------------------------------------------------------
8013 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8014 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8015 {
8016  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8017  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8018 }
8019 
8020 // -----------------------------------------------------------------------------
8021 // ParallelForEachVoxelIf
8022 // -----------------------------------------------------------------------------
8023 
8024 //
8025 // Image arguments by pointer
8026 //
8027 
8028 // -----------------------------------------------------------------------------
8029 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8030 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8031 {
8032  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8033  blocked_range<int> re(0, im9->GetNumberOfVoxels());
8034  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8035  parallel_reduce(re, body);
8036  vf.join(body._VoxelFunc);
8037  of.join(body._OutsideFunc);
8038  } else {
8039  parallel_for(re, body);
8040  }
8041 }
8042 
8043 // -----------------------------------------------------------------------------
8044 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8045 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8046 {
8047  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8048  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8049 }
8050 
8051 // -----------------------------------------------------------------------------
8052 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8053 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8054 {
8056  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8057 }
8058 
8059 // -----------------------------------------------------------------------------
8060 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8061 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8062 {
8063  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8064  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8065 }
8066 
8067 // -----------------------------------------------------------------------------
8068 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8069 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8070 {
8071  if (im9->GetTSize()) {
8072  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8073  } else {
8074  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8075  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
8076  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8077  parallel_reduce(re, body);
8078  vf.join(body._VoxelFunc);
8079  of.join(body._OutsideFunc);
8080  } else {
8081  parallel_for(re, body);
8082  }
8083  }
8084 }
8085 
8086 // -----------------------------------------------------------------------------
8087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8088 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8089 {
8090  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8091  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8092 }
8093 
8094 // -----------------------------------------------------------------------------
8095 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8096 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8097 {
8099  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8100 }
8101 
8102 // -----------------------------------------------------------------------------
8103 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8104 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8105 {
8106  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8107  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8108 }
8109 
8110 // -----------------------------------------------------------------------------
8111 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8112 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8113 {
8114  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8115  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
8116  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8117  if (attr._dt) {
8118  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
8119  } else {
8120  parallel_reduce(re, body);
8121  }
8122  vf.join(body._VoxelFunc);
8123  of.join(body._OutsideFunc);
8124  } else {
8125  if (attr._dt) {
8126  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
8127  } else {
8128  parallel_for(re, body);
8129  }
8130  }
8131 }
8132 
8133 // -----------------------------------------------------------------------------
8134 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8135 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8136 {
8137  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8138  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8139 }
8140 
8141 // -----------------------------------------------------------------------------
8142 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8143 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8144 {
8146  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8147 }
8148 
8149 // -----------------------------------------------------------------------------
8150 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8151 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8152 {
8153  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8154  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8155 }
8156 
8157 // -----------------------------------------------------------------------------
8158 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8159 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8160 {
8161  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8162  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8163  parallel_reduce(re, body);
8164  vf.join(body._VoxelFunc);
8165  of.join(body._OutsideFunc);
8166  } else {
8167  parallel_for(re, body);
8168  }
8169 }
8170 
8171 // -----------------------------------------------------------------------------
8172 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8173 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8174 {
8175  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8176  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8177 }
8178 
8179 // -----------------------------------------------------------------------------
8180 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8181 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8182 {
8184  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8185 }
8186 
8187 // -----------------------------------------------------------------------------
8188 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8189 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8190 {
8191  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8192  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8193 }
8194 
8195 // -----------------------------------------------------------------------------
8196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8197 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8198 {
8199  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8200  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8201  parallel_reduce(re, body);
8202  vf.join(body._VoxelFunc);
8203  of.join(body._OutsideFunc);
8204  } else {
8205  parallel_for(re, body);
8206  }
8207 }
8208 
8209 // -----------------------------------------------------------------------------
8210 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8211 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8212 {
8213  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8214  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8215 }
8216 
8217 // -----------------------------------------------------------------------------
8218 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8219 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8220 {
8222  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8223 }
8224 
8225 // -----------------------------------------------------------------------------
8226 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8227 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8228 {
8229  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8230  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8231 }
8232 
8233 // -----------------------------------------------------------------------------
8234 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8235 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
8236 {
8237  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8238  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8239  parallel_reduce(re, body);
8240  vf.join(body._VoxelFunc);
8241  of.join(body._OutsideFunc);
8242  } else {
8243  parallel_for(re, body);
8244  }
8245 }
8246 
8247 // -----------------------------------------------------------------------------
8248 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8249 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8250 {
8251  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8252  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8253 }
8254 
8255 // -----------------------------------------------------------------------------
8256 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8257 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8258 {
8260  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
8261 }
8262 
8263 // -----------------------------------------------------------------------------
8264 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8265 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8266 {
8267  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8268  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8269 }
8270 
8271 //
8272 // Image arguments by reference
8273 //
8274 
8275 // -----------------------------------------------------------------------------
8276 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8277 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8278 {
8279  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8281  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8282  parallel_reduce(re, body);
8283  vf.join(body._VoxelFunc);
8284  of.join(body._OutsideFunc);
8285  } else {
8286  parallel_for(re, body);
8287  }
8288 }
8289 
8290 // -----------------------------------------------------------------------------
8291 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8292 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8293 {
8294  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8295  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8296 }
8297 
8298 // -----------------------------------------------------------------------------
8299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8300 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8301 {
8303  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8304 }
8305 
8306 // -----------------------------------------------------------------------------
8307 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8308 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8309 {
8310  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8311  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8312 }
8313 
8314 // -----------------------------------------------------------------------------
8315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8316 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8317 {
8318  if (im9.GetTSize()) {
8319  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8320  } else {
8321  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8322  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
8323  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8324  parallel_reduce(re, body);
8325  vf.join(body._VoxelFunc);
8326  of.join(body._OutsideFunc);
8327  } else {
8328  parallel_for(re, body);
8329  }
8330  }
8331 }
8332 
8333 // -----------------------------------------------------------------------------
8334 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8335 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8336 {
8337  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8338  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8339 }
8340 
8341 // -----------------------------------------------------------------------------
8342 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8343 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8344 {
8346  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8347 }
8348 
8349 // -----------------------------------------------------------------------------
8350 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8351 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8352 {
8353  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8354  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8355 }
8356 
8357 // -----------------------------------------------------------------------------
8358 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8359 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8360 {
8361  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8362  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
8363  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8364  if (attr._dt) {
8365  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
8366  } else {
8367  parallel_reduce(re, body);
8368  }
8369  vf.join(body._VoxelFunc);
8370  of.join(body._OutsideFunc);
8371  } else {
8372  if (attr._dt) {
8373  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
8374  } else {
8375  parallel_for(re, body);
8376  }
8377  }
8378 }
8379 
8380 // -----------------------------------------------------------------------------
8381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8382 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8383 {
8384  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8385  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8386 }
8387 
8388 // -----------------------------------------------------------------------------
8389 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8390 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8391 {
8393  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8394 }
8395 
8396 // -----------------------------------------------------------------------------
8397 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8398 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8399 {
8400  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8401  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8402 }
8403 
8404 // -----------------------------------------------------------------------------
8405 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8406 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8407 {
8408  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8409  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8410  parallel_reduce(re, body);
8411  vf.join(body._VoxelFunc);
8412  of.join(body._OutsideFunc);
8413  } else {
8414  parallel_for(re, body);
8415  }
8416 }
8417 
8418 // -----------------------------------------------------------------------------
8419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8420 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8421 {
8422  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8423  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8424 }
8425 
8426 // -----------------------------------------------------------------------------
8427 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8428 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8429 {
8431  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8432 }
8433 
8434 // -----------------------------------------------------------------------------
8435 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8436 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8437 {
8438  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8439  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8440 }
8441 
8442 // -----------------------------------------------------------------------------
8443 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8444 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8445 {
8446  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8447  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8448  parallel_reduce(re, body);
8449  vf.join(body._VoxelFunc);
8450  of.join(body._OutsideFunc);
8451  } else {
8452  parallel_for(re, body);
8453  }
8454 }
8455 
8456 // -----------------------------------------------------------------------------
8457 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8458 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8459 {
8460  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8461  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8462 }
8463 
8464 // -----------------------------------------------------------------------------
8465 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8466 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8467 {
8469  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8470 }
8471 
8472 // -----------------------------------------------------------------------------
8473 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8474 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8475 {
8476  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8477  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8478 }
8479 
8480 // -----------------------------------------------------------------------------
8481 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8482 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
8483 {
8484  NonaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8485  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8486  parallel_reduce(re, body);
8487  vf.join(body._VoxelFunc);
8488  of.join(body._OutsideFunc);
8489  } else {
8490  parallel_for(re, body);
8491  }
8492 }
8493 
8494 // -----------------------------------------------------------------------------
8495 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
8496 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8497 {
8498  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8499  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8500 }
8501 
8502 // -----------------------------------------------------------------------------
8503 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8504 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8505 {
8507  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
8508 }
8509 
8510 // -----------------------------------------------------------------------------
8511 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8512 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8513 {
8514  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8515  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8516 }
8517 
8518 // =============================================================================
8519 // 4 const, 5 non-const images
8520 // =============================================================================
8521 
8522 // -----------------------------------------------------------------------------
8523 /**
8524  * ForEachVoxel body for voxel function of 4 const, 5 non-const images
8525  */
8526 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8528 {
8529  const GenericImage<T1> &im1;
8530  const GenericImage<T2> &im2;
8531  const GenericImage<T3> &im3;
8532  const GenericImage<T4> &im4;
8533  GenericImage<T5> &im5;
8534  GenericImage<T6> &im6;
8535  GenericImage<T7> &im7;
8536  GenericImage<T8> &im8;
8537  GenericImage<T9> &im9;
8538 
8539  /// Constructor
8541  const GenericImage<T2> &im2,
8542  const GenericImage<T3> &im3,
8543  const GenericImage<T4> &im4,
8544  GenericImage<T5> &im5,
8545  GenericImage<T6> &im6,
8546  GenericImage<T7> &im7,
8547  GenericImage<T8> &im8,
8548  GenericImage<T9> &im9,
8549  VoxelFunc &vf)
8550  :
8551  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
8552  {}
8553 
8554  /// Copy constructor
8556  :
8557  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
8558  {}
8559 
8560  /// Split constructor
8562  :
8563  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
8564  {}
8565 
8566  /// Process entire image
8567  void operator ()(const ImageAttributes &attr) const
8568  {
8569  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8570  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8571  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8572  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8573  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8574  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8575  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
8576  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
8577  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
8578 
8579  const int T = (attr._dt ? attr._t : 1);
8580 
8581  for (int l = 0; l < T; ++l)
8582  for (int k = 0; k < attr._z; ++k)
8583  for (int j = 0; j < attr._y; ++j)
8584  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
8585  // const_cast such that voxel functions need only implement
8586  // non-const operator() which is required for parallel_reduce
8587  const_cast<NonaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8588  }
8589  }
8590 
8591  /// Process image region using linear index
8592  void operator ()(const blocked_range<int> &re) const
8593  {
8594  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8595  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8596  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8597  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8598  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8599  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8600  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
8601  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
8602  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
8603 
8604  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8605  // const_cast such that voxel functions need only implement
8606  // non-const operator() which is required for parallel_reduce
8607  const_cast<NonaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8608  }
8609  }
8610 
8611  /// Process 2D image region
8612  void operator ()(const blocked_range2d<int> &re) const
8613  {
8614  const int bi = re.cols().begin();
8615  const int bj = re.rows().begin();
8616  const int ei = re.cols().end();
8617  const int ej = re.rows().end();
8618 
8619  const int s1 = im9.GetX() - (ei - bi);
8620 
8621  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8622  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8623  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8624  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8625  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8626  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8627  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8628  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8629  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8630 
8631  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
8632  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8633  // const_cast such that voxel functions need only implement
8634  // non-const operator() which is required for parallel_reduce
8635  const_cast<NonaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8636  }
8637  }
8638 
8639  /// Process 3D image region
8640  void operator ()(const blocked_range3d<int> &re) const
8641  {
8642  const int bi = re.cols ().begin();
8643  const int bj = re.rows ().begin();
8644  const int bk = re.pages().begin();
8645  const int ei = re.cols ().end();
8646  const int ej = re.rows ().end();
8647  const int ek = re.pages().end();
8648 
8649  const int s1 = im9.GetX() - (ei - bi);
8650  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
8651 
8652  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8653  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8654  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8655  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8656  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8657  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8658  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
8659  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
8660  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
8661 
8662  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
8663  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
8664  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8665  // const_cast such that voxel functions need only implement
8666  // non-const operator() which is required for parallel_reduce
8667  const_cast<NonaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8668  }
8669  }
8670 };
8671 
8672 // -----------------------------------------------------------------------------
8673 /**
8674  * ForEachVoxel body for inside and outside unary voxel function of 4 const, 5 non-const images
8675  */
8676 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
8677  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
8678  class Domain = ForEachVoxelDomain::Foreground>
8679 struct NonaryForEachVoxelIfBody_4Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
8680 {
8681  const GenericImage<T1> &im1;
8682  const GenericImage<T2> &im2;
8683  const GenericImage<T3> &im3;
8684  const GenericImage<T4> &im4;
8685  GenericImage<T5> &im5;
8686  GenericImage<T6> &im6;
8687  GenericImage<T7> &im7;
8688  GenericImage<T8> &im8;
8689  GenericImage<T9> &im9;
8690 
8691  /// Constructor
8693  const GenericImage<T2> &im2,
8694  const GenericImage<T3> &im3,
8695  const GenericImage<T4> &im4,
8696  GenericImage<T5> &im5,
8697  GenericImage<T6> &im6,
8698  GenericImage<T7> &im7,
8699  GenericImage<T8> &im8,
8700  GenericImage<T9> &im9,
8701  VoxelFunc &vf, OutsideFunc &of)
8702  :
8703  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
8704  {}
8705 
8706  /// Copy constructor
8708  :
8709  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
8710  {}
8711 
8712  /// Split constructor
8714  :
8715  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
8716  {}
8717 
8718  /// Process entire image
8719  void operator ()(const ImageAttributes &attr) const
8720  {
8721  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8722  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8723  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8724  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8725  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8726  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8727  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
8728  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
8729  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
8730 
8731  const int T = (attr._dt ? attr._t : 1);
8732 
8733  for (int l = 0; l < T; ++l)
8734  for (int k = 0; k < attr._z; ++k)
8735  for (int j = 0; j < attr._y; ++j)
8736  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
8737  if (Domain::IsInside(im9, i, j, k, l, p9)) {
8738  // const_cast such that voxel functions need only implement
8739  // non-const operator() which is required for parallel_reduce
8740  const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8741  } else const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8742  }
8743  }
8744 
8745  /// Process image region using linear index
8746  void operator ()(const blocked_range<int> &re) const
8747  {
8748  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8749  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8750  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8751  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8752  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8753  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8754  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
8755  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
8756  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
8757 
8758  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8759  if (Domain::IsInside(im9, idx, p9)) {
8760  // const_cast such that voxel functions need only implement
8761  // non-const operator() which is required for parallel_reduce
8762  const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8763  } else const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8764  }
8765  }
8766 
8767  /// Process 2D image region
8768  void operator ()(const blocked_range2d<int> &re) const
8769  {
8770  const int bi = re.cols().begin();
8771  const int bj = re.rows().begin();
8772  const int ei = re.cols().end();
8773  const int ej = re.rows().end();
8774 
8775  const int s1 = im9.GetX() - (ei - bi);
8776 
8777  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8778  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8779  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8780  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8781  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8782  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8783  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8784  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8785  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8786 
8787  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
8788  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8789  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
8790  // const_cast such that voxel functions need only implement
8791  // non-const operator() which is required for parallel_reduce
8792  const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8793  } else const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8794  }
8795  }
8796 
8797  /// Process 3D image region
8798  void operator ()(const blocked_range3d<int> &re) const
8799  {
8800  const int bi = re.cols ().begin();
8801  const int bj = re.rows ().begin();
8802  const int bk = re.pages().begin();
8803  const int ei = re.cols ().end();
8804  const int ej = re.rows ().end();
8805  const int ek = re.pages().end();
8806 
8807  const int s1 = im9.GetX() - (ei - bi);
8808  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
8809 
8810  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8811  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8812  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8813  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8814  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8815  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8816  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
8817  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
8818  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
8819 
8820  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
8821  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
8822  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
8823  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
8824  // const_cast such that voxel functions need only implement
8825  // non-const operator() which is required for parallel_reduce
8826  const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8827  } else const_cast<NonaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
8828  }
8829  }
8830 };
8831 
8832 // -----------------------------------------------------------------------------
8833 // ForEachVoxel
8834 // -----------------------------------------------------------------------------
8835 
8836 //
8837 // Image arguments by pointer
8838 //
8839 
8840 // -----------------------------------------------------------------------------
8841 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8842 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8843 {
8844  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8845  blocked_range<int> re(0, im9->GetNumberOfVoxels());
8846  body(re);
8847  vf.join(body._VoxelFunc);
8848 }
8849 
8850 // -----------------------------------------------------------------------------
8851 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8852 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8853 {
8854  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8855  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8856 }
8857 
8858 // -----------------------------------------------------------------------------
8859 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8860 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8861 {
8862  if (im9->GetTSize()) {
8863  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8864  } else {
8865  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8866  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
8867  body(re);
8868  vf.join(body._VoxelFunc);
8869  }
8870 }
8871 
8872 // -----------------------------------------------------------------------------
8873 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8874 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8875 {
8876  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8877  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8878 }
8879 
8880 // -----------------------------------------------------------------------------
8881 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8882 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8883 {
8884  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8885  body(attr);
8886  vf.join(body._VoxelFunc);
8887 }
8888 
8889 // -----------------------------------------------------------------------------
8890 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8891 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8892 {
8893  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8894  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8895 }
8896 
8897 // -----------------------------------------------------------------------------
8898 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8899 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8900 {
8901  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8902  body(re);
8903  vf.join(body._VoxelFunc);
8904 }
8905 
8906 // -----------------------------------------------------------------------------
8907 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8908 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8909 {
8910  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8911  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8912 }
8913 
8914 // -----------------------------------------------------------------------------
8915 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8916 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8917 {
8918  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8919  body(re);
8920  vf.join(body._VoxelFunc);
8921 }
8922 
8923 // -----------------------------------------------------------------------------
8924 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8925 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8926 {
8927  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8928  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8929 }
8930 
8931 // -----------------------------------------------------------------------------
8932 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8933 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
8934 {
8935  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8936  body(re);
8937  vf.join(body._VoxelFunc);
8938 }
8939 
8940 // -----------------------------------------------------------------------------
8941 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8942 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
8943 {
8944  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8945  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
8946 }
8947 
8948 //
8949 // Image arguments by reference
8950 //
8951 
8952 // -----------------------------------------------------------------------------
8953 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8954 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8955 {
8956  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8958  body(re);
8959  vf.join(body._VoxelFunc);
8960 }
8961 
8962 // -----------------------------------------------------------------------------
8963 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8964 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8965 {
8966  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8967  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8968 }
8969 
8970 // -----------------------------------------------------------------------------
8971 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8972 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8973 {
8974  if (im9.GetTSize()) {
8975  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8976  } else {
8977  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8978  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
8979  body(re);
8980  vf.join(body._VoxelFunc);
8981  }
8982 }
8983 
8984 // -----------------------------------------------------------------------------
8985 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8986 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
8987 {
8988  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
8989  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8990 }
8991 
8992 // -----------------------------------------------------------------------------
8993 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
8994 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
8995 {
8996  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
8997  body(attr);
8998  vf.join(body._VoxelFunc);
8999 }
9000 
9001 // -----------------------------------------------------------------------------
9002 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9003 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9004 {
9005  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9006  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9007 }
9008 
9009 // -----------------------------------------------------------------------------
9010 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9011 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9012 {
9013  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9014  body(re);
9015  vf.join(body._VoxelFunc);
9016 }
9017 
9018 // -----------------------------------------------------------------------------
9019 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9020 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9021 {
9022  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9023  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9024 }
9025 
9026 // -----------------------------------------------------------------------------
9027 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9028 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9029 {
9030  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9031  body(re);
9032  vf.join(body._VoxelFunc);
9033 }
9034 
9035 // -----------------------------------------------------------------------------
9036 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9037 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9038 {
9039  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9040  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9041 }
9042 
9043 // -----------------------------------------------------------------------------
9044 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9045 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9046 {
9047  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9048  body(re);
9049  vf.join(body._VoxelFunc);
9050 }
9051 
9052 // -----------------------------------------------------------------------------
9053 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9054 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9055 {
9056  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9057  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9058 }
9059 
9060 // -----------------------------------------------------------------------------
9061 // ForEachVoxelIf
9062 // -----------------------------------------------------------------------------
9063 
9064 //
9065 // Image arguments by pointer
9066 //
9067 
9068 // -----------------------------------------------------------------------------
9069 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9070 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9071 {
9072  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9073  blocked_range<int> re(0, im9->GetNumberOfVoxels());
9074  body(re);
9075  vf.join(body._VoxelFunc);
9076  of.join(body._OutsideFunc);
9077 }
9078 
9079 // -----------------------------------------------------------------------------
9080 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9081 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9082 {
9083  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9084  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9085 }
9086 
9087 // -----------------------------------------------------------------------------
9088 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9089 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9090 {
9092  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9093 }
9094 
9095 // -----------------------------------------------------------------------------
9096 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9097 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9098 {
9099  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9100  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9101 }
9102 
9103 // -----------------------------------------------------------------------------
9104 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9105 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9106 {
9107  if (im9->GetTSize()) {
9108  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9109  } else {
9110  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9111  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
9112  body(re);
9113  vf.join(body._VoxelFunc);
9114  of.join(body._OutsideFunc);
9115  }
9116 }
9117 
9118 // -----------------------------------------------------------------------------
9119 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9120 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9121 {
9122  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9123  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9124 }
9125 
9126 // -----------------------------------------------------------------------------
9127 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9128 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9129 {
9131  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9132 }
9133 
9134 // -----------------------------------------------------------------------------
9135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9136 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9137 {
9138  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9139  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9140 }
9141 
9142 // -----------------------------------------------------------------------------
9143 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9144 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9145 {
9146  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9147  body(attr);
9148  vf.join(body._VoxelFunc);
9149  of.join(body._OutsideFunc);
9150 }
9151 
9152 // -----------------------------------------------------------------------------
9153 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9154 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9155 {
9156  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9157  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9158 }
9159 
9160 // -----------------------------------------------------------------------------
9161 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9162 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9163 {
9165  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9166 }
9167 
9168 // -----------------------------------------------------------------------------
9169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9170 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9171 {
9172  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9173  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9174 }
9175 
9176 // -----------------------------------------------------------------------------
9177 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9178 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9179 {
9180  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
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 T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9188 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9189 {
9190  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9191  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9192 }
9193 
9194 // -----------------------------------------------------------------------------
9195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9196 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9197 {
9198  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9199  body(re);
9200  vf.join(body._VoxelFunc);
9201  of.join(body._OutsideFunc);
9202 }
9203 
9204 // -----------------------------------------------------------------------------
9205 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9206 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9207 {
9208  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9209  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9210 }
9211 
9212 // -----------------------------------------------------------------------------
9213 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9214 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9215 {
9217  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9218 }
9219 
9220 // -----------------------------------------------------------------------------
9221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9222 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9223 {
9224  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9225  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9226 }
9227 
9228 // -----------------------------------------------------------------------------
9229 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9230 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9231 {
9232  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9233  body(re);
9234  vf.join(body._VoxelFunc);
9235  of.join(body._OutsideFunc);
9236 }
9237 
9238 // -----------------------------------------------------------------------------
9239 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9240 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9241 {
9242  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9243  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9244 }
9245 
9246 // -----------------------------------------------------------------------------
9247 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9248 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9249 {
9251  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9252 }
9253 
9254 // -----------------------------------------------------------------------------
9255 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9256 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9257 {
9258  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9259  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9260 }
9261 
9262 //
9263 // Image arguments by reference
9264 //
9265 
9266 // -----------------------------------------------------------------------------
9267 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9268 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9269 {
9270  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9272  body(re);
9273  vf.join(body._VoxelFunc);
9274  of.join(body._OutsideFunc);
9275 }
9276 
9277 // -----------------------------------------------------------------------------
9278 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9279 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9280 {
9281  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9282  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9283 }
9284 
9285 // -----------------------------------------------------------------------------
9286 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9287 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9288 {
9290  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9291 }
9292 
9293 // -----------------------------------------------------------------------------
9294 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9295 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9296 {
9297  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9298  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9299 }
9300 
9301 // -----------------------------------------------------------------------------
9302 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9303 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9304 {
9305  if (im9.GetTSize()) {
9306  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9307  } else {
9308  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9309  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
9310  body(re);
9311  vf.join(body._VoxelFunc);
9312  of.join(body._OutsideFunc);
9313  }
9314 }
9315 
9316 // -----------------------------------------------------------------------------
9317 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9318 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9319 {
9320  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9321  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9322 }
9323 
9324 // -----------------------------------------------------------------------------
9325 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9326 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9327 {
9329  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9330 }
9331 
9332 // -----------------------------------------------------------------------------
9333 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9334 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9335 {
9336  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9337  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9338 }
9339 
9340 // -----------------------------------------------------------------------------
9341 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9342 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9343 {
9344  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9345  body(attr);
9346  vf.join(body._VoxelFunc);
9347  of.join(body._OutsideFunc);
9348 }
9349 
9350 // -----------------------------------------------------------------------------
9351 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9352 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9353 {
9354  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9355  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9356 }
9357 
9358 // -----------------------------------------------------------------------------
9359 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9360 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9361 {
9363  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9364 }
9365 
9366 // -----------------------------------------------------------------------------
9367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9368 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9369 {
9370  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9371  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9372 }
9373 
9374 // -----------------------------------------------------------------------------
9375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9376 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9377 {
9378  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9379  body(re);
9380  vf.join(body._VoxelFunc);
9381  of.join(body._OutsideFunc);
9382 }
9383 
9384 // -----------------------------------------------------------------------------
9385 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9386 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9387 {
9388  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9389  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9390 }
9391 
9392 // -----------------------------------------------------------------------------
9393 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9394 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9395 {
9396  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9397  body(re);
9398  vf.join(body._VoxelFunc);
9399  of.join(body._OutsideFunc);
9400 }
9401 
9402 // -----------------------------------------------------------------------------
9403 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9404 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9405 {
9406  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9407  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9408 }
9409 
9410 // -----------------------------------------------------------------------------
9411 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9412 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9413 {
9415  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9416 }
9417 
9418 // -----------------------------------------------------------------------------
9419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9420 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9421 {
9422  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9423  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9424 }
9425 
9426 // -----------------------------------------------------------------------------
9427 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9428 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9429 {
9430  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9431  body(re);
9432  vf.join(body._VoxelFunc);
9433  of.join(body._OutsideFunc);
9434 }
9435 
9436 // -----------------------------------------------------------------------------
9437 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9438 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9439 {
9440  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9441  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9442 }
9443 
9444 // -----------------------------------------------------------------------------
9445 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9446 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9447 {
9449  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9450 }
9451 
9452 // -----------------------------------------------------------------------------
9453 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9454 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9455 {
9456  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9457  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9458 }
9459 
9460 // -----------------------------------------------------------------------------
9461 // ParallelForEachVoxel
9462 // -----------------------------------------------------------------------------
9463 
9464 //
9465 // Image arguments by pointer
9466 //
9467 
9468 // -----------------------------------------------------------------------------
9469 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9470 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9471 {
9472  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9473  blocked_range<int> re(0, im9->GetNumberOfVoxels());
9474  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9475  else parallel_for (re, body);
9476 }
9477 
9478 // -----------------------------------------------------------------------------
9479 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9480 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9481 {
9482  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9483  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9484 }
9485 
9486 // -----------------------------------------------------------------------------
9487 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9488 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9489 {
9490  if (im9->GetTSize()) {
9491  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9492  } else {
9493  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9494  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
9495  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9496  else parallel_for (re, body);
9497  }
9498 }
9499 
9500 // -----------------------------------------------------------------------------
9501 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9502 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9503 {
9504  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9505  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9506 }
9507 
9508 // -----------------------------------------------------------------------------
9509 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9510 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9511 {
9512  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9513  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9514  if (VoxelFunc::IsReduction()) {
9515  if (attr._dt) {
9516  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9517  } else {
9518  parallel_reduce(re, body);
9519  }
9520  vf.join(body._VoxelFunc);
9521  } else {
9522  if (attr._dt) {
9523  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9524  } else {
9525  parallel_for(re, body);
9526  }
9527  }
9528 }
9529 
9530 // -----------------------------------------------------------------------------
9531 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9532 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9533 {
9534  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9535  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9536 }
9537 
9538 // -----------------------------------------------------------------------------
9539 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9540 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9541 {
9542  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9543  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9544  else parallel_for (re, body);
9545 }
9546 
9547 // -----------------------------------------------------------------------------
9548 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9549 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9550 {
9551  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9552  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9553 }
9554 
9555 // -----------------------------------------------------------------------------
9556 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9557 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9558 {
9559  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9560  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9561  else parallel_for (re, body);
9562 }
9563 
9564 // -----------------------------------------------------------------------------
9565 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9566 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9567 {
9568  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9569  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9570 }
9571 
9572 // -----------------------------------------------------------------------------
9573 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9574 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9575 {
9576  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9577  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9578  else parallel_for (re, body);
9579 }
9580 
9581 // -----------------------------------------------------------------------------
9582 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9583 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9584 {
9585  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9586  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9587 }
9588 
9589 //
9590 // Image arguments by reference
9591 //
9592 
9593 // -----------------------------------------------------------------------------
9594 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9595 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9596 {
9597  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9599  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9600  else parallel_for (re, body);
9601 }
9602 
9603 // -----------------------------------------------------------------------------
9604 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9605 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9606 {
9607  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9608  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9609 }
9610 
9611 // -----------------------------------------------------------------------------
9612 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9613 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9614 {
9615  if (im9.GetTSize()) {
9616  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9617  } else {
9618  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9619  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
9620  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9621  else parallel_for (re, body);
9622  }
9623 }
9624 
9625 // -----------------------------------------------------------------------------
9626 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9627 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9628 {
9629  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9630  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9631 }
9632 
9633 // -----------------------------------------------------------------------------
9634 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9635 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9636 {
9637  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9638  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9639  if (VoxelFunc::IsReduction()) {
9640  if (attr._dt) {
9641  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9642  } else {
9643  parallel_reduce(re, body);
9644  }
9645  vf.join(body._VoxelFunc);
9646  } else {
9647  if (attr._dt) {
9648  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9649  } else {
9650  parallel_for(re, body);
9651  }
9652  }
9653 }
9654 
9655 // -----------------------------------------------------------------------------
9656 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9657 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9658 {
9659  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9660  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9661 }
9662 
9663 // -----------------------------------------------------------------------------
9664 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9665 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9666 {
9667  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9668  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9669  else parallel_for (re, body);
9670 }
9671 
9672 // -----------------------------------------------------------------------------
9673 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9674 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9675 {
9676  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9677  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9678 }
9679 
9680 // -----------------------------------------------------------------------------
9681 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9682 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9683 {
9684  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9685  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9686  else parallel_for (re, body);
9687 }
9688 
9689 // -----------------------------------------------------------------------------
9690 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9691 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9692 {
9693  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9694  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9695 }
9696 
9697 // -----------------------------------------------------------------------------
9698 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9699 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9700 {
9701  NonaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9702  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9703  else parallel_for (re, body);
9704 }
9705 
9706 // -----------------------------------------------------------------------------
9707 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9708 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9709 {
9710  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9711  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
9712 }
9713 
9714 // -----------------------------------------------------------------------------
9715 // ParallelForEachVoxelIf
9716 // -----------------------------------------------------------------------------
9717 
9718 //
9719 // Image arguments by pointer
9720 //
9721 
9722 // -----------------------------------------------------------------------------
9723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9724 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9725 {
9726  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9727  blocked_range<int> re(0, im9->GetNumberOfVoxels());
9728  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9729  parallel_reduce(re, body);
9730  vf.join(body._VoxelFunc);
9731  of.join(body._OutsideFunc);
9732  } else {
9733  parallel_for(re, body);
9734  }
9735 }
9736 
9737 // -----------------------------------------------------------------------------
9738 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9739 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9740 {
9741  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9742  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9743 }
9744 
9745 // -----------------------------------------------------------------------------
9746 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9747 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9748 {
9750  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9751 }
9752 
9753 // -----------------------------------------------------------------------------
9754 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9755 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9756 {
9757  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9758  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9759 }
9760 
9761 // -----------------------------------------------------------------------------
9762 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9763 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9764 {
9765  if (im9->GetTSize()) {
9766  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9767  } else {
9768  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9769  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
9770  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9771  parallel_reduce(re, body);
9772  vf.join(body._VoxelFunc);
9773  of.join(body._OutsideFunc);
9774  } else {
9775  parallel_for(re, body);
9776  }
9777  }
9778 }
9779 
9780 // -----------------------------------------------------------------------------
9781 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9782 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9783 {
9784  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9785  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9786 }
9787 
9788 // -----------------------------------------------------------------------------
9789 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9790 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, const GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9791 {
9793  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9794 }
9795 
9796 // -----------------------------------------------------------------------------
9797 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9798 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9799 {
9800  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9801  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9802 }
9803 
9804 // -----------------------------------------------------------------------------
9805 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9806 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9807 {
9808  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9809  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9810  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9811  if (attr._dt) {
9812  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9813  } else {
9814  parallel_reduce(re, body);
9815  }
9816  vf.join(body._VoxelFunc);
9817  of.join(body._OutsideFunc);
9818  } else {
9819  if (attr._dt) {
9820  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9821  } else {
9822  parallel_for(re, body);
9823  }
9824  }
9825 }
9826 
9827 // -----------------------------------------------------------------------------
9828 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9829 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9830 {
9831  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9832  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9833 }
9834 
9835 // -----------------------------------------------------------------------------
9836 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9837 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9838 {
9840  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9841 }
9842 
9843 // -----------------------------------------------------------------------------
9844 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9845 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9846 {
9847  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9848  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9849 }
9850 
9851 // -----------------------------------------------------------------------------
9852 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9853 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9854 {
9855  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9856  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9857  parallel_reduce(re, body);
9858  vf.join(body._VoxelFunc);
9859  of.join(body._OutsideFunc);
9860  } else {
9861  parallel_for(re, body);
9862  }
9863 }
9864 
9865 // -----------------------------------------------------------------------------
9866 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9867 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9868 {
9869  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9870  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9871 }
9872 
9873 // -----------------------------------------------------------------------------
9874 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9875 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9876 {
9878  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9879 }
9880 
9881 // -----------------------------------------------------------------------------
9882 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9883 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9884 {
9885  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9886  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9887 }
9888 
9889 // -----------------------------------------------------------------------------
9890 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9891 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9892 {
9893  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9894  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9895  parallel_reduce(re, body);
9896  vf.join(body._VoxelFunc);
9897  of.join(body._OutsideFunc);
9898  } else {
9899  parallel_for(re, body);
9900  }
9901 }
9902 
9903 // -----------------------------------------------------------------------------
9904 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9905 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9906 {
9907  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9908  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9909 }
9910 
9911 // -----------------------------------------------------------------------------
9912 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9913 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9914 {
9916  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9917 }
9918 
9919 // -----------------------------------------------------------------------------
9920 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9921 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9922 {
9923  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9924  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9925 }
9926 
9927 // -----------------------------------------------------------------------------
9928 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9929 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
9930 {
9931  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9932  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9933  parallel_reduce(re, body);
9934  vf.join(body._VoxelFunc);
9935  of.join(body._OutsideFunc);
9936  } else {
9937  parallel_for(re, body);
9938  }
9939 }
9940 
9941 // -----------------------------------------------------------------------------
9942 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9943 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9944 {
9945  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9946  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9947 }
9948 
9949 // -----------------------------------------------------------------------------
9950 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9951 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
9952 {
9954  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
9955 }
9956 
9957 // -----------------------------------------------------------------------------
9958 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9959 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
9960 {
9961  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9962  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
9963 }
9964 
9965 //
9966 // Image arguments by reference
9967 //
9968 
9969 // -----------------------------------------------------------------------------
9970 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9971 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
9972 {
9973  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9975  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9976  parallel_reduce(re, body);
9977  vf.join(body._VoxelFunc);
9978  of.join(body._OutsideFunc);
9979  } else {
9980  parallel_for(re, body);
9981  }
9982 }
9983 
9984 // -----------------------------------------------------------------------------
9985 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
9986 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
9987 {
9988  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
9989  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9990 }
9991 
9992 // -----------------------------------------------------------------------------
9993 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
9994 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
9995 {
9997  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
9998 }
9999 
10000 // -----------------------------------------------------------------------------
10001 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10002 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10003 {
10004  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10005  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10006 }
10007 
10008 // -----------------------------------------------------------------------------
10009 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10010 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10011 {
10012  if (im9.GetTSize()) {
10013  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10014  } else {
10015  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10016  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
10017  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10018  parallel_reduce(re, body);
10019  vf.join(body._VoxelFunc);
10020  of.join(body._OutsideFunc);
10021  } else {
10022  parallel_for(re, body);
10023  }
10024  }
10025 }
10026 
10027 // -----------------------------------------------------------------------------
10028 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10029 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10030 {
10031  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10032  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10033 }
10034 
10035 // -----------------------------------------------------------------------------
10036 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10037 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, const GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10038 {
10040  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10041 }
10042 
10043 // -----------------------------------------------------------------------------
10044 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10045 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10046 {
10047  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10048  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10049 }
10050 
10051 // -----------------------------------------------------------------------------
10052 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10053 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10054 {
10055  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10056  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
10057  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10058  if (attr._dt) {
10059  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
10060  } else {
10061  parallel_reduce(re, body);
10062  }
10063  vf.join(body._VoxelFunc);
10064  of.join(body._OutsideFunc);
10065  } else {
10066  if (attr._dt) {
10067  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
10068  } else {
10069  parallel_for(re, body);
10070  }
10071  }
10072 }
10073 
10074 // -----------------------------------------------------------------------------
10075 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10076 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10077 {
10078  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10079  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10080 }
10081 
10082 // -----------------------------------------------------------------------------
10083 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10084 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10085 {
10087  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10088 }
10089 
10090 // -----------------------------------------------------------------------------
10091 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10092 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10093 {
10094  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10095  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10096 }
10097 
10098 // -----------------------------------------------------------------------------
10099 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10100 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10101 {
10102  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10103  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10104  parallel_reduce(re, body);
10105  vf.join(body._VoxelFunc);
10106  of.join(body._OutsideFunc);
10107  } else {
10108  parallel_for(re, body);
10109  }
10110 }
10111 
10112 // -----------------------------------------------------------------------------
10113 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10114 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10115 {
10116  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10117  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10118 }
10119 
10120 // -----------------------------------------------------------------------------
10121 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10122 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10123 {
10125  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10126 }
10127 
10128 // -----------------------------------------------------------------------------
10129 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10130 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10131 {
10132  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10133  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10134 }
10135 
10136 // -----------------------------------------------------------------------------
10137 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10138 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10139 {
10140  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10141  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10142  parallel_reduce(re, body);
10143  vf.join(body._VoxelFunc);
10144  of.join(body._OutsideFunc);
10145  } else {
10146  parallel_for(re, body);
10147  }
10148 }
10149 
10150 // -----------------------------------------------------------------------------
10151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10152 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10153 {
10154  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10155  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10156 }
10157 
10158 // -----------------------------------------------------------------------------
10159 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10160 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10161 {
10163  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10164 }
10165 
10166 // -----------------------------------------------------------------------------
10167 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10168 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10169 {
10170  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10171  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10172 }
10173 
10174 // -----------------------------------------------------------------------------
10175 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10176 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10177 {
10178  NonaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10179  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10180  parallel_reduce(re, body);
10181  vf.join(body._VoxelFunc);
10182  of.join(body._OutsideFunc);
10183  } else {
10184  parallel_for(re, body);
10185  }
10186 }
10187 
10188 // -----------------------------------------------------------------------------
10189 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10190 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10191 {
10192  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10193  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10194 }
10195 
10196 // -----------------------------------------------------------------------------
10197 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10198 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10199 {
10201  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10202 }
10203 
10204 // -----------------------------------------------------------------------------
10205 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10206 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10207 {
10208  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10209  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10210 }
10211 
10212 // =============================================================================
10213 // 3 const, 6 non-const images
10214 // =============================================================================
10215 
10216 // -----------------------------------------------------------------------------
10217 /**
10218  * ForEachVoxel body for voxel function of 3 const, 6 non-const images
10219  */
10220 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10222 {
10223  const GenericImage<T1> &im1;
10224  const GenericImage<T2> &im2;
10225  const GenericImage<T3> &im3;
10226  GenericImage<T4> &im4;
10227  GenericImage<T5> &im5;
10228  GenericImage<T6> &im6;
10229  GenericImage<T7> &im7;
10230  GenericImage<T8> &im8;
10231  GenericImage<T9> &im9;
10232 
10233  /// Constructor
10235  const GenericImage<T2> &im2,
10236  const GenericImage<T3> &im3,
10237  GenericImage<T4> &im4,
10238  GenericImage<T5> &im5,
10239  GenericImage<T6> &im6,
10240  GenericImage<T7> &im7,
10241  GenericImage<T8> &im8,
10242  GenericImage<T9> &im9,
10243  VoxelFunc &vf)
10244  :
10245  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
10246  {}
10247 
10248  /// Copy constructor
10250  :
10251  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
10252  {}
10253 
10254  /// Split constructor
10256  :
10257  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
10258  {}
10259 
10260  /// Process entire image
10261  void operator ()(const ImageAttributes &attr) const
10262  {
10263  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10264  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10265  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10266  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10267  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10268  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10269  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
10270  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
10271  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
10272 
10273  const int T = (attr._dt ? attr._t : 1);
10274 
10275  for (int l = 0; l < T; ++l)
10276  for (int k = 0; k < attr._z; ++k)
10277  for (int j = 0; j < attr._y; ++j)
10278  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
10279  // const_cast such that voxel functions need only implement
10280  // non-const operator() which is required for parallel_reduce
10281  const_cast<NonaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10282  }
10283  }
10284 
10285  /// Process image region using linear index
10286  void operator ()(const blocked_range<int> &re) const
10287  {
10288  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10289  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10290  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10291  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10292  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10293  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10294  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
10295  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
10296  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
10297 
10298  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10299  // const_cast such that voxel functions need only implement
10300  // non-const operator() which is required for parallel_reduce
10301  const_cast<NonaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10302  }
10303  }
10304 
10305  /// Process 2D image region
10306  void operator ()(const blocked_range2d<int> &re) const
10307  {
10308  const int bi = re.cols().begin();
10309  const int bj = re.rows().begin();
10310  const int ei = re.cols().end();
10311  const int ej = re.rows().end();
10312 
10313  const int s1 = im9.GetX() - (ei - bi);
10314 
10315  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10316  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10317  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10318  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10319  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10320  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10321  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10322  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10323  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10324 
10325  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
10326  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10327  // const_cast such that voxel functions need only implement
10328  // non-const operator() which is required for parallel_reduce
10329  const_cast<NonaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10330  }
10331  }
10332 
10333  /// Process 3D image region
10334  void operator ()(const blocked_range3d<int> &re) const
10335  {
10336  const int bi = re.cols ().begin();
10337  const int bj = re.rows ().begin();
10338  const int bk = re.pages().begin();
10339  const int ei = re.cols ().end();
10340  const int ej = re.rows ().end();
10341  const int ek = re.pages().end();
10342 
10343  const int s1 = im9.GetX() - (ei - bi);
10344  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
10345 
10346  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10347  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10348  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10349  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10350  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10351  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10352  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
10353  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
10354  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
10355 
10356  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
10357  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
10358  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10359  // const_cast such that voxel functions need only implement
10360  // non-const operator() which is required for parallel_reduce
10361  const_cast<NonaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10362  }
10363  }
10364 };
10365 
10366 // -----------------------------------------------------------------------------
10367 /**
10368  * ForEachVoxel body for inside and outside unary voxel function of 3 const, 6 non-const images
10369  */
10370 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
10371  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
10372  class Domain = ForEachVoxelDomain::Foreground>
10373 struct NonaryForEachVoxelIfBody_3Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
10374 {
10375  const GenericImage<T1> &im1;
10376  const GenericImage<T2> &im2;
10377  const GenericImage<T3> &im3;
10378  GenericImage<T4> &im4;
10379  GenericImage<T5> &im5;
10380  GenericImage<T6> &im6;
10381  GenericImage<T7> &im7;
10382  GenericImage<T8> &im8;
10383  GenericImage<T9> &im9;
10384 
10385  /// Constructor
10387  const GenericImage<T2> &im2,
10388  const GenericImage<T3> &im3,
10389  GenericImage<T4> &im4,
10390  GenericImage<T5> &im5,
10391  GenericImage<T6> &im6,
10392  GenericImage<T7> &im7,
10393  GenericImage<T8> &im8,
10394  GenericImage<T9> &im9,
10395  VoxelFunc &vf, OutsideFunc &of)
10396  :
10397  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
10398  {}
10399 
10400  /// Copy constructor
10402  :
10403  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
10404  {}
10405 
10406  /// Split constructor
10408  :
10409  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
10410  {}
10411 
10412  /// Process entire image
10413  void operator ()(const ImageAttributes &attr) const
10414  {
10415  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10416  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10417  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10418  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10419  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10420  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10421  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
10422  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
10423  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
10424 
10425  const int T = (attr._dt ? attr._t : 1);
10426 
10427  for (int l = 0; l < T; ++l)
10428  for (int k = 0; k < attr._z; ++k)
10429  for (int j = 0; j < attr._y; ++j)
10430  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
10431  if (Domain::IsInside(im9, i, j, k, l, p9)) {
10432  // const_cast such that voxel functions need only implement
10433  // non-const operator() which is required for parallel_reduce
10434  const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10435  } else const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10436  }
10437  }
10438 
10439  /// Process image region using linear index
10440  void operator ()(const blocked_range<int> &re) const
10441  {
10442  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10443  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10444  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10445  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10446  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10447  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10448  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
10449  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
10450  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
10451 
10452  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10453  if (Domain::IsInside(im9, idx, p9)) {
10454  // const_cast such that voxel functions need only implement
10455  // non-const operator() which is required for parallel_reduce
10456  const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10457  } else const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10458  }
10459  }
10460 
10461  /// Process 2D image region
10462  void operator ()(const blocked_range2d<int> &re) const
10463  {
10464  const int bi = re.cols().begin();
10465  const int bj = re.rows().begin();
10466  const int ei = re.cols().end();
10467  const int ej = re.rows().end();
10468 
10469  const int s1 = im9.GetX() - (ei - bi);
10470 
10471  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10472  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10473  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10474  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10475  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10476  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10477  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10478  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10479  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10480 
10481  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
10482  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10483  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
10484  // const_cast such that voxel functions need only implement
10485  // non-const operator() which is required for parallel_reduce
10486  const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10487  } else const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10488  }
10489  }
10490 
10491  /// Process 3D image region
10492  void operator ()(const blocked_range3d<int> &re) const
10493  {
10494  const int bi = re.cols ().begin();
10495  const int bj = re.rows ().begin();
10496  const int bk = re.pages().begin();
10497  const int ei = re.cols ().end();
10498  const int ej = re.rows ().end();
10499  const int ek = re.pages().end();
10500 
10501  const int s1 = im9.GetX() - (ei - bi);
10502  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
10503 
10504  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10505  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10506  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10507  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10508  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10509  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10510  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
10511  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
10512  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
10513 
10514  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
10515  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
10516  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
10517  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
10518  // const_cast such that voxel functions need only implement
10519  // non-const operator() which is required for parallel_reduce
10520  const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10521  } else const_cast<NonaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
10522  }
10523  }
10524 };
10525 
10526 // -----------------------------------------------------------------------------
10527 // ForEachVoxel
10528 // -----------------------------------------------------------------------------
10529 
10530 //
10531 // Image arguments by pointer
10532 //
10533 
10534 // -----------------------------------------------------------------------------
10535 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10536 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10537 {
10538  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10539  blocked_range<int> re(0, im9->GetNumberOfVoxels());
10540  body(re);
10541  vf.join(body._VoxelFunc);
10542 }
10543 
10544 // -----------------------------------------------------------------------------
10545 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10546 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10547 {
10548  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10549  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10550 }
10551 
10552 // -----------------------------------------------------------------------------
10553 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10554 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10555 {
10556  if (im9->GetTSize()) {
10557  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10558  } else {
10559  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10560  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
10561  body(re);
10562  vf.join(body._VoxelFunc);
10563  }
10564 }
10565 
10566 // -----------------------------------------------------------------------------
10567 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10568 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10569 {
10570  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10571  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10572 }
10573 
10574 // -----------------------------------------------------------------------------
10575 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10576 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10577 {
10578  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10579  body(attr);
10580  vf.join(body._VoxelFunc);
10581 }
10582 
10583 // -----------------------------------------------------------------------------
10584 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10585 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10586 {
10587  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10588  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10589 }
10590 
10591 // -----------------------------------------------------------------------------
10592 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10593 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10594 {
10595  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10596  body(re);
10597  vf.join(body._VoxelFunc);
10598 }
10599 
10600 // -----------------------------------------------------------------------------
10601 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10602 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10603 {
10604  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10605  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10606 }
10607 
10608 // -----------------------------------------------------------------------------
10609 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10610 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10611 {
10612  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10613  body(re);
10614  vf.join(body._VoxelFunc);
10615 }
10616 
10617 // -----------------------------------------------------------------------------
10618 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10619 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10620 {
10621  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10622  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10623 }
10624 
10625 // -----------------------------------------------------------------------------
10626 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10627 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10628 {
10629  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10630  body(re);
10631  vf.join(body._VoxelFunc);
10632 }
10633 
10634 // -----------------------------------------------------------------------------
10635 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10636 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10637 {
10638  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10639  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10640 }
10641 
10642 //
10643 // Image arguments by reference
10644 //
10645 
10646 // -----------------------------------------------------------------------------
10647 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10648 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10649 {
10650  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10652  body(re);
10653  vf.join(body._VoxelFunc);
10654 }
10655 
10656 // -----------------------------------------------------------------------------
10657 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10658 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10659 {
10660  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10661  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10662 }
10663 
10664 // -----------------------------------------------------------------------------
10665 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10666 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10667 {
10668  if (im9.GetTSize()) {
10669  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10670  } else {
10671  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10672  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
10673  body(re);
10674  vf.join(body._VoxelFunc);
10675  }
10676 }
10677 
10678 // -----------------------------------------------------------------------------
10679 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10680 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10681 {
10682  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10683  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10684 }
10685 
10686 // -----------------------------------------------------------------------------
10687 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10688 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10689 {
10690  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10691  body(attr);
10692  vf.join(body._VoxelFunc);
10693 }
10694 
10695 // -----------------------------------------------------------------------------
10696 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10697 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10698 {
10699  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10700  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10701 }
10702 
10703 // -----------------------------------------------------------------------------
10704 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10705 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10706 {
10707  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10708  body(re);
10709  vf.join(body._VoxelFunc);
10710 }
10711 
10712 // -----------------------------------------------------------------------------
10713 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10714 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10715 {
10716  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10717  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10718 }
10719 
10720 // -----------------------------------------------------------------------------
10721 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10722 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10723 {
10724  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10725  body(re);
10726  vf.join(body._VoxelFunc);
10727 }
10728 
10729 // -----------------------------------------------------------------------------
10730 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10731 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10732 {
10733  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10734  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10735 }
10736 
10737 // -----------------------------------------------------------------------------
10738 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10739 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10740 {
10741  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10742  body(re);
10743  vf.join(body._VoxelFunc);
10744 }
10745 
10746 // -----------------------------------------------------------------------------
10747 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10748 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10749 {
10750  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10751  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10752 }
10753 
10754 // -----------------------------------------------------------------------------
10755 // ForEachVoxelIf
10756 // -----------------------------------------------------------------------------
10757 
10758 //
10759 // Image arguments by pointer
10760 //
10761 
10762 // -----------------------------------------------------------------------------
10763 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10764 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10765 {
10766  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10767  blocked_range<int> re(0, im9->GetNumberOfVoxels());
10768  body(re);
10769  vf.join(body._VoxelFunc);
10770  of.join(body._OutsideFunc);
10771 }
10772 
10773 // -----------------------------------------------------------------------------
10774 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10775 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10776 {
10777  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10778  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10779 }
10780 
10781 // -----------------------------------------------------------------------------
10782 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10783 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10784 {
10786  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10787 }
10788 
10789 // -----------------------------------------------------------------------------
10790 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10791 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10792 {
10793  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10794  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10795 }
10796 
10797 // -----------------------------------------------------------------------------
10798 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10799 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10800 {
10801  if (im9->GetTSize()) {
10802  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10803  } else {
10804  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10805  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
10806  body(re);
10807  vf.join(body._VoxelFunc);
10808  of.join(body._OutsideFunc);
10809  }
10810 }
10811 
10812 // -----------------------------------------------------------------------------
10813 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10814 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10815 {
10816  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10817  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10818 }
10819 
10820 // -----------------------------------------------------------------------------
10821 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10822 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10823 {
10825  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10826 }
10827 
10828 // -----------------------------------------------------------------------------
10829 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10830 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10831 {
10832  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10833  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10834 }
10835 
10836 // -----------------------------------------------------------------------------
10837 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10838 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10839 {
10840  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10841  body(attr);
10842  vf.join(body._VoxelFunc);
10843  of.join(body._OutsideFunc);
10844 }
10845 
10846 // -----------------------------------------------------------------------------
10847 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10848 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10849 {
10850  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10851  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10852 }
10853 
10854 // -----------------------------------------------------------------------------
10855 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10856 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10857 {
10859  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10860 }
10861 
10862 // -----------------------------------------------------------------------------
10863 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10864 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10865 {
10866  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10867  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10868 }
10869 
10870 // -----------------------------------------------------------------------------
10871 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10872 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10873 {
10874  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10875  body(re);
10876  vf.join(body._VoxelFunc);
10877  of.join(body._OutsideFunc);
10878 }
10879 
10880 // -----------------------------------------------------------------------------
10881 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10882 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10883 {
10884  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10885  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10886 }
10887 
10888 // -----------------------------------------------------------------------------
10889 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10890 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10891 {
10892  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10893  body(re);
10894  vf.join(body._VoxelFunc);
10895  of.join(body._OutsideFunc);
10896 }
10897 
10898 // -----------------------------------------------------------------------------
10899 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10900 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10901 {
10902  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10903  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10904 }
10905 
10906 // -----------------------------------------------------------------------------
10907 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10908 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10909 {
10911  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10912 }
10913 
10914 // -----------------------------------------------------------------------------
10915 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10916 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10917 {
10918  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10919  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10920 }
10921 
10922 // -----------------------------------------------------------------------------
10923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10924 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
10925 {
10926  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10927  body(re);
10928  vf.join(body._VoxelFunc);
10929  of.join(body._OutsideFunc);
10930 }
10931 
10932 // -----------------------------------------------------------------------------
10933 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10934 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10935 {
10936  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10937  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10938 }
10939 
10940 // -----------------------------------------------------------------------------
10941 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10942 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
10943 {
10945  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
10946 }
10947 
10948 // -----------------------------------------------------------------------------
10949 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10950 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
10951 {
10952  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10953  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
10954 }
10955 
10956 //
10957 // Image arguments by reference
10958 //
10959 
10960 // -----------------------------------------------------------------------------
10961 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10962 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10963 {
10964  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10966  body(re);
10967  vf.join(body._VoxelFunc);
10968  of.join(body._OutsideFunc);
10969 }
10970 
10971 // -----------------------------------------------------------------------------
10972 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10973 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10974 {
10975  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10976  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10977 }
10978 
10979 // -----------------------------------------------------------------------------
10980 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10981 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
10982 {
10984  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
10985 }
10986 
10987 // -----------------------------------------------------------------------------
10988 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
10989 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
10990 {
10991  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
10992  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
10993 }
10994 
10995 // -----------------------------------------------------------------------------
10996 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
10997 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
10998 {
10999  if (im9.GetTSize()) {
11000  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11001  } else {
11002  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11003  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
11004  body(re);
11005  vf.join(body._VoxelFunc);
11006  of.join(body._OutsideFunc);
11007  }
11008 }
11009 
11010 // -----------------------------------------------------------------------------
11011 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11012 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11013 {
11014  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11015  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11016 }
11017 
11018 // -----------------------------------------------------------------------------
11019 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11020 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11021 {
11023  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11024 }
11025 
11026 // -----------------------------------------------------------------------------
11027 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11028 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11029 {
11030  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11031  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11032 }
11033 
11034 // -----------------------------------------------------------------------------
11035 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11036 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11037 {
11038  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11039  body(attr);
11040  vf.join(body._VoxelFunc);
11041  of.join(body._OutsideFunc);
11042 }
11043 
11044 // -----------------------------------------------------------------------------
11045 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11046 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11047 {
11048  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11049  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11050 }
11051 
11052 // -----------------------------------------------------------------------------
11053 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11054 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11055 {
11057  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11058 }
11059 
11060 // -----------------------------------------------------------------------------
11061 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11062 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11063 {
11064  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11065  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11066 }
11067 
11068 // -----------------------------------------------------------------------------
11069 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11070 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11071 {
11072  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11073  body(re);
11074  vf.join(body._VoxelFunc);
11075  of.join(body._OutsideFunc);
11076 }
11077 
11078 // -----------------------------------------------------------------------------
11079 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11080 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11081 {
11082  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11083  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11084 }
11085 
11086 // -----------------------------------------------------------------------------
11087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11088 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11089 {
11090  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11091  body(re);
11092  vf.join(body._VoxelFunc);
11093  of.join(body._OutsideFunc);
11094 }
11095 
11096 // -----------------------------------------------------------------------------
11097 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11098 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11099 {
11100  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11101  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11102 }
11103 
11104 // -----------------------------------------------------------------------------
11105 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11106 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11107 {
11109  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11110 }
11111 
11112 // -----------------------------------------------------------------------------
11113 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11114 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11115 {
11116  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11117  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11118 }
11119 
11120 // -----------------------------------------------------------------------------
11121 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11122 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11123 {
11124  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11125  body(re);
11126  vf.join(body._VoxelFunc);
11127  of.join(body._OutsideFunc);
11128 }
11129 
11130 // -----------------------------------------------------------------------------
11131 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11132 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11133 {
11134  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11135  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11136 }
11137 
11138 // -----------------------------------------------------------------------------
11139 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11140 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11141 {
11143  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11144 }
11145 
11146 // -----------------------------------------------------------------------------
11147 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11148 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11149 {
11150  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11151  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11152 }
11153 
11154 // -----------------------------------------------------------------------------
11155 // ParallelForEachVoxel
11156 // -----------------------------------------------------------------------------
11157 
11158 //
11159 // Image arguments by pointer
11160 //
11161 
11162 // -----------------------------------------------------------------------------
11163 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11164 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11165 {
11166  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11167  blocked_range<int> re(0, im9->GetNumberOfVoxels());
11168  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11169  else parallel_for (re, body);
11170 }
11171 
11172 // -----------------------------------------------------------------------------
11173 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11174 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11175 {
11176  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11177  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11178 }
11179 
11180 // -----------------------------------------------------------------------------
11181 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11182 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11183 {
11184  if (im9->GetTSize()) {
11185  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11186  } else {
11187  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11188  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
11189  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11190  else parallel_for (re, body);
11191  }
11192 }
11193 
11194 // -----------------------------------------------------------------------------
11195 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11196 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11197 {
11198  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11199  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11200 }
11201 
11202 // -----------------------------------------------------------------------------
11203 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11204 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11205 {
11206  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11207  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11208  if (VoxelFunc::IsReduction()) {
11209  if (attr._dt) {
11210  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11211  } else {
11212  parallel_reduce(re, body);
11213  }
11214  vf.join(body._VoxelFunc);
11215  } else {
11216  if (attr._dt) {
11217  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11218  } else {
11219  parallel_for(re, body);
11220  }
11221  }
11222 }
11223 
11224 // -----------------------------------------------------------------------------
11225 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11226 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11227 {
11228  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11229  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11230 }
11231 
11232 // -----------------------------------------------------------------------------
11233 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11234 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11235 {
11236  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11237  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11238  else parallel_for (re, body);
11239 }
11240 
11241 // -----------------------------------------------------------------------------
11242 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11243 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11244 {
11245  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11246  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11247 }
11248 
11249 // -----------------------------------------------------------------------------
11250 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11251 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11252 {
11253  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11254  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11255  else parallel_for (re, body);
11256 }
11257 
11258 // -----------------------------------------------------------------------------
11259 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11260 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11261 {
11262  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11263  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11264 }
11265 
11266 // -----------------------------------------------------------------------------
11267 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11268 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11269 {
11270  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11271  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11272  else parallel_for (re, body);
11273 }
11274 
11275 // -----------------------------------------------------------------------------
11276 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11277 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11278 {
11279  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11280  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11281 }
11282 
11283 //
11284 // Image arguments by reference
11285 //
11286 
11287 // -----------------------------------------------------------------------------
11288 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11289 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11290 {
11291  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11293  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11294  else parallel_for (re, body);
11295 }
11296 
11297 // -----------------------------------------------------------------------------
11298 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11299 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11300 {
11301  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11302  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11303 }
11304 
11305 // -----------------------------------------------------------------------------
11306 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11307 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11308 {
11309  if (im9.GetTSize()) {
11310  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11311  } else {
11312  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11313  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
11314  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11315  else parallel_for (re, body);
11316  }
11317 }
11318 
11319 // -----------------------------------------------------------------------------
11320 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11321 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11322 {
11323  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11324  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11325 }
11326 
11327 // -----------------------------------------------------------------------------
11328 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11329 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11330 {
11331  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11332  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11333  if (VoxelFunc::IsReduction()) {
11334  if (attr._dt) {
11335  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11336  } else {
11337  parallel_reduce(re, body);
11338  }
11339  vf.join(body._VoxelFunc);
11340  } else {
11341  if (attr._dt) {
11342  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11343  } else {
11344  parallel_for(re, body);
11345  }
11346  }
11347 }
11348 
11349 // -----------------------------------------------------------------------------
11350 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11351 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11352 {
11353  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11354  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11355 }
11356 
11357 // -----------------------------------------------------------------------------
11358 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11359 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11360 {
11361  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11362  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11363  else parallel_for (re, body);
11364 }
11365 
11366 // -----------------------------------------------------------------------------
11367 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11368 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11369 {
11370  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11371  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11372 }
11373 
11374 // -----------------------------------------------------------------------------
11375 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11376 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11377 {
11378  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11379  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11380  else parallel_for (re, body);
11381 }
11382 
11383 // -----------------------------------------------------------------------------
11384 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11385 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11386 {
11387  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11388  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11389 }
11390 
11391 // -----------------------------------------------------------------------------
11392 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11393 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11394 {
11395  NonaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11396  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11397  else parallel_for (re, body);
11398 }
11399 
11400 // -----------------------------------------------------------------------------
11401 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11402 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11403 {
11404  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11405  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11406 }
11407 
11408 // -----------------------------------------------------------------------------
11409 // ParallelForEachVoxelIf
11410 // -----------------------------------------------------------------------------
11411 
11412 //
11413 // Image arguments by pointer
11414 //
11415 
11416 // -----------------------------------------------------------------------------
11417 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11418 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11419 {
11420  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11421  blocked_range<int> re(0, im9->GetNumberOfVoxels());
11422  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11423  parallel_reduce(re, body);
11424  vf.join(body._VoxelFunc);
11425  of.join(body._OutsideFunc);
11426  } else {
11427  parallel_for(re, body);
11428  }
11429 }
11430 
11431 // -----------------------------------------------------------------------------
11432 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11433 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11434 {
11435  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11436  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11437 }
11438 
11439 // -----------------------------------------------------------------------------
11440 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11441 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11442 {
11444  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11445 }
11446 
11447 // -----------------------------------------------------------------------------
11448 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11449 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11450 {
11451  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11452  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11453 }
11454 
11455 // -----------------------------------------------------------------------------
11456 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11457 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11458 {
11459  if (im9->GetTSize()) {
11460  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11461  } else {
11462  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11463  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
11464  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11465  parallel_reduce(re, body);
11466  vf.join(body._VoxelFunc);
11467  of.join(body._OutsideFunc);
11468  } else {
11469  parallel_for(re, body);
11470  }
11471  }
11472 }
11473 
11474 // -----------------------------------------------------------------------------
11475 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11476 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11477 {
11478  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11479  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11480 }
11481 
11482 // -----------------------------------------------------------------------------
11483 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11484 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, const GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11485 {
11487  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11488 }
11489 
11490 // -----------------------------------------------------------------------------
11491 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11492 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11493 {
11494  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11495  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11496 }
11497 
11498 // -----------------------------------------------------------------------------
11499 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11500 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11501 {
11502  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11503  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11504  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11505  if (attr._dt) {
11506  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11507  } else {
11508  parallel_reduce(re, body);
11509  }
11510  vf.join(body._VoxelFunc);
11511  of.join(body._OutsideFunc);
11512  } else {
11513  if (attr._dt) {
11514  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11515  } else {
11516  parallel_for(re, body);
11517  }
11518  }
11519 }
11520 
11521 // -----------------------------------------------------------------------------
11522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11523 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11524 {
11525  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11526  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11527 }
11528 
11529 // -----------------------------------------------------------------------------
11530 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11531 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11532 {
11534  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11535 }
11536 
11537 // -----------------------------------------------------------------------------
11538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11539 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11540 {
11541  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11542  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11543 }
11544 
11545 // -----------------------------------------------------------------------------
11546 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11547 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11548 {
11549  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11550  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11551  parallel_reduce(re, body);
11552  vf.join(body._VoxelFunc);
11553  of.join(body._OutsideFunc);
11554  } else {
11555  parallel_for(re, body);
11556  }
11557 }
11558 
11559 // -----------------------------------------------------------------------------
11560 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11561 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11562 {
11563  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11564  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11565 }
11566 
11567 // -----------------------------------------------------------------------------
11568 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11569 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11570 {
11572  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11573 }
11574 
11575 // -----------------------------------------------------------------------------
11576 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11577 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11578 {
11579  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11580  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11581 }
11582 
11583 // -----------------------------------------------------------------------------
11584 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11585 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11586 {
11587  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11588  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11589  parallel_reduce(re, body);
11590  vf.join(body._VoxelFunc);
11591  of.join(body._OutsideFunc);
11592  } else {
11593  parallel_for(re, body);
11594  }
11595 }
11596 
11597 // -----------------------------------------------------------------------------
11598 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11599 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11600 {
11601  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11602  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11603 }
11604 
11605 // -----------------------------------------------------------------------------
11606 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11607 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11608 {
11610  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11611 }
11612 
11613 // -----------------------------------------------------------------------------
11614 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11615 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11616 {
11617  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11618  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11619 }
11620 
11621 // -----------------------------------------------------------------------------
11622 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11623 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
11624 {
11625  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11626  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11627  parallel_reduce(re, body);
11628  vf.join(body._VoxelFunc);
11629  of.join(body._OutsideFunc);
11630  } else {
11631  parallel_for(re, body);
11632  }
11633 }
11634 
11635 // -----------------------------------------------------------------------------
11636 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11637 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11638 {
11639  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11640  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11641 }
11642 
11643 // -----------------------------------------------------------------------------
11644 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11645 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
11646 {
11648  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
11649 }
11650 
11651 // -----------------------------------------------------------------------------
11652 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11653 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
11654 {
11655  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11656  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
11657 }
11658 
11659 //
11660 // Image arguments by reference
11661 //
11662 
11663 // -----------------------------------------------------------------------------
11664 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11665 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11666 {
11667  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11669  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11670  parallel_reduce(re, body);
11671  vf.join(body._VoxelFunc);
11672  of.join(body._OutsideFunc);
11673  } else {
11674  parallel_for(re, body);
11675  }
11676 }
11677 
11678 // -----------------------------------------------------------------------------
11679 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11680 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11681 {
11682  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11683  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11684 }
11685 
11686 // -----------------------------------------------------------------------------
11687 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11688 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11689 {
11691  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11692 }
11693 
11694 // -----------------------------------------------------------------------------
11695 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11696 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11697 {
11698  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11699  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11700 }
11701 
11702 // -----------------------------------------------------------------------------
11703 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11704 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11705 {
11706  if (im9.GetTSize()) {
11707  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11708  } else {
11709  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11710  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
11711  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11712  parallel_reduce(re, body);
11713  vf.join(body._VoxelFunc);
11714  of.join(body._OutsideFunc);
11715  } else {
11716  parallel_for(re, body);
11717  }
11718  }
11719 }
11720 
11721 // -----------------------------------------------------------------------------
11722 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11723 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11724 {
11725  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11726  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11727 }
11728 
11729 // -----------------------------------------------------------------------------
11730 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11731 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, const GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11732 {
11734  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11735 }
11736 
11737 // -----------------------------------------------------------------------------
11738 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11739 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11740 {
11741  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11742  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11743 }
11744 
11745 // -----------------------------------------------------------------------------
11746 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11747 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11748 {
11749  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11750  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11751  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11752  if (attr._dt) {
11753  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11754  } else {
11755  parallel_reduce(re, body);
11756  }
11757  vf.join(body._VoxelFunc);
11758  of.join(body._OutsideFunc);
11759  } else {
11760  if (attr._dt) {
11761  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11762  } else {
11763  parallel_for(re, body);
11764  }
11765  }
11766 }
11767 
11768 // -----------------------------------------------------------------------------
11769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11770 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11771 {
11772  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11773  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11774 }
11775 
11776 // -----------------------------------------------------------------------------
11777 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11778 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11779 {
11781  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11782 }
11783 
11784 // -----------------------------------------------------------------------------
11785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11786 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11787 {
11788  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11789  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11790 }
11791 
11792 // -----------------------------------------------------------------------------
11793 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11794 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11795 {
11796  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11797  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11798  parallel_reduce(re, body);
11799  vf.join(body._VoxelFunc);
11800  of.join(body._OutsideFunc);
11801  } else {
11802  parallel_for(re, body);
11803  }
11804 }
11805 
11806 // -----------------------------------------------------------------------------
11807 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11808 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11809 {
11810  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11811  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11812 }
11813 
11814 // -----------------------------------------------------------------------------
11815 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11816 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11817 {
11819  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11820 }
11821 
11822 // -----------------------------------------------------------------------------
11823 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11824 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11825 {
11826  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11827  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11828 }
11829 
11830 // -----------------------------------------------------------------------------
11831 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11832 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11833 {
11834  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11835  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11836  parallel_reduce(re, body);
11837  vf.join(body._VoxelFunc);
11838  of.join(body._OutsideFunc);
11839  } else {
11840  parallel_for(re, body);
11841  }
11842 }
11843 
11844 // -----------------------------------------------------------------------------
11845 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11846 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11847 {
11848  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11849  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11850 }
11851 
11852 // -----------------------------------------------------------------------------
11853 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11854 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11855 {
11857  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11858 }
11859 
11860 // -----------------------------------------------------------------------------
11861 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11862 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11863 {
11864  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11865  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11866 }
11867 
11868 // -----------------------------------------------------------------------------
11869 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11870 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
11871 {
11872  NonaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11873  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11874  parallel_reduce(re, body);
11875  vf.join(body._VoxelFunc);
11876  of.join(body._OutsideFunc);
11877  } else {
11878  parallel_for(re, body);
11879  }
11880 }
11881 
11882 // -----------------------------------------------------------------------------
11883 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
11884 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11885 {
11886  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11887  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11888 }
11889 
11890 // -----------------------------------------------------------------------------
11891 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11892 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
11893 {
11895  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
11896 }
11897 
11898 // -----------------------------------------------------------------------------
11899 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11900 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
11901 {
11902  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
11903  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
11904 }
11905 
11906 // =============================================================================
11907 // 2 const, 7 non-const images
11908 // =============================================================================
11909 
11910 // -----------------------------------------------------------------------------
11911 /**
11912  * ForEachVoxel body for voxel function of 2 const, 7 non-const images
11913  */
11914 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
11916 {
11917  const GenericImage<T1> &im1;
11918  const GenericImage<T2> &im2;
11919  GenericImage<T3> &im3;
11920  GenericImage<T4> &im4;
11921  GenericImage<T5> &im5;
11922  GenericImage<T6> &im6;
11923  GenericImage<T7> &im7;
11924  GenericImage<T8> &im8;
11925  GenericImage<T9> &im9;
11926 
11927  /// Constructor
11929  const GenericImage<T2> &im2,
11930  GenericImage<T3> &im3,
11931  GenericImage<T4> &im4,
11932  GenericImage<T5> &im5,
11933  GenericImage<T6> &im6,
11934  GenericImage<T7> &im7,
11935  GenericImage<T8> &im8,
11936  GenericImage<T9> &im9,
11937  VoxelFunc &vf)
11938  :
11939  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
11940  {}
11941 
11942  /// Copy constructor
11944  :
11945  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
11946  {}
11947 
11948  /// Split constructor
11950  :
11951  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
11952  {}
11953 
11954  /// Process entire image
11955  void operator ()(const ImageAttributes &attr) const
11956  {
11957  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
11958  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
11959  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
11960  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
11961  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
11962  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
11963  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
11964  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
11965  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
11966 
11967  const int T = (attr._dt ? attr._t : 1);
11968 
11969  for (int l = 0; l < T; ++l)
11970  for (int k = 0; k < attr._z; ++k)
11971  for (int j = 0; j < attr._y; ++j)
11972  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
11973  // const_cast such that voxel functions need only implement
11974  // non-const operator() which is required for parallel_reduce
11975  const_cast<NonaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
11976  }
11977  }
11978 
11979  /// Process image region using linear index
11980  void operator ()(const blocked_range<int> &re) const
11981  {
11982  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
11983  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
11984  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
11985  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
11986  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
11987  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
11988  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
11989  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
11990  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
11991 
11992  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
11993  // const_cast such that voxel functions need only implement
11994  // non-const operator() which is required for parallel_reduce
11995  const_cast<NonaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
11996  }
11997  }
11998 
11999  /// Process 2D image region
12000  void operator ()(const blocked_range2d<int> &re) const
12001  {
12002  const int bi = re.cols().begin();
12003  const int bj = re.rows().begin();
12004  const int ei = re.cols().end();
12005  const int ej = re.rows().end();
12006 
12007  const int s1 = im9.GetX() - (ei - bi);
12008 
12009  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12010  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12011  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12012  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12013  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12014  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12015  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12016  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12017  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12018 
12019  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
12020  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
12021  // const_cast such that voxel functions need only implement
12022  // non-const operator() which is required for parallel_reduce
12023  const_cast<NonaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12024  }
12025  }
12026 
12027  /// Process 3D image region
12028  void operator ()(const blocked_range3d<int> &re) const
12029  {
12030  const int bi = re.cols ().begin();
12031  const int bj = re.rows ().begin();
12032  const int bk = re.pages().begin();
12033  const int ei = re.cols ().end();
12034  const int ej = re.rows ().end();
12035  const int ek = re.pages().end();
12036 
12037  const int s1 = im9.GetX() - (ei - bi);
12038  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
12039 
12040  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
12041  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
12042  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
12043  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
12044  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
12045  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
12046  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
12047  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
12048  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
12049 
12050  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
12051  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
12052  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
12053  // const_cast such that voxel functions need only implement
12054  // non-const operator() which is required for parallel_reduce
12055  const_cast<NonaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12056  }
12057  }
12058 };
12059 
12060 // -----------------------------------------------------------------------------
12061 /**
12062  * ForEachVoxel body for inside and outside unary voxel function of 2 const, 7 non-const images
12063  */
12064 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
12065  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
12066  class Domain = ForEachVoxelDomain::Foreground>
12067 struct NonaryForEachVoxelIfBody_2Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
12068 {
12069  const GenericImage<T1> &im1;
12070  const GenericImage<T2> &im2;
12071  GenericImage<T3> &im3;
12072  GenericImage<T4> &im4;
12073  GenericImage<T5> &im5;
12074  GenericImage<T6> &im6;
12075  GenericImage<T7> &im7;
12076  GenericImage<T8> &im8;
12077  GenericImage<T9> &im9;
12078 
12079  /// Constructor
12081  const GenericImage<T2> &im2,
12082  GenericImage<T3> &im3,
12083  GenericImage<T4> &im4,
12084  GenericImage<T5> &im5,
12085  GenericImage<T6> &im6,
12086  GenericImage<T7> &im7,
12087  GenericImage<T8> &im8,
12088  GenericImage<T9> &im9,
12089  VoxelFunc &vf, OutsideFunc &of)
12090  :
12091  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
12092  {}
12093 
12094  /// Copy constructor
12096  :
12097  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
12098  {}
12099 
12100  /// Split constructor
12102  :
12103  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
12104  {}
12105 
12106  /// Process entire image
12107  void operator ()(const ImageAttributes &attr) const
12108  {
12109  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
12110  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
12111  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
12112  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
12113  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
12114  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
12115  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
12116  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
12117  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
12118 
12119  const int T = (attr._dt ? attr._t : 1);
12120 
12121  for (int l = 0; l < T; ++l)
12122  for (int k = 0; k < attr._z; ++k)
12123  for (int j = 0; j < attr._y; ++j)
12124  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
12125  if (Domain::IsInside(im9, i, j, k, l, p9)) {
12126  // const_cast such that voxel functions need only implement
12127  // non-const operator() which is required for parallel_reduce
12128  const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12129  } else const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12130  }
12131  }
12132 
12133  /// Process image region using linear index
12134  void operator ()(const blocked_range<int> &re) const
12135  {
12136  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
12137  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
12138  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
12139  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
12140  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
12141  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
12142  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
12143  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
12144  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
12145 
12146  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
12147  if (Domain::IsInside(im9, idx, p9)) {
12148  // const_cast such that voxel functions need only implement
12149  // non-const operator() which is required for parallel_reduce
12150  const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12151  } else const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12152  }
12153  }
12154 
12155  /// Process 2D image region
12156  void operator ()(const blocked_range2d<int> &re) const
12157  {
12158  const int bi = re.cols().begin();
12159  const int bj = re.rows().begin();
12160  const int ei = re.cols().end();
12161  const int ej = re.rows().end();
12162 
12163  const int s1 = im9.GetX() - (ei - bi);
12164 
12165  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12166  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12167  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12168  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12169  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12170  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12171  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12172  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12173  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12174 
12175  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
12176  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
12177  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
12178  // const_cast such that voxel functions need only implement
12179  // non-const operator() which is required for parallel_reduce
12180  const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12181  } else const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12182  }
12183  }
12184 
12185  /// Process 3D image region
12186  void operator ()(const blocked_range3d<int> &re) const
12187  {
12188  const int bi = re.cols ().begin();
12189  const int bj = re.rows ().begin();
12190  const int bk = re.pages().begin();
12191  const int ei = re.cols ().end();
12192  const int ej = re.rows ().end();
12193  const int ek = re.pages().end();
12194 
12195  const int s1 = im9.GetX() - (ei - bi);
12196  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
12197 
12198  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
12199  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
12200  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
12201  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
12202  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
12203  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
12204  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
12205  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
12206  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
12207 
12208  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
12209  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
12210  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
12211  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
12212  // const_cast such that voxel functions need only implement
12213  // non-const operator() which is required for parallel_reduce
12214  const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12215  } else const_cast<NonaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
12216  }
12217  }
12218 };
12219 
12220 // -----------------------------------------------------------------------------
12221 // ForEachVoxel
12222 // -----------------------------------------------------------------------------
12223 
12224 //
12225 // Image arguments by pointer
12226 //
12227 
12228 // -----------------------------------------------------------------------------
12229 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12230 void ForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12231 {
12232  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12233  blocked_range<int> re(0, im9->GetNumberOfVoxels());
12234  body(re);
12235  vf.join(body._VoxelFunc);
12236 }
12237 
12238 // -----------------------------------------------------------------------------
12239 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12240 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12241 {
12242  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12243  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12244 }
12245 
12246 // -----------------------------------------------------------------------------
12247 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12248 void ForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12249 {
12250  if (im9->GetTSize()) {
12251  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12252  } else {
12253  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12254  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
12255  body(re);
12256  vf.join(body._VoxelFunc);
12257  }
12258 }
12259 
12260 // -----------------------------------------------------------------------------
12261 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12262 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12263 {
12264  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12265  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12266 }
12267 
12268 // -----------------------------------------------------------------------------
12269 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12270 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12271 {
12272  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12273  body(attr);
12274  vf.join(body._VoxelFunc);
12275 }
12276 
12277 // -----------------------------------------------------------------------------
12278 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12279 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12280 {
12281  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12282  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12283 }
12284 
12285 // -----------------------------------------------------------------------------
12286 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12287 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12288 {
12289  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12290  body(re);
12291  vf.join(body._VoxelFunc);
12292 }
12293 
12294 // -----------------------------------------------------------------------------
12295 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12296 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12297 {
12298  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12299  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12300 }
12301 
12302 // -----------------------------------------------------------------------------
12303 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12304 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12305 {
12306  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12307  body(re);
12308  vf.join(body._VoxelFunc);
12309 }
12310 
12311 // -----------------------------------------------------------------------------
12312 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12313 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12314 {
12315  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12316  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12317 }
12318 
12319 // -----------------------------------------------------------------------------
12320 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12321 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12322 {
12323  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12324  body(re);
12325  vf.join(body._VoxelFunc);
12326 }
12327 
12328 // -----------------------------------------------------------------------------
12329 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12330 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12331 {
12332  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12333  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12334 }
12335 
12336 //
12337 // Image arguments by reference
12338 //
12339 
12340 // -----------------------------------------------------------------------------
12341 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12342 void ForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12343 {
12344  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12346  body(re);
12347  vf.join(body._VoxelFunc);
12348 }
12349 
12350 // -----------------------------------------------------------------------------
12351 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12352 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12353 {
12354  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12355  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12356 }
12357 
12358 // -----------------------------------------------------------------------------
12359 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12360 void ForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12361 {
12362  if (im9.GetTSize()) {
12363  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12364  } else {
12365  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12366  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
12367  body(re);
12368  vf.join(body._VoxelFunc);
12369  }
12370 }
12371 
12372 // -----------------------------------------------------------------------------
12373 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12374 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12375 {
12376  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12377  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12378 }
12379 
12380 // -----------------------------------------------------------------------------
12381 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12382 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12383 {
12384  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12385  body(attr);
12386  vf.join(body._VoxelFunc);
12387 }
12388 
12389 // -----------------------------------------------------------------------------
12390 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12391 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12392 {
12393  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12394  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12395 }
12396 
12397 // -----------------------------------------------------------------------------
12398 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12399 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12400 {
12401  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12402  body(re);
12403  vf.join(body._VoxelFunc);
12404 }
12405 
12406 // -----------------------------------------------------------------------------
12407 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12408 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12409 {
12410  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12411  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12412 }
12413 
12414 // -----------------------------------------------------------------------------
12415 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12416 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12417 {
12418  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12419  body(re);
12420  vf.join(body._VoxelFunc);
12421 }
12422 
12423 // -----------------------------------------------------------------------------
12424 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12425 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12426 {
12427  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12428  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12429 }
12430 
12431 // -----------------------------------------------------------------------------
12432 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12433 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12434 {
12435  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12436  body(re);
12437  vf.join(body._VoxelFunc);
12438 }
12439 
12440 // -----------------------------------------------------------------------------
12441 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12442 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12443 {
12444  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12445  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12446 }
12447 
12448 // -----------------------------------------------------------------------------
12449 // ForEachVoxelIf
12450 // -----------------------------------------------------------------------------
12451 
12452 //
12453 // Image arguments by pointer
12454 //
12455 
12456 // -----------------------------------------------------------------------------
12457 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12458 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12459 {
12460  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12461  blocked_range<int> re(0, im9->GetNumberOfVoxels());
12462  body(re);
12463  vf.join(body._VoxelFunc);
12464  of.join(body._OutsideFunc);
12465 }
12466 
12467 // -----------------------------------------------------------------------------
12468 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12469 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12470 {
12471  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12472  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12473 }
12474 
12475 // -----------------------------------------------------------------------------
12476 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12477 void ForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12478 {
12480  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12481 }
12482 
12483 // -----------------------------------------------------------------------------
12484 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12485 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12486 {
12487  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12488  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12489 }
12490 
12491 // -----------------------------------------------------------------------------
12492 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12493 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12494 {
12495  if (im9->GetTSize()) {
12496  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12497  } else {
12498  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12499  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
12500  body(re);
12501  vf.join(body._VoxelFunc);
12502  of.join(body._OutsideFunc);
12503  }
12504 }
12505 
12506 // -----------------------------------------------------------------------------
12507 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12508 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12509 {
12510  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12511  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12512 }
12513 
12514 // -----------------------------------------------------------------------------
12515 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12516 void ForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12517 {
12519  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12520 }
12521 
12522 // -----------------------------------------------------------------------------
12523 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12524 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12525 {
12526  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12527  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12528 }
12529 
12530 // -----------------------------------------------------------------------------
12531 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12532 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12533 {
12534  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12535  body(attr);
12536  vf.join(body._VoxelFunc);
12537  of.join(body._OutsideFunc);
12538 }
12539 
12540 // -----------------------------------------------------------------------------
12541 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12542 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12543 {
12544  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12545  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12546 }
12547 
12548 // -----------------------------------------------------------------------------
12549 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12550 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12551 {
12553  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12554 }
12555 
12556 // -----------------------------------------------------------------------------
12557 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12558 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12559 {
12560  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12561  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12562 }
12563 
12564 // -----------------------------------------------------------------------------
12565 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12566 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12567 {
12568  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12569  body(re);
12570  vf.join(body._VoxelFunc);
12571  of.join(body._OutsideFunc);
12572 }
12573 
12574 // -----------------------------------------------------------------------------
12575 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12576 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12577 {
12578  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12579  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12580 }
12581 
12582 // -----------------------------------------------------------------------------
12583 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12584 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12585 {
12586  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12587  body(re);
12588  vf.join(body._VoxelFunc);
12589  of.join(body._OutsideFunc);
12590 }
12591 
12592 // -----------------------------------------------------------------------------
12593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12594 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12595 {
12596  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12597  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12598 }
12599 
12600 // -----------------------------------------------------------------------------
12601 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12602 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12603 {
12605  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12606 }
12607 
12608 // -----------------------------------------------------------------------------
12609 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12610 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12611 {
12612  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12613  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12614 }
12615 
12616 // -----------------------------------------------------------------------------
12617 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12618 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
12619 {
12620  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12621  body(re);
12622  vf.join(body._VoxelFunc);
12623  of.join(body._OutsideFunc);
12624 }
12625 
12626 // -----------------------------------------------------------------------------
12627 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12628 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12629 {
12630  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12631  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12632 }
12633 
12634 // -----------------------------------------------------------------------------
12635 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12636 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12637 {
12639  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
12640 }
12641 
12642 // -----------------------------------------------------------------------------
12643 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12644 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12645 {
12646  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12647  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12648 }
12649 
12650 //
12651 // Image arguments by reference
12652 //
12653 
12654 // -----------------------------------------------------------------------------
12655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12656 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12657 {
12658  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12660  body(re);
12661  vf.join(body._VoxelFunc);
12662  of.join(body._OutsideFunc);
12663 }
12664 
12665 // -----------------------------------------------------------------------------
12666 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12667 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12668 {
12669  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12670  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12671 }
12672 
12673 // -----------------------------------------------------------------------------
12674 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12675 void ForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12676 {
12678  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12679 }
12680 
12681 // -----------------------------------------------------------------------------
12682 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12683 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12684 {
12685  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12686  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12687 }
12688 
12689 // -----------------------------------------------------------------------------
12690 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12691 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12692 {
12693  if (im9.GetTSize()) {
12694  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12695  } else {
12696  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12697  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
12698  body(re);
12699  vf.join(body._VoxelFunc);
12700  of.join(body._OutsideFunc);
12701  }
12702 }
12703 
12704 // -----------------------------------------------------------------------------
12705 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12706 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12707 {
12708  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12709  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12710 }
12711 
12712 // -----------------------------------------------------------------------------
12713 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12714 void ForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12715 {
12717  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12718 }
12719 
12720 // -----------------------------------------------------------------------------
12721 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12722 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12723 {
12724  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12725  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12726 }
12727 
12728 // -----------------------------------------------------------------------------
12729 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12730 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12731 {
12732  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12733  body(attr);
12734  vf.join(body._VoxelFunc);
12735  of.join(body._OutsideFunc);
12736 }
12737 
12738 // -----------------------------------------------------------------------------
12739 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12740 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12741 {
12742  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12743  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12744 }
12745 
12746 // -----------------------------------------------------------------------------
12747 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12748 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12749 {
12751  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12752 }
12753 
12754 // -----------------------------------------------------------------------------
12755 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12756 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12757 {
12758  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12759  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12760 }
12761 
12762 // -----------------------------------------------------------------------------
12763 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12764 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12765 {
12766  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12767  body(re);
12768  vf.join(body._VoxelFunc);
12769  of.join(body._OutsideFunc);
12770 }
12771 
12772 // -----------------------------------------------------------------------------
12773 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12774 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12775 {
12776  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12777  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12778 }
12779 
12780 // -----------------------------------------------------------------------------
12781 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12782 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12783 {
12784  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12785  body(re);
12786  vf.join(body._VoxelFunc);
12787  of.join(body._OutsideFunc);
12788 }
12789 
12790 // -----------------------------------------------------------------------------
12791 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12792 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12793 {
12794  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12795  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12796 }
12797 
12798 // -----------------------------------------------------------------------------
12799 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12800 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12801 {
12803  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12804 }
12805 
12806 // -----------------------------------------------------------------------------
12807 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12808 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12809 {
12810  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12811  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12812 }
12813 
12814 // -----------------------------------------------------------------------------
12815 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12816 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
12817 {
12818  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12819  body(re);
12820  vf.join(body._VoxelFunc);
12821  of.join(body._OutsideFunc);
12822 }
12823 
12824 // -----------------------------------------------------------------------------
12825 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
12826 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12827 {
12828  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12829  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12830 }
12831 
12832 // -----------------------------------------------------------------------------
12833 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12834 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12835 {
12837  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
12838 }
12839 
12840 // -----------------------------------------------------------------------------
12841 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12842 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12843 {
12844  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12845  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12846 }
12847 
12848 // -----------------------------------------------------------------------------
12849 // ParallelForEachVoxel
12850 // -----------------------------------------------------------------------------
12851 
12852 //
12853 // Image arguments by pointer
12854 //
12855 
12856 // -----------------------------------------------------------------------------
12857 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12858 void ParallelForEachScalar(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12859 {
12860  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12861  blocked_range<int> re(0, im9->GetNumberOfVoxels());
12862  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12863  else parallel_for (re, body);
12864 }
12865 
12866 // -----------------------------------------------------------------------------
12867 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12868 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12869 {
12870  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12871  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12872 }
12873 
12874 // -----------------------------------------------------------------------------
12875 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12876 void ParallelForEachVoxel(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12877 {
12878  if (im9->GetTSize()) {
12879  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12880  } else {
12881  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12882  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
12883  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12884  else parallel_for (re, body);
12885  }
12886 }
12887 
12888 // -----------------------------------------------------------------------------
12889 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12890 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12891 {
12892  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12893  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12894 }
12895 
12896 // -----------------------------------------------------------------------------
12897 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12898 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12899 {
12900  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12901  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
12902  if (VoxelFunc::IsReduction()) {
12903  if (attr._dt) {
12904  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
12905  } else {
12906  parallel_reduce(re, body);
12907  }
12908  vf.join(body._VoxelFunc);
12909  } else {
12910  if (attr._dt) {
12911  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
12912  } else {
12913  parallel_for(re, body);
12914  }
12915  }
12916 }
12917 
12918 // -----------------------------------------------------------------------------
12919 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12920 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12921 {
12922  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12923  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12924 }
12925 
12926 // -----------------------------------------------------------------------------
12927 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12928 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12929 {
12930  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12931  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12932  else parallel_for (re, body);
12933 }
12934 
12935 // -----------------------------------------------------------------------------
12936 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12937 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12938 {
12939  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12940  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12941 }
12942 
12943 // -----------------------------------------------------------------------------
12944 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12945 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12946 {
12947  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12948  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12949  else parallel_for (re, body);
12950 }
12951 
12952 // -----------------------------------------------------------------------------
12953 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12954 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12955 {
12956  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12957  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12958 }
12959 
12960 // -----------------------------------------------------------------------------
12961 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12962 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
12963 {
12964  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12965  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12966  else parallel_for (re, body);
12967 }
12968 
12969 // -----------------------------------------------------------------------------
12970 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12971 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
12972 {
12973  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12974  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
12975 }
12976 
12977 //
12978 // Image arguments by reference
12979 //
12980 
12981 // -----------------------------------------------------------------------------
12982 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12983 void ParallelForEachScalar(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
12984 {
12985  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12987  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12988  else parallel_for (re, body);
12989 }
12990 
12991 // -----------------------------------------------------------------------------
12992 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
12993 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
12994 {
12995  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
12996  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
12997 }
12998 
12999 // -----------------------------------------------------------------------------
13000 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13001 void ParallelForEachVoxel(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13002 {
13003  if (im9.GetTSize()) {
13004  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13005  } else {
13006  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13007  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
13008  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
13009  else parallel_for (re, body);
13010  }
13011 }
13012 
13013 // -----------------------------------------------------------------------------
13014 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13015 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13016 {
13017  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13018  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13019 }
13020 
13021 // -----------------------------------------------------------------------------
13022 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13023 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13024 {
13025  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13026  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
13027  if (VoxelFunc::IsReduction()) {
13028  if (attr._dt) {
13029  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
13030  } else {
13031  parallel_reduce(re, body);
13032  }
13033  vf.join(body._VoxelFunc);
13034  } else {
13035  if (attr._dt) {
13036  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
13037  } else {
13038  parallel_for(re, body);
13039  }
13040  }
13041 }
13042 
13043 // -----------------------------------------------------------------------------
13044 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13045 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13046 {
13047  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13048  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13049 }
13050 
13051 // -----------------------------------------------------------------------------
13052 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13053 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13054 {
13055  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13056  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
13057  else parallel_for (re, body);
13058 }
13059 
13060 // -----------------------------------------------------------------------------
13061 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13062 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13063 {
13064  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13065  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13066 }
13067 
13068 // -----------------------------------------------------------------------------
13069 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13070 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13071 {
13072  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13073  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
13074  else parallel_for (re, body);
13075 }
13076 
13077 // -----------------------------------------------------------------------------
13078 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13079 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13080 {
13081  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13082  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13083 }
13084 
13085 // -----------------------------------------------------------------------------
13086 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13087 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13088 {
13089  NonaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13090  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
13091  else parallel_for (re, body);
13092 }
13093 
13094 // -----------------------------------------------------------------------------
13095 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13096 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13097 {
13098  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13099  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13100 }
13101 
13102 // -----------------------------------------------------------------------------
13103 // ParallelForEachVoxelIf
13104 // -----------------------------------------------------------------------------
13105 
13106 //
13107 // Image arguments by pointer
13108 //
13109 
13110 // -----------------------------------------------------------------------------
13111 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13112 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13113 {
13114  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13115  blocked_range<int> re(0, im9->GetNumberOfVoxels());
13116  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13117  parallel_reduce(re, body);
13118  vf.join(body._VoxelFunc);
13119  of.join(body._OutsideFunc);
13120  } else {
13121  parallel_for(re, body);
13122  }
13123 }
13124 
13125 // -----------------------------------------------------------------------------
13126 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13127 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13128 {
13129  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13130  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13131 }
13132 
13133 // -----------------------------------------------------------------------------
13134 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13135 void ParallelForEachScalarIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13136 {
13138  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13139 }
13140 
13141 // -----------------------------------------------------------------------------
13142 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13143 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13144 {
13145  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13146  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13147 }
13148 
13149 // -----------------------------------------------------------------------------
13150 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13151 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13152 {
13153  if (im9->GetTSize()) {
13154  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13155  } else {
13156  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13157  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
13158  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13159  parallel_reduce(re, body);
13160  vf.join(body._VoxelFunc);
13161  of.join(body._OutsideFunc);
13162  } else {
13163  parallel_for(re, body);
13164  }
13165  }
13166 }
13167 
13168 // -----------------------------------------------------------------------------
13169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13170 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13171 {
13172  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13173  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13174 }
13175 
13176 // -----------------------------------------------------------------------------
13177 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13178 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13179 {
13181  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13182 }
13183 
13184 // -----------------------------------------------------------------------------
13185 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13186 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, const GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13187 {
13188  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13189  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13190 }
13191 
13192 // -----------------------------------------------------------------------------
13193 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13194 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13195 {
13196  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13197  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
13198  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13199  if (attr._dt) {
13200  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
13201  } else {
13202  parallel_reduce(re, body);
13203  }
13204  vf.join(body._VoxelFunc);
13205  of.join(body._OutsideFunc);
13206  } else {
13207  if (attr._dt) {
13208  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
13209  } else {
13210  parallel_for(re, body);
13211  }
13212  }
13213 }
13214 
13215 // -----------------------------------------------------------------------------
13216 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13217 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13218 {
13219  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13220  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13221 }
13222 
13223 // -----------------------------------------------------------------------------
13224 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13225 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13226 {
13228  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13229 }
13230 
13231 // -----------------------------------------------------------------------------
13232 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13233 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13234 {
13235  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13236  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13237 }
13238 
13239 // -----------------------------------------------------------------------------
13240 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13241 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13242 {
13243  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13244  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13245  parallel_reduce(re, body);
13246  vf.join(body._VoxelFunc);
13247  of.join(body._OutsideFunc);
13248  } else {
13249  parallel_for(re, body);
13250  }
13251 }
13252 
13253 // -----------------------------------------------------------------------------
13254 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13255 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13256 {
13257  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13258  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13259 }
13260 
13261 // -----------------------------------------------------------------------------
13262 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13263 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13264 {
13266  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13267 }
13268 
13269 // -----------------------------------------------------------------------------
13270 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13271 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13272 {
13273  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13274  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13275 }
13276 
13277 // -----------------------------------------------------------------------------
13278 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13279 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13280 {
13281  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13282  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13283  parallel_reduce(re, body);
13284  vf.join(body._VoxelFunc);
13285  of.join(body._OutsideFunc);
13286  } else {
13287  parallel_for(re, body);
13288  }
13289 }
13290 
13291 // -----------------------------------------------------------------------------
13292 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13293 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13294 {
13295  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13296  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13297 }
13298 
13299 // -----------------------------------------------------------------------------
13300 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13301 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13302 {
13304  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13305 }
13306 
13307 // -----------------------------------------------------------------------------
13308 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13309 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13310 {
13311  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13312  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13313 }
13314 
13315 // -----------------------------------------------------------------------------
13316 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13317 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
13318 {
13319  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13320  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13321  parallel_reduce(re, body);
13322  vf.join(body._VoxelFunc);
13323  of.join(body._OutsideFunc);
13324  } else {
13325  parallel_for(re, body);
13326  }
13327 }
13328 
13329 // -----------------------------------------------------------------------------
13330 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13331 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13332 {
13333  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13334  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13335 }
13336 
13337 // -----------------------------------------------------------------------------
13338 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13339 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13340 {
13342  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
13343 }
13344 
13345 // -----------------------------------------------------------------------------
13346 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13347 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13348 {
13349  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13350  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13351 }
13352 
13353 //
13354 // Image arguments by reference
13355 //
13356 
13357 // -----------------------------------------------------------------------------
13358 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13359 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13360 {
13361  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13363  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13364  parallel_reduce(re, body);
13365  vf.join(body._VoxelFunc);
13366  of.join(body._OutsideFunc);
13367  } else {
13368  parallel_for(re, body);
13369  }
13370 }
13371 
13372 // -----------------------------------------------------------------------------
13373 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13374 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13375 {
13376  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13377  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13378 }
13379 
13380 // -----------------------------------------------------------------------------
13381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13382 void ParallelForEachScalarIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13383 {
13385  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13386 }
13387 
13388 // -----------------------------------------------------------------------------
13389 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13390 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13391 {
13392  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13393  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13394 }
13395 
13396 // -----------------------------------------------------------------------------
13397 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13398 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13399 {
13400  if (im9.GetTSize()) {
13401  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13402  } else {
13403  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13404  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
13405  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13406  parallel_reduce(re, body);
13407  vf.join(body._VoxelFunc);
13408  of.join(body._OutsideFunc);
13409  } else {
13410  parallel_for(re, body);
13411  }
13412  }
13413 }
13414 
13415 // -----------------------------------------------------------------------------
13416 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13417 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13418 {
13419  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13420  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13421 }
13422 
13423 // -----------------------------------------------------------------------------
13424 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13425 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13426 {
13428  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13429 }
13430 
13431 // -----------------------------------------------------------------------------
13432 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13433 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, const GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13434 {
13435  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13436  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13437 }
13438 
13439 // -----------------------------------------------------------------------------
13440 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13441 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13442 {
13443  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13444  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
13445  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13446  if (attr._dt) {
13447  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
13448  } else {
13449  parallel_reduce(re, body);
13450  }
13451  vf.join(body._VoxelFunc);
13452  of.join(body._OutsideFunc);
13453  } else {
13454  if (attr._dt) {
13455  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
13456  } else {
13457  parallel_for(re, body);
13458  }
13459  }
13460 }
13461 
13462 // -----------------------------------------------------------------------------
13463 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13464 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13465 {
13466  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13467  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13468 }
13469 
13470 // -----------------------------------------------------------------------------
13471 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13472 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13473 {
13475  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13476 }
13477 
13478 // -----------------------------------------------------------------------------
13479 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13480 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13481 {
13482  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13483  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13484 }
13485 
13486 // -----------------------------------------------------------------------------
13487 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13488 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13489 {
13490  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13491  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13492  parallel_reduce(re, body);
13493  vf.join(body._VoxelFunc);
13494  of.join(body._OutsideFunc);
13495  } else {
13496  parallel_for(re, body);
13497  }
13498 }
13499 
13500 // -----------------------------------------------------------------------------
13501 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13502 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13503 {
13504  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13505  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13506 }
13507 
13508 // -----------------------------------------------------------------------------
13509 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13510 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13511 {
13513  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13514 }
13515 
13516 // -----------------------------------------------------------------------------
13517 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13518 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13519 {
13520  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13521  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13522 }
13523 
13524 // -----------------------------------------------------------------------------
13525 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13526 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13527 {
13528  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13529  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13530  parallel_reduce(re, body);
13531  vf.join(body._VoxelFunc);
13532  of.join(body._OutsideFunc);
13533  } else {
13534  parallel_for(re, body);
13535  }
13536 }
13537 
13538 // -----------------------------------------------------------------------------
13539 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13540 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13541 {
13542  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13543  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13544 }
13545 
13546 // -----------------------------------------------------------------------------
13547 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13548 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13549 {
13551  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13552 }
13553 
13554 // -----------------------------------------------------------------------------
13555 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13556 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13557 {
13558  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13559  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13560 }
13561 
13562 // -----------------------------------------------------------------------------
13563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13564 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
13565 {
13566  NonaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13567  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13568  parallel_reduce(re, body);
13569  vf.join(body._VoxelFunc);
13570  of.join(body._OutsideFunc);
13571  } else {
13572  parallel_for(re, body);
13573  }
13574 }
13575 
13576 // -----------------------------------------------------------------------------
13577 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
13578 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13579 {
13580  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13581  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13582 }
13583 
13584 // -----------------------------------------------------------------------------
13585 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13586 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
13587 {
13589  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
13590 }
13591 
13592 // -----------------------------------------------------------------------------
13593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13594 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
13595 {
13596  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13597  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
13598 }
13599 
13600 // =============================================================================
13601 // 1 const, 8 non-const images
13602 // =============================================================================
13603 
13604 // -----------------------------------------------------------------------------
13605 /**
13606  * ForEachVoxel body for voxel function of 1 const, 8 non-const images
13607  */
13608 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13610 {
13611  const GenericImage<T1> &im1;
13612  GenericImage<T2> &im2;
13613  GenericImage<T3> &im3;
13614  GenericImage<T4> &im4;
13615  GenericImage<T5> &im5;
13616  GenericImage<T6> &im6;
13617  GenericImage<T7> &im7;
13618  GenericImage<T8> &im8;
13619  GenericImage<T9> &im9;
13620 
13621  /// Constructor
13623  GenericImage<T2> &im2,
13624  GenericImage<T3> &im3,
13625  GenericImage<T4> &im4,
13626  GenericImage<T5> &im5,
13627  GenericImage<T6> &im6,
13628  GenericImage<T7> &im7,
13629  GenericImage<T8> &im8,
13630  GenericImage<T9> &im9,
13631  VoxelFunc &vf)
13632  :
13633  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
13634  {}
13635 
13636  /// Copy constructor
13638  :
13639  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
13640  {}
13641 
13642  /// Split constructor
13644  :
13645  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
13646  {}
13647 
13648  /// Process entire image
13649  void operator ()(const ImageAttributes &attr) const
13650  {
13651  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
13652  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
13653  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
13654  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
13655  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
13656  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
13657  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
13658  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
13659  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
13660 
13661  const int T = (attr._dt ? attr._t : 1);
13662 
13663  for (int l = 0; l < T; ++l)
13664  for (int k = 0; k < attr._z; ++k)
13665  for (int j = 0; j < attr._y; ++j)
13666  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
13667  // const_cast such that voxel functions need only implement
13668  // non-const operator() which is required for parallel_reduce
13669  const_cast<NonaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13670  }
13671  }
13672 
13673  /// Process image region using linear index
13674  void operator ()(const blocked_range<int> &re) const
13675  {
13676  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
13677  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
13678  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
13679  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
13680  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
13681  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
13682  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
13683  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
13684  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
13685 
13686  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13687  // const_cast such that voxel functions need only implement
13688  // non-const operator() which is required for parallel_reduce
13689  const_cast<NonaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13690  }
13691  }
13692 
13693  /// Process 2D image region
13694  void operator ()(const blocked_range2d<int> &re) const
13695  {
13696  const int bi = re.cols().begin();
13697  const int bj = re.rows().begin();
13698  const int ei = re.cols().end();
13699  const int ej = re.rows().end();
13700 
13701  const int s1 = im9.GetX() - (ei - bi);
13702 
13703  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13704  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13705  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13706  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13707  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13708  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13709  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13710  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13711  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13712 
13713  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
13714  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13715  // const_cast such that voxel functions need only implement
13716  // non-const operator() which is required for parallel_reduce
13717  const_cast<NonaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13718  }
13719  }
13720 
13721  /// Process 3D image region
13722  void operator ()(const blocked_range3d<int> &re) const
13723  {
13724  const int bi = re.cols ().begin();
13725  const int bj = re.rows ().begin();
13726  const int bk = re.pages().begin();
13727  const int ei = re.cols ().end();
13728  const int ej = re.rows ().end();
13729  const int ek = re.pages().end();
13730 
13731  const int s1 = im9.GetX() - (ei - bi);
13732  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
13733 
13734  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
13735  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
13736  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
13737  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
13738  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
13739  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
13740  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
13741  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
13742  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
13743 
13744  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
13745  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
13746  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13747  // const_cast such that voxel functions need only implement
13748  // non-const operator() which is required for parallel_reduce
13749  const_cast<NonaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13750  }
13751  }
13752 };
13753 
13754 // -----------------------------------------------------------------------------
13755 /**
13756  * ForEachVoxel body for inside and outside unary voxel function of 1 const, 8 non-const images
13757  */
13758 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
13759  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
13760  class Domain = ForEachVoxelDomain::Foreground>
13761 struct NonaryForEachVoxelIfBody_1Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
13762 {
13763  const GenericImage<T1> &im1;
13764  GenericImage<T2> &im2;
13765  GenericImage<T3> &im3;
13766  GenericImage<T4> &im4;
13767  GenericImage<T5> &im5;
13768  GenericImage<T6> &im6;
13769  GenericImage<T7> &im7;
13770  GenericImage<T8> &im8;
13771  GenericImage<T9> &im9;
13772 
13773  /// Constructor
13775  GenericImage<T2> &im2,
13776  GenericImage<T3> &im3,
13777  GenericImage<T4> &im4,
13778  GenericImage<T5> &im5,
13779  GenericImage<T6> &im6,
13780  GenericImage<T7> &im7,
13781  GenericImage<T8> &im8,
13782  GenericImage<T9> &im9,
13783  VoxelFunc &vf, OutsideFunc &of)
13784  :
13785  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
13786  {}
13787 
13788  /// Copy constructor
13790  :
13791  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
13792  {}
13793 
13794  /// Split constructor
13796  :
13797  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
13798  {}
13799 
13800  /// Process entire image
13801  void operator ()(const ImageAttributes &attr) const
13802  {
13803  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
13804  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
13805  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
13806  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
13807  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
13808  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
13809  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
13810  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
13811  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
13812 
13813  const int T = (attr._dt ? attr._t : 1);
13814 
13815  for (int l = 0; l < T; ++l)
13816  for (int k = 0; k < attr._z; ++k)
13817  for (int j = 0; j < attr._y; ++j)
13818  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
13819  if (Domain::IsInside(im9, i, j, k, l, p9)) {
13820  // const_cast such that voxel functions need only implement
13821  // non-const operator() which is required for parallel_reduce
13822  const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13823  } else const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13824  }
13825  }
13826 
13827  /// Process image region using linear index
13828  void operator ()(const blocked_range<int> &re) const
13829  {
13830  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
13831  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
13832  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
13833  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
13834  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
13835  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
13836  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
13837  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
13838  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
13839 
13840  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13841  if (Domain::IsInside(im9, idx, p9)) {
13842  // const_cast such that voxel functions need only implement
13843  // non-const operator() which is required for parallel_reduce
13844  const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13845  } else const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13846  }
13847  }
13848 
13849  /// Process 2D image region
13850  void operator ()(const blocked_range2d<int> &re) const
13851  {
13852  const int bi = re.cols().begin();
13853  const int bj = re.rows().begin();
13854  const int ei = re.cols().end();
13855  const int ej = re.rows().end();
13856 
13857  const int s1 = im9.GetX() - (ei - bi);
13858 
13859  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13860  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13861  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13862  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13863  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13864  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13865  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13866  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13867  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13868 
13869  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
13870  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13871  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
13872  // const_cast such that voxel functions need only implement
13873  // non-const operator() which is required for parallel_reduce
13874  const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13875  } else const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13876  }
13877  }
13878 
13879  /// Process 3D image region
13880  void operator ()(const blocked_range3d<int> &re) const
13881  {
13882  const int bi = re.cols ().begin();
13883  const int bj = re.rows ().begin();
13884  const int bk = re.pages().begin();
13885  const int ei = re.cols ().end();
13886  const int ej = re.rows ().end();
13887  const int ek = re.pages().end();
13888 
13889  const int s1 = im9.GetX() - (ei - bi);
13890  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
13891 
13892  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
13893  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
13894  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
13895  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
13896  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
13897  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
13898  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
13899  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
13900  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
13901 
13902  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
13903  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
13904  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
13905  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
13906  // const_cast such that voxel functions need only implement
13907  // non-const operator() which is required for parallel_reduce
13908  const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13909  } else const_cast<NonaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
13910  }
13911  }
13912 };
13913 
13914 // -----------------------------------------------------------------------------
13915 // ForEachVoxel
13916 // -----------------------------------------------------------------------------
13917 
13918 //
13919 // Image arguments by pointer
13920 //
13921 
13922 // -----------------------------------------------------------------------------
13923 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13924 void ForEachScalar(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13925 {
13926  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13927  blocked_range<int> re(0, im9->GetNumberOfVoxels());
13928  body(re);
13929  vf.join(body._VoxelFunc);
13930 }
13931 
13932 // -----------------------------------------------------------------------------
13933 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13934 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13935 {
13936  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13937  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13938 }
13939 
13940 // -----------------------------------------------------------------------------
13941 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13942 void ForEachVoxel(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13943 {
13944  if (im9->GetTSize()) {
13945  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13946  } else {
13947  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13948  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
13949  body(re);
13950  vf.join(body._VoxelFunc);
13951  }
13952 }
13953 
13954 // -----------------------------------------------------------------------------
13955 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13956 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13957 {
13958  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13959  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13960 }
13961 
13962 // -----------------------------------------------------------------------------
13963 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13964 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13965 {
13966  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13967  body(attr);
13968  vf.join(body._VoxelFunc);
13969 }
13970 
13971 // -----------------------------------------------------------------------------
13972 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13973 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13974 {
13975  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13976  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13977 }
13978 
13979 // -----------------------------------------------------------------------------
13980 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13981 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13982 {
13983  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13984  body(re);
13985  vf.join(body._VoxelFunc);
13986 }
13987 
13988 // -----------------------------------------------------------------------------
13989 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13990 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
13991 {
13992  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
13993  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
13994 }
13995 
13996 // -----------------------------------------------------------------------------
13997 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
13998 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
13999 {
14000  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14001  body(re);
14002  vf.join(body._VoxelFunc);
14003 }
14004 
14005 // -----------------------------------------------------------------------------
14006 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14007 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14008 {
14009  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14010  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14011 }
14012 
14013 // -----------------------------------------------------------------------------
14014 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14015 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14016 {
14017  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14018  body(re);
14019  vf.join(body._VoxelFunc);
14020 }
14021 
14022 // -----------------------------------------------------------------------------
14023 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14024 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14025 {
14026  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14027  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14028 }
14029 
14030 //
14031 // Image arguments by reference
14032 //
14033 
14034 // -----------------------------------------------------------------------------
14035 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14036 void ForEachScalar(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14037 {
14038  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14040  body(re);
14041  vf.join(body._VoxelFunc);
14042 }
14043 
14044 // -----------------------------------------------------------------------------
14045 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14046 void ForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14047 {
14048  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14049  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14050 }
14051 
14052 // -----------------------------------------------------------------------------
14053 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14054 void ForEachVoxel(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14055 {
14056  if (im9.GetTSize()) {
14057  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14058  } else {
14059  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14060  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
14061  body(re);
14062  vf.join(body._VoxelFunc);
14063  }
14064 }
14065 
14066 // -----------------------------------------------------------------------------
14067 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14068 void ForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14069 {
14070  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14071  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14072 }
14073 
14074 // -----------------------------------------------------------------------------
14075 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14076 void ForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14077 {
14078  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14079  body(attr);
14080  vf.join(body._VoxelFunc);
14081 }
14082 
14083 // -----------------------------------------------------------------------------
14084 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14085 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14086 {
14087  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14088  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14089 }
14090 
14091 // -----------------------------------------------------------------------------
14092 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14093 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14094 {
14095  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14096  body(re);
14097  vf.join(body._VoxelFunc);
14098 }
14099 
14100 // -----------------------------------------------------------------------------
14101 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14102 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14103 {
14104  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14105  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14106 }
14107 
14108 // -----------------------------------------------------------------------------
14109 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14110 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14111 {
14112  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14113  body(re);
14114  vf.join(body._VoxelFunc);
14115 }
14116 
14117 // -----------------------------------------------------------------------------
14118 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14119 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14120 {
14121  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14122  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14123 }
14124 
14125 // -----------------------------------------------------------------------------
14126 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14127 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14128 {
14129  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14130  body(re);
14131  vf.join(body._VoxelFunc);
14132 }
14133 
14134 // -----------------------------------------------------------------------------
14135 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14136 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14137 {
14138  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14139  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14140 }
14141 
14142 // -----------------------------------------------------------------------------
14143 // ForEachVoxelIf
14144 // -----------------------------------------------------------------------------
14145 
14146 //
14147 // Image arguments by pointer
14148 //
14149 
14150 // -----------------------------------------------------------------------------
14151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14152 void ForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14153 {
14154  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14155  blocked_range<int> re(0, im9->GetNumberOfVoxels());
14156  body(re);
14157  vf.join(body._VoxelFunc);
14158  of.join(body._OutsideFunc);
14159 }
14160 
14161 // -----------------------------------------------------------------------------
14162 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14163 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14164 {
14165  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14166  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14167 }
14168 
14169 // -----------------------------------------------------------------------------
14170 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14171 void ForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14172 {
14174  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14175 }
14176 
14177 // -----------------------------------------------------------------------------
14178 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14179 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14180 {
14181  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14182  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14183 }
14184 
14185 // -----------------------------------------------------------------------------
14186 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14187 void ForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14188 {
14189  if (im9->GetTSize()) {
14190  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14191  } else {
14192  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14193  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
14194  body(re);
14195  vf.join(body._VoxelFunc);
14196  of.join(body._OutsideFunc);
14197  }
14198 }
14199 
14200 // -----------------------------------------------------------------------------
14201 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14202 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14203 {
14204  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14205  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14206 }
14207 
14208 // -----------------------------------------------------------------------------
14209 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14210 void ForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14211 {
14213  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14214 }
14215 
14216 // -----------------------------------------------------------------------------
14217 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14218 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14219 {
14220  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14221  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14222 }
14223 
14224 // -----------------------------------------------------------------------------
14225 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14226 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14227 {
14228  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14229  body(attr);
14230  vf.join(body._VoxelFunc);
14231  of.join(body._OutsideFunc);
14232 }
14233 
14234 // -----------------------------------------------------------------------------
14235 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14236 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14237 {
14238  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14239  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14240 }
14241 
14242 // -----------------------------------------------------------------------------
14243 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14244 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14245 {
14247  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14248 }
14249 
14250 // -----------------------------------------------------------------------------
14251 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14252 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14253 {
14254  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14255  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14256 }
14257 
14258 // -----------------------------------------------------------------------------
14259 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14260 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14261 {
14262  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14263  body(re);
14264  vf.join(body._VoxelFunc);
14265  of.join(body._OutsideFunc);
14266 }
14267 
14268 // -----------------------------------------------------------------------------
14269 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14270 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14271 {
14272  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14273  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14274 }
14275 
14276 // -----------------------------------------------------------------------------
14277 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14278 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14279 {
14280  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14281  body(re);
14282  vf.join(body._VoxelFunc);
14283  of.join(body._OutsideFunc);
14284 }
14285 
14286 // -----------------------------------------------------------------------------
14287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14288 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14289 {
14290  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14291  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14292 }
14293 
14294 // -----------------------------------------------------------------------------
14295 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14296 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14297 {
14299  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14300 }
14301 
14302 // -----------------------------------------------------------------------------
14303 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14304 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14305 {
14306  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14307  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14308 }
14309 
14310 // -----------------------------------------------------------------------------
14311 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14312 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14313 {
14314  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14315  body(re);
14316  vf.join(body._VoxelFunc);
14317  of.join(body._OutsideFunc);
14318 }
14319 
14320 // -----------------------------------------------------------------------------
14321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14322 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14323 {
14324  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14325  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14326 }
14327 
14328 // -----------------------------------------------------------------------------
14329 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14330 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14331 {
14333  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14334 }
14335 
14336 // -----------------------------------------------------------------------------
14337 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14338 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14339 {
14340  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14341  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14342 }
14343 
14344 //
14345 // Image arguments by reference
14346 //
14347 
14348 // -----------------------------------------------------------------------------
14349 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14350 void ForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14351 {
14352  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14354  body(re);
14355  vf.join(body._VoxelFunc);
14356  of.join(body._OutsideFunc);
14357 }
14358 
14359 // -----------------------------------------------------------------------------
14360 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14361 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14362 {
14363  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14364  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14365 }
14366 
14367 // -----------------------------------------------------------------------------
14368 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14369 void ForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14370 {
14372  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14373 }
14374 
14375 // -----------------------------------------------------------------------------
14376 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14377 void ForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14378 {
14379  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14380  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14381 }
14382 
14383 // -----------------------------------------------------------------------------
14384 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14385 void ForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14386 {
14387  if (im9.GetTSize()) {
14388  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14389  } else {
14390  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14391  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
14392  body(re);
14393  vf.join(body._VoxelFunc);
14394  of.join(body._OutsideFunc);
14395  }
14396 }
14397 
14398 // -----------------------------------------------------------------------------
14399 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14400 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14401 {
14402  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14403  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14404 }
14405 
14406 // -----------------------------------------------------------------------------
14407 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14408 void ForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14409 {
14411  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14412 }
14413 
14414 // -----------------------------------------------------------------------------
14415 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14416 void ForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14417 {
14418  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14419  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14420 }
14421 
14422 // -----------------------------------------------------------------------------
14423 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14424 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14425 {
14426  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14427  body(attr);
14428  vf.join(body._VoxelFunc);
14429  of.join(body._OutsideFunc);
14430 }
14431 
14432 // -----------------------------------------------------------------------------
14433 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14434 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14435 {
14436  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14437  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14438 }
14439 
14440 // -----------------------------------------------------------------------------
14441 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14442 void ForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14443 {
14445  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14446 }
14447 
14448 // -----------------------------------------------------------------------------
14449 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14450 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14451 {
14452  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14453  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14454 }
14455 
14456 // -----------------------------------------------------------------------------
14457 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14458 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14459 {
14460  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14461  body(re);
14462  vf.join(body._VoxelFunc);
14463  of.join(body._OutsideFunc);
14464 }
14465 
14466 // -----------------------------------------------------------------------------
14467 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14468 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14469 {
14470  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14471  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14472 }
14473 
14474 // -----------------------------------------------------------------------------
14475 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14476 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14477 {
14478  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14479  body(re);
14480  vf.join(body._VoxelFunc);
14481  of.join(body._OutsideFunc);
14482 }
14483 
14484 // -----------------------------------------------------------------------------
14485 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14486 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14487 {
14488  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14489  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14490 }
14491 
14492 // -----------------------------------------------------------------------------
14493 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14494 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14495 {
14497  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14498 }
14499 
14500 // -----------------------------------------------------------------------------
14501 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14502 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14503 {
14504  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14505  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14506 }
14507 
14508 // -----------------------------------------------------------------------------
14509 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14510 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
14511 {
14512  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14513  body(re);
14514  vf.join(body._VoxelFunc);
14515  of.join(body._OutsideFunc);
14516 }
14517 
14518 // -----------------------------------------------------------------------------
14519 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14520 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14521 {
14522  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14523  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14524 }
14525 
14526 // -----------------------------------------------------------------------------
14527 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14528 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14529 {
14531  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
14532 }
14533 
14534 // -----------------------------------------------------------------------------
14535 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14536 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14537 {
14538  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14539  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14540 }
14541 
14542 // -----------------------------------------------------------------------------
14543 // ParallelForEachVoxel
14544 // -----------------------------------------------------------------------------
14545 
14546 //
14547 // Image arguments by pointer
14548 //
14549 
14550 // -----------------------------------------------------------------------------
14551 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14552 void ParallelForEachScalar(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14553 {
14554  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14555  blocked_range<int> re(0, im9->GetNumberOfVoxels());
14556  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14557  else parallel_for (re, body);
14558 }
14559 
14560 // -----------------------------------------------------------------------------
14561 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14562 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14563 {
14564  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14565  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14566 }
14567 
14568 // -----------------------------------------------------------------------------
14569 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14570 void ParallelForEachVoxel(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14571 {
14572  if (im9->GetTSize()) {
14573  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14574  } else {
14575  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14576  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
14577  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14578  else parallel_for (re, body);
14579  }
14580 }
14581 
14582 // -----------------------------------------------------------------------------
14583 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14584 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14585 {
14586  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14587  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14588 }
14589 
14590 // -----------------------------------------------------------------------------
14591 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14592 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14593 {
14594  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14595  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14596  if (VoxelFunc::IsReduction()) {
14597  if (attr._dt) {
14598  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14599  } else {
14600  parallel_reduce(re, body);
14601  }
14602  vf.join(body._VoxelFunc);
14603  } else {
14604  if (attr._dt) {
14605  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14606  } else {
14607  parallel_for(re, body);
14608  }
14609  }
14610 }
14611 
14612 // -----------------------------------------------------------------------------
14613 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14614 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14615 {
14616  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14617  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14618 }
14619 
14620 // -----------------------------------------------------------------------------
14621 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14622 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14623 {
14624  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14625  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14626  else parallel_for (re, body);
14627 }
14628 
14629 // -----------------------------------------------------------------------------
14630 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14631 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14632 {
14633  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14634  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14635 }
14636 
14637 // -----------------------------------------------------------------------------
14638 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14639 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14640 {
14641  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14642  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14643  else parallel_for (re, body);
14644 }
14645 
14646 // -----------------------------------------------------------------------------
14647 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14648 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14649 {
14650  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14651  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14652 }
14653 
14654 // -----------------------------------------------------------------------------
14655 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14656 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14657 {
14658  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14659  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14660  else parallel_for (re, body);
14661 }
14662 
14663 // -----------------------------------------------------------------------------
14664 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14665 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14666 {
14667  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14668  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14669 }
14670 
14671 //
14672 // Image arguments by reference
14673 //
14674 
14675 // -----------------------------------------------------------------------------
14676 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14677 void ParallelForEachScalar(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14678 {
14679  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14681  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14682  else parallel_for (re, body);
14683 }
14684 
14685 // -----------------------------------------------------------------------------
14686 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14687 void ParallelForEachScalar(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14688 {
14689  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14690  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14691 }
14692 
14693 // -----------------------------------------------------------------------------
14694 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14695 void ParallelForEachVoxel(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14696 {
14697  if (im9.GetTSize()) {
14698  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14699  } else {
14700  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14701  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
14702  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14703  else parallel_for (re, body);
14704  }
14705 }
14706 
14707 // -----------------------------------------------------------------------------
14708 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14709 void ParallelForEachVoxel(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14710 {
14711  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14712  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14713 }
14714 
14715 // -----------------------------------------------------------------------------
14716 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14717 void ParallelForEachVoxel(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14718 {
14719  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14720  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14721  if (VoxelFunc::IsReduction()) {
14722  if (attr._dt) {
14723  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14724  } else {
14725  parallel_reduce(re, body);
14726  }
14727  vf.join(body._VoxelFunc);
14728  } else {
14729  if (attr._dt) {
14730  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14731  } else {
14732  parallel_for(re, body);
14733  }
14734  }
14735 }
14736 
14737 // -----------------------------------------------------------------------------
14738 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14739 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14740 {
14741  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14742  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14743 }
14744 
14745 // -----------------------------------------------------------------------------
14746 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14747 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14748 {
14749  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14750  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14751  else parallel_for (re, body);
14752 }
14753 
14754 // -----------------------------------------------------------------------------
14755 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14756 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14757 {
14758  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14759  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14760 }
14761 
14762 // -----------------------------------------------------------------------------
14763 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14764 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14765 {
14766  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14767  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14768  else parallel_for (re, body);
14769 }
14770 
14771 // -----------------------------------------------------------------------------
14772 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14773 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14774 {
14775  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14776  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14777 }
14778 
14779 // -----------------------------------------------------------------------------
14780 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14781 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
14782 {
14783  NonaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14784  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14785  else parallel_for (re, body);
14786 }
14787 
14788 // -----------------------------------------------------------------------------
14789 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14790 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
14791 {
14792  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14793  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
14794 }
14795 
14796 // -----------------------------------------------------------------------------
14797 // ParallelForEachVoxelIf
14798 // -----------------------------------------------------------------------------
14799 
14800 //
14801 // Image arguments by pointer
14802 //
14803 
14804 // -----------------------------------------------------------------------------
14805 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14806 void ParallelForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14807 {
14808  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14809  blocked_range<int> re(0, im9->GetNumberOfVoxels());
14810  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14811  parallel_reduce(re, body);
14812  vf.join(body._VoxelFunc);
14813  of.join(body._OutsideFunc);
14814  } else {
14815  parallel_for(re, body);
14816  }
14817 }
14818 
14819 // -----------------------------------------------------------------------------
14820 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14821 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14822 {
14823  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14824  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14825 }
14826 
14827 // -----------------------------------------------------------------------------
14828 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14829 void ParallelForEachScalarIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14830 {
14832  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14833 }
14834 
14835 // -----------------------------------------------------------------------------
14836 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14837 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14838 {
14839  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14840  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14841 }
14842 
14843 // -----------------------------------------------------------------------------
14844 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14845 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14846 {
14847  if (im9->GetTSize()) {
14848  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14849  } else {
14850  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14851  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
14852  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14853  parallel_reduce(re, body);
14854  vf.join(body._VoxelFunc);
14855  of.join(body._OutsideFunc);
14856  } else {
14857  parallel_for(re, body);
14858  }
14859  }
14860 }
14861 
14862 // -----------------------------------------------------------------------------
14863 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14864 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14865 {
14866  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14867  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14868 }
14869 
14870 // -----------------------------------------------------------------------------
14871 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14872 void ParallelForEachVoxelIf(const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14873 {
14875  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14876 }
14877 
14878 // -----------------------------------------------------------------------------
14879 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14880 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14881 {
14882  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14883  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14884 }
14885 
14886 // -----------------------------------------------------------------------------
14887 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14888 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14889 {
14890  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14891  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14892  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14893  if (attr._dt) {
14894  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14895  } else {
14896  parallel_reduce(re, body);
14897  }
14898  vf.join(body._VoxelFunc);
14899  of.join(body._OutsideFunc);
14900  } else {
14901  if (attr._dt) {
14902  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14903  } else {
14904  parallel_for(re, body);
14905  }
14906  }
14907 }
14908 
14909 // -----------------------------------------------------------------------------
14910 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14911 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14912 {
14913  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14914  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14915 }
14916 
14917 // -----------------------------------------------------------------------------
14918 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14919 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14920 {
14922  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14923 }
14924 
14925 // -----------------------------------------------------------------------------
14926 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14927 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14928 {
14929  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14930  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14931 }
14932 
14933 // -----------------------------------------------------------------------------
14934 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14935 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14936 {
14937  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14938  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14939  parallel_reduce(re, body);
14940  vf.join(body._VoxelFunc);
14941  of.join(body._OutsideFunc);
14942  } else {
14943  parallel_for(re, body);
14944  }
14945 }
14946 
14947 // -----------------------------------------------------------------------------
14948 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14949 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14950 {
14951  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14952  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14953 }
14954 
14955 // -----------------------------------------------------------------------------
14956 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14957 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14958 {
14960  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14961 }
14962 
14963 // -----------------------------------------------------------------------------
14964 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14965 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14966 {
14967  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14968  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
14969 }
14970 
14971 // -----------------------------------------------------------------------------
14972 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14973 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
14974 {
14975  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14976  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14977  parallel_reduce(re, body);
14978  vf.join(body._VoxelFunc);
14979  of.join(body._OutsideFunc);
14980  } else {
14981  parallel_for(re, body);
14982  }
14983 }
14984 
14985 // -----------------------------------------------------------------------------
14986 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
14987 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
14988 {
14989  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
14990  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14991 }
14992 
14993 // -----------------------------------------------------------------------------
14994 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
14995 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
14996 {
14998  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
14999 }
15000 
15001 // -----------------------------------------------------------------------------
15002 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15003 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15004 {
15005  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15006  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15007 }
15008 
15009 // -----------------------------------------------------------------------------
15010 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15011 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15012 {
15013  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15014  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15015  parallel_reduce(re, body);
15016  vf.join(body._VoxelFunc);
15017  of.join(body._OutsideFunc);
15018  } else {
15019  parallel_for(re, body);
15020  }
15021 }
15022 
15023 // -----------------------------------------------------------------------------
15024 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15025 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15026 {
15027  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15028  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15029 }
15030 
15031 // -----------------------------------------------------------------------------
15032 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15033 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15034 {
15036  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15037 }
15038 
15039 // -----------------------------------------------------------------------------
15040 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15041 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15042 {
15043  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15044  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15045 }
15046 
15047 //
15048 // Image arguments by reference
15049 //
15050 
15051 // -----------------------------------------------------------------------------
15052 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15053 void ParallelForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15054 {
15055  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15057  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15058  parallel_reduce(re, body);
15059  vf.join(body._VoxelFunc);
15060  of.join(body._OutsideFunc);
15061  } else {
15062  parallel_for(re, body);
15063  }
15064 }
15065 
15066 // -----------------------------------------------------------------------------
15067 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15068 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15069 {
15070  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15071  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15072 }
15073 
15074 // -----------------------------------------------------------------------------
15075 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15076 void ParallelForEachScalarIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15077 {
15079  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15080 }
15081 
15082 // -----------------------------------------------------------------------------
15083 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15084 void ParallelForEachScalarIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15085 {
15086  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15087  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15088 }
15089 
15090 // -----------------------------------------------------------------------------
15091 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15092 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15093 {
15094  if (im9.GetTSize()) {
15095  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15096  } else {
15097  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15098  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
15099  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15100  parallel_reduce(re, body);
15101  vf.join(body._VoxelFunc);
15102  of.join(body._OutsideFunc);
15103  } else {
15104  parallel_for(re, body);
15105  }
15106  }
15107 }
15108 
15109 // -----------------------------------------------------------------------------
15110 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15111 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15112 {
15113  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15114  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15115 }
15116 
15117 // -----------------------------------------------------------------------------
15118 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15119 void ParallelForEachVoxelIf(const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15120 {
15122  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15123 }
15124 
15125 // -----------------------------------------------------------------------------
15126 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15127 void ParallelForEachVoxelIf(VoxelFunc vf, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15128 {
15129  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15130  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15131 }
15132 
15133 // -----------------------------------------------------------------------------
15134 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15135 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15136 {
15137  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15138  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
15139  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15140  if (attr._dt) {
15141  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
15142  } else {
15143  parallel_reduce(re, body);
15144  }
15145  vf.join(body._VoxelFunc);
15146  of.join(body._OutsideFunc);
15147  } else {
15148  if (attr._dt) {
15149  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
15150  } else {
15151  parallel_for(re, body);
15152  }
15153  }
15154 }
15155 
15156 // -----------------------------------------------------------------------------
15157 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15158 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15159 {
15160  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15161  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15162 }
15163 
15164 // -----------------------------------------------------------------------------
15165 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15166 void ParallelForEachVoxelIf(const ImageAttributes &attr, const GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15167 {
15169  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15170 }
15171 
15172 // -----------------------------------------------------------------------------
15173 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15174 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15175 {
15176  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15177  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15178 }
15179 
15180 // -----------------------------------------------------------------------------
15181 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15182 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15183 {
15184  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15185  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15186  parallel_reduce(re, body);
15187  vf.join(body._VoxelFunc);
15188  of.join(body._OutsideFunc);
15189  } else {
15190  parallel_for(re, body);
15191  }
15192 }
15193 
15194 // -----------------------------------------------------------------------------
15195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15196 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15197 {
15198  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15199  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15200 }
15201 
15202 // -----------------------------------------------------------------------------
15203 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15204 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15205 {
15207  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15208 }
15209 
15210 // -----------------------------------------------------------------------------
15211 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15212 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15213 {
15214  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15215  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15216 }
15217 
15218 // -----------------------------------------------------------------------------
15219 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15220 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15221 {
15222  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15223  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15224  parallel_reduce(re, body);
15225  vf.join(body._VoxelFunc);
15226  of.join(body._OutsideFunc);
15227  } else {
15228  parallel_for(re, body);
15229  }
15230 }
15231 
15232 // -----------------------------------------------------------------------------
15233 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15234 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15235 {
15236  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15237  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15238 }
15239 
15240 // -----------------------------------------------------------------------------
15241 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15242 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15243 {
15245  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15246 }
15247 
15248 // -----------------------------------------------------------------------------
15249 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15250 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15251 {
15252  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15253  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15254 }
15255 
15256 // -----------------------------------------------------------------------------
15257 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15258 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
15259 {
15260  NonaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15261  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15262  parallel_reduce(re, body);
15263  vf.join(body._VoxelFunc);
15264  of.join(body._OutsideFunc);
15265  } else {
15266  parallel_for(re, body);
15267  }
15268 }
15269 
15270 // -----------------------------------------------------------------------------
15271 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15272 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15273 {
15274  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15275  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15276 }
15277 
15278 // -----------------------------------------------------------------------------
15279 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15280 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15281 {
15283  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
15284 }
15285 
15286 // -----------------------------------------------------------------------------
15287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15288 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15289 {
15290  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15291  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15292 }
15293 
15294 // =============================================================================
15295 // 9 non-const images
15296 // =============================================================================
15297 
15298 // -----------------------------------------------------------------------------
15299 /**
15300  * ForEachVoxel body for voxel function of 9 non-const images
15301  */
15302 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15303 struct NonaryForEachVoxelBody : public ForEachVoxelBody<VoxelFunc>
15304 {
15305  GenericImage<T1> &im1;
15306  GenericImage<T2> &im2;
15307  GenericImage<T3> &im3;
15308  GenericImage<T4> &im4;
15309  GenericImage<T5> &im5;
15310  GenericImage<T6> &im6;
15311  GenericImage<T7> &im7;
15312  GenericImage<T8> &im8;
15313  GenericImage<T9> &im9;
15314 
15315  /// Constructor
15317  GenericImage<T2> &im2,
15318  GenericImage<T3> &im3,
15319  GenericImage<T4> &im4,
15320  GenericImage<T5> &im5,
15321  GenericImage<T6> &im6,
15322  GenericImage<T7> &im7,
15323  GenericImage<T8> &im8,
15324  GenericImage<T9> &im9,
15325  VoxelFunc &vf)
15326  :
15327  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
15328  {}
15329 
15330  /// Copy constructor
15332  :
15333  ForEachVoxelBody<VoxelFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
15334  {}
15335 
15336  /// Split constructor
15338  :
15339  ForEachVoxelBody<VoxelFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
15340  {}
15341 
15342  /// Process entire image
15343  void operator ()(const ImageAttributes &attr) const
15344  {
15345  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
15346  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
15347  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
15348  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
15349  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
15350  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
15351  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
15352  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
15353  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
15354 
15355  const int T = (attr._dt ? attr._t : 1);
15356 
15357  for (int l = 0; l < T; ++l)
15358  for (int k = 0; k < attr._z; ++k)
15359  for (int j = 0; j < attr._y; ++j)
15360  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
15361  // const_cast such that voxel functions need only implement
15362  // non-const operator() which is required for parallel_reduce
15363  const_cast<NonaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15364  }
15365  }
15366 
15367  /// Process image region using linear index
15368  void operator ()(const blocked_range<int> &re) const
15369  {
15370  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
15371  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
15372  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
15373  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
15374  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
15375  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
15376  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
15377  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
15378  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
15379 
15380  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15381  // const_cast such that voxel functions need only implement
15382  // non-const operator() which is required for parallel_reduce
15383  const_cast<NonaryForEachVoxelBody *>(this)->_VoxelFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15384  }
15385  }
15386 
15387  /// Process 2D image region
15388  void operator ()(const blocked_range2d<int> &re) const
15389  {
15390  const int bi = re.cols().begin();
15391  const int bj = re.rows().begin();
15392  const int ei = re.cols().end();
15393  const int ej = re.rows().end();
15394 
15395  const int s1 = im9.GetX() - (ei - bi);
15396 
15397  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15398  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15399  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15400  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15401  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15402  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15403  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15404  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15405  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15406 
15407  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
15408  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15409  // const_cast such that voxel functions need only implement
15410  // non-const operator() which is required for parallel_reduce
15411  const_cast<NonaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15412  }
15413  }
15414 
15415  /// Process 3D image region
15416  void operator ()(const blocked_range3d<int> &re) const
15417  {
15418  const int bi = re.cols ().begin();
15419  const int bj = re.rows ().begin();
15420  const int bk = re.pages().begin();
15421  const int ei = re.cols ().end();
15422  const int ej = re.rows ().end();
15423  const int ek = re.pages().end();
15424 
15425  const int s1 = im9.GetX() - (ei - bi);
15426  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
15427 
15428  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
15429  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
15430  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
15431  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
15432  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
15433  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
15434  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
15435  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
15436  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
15437 
15438  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
15439  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
15440  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15441  // const_cast such that voxel functions need only implement
15442  // non-const operator() which is required for parallel_reduce
15443  const_cast<NonaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15444  }
15445  }
15446 };
15447 
15448 // -----------------------------------------------------------------------------
15449 /**
15450  * ForEachVoxel body for inside and outside unary voxel function of 9 non-const images
15451  */
15452 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9,
15453  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
15454  class Domain = ForEachVoxelDomain::Foreground>
15455 struct NonaryForEachVoxelIfBody : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
15456 {
15457  GenericImage<T1> &im1;
15458  GenericImage<T2> &im2;
15459  GenericImage<T3> &im3;
15460  GenericImage<T4> &im4;
15461  GenericImage<T5> &im5;
15462  GenericImage<T6> &im6;
15463  GenericImage<T7> &im7;
15464  GenericImage<T8> &im8;
15465  GenericImage<T9> &im9;
15466 
15467  /// Constructor
15469  GenericImage<T2> &im2,
15470  GenericImage<T3> &im3,
15471  GenericImage<T4> &im4,
15472  GenericImage<T5> &im5,
15473  GenericImage<T6> &im6,
15474  GenericImage<T7> &im7,
15475  GenericImage<T8> &im8,
15476  GenericImage<T9> &im9,
15477  VoxelFunc &vf, OutsideFunc &of)
15478  :
15479  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8), im9(im9)
15480  {}
15481 
15482  /// Copy constructor
15484  :
15485  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
15486  {}
15487 
15488  /// Split constructor
15490  :
15491  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(o, s), im1(o.im1), im2(o.im2), im3(o.im3), im4(o.im4), im5(o.im5), im6(o.im6), im7(o.im7), im8(o.im8), im9(o.im9)
15492  {}
15493 
15494  /// Process entire image
15495  void operator ()(const ImageAttributes &attr) const
15496  {
15497  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
15498  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
15499  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
15500  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
15501  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
15502  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
15503  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
15504  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
15505  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels();
15506 
15507  const int T = (attr._dt ? attr._t : 1);
15508 
15509  for (int l = 0; l < T; ++l)
15510  for (int k = 0; k < attr._z; ++k)
15511  for (int j = 0; j < attr._y; ++j)
15512  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8, ++p9) {
15513  if (Domain::IsInside(im9, i, j, k, l, p9)) {
15514  // const_cast such that voxel functions need only implement
15515  // non-const operator() which is required for parallel_reduce
15516  const_cast<NonaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15517  } else const_cast<NonaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15518  }
15519  }
15520 
15521  /// Process image region using linear index
15522  void operator ()(const blocked_range<int> &re) const
15523  {
15524  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
15525  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
15526  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
15527  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
15528  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
15529  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
15530  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
15531  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
15532  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels() + re.begin();
15533 
15534  for (int idx = re.begin(); idx < re.end(); ++idx, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15535  if (Domain::IsInside(im9, idx, p9)) {
15536  // const_cast such that voxel functions need only implement
15537  // non-const operator() which is required for parallel_reduce
15538  const_cast<NonaryForEachVoxelIfBody *>(this)->_VoxelFunc (im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15539  } else const_cast<NonaryForEachVoxelIfBody *>(this)->_OutsideFunc(im9, idx, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15540  }
15541  }
15542 
15543  /// Process 2D image region
15544  void operator ()(const blocked_range2d<int> &re) const
15545  {
15546  const int bi = re.cols().begin();
15547  const int bj = re.rows().begin();
15548  const int ei = re.cols().end();
15549  const int ej = re.rows().end();
15550 
15551  const int s1 = im9.GetX() - (ei - bi);
15552 
15553  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15554  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15555  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15556  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15557  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15558  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15559  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15560  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15561  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, this->_k, this->_l);
15562 
15563  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
15564  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15565  if (Domain::IsInside(im9, i, j, this->_k, this->_l, p9)) {
15566  // const_cast such that voxel functions need only implement
15567  // non-const operator() which is required for parallel_reduce
15568  const_cast<NonaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15569  } else const_cast<NonaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15570  }
15571  }
15572 
15573  /// Process 3D image region
15574  void operator ()(const blocked_range3d<int> &re) const
15575  {
15576  const int bi = re.cols ().begin();
15577  const int bj = re.rows ().begin();
15578  const int bk = re.pages().begin();
15579  const int ei = re.cols ().end();
15580  const int ej = re.rows ().end();
15581  const int ek = re.pages().end();
15582 
15583  const int s1 = im9.GetX() - (ei - bi);
15584  const int s2 = (im9.GetY() - (ej - bj)) * im9.GetX();
15585 
15586  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
15587  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
15588  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
15589  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
15590  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
15591  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
15592  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
15593  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
15594  T9 *p9 = im9.IsEmpty() ? NULL : im9.GetPointerToVoxels(bi, bj, bk, this->_l);
15595 
15596  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2, p9 += s2)
15597  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1, p9 += s1)
15598  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1, p9 += 1) {
15599  if (Domain::IsInside(im9, i, j, k, this->_l, p9)) {
15600  // const_cast such that voxel functions need only implement
15601  // non-const operator() which is required for parallel_reduce
15602  const_cast<NonaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15603  } else const_cast<NonaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8, p9);
15604  }
15605  }
15606 };
15607 
15608 // -----------------------------------------------------------------------------
15609 // ForEachVoxel
15610 // -----------------------------------------------------------------------------
15611 
15612 //
15613 // Image arguments by pointer
15614 //
15615 
15616 // -----------------------------------------------------------------------------
15617 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15618 void ForEachScalar(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15619 {
15620  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15621  blocked_range<int> re(0, im9->GetNumberOfVoxels());
15622  body(re);
15623  vf.join(body._VoxelFunc);
15624 }
15625 
15626 // -----------------------------------------------------------------------------
15627 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15628 void ForEachScalar(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15629 {
15630  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15631  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15632 }
15633 
15634 // -----------------------------------------------------------------------------
15635 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15636 void ForEachVoxel(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15637 {
15638  if (im9->GetTSize()) {
15639  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15640  } else {
15641  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15642  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
15643  body(re);
15644  vf.join(body._VoxelFunc);
15645  }
15646 }
15647 
15648 // -----------------------------------------------------------------------------
15649 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15650 void ForEachVoxel(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15651 {
15652  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15653  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15654 }
15655 
15656 // -----------------------------------------------------------------------------
15657 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15658 void ForEachVoxel(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15659 {
15660  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15661  body(attr);
15662  vf.join(body._VoxelFunc);
15663 }
15664 
15665 // -----------------------------------------------------------------------------
15666 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15667 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15668 {
15669  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15670  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15671 }
15672 
15673 // -----------------------------------------------------------------------------
15674 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15675 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15676 {
15677  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15678  body(re);
15679  vf.join(body._VoxelFunc);
15680 }
15681 
15682 // -----------------------------------------------------------------------------
15683 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15684 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15685 {
15686  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15687  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15688 }
15689 
15690 // -----------------------------------------------------------------------------
15691 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15692 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15693 {
15694  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15695  body(re);
15696  vf.join(body._VoxelFunc);
15697 }
15698 
15699 // -----------------------------------------------------------------------------
15700 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15701 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15702 {
15703  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15704  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15705 }
15706 
15707 // -----------------------------------------------------------------------------
15708 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15709 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15710 {
15711  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15712  body(re);
15713  vf.join(body._VoxelFunc);
15714 }
15715 
15716 // -----------------------------------------------------------------------------
15717 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15718 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15719 {
15720  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15721  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15722 }
15723 
15724 //
15725 // Image arguments by reference
15726 //
15727 
15728 // -----------------------------------------------------------------------------
15729 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15730 void ForEachScalar(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15731 {
15732  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15734  body(re);
15735  vf.join(body._VoxelFunc);
15736 }
15737 
15738 // -----------------------------------------------------------------------------
15739 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15740 void ForEachScalar(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15741 {
15742  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15743  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15744 }
15745 
15746 // -----------------------------------------------------------------------------
15747 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15748 void ForEachVoxel(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15749 {
15750  if (im9.GetTSize()) {
15751  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15752  } else {
15753  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15754  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
15755  body(re);
15756  vf.join(body._VoxelFunc);
15757  }
15758 }
15759 
15760 // -----------------------------------------------------------------------------
15761 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15762 void ForEachVoxel(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15763 {
15764  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15765  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15766 }
15767 
15768 // -----------------------------------------------------------------------------
15769 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15770 void ForEachVoxel(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15771 {
15772  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15773  body(attr);
15774  vf.join(body._VoxelFunc);
15775 }
15776 
15777 // -----------------------------------------------------------------------------
15778 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15779 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15780 {
15781  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15782  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15783 }
15784 
15785 // -----------------------------------------------------------------------------
15786 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15787 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15788 {
15789  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15790  body(re);
15791  vf.join(body._VoxelFunc);
15792 }
15793 
15794 // -----------------------------------------------------------------------------
15795 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15796 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15797 {
15798  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15799  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15800 }
15801 
15802 // -----------------------------------------------------------------------------
15803 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15804 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15805 {
15806  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15807  body(re);
15808  vf.join(body._VoxelFunc);
15809 }
15810 
15811 // -----------------------------------------------------------------------------
15812 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15813 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15814 {
15815  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15816  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15817 }
15818 
15819 // -----------------------------------------------------------------------------
15820 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15821 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
15822 {
15823  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15824  body(re);
15825  vf.join(body._VoxelFunc);
15826 }
15827 
15828 // -----------------------------------------------------------------------------
15829 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15830 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
15831 {
15832  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15833  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
15834 }
15835 
15836 // -----------------------------------------------------------------------------
15837 // ForEachVoxelIf
15838 // -----------------------------------------------------------------------------
15839 
15840 //
15841 // Image arguments by pointer
15842 //
15843 
15844 // -----------------------------------------------------------------------------
15845 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15846 void ForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15847 {
15848  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15849  blocked_range<int> re(0, im9->GetNumberOfVoxels());
15850  body(re);
15851  vf.join(body._VoxelFunc);
15852  of.join(body._OutsideFunc);
15853 }
15854 
15855 // -----------------------------------------------------------------------------
15856 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15857 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15858 {
15859  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15860  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15861 }
15862 
15863 // -----------------------------------------------------------------------------
15864 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15865 void ForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15866 {
15868  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15869 }
15870 
15871 // -----------------------------------------------------------------------------
15872 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15873 void ForEachScalarIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15874 {
15875  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15876  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15877 }
15878 
15879 // -----------------------------------------------------------------------------
15880 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15881 void ForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15882 {
15883  if (im9->GetTSize()) {
15884  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15885  } else {
15886  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15887  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
15888  body(re);
15889  vf.join(body._VoxelFunc);
15890  of.join(body._OutsideFunc);
15891  }
15892 }
15893 
15894 // -----------------------------------------------------------------------------
15895 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15896 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15897 {
15898  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15899  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15900 }
15901 
15902 // -----------------------------------------------------------------------------
15903 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15904 void ForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15905 {
15907  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15908 }
15909 
15910 // -----------------------------------------------------------------------------
15911 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15912 void ForEachVoxelIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15913 {
15914  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15915  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15916 }
15917 
15918 // -----------------------------------------------------------------------------
15919 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15920 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15921 {
15922  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15923  body(attr);
15924  vf.join(body._VoxelFunc);
15925  of.join(body._OutsideFunc);
15926 }
15927 
15928 // -----------------------------------------------------------------------------
15929 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15930 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15931 {
15932  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15933  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15934 }
15935 
15936 // -----------------------------------------------------------------------------
15937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15938 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15939 {
15941  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15942 }
15943 
15944 // -----------------------------------------------------------------------------
15945 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15946 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15947 {
15948  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15949  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
15950 }
15951 
15952 // -----------------------------------------------------------------------------
15953 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15954 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15955 {
15956  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15957  body(re);
15958  vf.join(body._VoxelFunc);
15959  of.join(body._OutsideFunc);
15960 }
15961 
15962 // -----------------------------------------------------------------------------
15963 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15964 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15965 {
15966  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15967  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15968 }
15969 
15970 // -----------------------------------------------------------------------------
15971 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15972 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
15973 {
15974  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15975  body(re);
15976  vf.join(body._VoxelFunc);
15977  of.join(body._OutsideFunc);
15978 }
15979 
15980 // -----------------------------------------------------------------------------
15981 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
15982 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15983 {
15984  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
15985  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15986 }
15987 
15988 // -----------------------------------------------------------------------------
15989 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15990 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
15991 {
15993  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
15994 }
15995 
15996 // -----------------------------------------------------------------------------
15997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
15998 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
15999 {
16000  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16001  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16002 }
16003 
16004 // -----------------------------------------------------------------------------
16005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16006 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16007 {
16008  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16009  body(re);
16010  vf.join(body._VoxelFunc);
16011  of.join(body._OutsideFunc);
16012 }
16013 
16014 // -----------------------------------------------------------------------------
16015 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16016 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16017 {
16018  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16019  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16020 }
16021 
16022 // -----------------------------------------------------------------------------
16023 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16024 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16025 {
16027  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16028 }
16029 
16030 // -----------------------------------------------------------------------------
16031 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16032 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16033 {
16034  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16035  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16036 }
16037 
16038 //
16039 // Image arguments by reference
16040 //
16041 
16042 // -----------------------------------------------------------------------------
16043 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16044 void ForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16045 {
16046  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16048  body(re);
16049  vf.join(body._VoxelFunc);
16050  of.join(body._OutsideFunc);
16051 }
16052 
16053 // -----------------------------------------------------------------------------
16054 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16055 void ForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16056 {
16057  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16058  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16059 }
16060 
16061 // -----------------------------------------------------------------------------
16062 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16063 void ForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16064 {
16066  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16067 }
16068 
16069 // -----------------------------------------------------------------------------
16070 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16071 void ForEachScalarIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16072 {
16073  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16074  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16075 }
16076 
16077 // -----------------------------------------------------------------------------
16078 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16079 void ForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16080 {
16081  if (im9.GetTSize()) {
16082  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16083  } else {
16084  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16085  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
16086  body(re);
16087  vf.join(body._VoxelFunc);
16088  of.join(body._OutsideFunc);
16089  }
16090 }
16091 
16092 // -----------------------------------------------------------------------------
16093 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16094 void ForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16095 {
16096  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16097  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16098 }
16099 
16100 // -----------------------------------------------------------------------------
16101 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16102 void ForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16103 {
16105  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16106 }
16107 
16108 // -----------------------------------------------------------------------------
16109 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16110 void ForEachVoxelIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16111 {
16112  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16113  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16114 }
16115 
16116 // -----------------------------------------------------------------------------
16117 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16118 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16119 {
16120  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16121  body(attr);
16122  vf.join(body._VoxelFunc);
16123  of.join(body._OutsideFunc);
16124 }
16125 
16126 // -----------------------------------------------------------------------------
16127 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16128 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16129 {
16130  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16131  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16132 }
16133 
16134 // -----------------------------------------------------------------------------
16135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16136 void ForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16137 {
16139  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16140 }
16141 
16142 // -----------------------------------------------------------------------------
16143 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16144 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16145 {
16146  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16147  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16148 }
16149 
16150 // -----------------------------------------------------------------------------
16151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16152 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16153 {
16154  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16155  body(re);
16156  vf.join(body._VoxelFunc);
16157  of.join(body._OutsideFunc);
16158 }
16159 
16160 // -----------------------------------------------------------------------------
16161 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16162 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16163 {
16164  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16165  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16166 }
16167 
16168 // -----------------------------------------------------------------------------
16169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16170 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16171 {
16172  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16173  body(re);
16174  vf.join(body._VoxelFunc);
16175  of.join(body._OutsideFunc);
16176 }
16177 
16178 // -----------------------------------------------------------------------------
16179 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16180 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16181 {
16182  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16183  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16184 }
16185 
16186 // -----------------------------------------------------------------------------
16187 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16188 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16189 {
16191  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16192 }
16193 
16194 // -----------------------------------------------------------------------------
16195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16196 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16197 {
16198  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16199  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16200 }
16201 
16202 // -----------------------------------------------------------------------------
16203 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16204 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16205 {
16206  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16207  body(re);
16208  vf.join(body._VoxelFunc);
16209  of.join(body._OutsideFunc);
16210 }
16211 
16212 // -----------------------------------------------------------------------------
16213 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16214 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16215 {
16216  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16217  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16218 }
16219 
16220 // -----------------------------------------------------------------------------
16221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16222 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16223 {
16225  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16226 }
16227 
16228 // -----------------------------------------------------------------------------
16229 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16230 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16231 {
16232  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16233  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16234 }
16235 
16236 // -----------------------------------------------------------------------------
16237 // ParallelForEachVoxel
16238 // -----------------------------------------------------------------------------
16239 
16240 //
16241 // Image arguments by pointer
16242 //
16243 
16244 // -----------------------------------------------------------------------------
16245 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16246 void ParallelForEachScalar(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16247 {
16248  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16249  blocked_range<int> re(0, im9->GetNumberOfVoxels());
16250  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16251  else parallel_for (re, body);
16252 }
16253 
16254 // -----------------------------------------------------------------------------
16255 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16256 void ParallelForEachScalar(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16257 {
16258  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16259  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16260 }
16261 
16262 // -----------------------------------------------------------------------------
16263 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16264 void ParallelForEachVoxel(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16265 {
16266  if (im9->GetTSize()) {
16267  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16268  } else {
16269  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16270  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
16271  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16272  else parallel_for (re, body);
16273  }
16274 }
16275 
16276 // -----------------------------------------------------------------------------
16277 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16278 void ParallelForEachVoxel(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16279 {
16280  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16281  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16282 }
16283 
16284 // -----------------------------------------------------------------------------
16285 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16286 void ParallelForEachVoxel(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16287 {
16288  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16289  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
16290  if (VoxelFunc::IsReduction()) {
16291  if (attr._dt) {
16292  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
16293  } else {
16294  parallel_reduce(re, body);
16295  }
16296  vf.join(body._VoxelFunc);
16297  } else {
16298  if (attr._dt) {
16299  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
16300  } else {
16301  parallel_for(re, body);
16302  }
16303  }
16304 }
16305 
16306 // -----------------------------------------------------------------------------
16307 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16308 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16309 {
16310  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16311  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16312 }
16313 
16314 // -----------------------------------------------------------------------------
16315 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16316 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16317 {
16318  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16319  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16320  else parallel_for (re, body);
16321 }
16322 
16323 // -----------------------------------------------------------------------------
16324 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16325 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16326 {
16327  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16328  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16329 }
16330 
16331 // -----------------------------------------------------------------------------
16332 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16333 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16334 {
16335  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16336  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16337  else parallel_for (re, body);
16338 }
16339 
16340 // -----------------------------------------------------------------------------
16341 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16342 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16343 {
16344  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16345  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16346 }
16347 
16348 // -----------------------------------------------------------------------------
16349 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16350 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16351 {
16352  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16353  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16354  else parallel_for (re, body);
16355 }
16356 
16357 // -----------------------------------------------------------------------------
16358 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16359 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16360 {
16361  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16362  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16363 }
16364 
16365 //
16366 // Image arguments by reference
16367 //
16368 
16369 // -----------------------------------------------------------------------------
16370 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16371 void ParallelForEachScalar(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16372 {
16373  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16375  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16376  else parallel_for (re, body);
16377 }
16378 
16379 // -----------------------------------------------------------------------------
16380 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16381 void ParallelForEachScalar(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16382 {
16383  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16384  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16385 }
16386 
16387 // -----------------------------------------------------------------------------
16388 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16389 void ParallelForEachVoxel(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16390 {
16391  if (im9.GetTSize()) {
16392  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16393  } else {
16394  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16395  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
16396  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16397  else parallel_for (re, body);
16398  }
16399 }
16400 
16401 // -----------------------------------------------------------------------------
16402 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16403 void ParallelForEachVoxel(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16404 {
16405  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16406  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16407 }
16408 
16409 // -----------------------------------------------------------------------------
16410 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16411 void ParallelForEachVoxel(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16412 {
16413  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16414  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
16415  if (VoxelFunc::IsReduction()) {
16416  if (attr._dt) {
16417  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
16418  } else {
16419  parallel_reduce(re, body);
16420  }
16421  vf.join(body._VoxelFunc);
16422  } else {
16423  if (attr._dt) {
16424  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
16425  } else {
16426  parallel_for(re, body);
16427  }
16428  }
16429 }
16430 
16431 // -----------------------------------------------------------------------------
16432 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16433 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16434 {
16435  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16436  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16437 }
16438 
16439 // -----------------------------------------------------------------------------
16440 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16441 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16442 {
16443  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16444  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16445  else parallel_for (re, body);
16446 }
16447 
16448 // -----------------------------------------------------------------------------
16449 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16450 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16451 {
16452  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16453  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16454 }
16455 
16456 // -----------------------------------------------------------------------------
16457 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16458 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16459 {
16460  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16461  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16462  else parallel_for (re, body);
16463 }
16464 
16465 // -----------------------------------------------------------------------------
16466 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16467 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16468 {
16469  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16470  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16471 }
16472 
16473 // -----------------------------------------------------------------------------
16474 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16475 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16476 {
16477  NonaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16478  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
16479  else parallel_for (re, body);
16480 }
16481 
16482 // -----------------------------------------------------------------------------
16483 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16484 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16485 {
16486  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16487  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16488 }
16489 
16490 // -----------------------------------------------------------------------------
16491 // ParallelForEachVoxelIf
16492 // -----------------------------------------------------------------------------
16493 
16494 //
16495 // Image arguments by pointer
16496 //
16497 
16498 // -----------------------------------------------------------------------------
16499 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16500 void ParallelForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16501 {
16502  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16503  blocked_range<int> re(0, im9->GetNumberOfVoxels());
16504  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16505  parallel_reduce(re, body);
16506  vf.join(body._VoxelFunc);
16507  of.join(body._OutsideFunc);
16508  } else {
16509  parallel_for(re, body);
16510  }
16511 }
16512 
16513 // -----------------------------------------------------------------------------
16514 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16515 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16516 {
16517  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16518  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16519 }
16520 
16521 // -----------------------------------------------------------------------------
16522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16523 void ParallelForEachScalarIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16524 {
16526  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16527 }
16528 
16529 // -----------------------------------------------------------------------------
16530 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16531 void ParallelForEachScalarIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16532 {
16533  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16534  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16535 }
16536 
16537 // -----------------------------------------------------------------------------
16538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16539 void ParallelForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16540 {
16541  if (im9->GetTSize()) {
16542  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16543  } else {
16544  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16545  blocked_range<int> re(0, im9->GetNumberOfVoxels() / im9->GetT());
16546  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16547  parallel_reduce(re, body);
16548  vf.join(body._VoxelFunc);
16549  of.join(body._OutsideFunc);
16550  } else {
16551  parallel_for(re, body);
16552  }
16553  }
16554 }
16555 
16556 // -----------------------------------------------------------------------------
16557 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16558 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16559 {
16560  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16561  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16562 }
16563 
16564 // -----------------------------------------------------------------------------
16565 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16566 void ParallelForEachVoxelIf(GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16567 {
16569  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16570 }
16571 
16572 // -----------------------------------------------------------------------------
16573 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16574 void ParallelForEachVoxelIf(VoxelFunc vf, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16575 {
16576  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16577  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16578 }
16579 
16580 // -----------------------------------------------------------------------------
16581 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16582 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16583 {
16584  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16585  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
16586  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16587  if (attr._dt) {
16588  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
16589  } else {
16590  parallel_reduce(re, body);
16591  }
16592  vf.join(body._VoxelFunc);
16593  of.join(body._OutsideFunc);
16594  } else {
16595  if (attr._dt) {
16596  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
16597  } else {
16598  parallel_for(re, body);
16599  }
16600  }
16601 }
16602 
16603 // -----------------------------------------------------------------------------
16604 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16605 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16606 {
16607  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16608  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16609 }
16610 
16611 // -----------------------------------------------------------------------------
16612 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16613 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> *im1, GenericImage<T2> *im2, GenericImage<T3> *im3, GenericImage<T4> *im4, GenericImage<T5> *im5, GenericImage<T6> *im6, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16614 {
16616  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16617 }
16618 
16619 // -----------------------------------------------------------------------------
16620 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16621 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16622 {
16623  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16624  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16625 }
16626 
16627 // -----------------------------------------------------------------------------
16628 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16629 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16630 {
16631  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16632  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16633  parallel_reduce(re, body);
16634  vf.join(body._VoxelFunc);
16635  of.join(body._OutsideFunc);
16636  } else {
16637  parallel_for(re, body);
16638  }
16639 }
16640 
16641 // -----------------------------------------------------------------------------
16642 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16643 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16644 {
16645  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16646  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16647 }
16648 
16649 // -----------------------------------------------------------------------------
16650 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16651 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16652 {
16654  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16655 }
16656 
16657 // -----------------------------------------------------------------------------
16658 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16659 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16660 {
16661  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16662  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16663 }
16664 
16665 // -----------------------------------------------------------------------------
16666 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16667 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16668 {
16669  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16670  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16671  parallel_reduce(re, body);
16672  vf.join(body._VoxelFunc);
16673  of.join(body._OutsideFunc);
16674  } else {
16675  parallel_for(re, body);
16676  }
16677 }
16678 
16679 // -----------------------------------------------------------------------------
16680 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16681 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16682 {
16683  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16684  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16685 }
16686 
16687 // -----------------------------------------------------------------------------
16688 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16689 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16690 {
16692  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16693 }
16694 
16695 // -----------------------------------------------------------------------------
16696 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16697 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16698 {
16699  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16700  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16701 }
16702 
16703 // -----------------------------------------------------------------------------
16704 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16705 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf, OutsideFunc &of)
16706 {
16707  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16708  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16709  parallel_reduce(re, body);
16710  vf.join(body._VoxelFunc);
16711  of.join(body._OutsideFunc);
16712  } else {
16713  parallel_for(re, body);
16714  }
16715 }
16716 
16717 // -----------------------------------------------------------------------------
16718 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16719 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16720 {
16721  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16722  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16723 }
16724 
16725 // -----------------------------------------------------------------------------
16726 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16727 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9, VoxelFunc &vf)
16728 {
16730  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf, of);
16731 }
16732 
16733 // -----------------------------------------------------------------------------
16734 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16735 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, GenericImage<T7> *im7, GenericImage<T8> *im8, GenericImage<T9> *im9)
16736 {
16737  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16738  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, *im9, vf);
16739 }
16740 
16741 //
16742 // Image arguments by reference
16743 //
16744 
16745 // -----------------------------------------------------------------------------
16746 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16747 void ParallelForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16748 {
16749  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16751  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16752  parallel_reduce(re, body);
16753  vf.join(body._VoxelFunc);
16754  of.join(body._OutsideFunc);
16755  } else {
16756  parallel_for(re, body);
16757  }
16758 }
16759 
16760 // -----------------------------------------------------------------------------
16761 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16762 void ParallelForEachScalarIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16763 {
16764  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16765  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16766 }
16767 
16768 // -----------------------------------------------------------------------------
16769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16770 void ParallelForEachScalarIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16771 {
16773  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16774 }
16775 
16776 // -----------------------------------------------------------------------------
16777 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16778 void ParallelForEachScalarIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16779 {
16780  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16781  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16782 }
16783 
16784 // -----------------------------------------------------------------------------
16785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16786 void ParallelForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16787 {
16788  if (im9.GetTSize()) {
16789  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16790  } else {
16791  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16792  blocked_range<int> re(0, im9.GetNumberOfVoxels() / im9.GetT());
16793  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16794  parallel_reduce(re, body);
16795  vf.join(body._VoxelFunc);
16796  of.join(body._OutsideFunc);
16797  } else {
16798  parallel_for(re, body);
16799  }
16800  }
16801 }
16802 
16803 // -----------------------------------------------------------------------------
16804 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16805 void ParallelForEachVoxelIf(VoxelFunc vf, OutsideFunc of, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16806 {
16807  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16808  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16809 }
16810 
16811 // -----------------------------------------------------------------------------
16812 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16813 void ParallelForEachVoxelIf(GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16814 {
16816  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16817 }
16818 
16819 // -----------------------------------------------------------------------------
16820 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16821 void ParallelForEachVoxelIf(VoxelFunc vf, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16822 {
16823  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16824  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16825 }
16826 
16827 // -----------------------------------------------------------------------------
16828 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16829 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16830 {
16831  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16832  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
16833  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16834  if (attr._dt) {
16835  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
16836  } else {
16837  parallel_reduce(re, body);
16838  }
16839  vf.join(body._VoxelFunc);
16840  of.join(body._OutsideFunc);
16841  } else {
16842  if (attr._dt) {
16843  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
16844  } else {
16845  parallel_for(re, body);
16846  }
16847  }
16848 }
16849 
16850 // -----------------------------------------------------------------------------
16851 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16852 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16853 {
16854  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16855  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16856 }
16857 
16858 // -----------------------------------------------------------------------------
16859 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16860 void ParallelForEachVoxelIf(const ImageAttributes &attr, GenericImage<T1> &im1, GenericImage<T2> &im2, GenericImage<T3> &im3, GenericImage<T4> &im4, GenericImage<T5> &im5, GenericImage<T6> &im6, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16861 {
16863  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16864 }
16865 
16866 // -----------------------------------------------------------------------------
16867 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16868 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16869 {
16870  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16871  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16872 }
16873 
16874 // -----------------------------------------------------------------------------
16875 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16876 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16877 {
16878  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16879  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16880  parallel_reduce(re, body);
16881  vf.join(body._VoxelFunc);
16882  of.join(body._OutsideFunc);
16883  } else {
16884  parallel_for(re, body);
16885  }
16886 }
16887 
16888 // -----------------------------------------------------------------------------
16889 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16890 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16891 {
16892  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16893  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16894 }
16895 
16896 // -----------------------------------------------------------------------------
16897 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16898 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16899 {
16901  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16902 }
16903 
16904 // -----------------------------------------------------------------------------
16905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16906 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16907 {
16908  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16909  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16910 }
16911 
16912 // -----------------------------------------------------------------------------
16913 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16914 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16915 {
16916  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16917  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16918  parallel_reduce(re, body);
16919  vf.join(body._VoxelFunc);
16920  of.join(body._OutsideFunc);
16921  } else {
16922  parallel_for(re, body);
16923  }
16924 }
16925 
16926 // -----------------------------------------------------------------------------
16927 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16928 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16929 {
16930  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16931  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16932 }
16933 
16934 // -----------------------------------------------------------------------------
16935 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16936 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16937 {
16939  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16940 }
16941 
16942 // -----------------------------------------------------------------------------
16943 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16944 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16945 {
16946  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16947  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16948 }
16949 
16950 // -----------------------------------------------------------------------------
16951 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16952 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf, OutsideFunc &of)
16953 {
16954  NonaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, T9, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16955  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
16956  parallel_reduce(re, body);
16957  vf.join(body._VoxelFunc);
16958  of.join(body._OutsideFunc);
16959  } else {
16960  parallel_for(re, body);
16961  }
16962 }
16963 
16964 // -----------------------------------------------------------------------------
16965 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc, class OutsideFunc>
16966 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16967 {
16968  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16969  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16970 }
16971 
16972 // -----------------------------------------------------------------------------
16973 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16974 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9, VoxelFunc &vf)
16975 {
16977  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf, of);
16978 }
16979 
16980 // -----------------------------------------------------------------------------
16981 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class VoxelFunc>
16982 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, GenericImage<T7> &im7, GenericImage<T8> &im8, GenericImage<T9> &im9)
16983 {
16984  if (VoxelFunc::IsReduction()) _foreachnonaryvoxelfunction_must_not_be_reduction();
16985  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, im9, vf);
16986 }
16987 
16988 
16989 } // namespace mirtk
16990 
16991 #endif
NonaryForEachVoxelBody_2Const(const NonaryForEachVoxelBody_2Const &o)
Copy constructor.
NonaryForEachVoxelBody_1Const(const NonaryForEachVoxelBody_1Const &o)
Copy constructor.
double _dt
Voxel t-dimensions (in ms)
NonaryForEachVoxelBody_6Const(const NonaryForEachVoxelBody_6Const &o)
Copy constructor.
NonaryForEachVoxelBody_2Const(NonaryForEachVoxelBody_2Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_5Const(const NonaryForEachVoxelBody_5Const &o)
Copy constructor.
Dummy type used to distinguish split constructor from copy constructor.
Definition: Parallel.h:143
NonaryForEachVoxelIfBody_5Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_8Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, const GenericImage< T7 > &im7, const GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_2Const(NonaryForEachVoxelIfBody_2Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_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, const GenericImage< T7 > &im7, const GenericImage< T8 > &im8, const GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
Two-dimensional range.
Definition: Parallel.h:168
bool IsEmpty() const
Whether image is uninitialized.
Definition: BaseImage.h:1283
NonaryForEachVoxelBody_3Const(NonaryForEachVoxelBody_3Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_Const(const NonaryForEachVoxelBody_Const &o)
Copy constructor.
NonaryForEachVoxelIfBody_7Const(NonaryForEachVoxelIfBody_7Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_Const(const NonaryForEachVoxelIfBody_Const &o)
Copy constructor.
NonaryForEachVoxelBody(const NonaryForEachVoxelBody &o)
Copy constructor.
int _y
Image y-dimension (in voxels)
NonaryForEachVoxelBody_8Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, const GenericImage< T7 > &im7, const GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelIfBody_4Const(NonaryForEachVoxelIfBody_4Const &o, split s)
Split constructor.
One-dimensional range.
Definition: Parallel.h:155
NonaryForEachVoxelBody(NonaryForEachVoxelBody &o, split s)
Split constructor.
VoxelFunc _VoxelFunc
Functor executed for each voxel.
NonaryForEachVoxelBody_Const(NonaryForEachVoxelBody_Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_1Const(NonaryForEachVoxelIfBody_1Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_8Const(const NonaryForEachVoxelBody_8Const &o)
Copy constructor.
NonaryForEachVoxelIfBody_1Const(const GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_3Const(NonaryForEachVoxelIfBody_3Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_6Const(NonaryForEachVoxelBody_6Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_1Const(NonaryForEachVoxelBody_1Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_4Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
Definition: IOConfig.h:41
NonaryForEachVoxelIfBody_8Const(const NonaryForEachVoxelIfBody_8Const &o)
Copy 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
NonaryForEachVoxelBody_3Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelIfBody_1Const(const NonaryForEachVoxelIfBody_1Const &o)
Copy constructor.
NonaryForEachVoxelBody_7Const(const NonaryForEachVoxelBody_7Const &o)
Copy constructor.
NonaryForEachVoxelIfBody(NonaryForEachVoxelIfBody &o, split s)
Split constructor.
int _z
Image z-dimension (in voxels)
int _l
Indices for fixed dimensions.
NonaryForEachVoxelIfBody_2Const(const NonaryForEachVoxelIfBody_2Const &o)
Copy constructor.
NonaryForEachVoxelBody_4Const(NonaryForEachVoxelBody_4Const &o, split s)
Split constructor.
int _t
Image t-dimension (in voxels)
NonaryForEachVoxelIfBody_7Const(const NonaryForEachVoxelIfBody_7Const &o)
Copy constructor.
int GetT() const
Returns the number of voxels in the t-direction.
Definition: BaseImage.h:922
int GetY() const
Returns the number of voxels in the y-direction.
Definition: BaseImage.h:910
Three-dimensional range.
Definition: Parallel.h:197
int GetNumberOfVoxels() const
Definition: BaseImage.h:1741
NonaryForEachVoxelBody_3Const(const NonaryForEachVoxelBody_3Const &o)
Copy constructor.
NonaryForEachVoxelIfBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_Const(NonaryForEachVoxelIfBody_Const &o, split s)
Split constructor.
OutsideFunc _OutsideFunc
Functor executed for each background voxel.
NonaryForEachVoxelBody_6Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelBody_8Const(NonaryForEachVoxelBody_8Const &o, split s)
Split constructor.
NonaryForEachVoxelBody_7Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, const GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelBody_2Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelBody_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, const GenericImage< T7 > &im7, const GenericImage< T8 > &im8, const GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
NonaryForEachVoxelBody_7Const(NonaryForEachVoxelBody_7Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_4Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_3Const(const NonaryForEachVoxelIfBody_3Const &o)
Copy constructor.
NonaryForEachVoxelIfBody(const NonaryForEachVoxelIfBody &o)
Copy constructor.
double GetTSize() const
Returns the size of a voxel in the t-direction.
Definition: BaseImage.h:970
NonaryForEachVoxelIfBody_6Const(NonaryForEachVoxelIfBody_6Const &o, split s)
Split constructor.
void operator()(const ImageAttributes &attr) const
Process entire image.
NonaryForEachVoxelIfBody_5Const(NonaryForEachVoxelIfBody_5Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_6Const(const NonaryForEachVoxelIfBody_6Const &o)
Copy constructor.
NonaryForEachVoxelBody_1Const(const GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
int _x
Image x-dimension (in voxels)
NonaryForEachVoxelIfBody_5Const(const NonaryForEachVoxelIfBody_5Const &o)
Copy constructor.
NonaryForEachVoxelIfBody_4Const(const NonaryForEachVoxelIfBody_4Const &o)
Copy constructor.
NonaryForEachVoxelBody_4Const(const NonaryForEachVoxelBody_4Const &o)
Copy constructor.
NonaryForEachVoxelIfBody_3Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelIfBody_7Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, const GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
void parallel_reduce(const Range &range, Body &body)
parallel_reduce dummy template function which executes the body serially
Definition: Parallel.h:238
NonaryForEachVoxelIfBody_8Const(NonaryForEachVoxelIfBody_8Const &o, split s)
Split constructor.
NonaryForEachVoxelIfBody_2Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelBody_5Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.
void parallel_for(const Range &range, const Body &body)
parallel_for dummy template function which executes the body serially
Definition: Parallel.h:232
NonaryForEachVoxelIfBody_6Const(const GenericImage< T1 > &im1, const GenericImage< T2 > &im2, const GenericImage< T3 > &im3, const GenericImage< T4 > &im4, const GenericImage< T5 > &im5, const GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf, OutsideFunc &of)
Constructor.
NonaryForEachVoxelBody_5Const(NonaryForEachVoxelBody_5Const &o, split s)
Split constructor.
NonaryForEachVoxelBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, GenericImage< T9 > &im9, VoxelFunc &vf)
Constructor.