ForEachOctaryVoxelFunction.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_ForEachOctaryVoxelFunction_H
31 #define MIRTK_ForEachOctaryVoxelFunction_H
32 
33 #include "mirtk/Stream.h"
34 #include "mirtk/VoxelFunction.h"
35 
36 
37 namespace mirtk {
38 
39 
40 inline void _foreachoctaryvoxelfunction_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 // 8 const images
50 // =============================================================================
51 
52 // -----------------------------------------------------------------------------
53 /**
54  * ForEachVoxel body for voxel function of 8 const images
55  */
56 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, 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 
68  /// Constructor
70  const GenericImage<T2> &im2,
71  const GenericImage<T3> &im3,
72  const GenericImage<T4> &im4,
73  const GenericImage<T5> &im5,
74  const GenericImage<T6> &im6,
75  const GenericImage<T7> &im7,
76  const GenericImage<T8> &im8,
77  VoxelFunc &vf)
78  :
79  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
80  {}
81 
82  /// Copy constructor
84  :
85  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)
86  {}
87 
88  /// Split constructor
90  :
91  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)
92  {}
93 
94  /// Process entire image
95  void operator ()(const ImageAttributes &attr) const
96  {
97  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
98  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
99  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
100  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
101  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
102  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
103  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
104  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
105 
106  const int T = (attr._dt ? attr._t : 1);
107 
108  for (int l = 0; l < T; ++l)
109  for (int k = 0; k < attr._z; ++k)
110  for (int j = 0; j < attr._y; ++j)
111  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
112  // const_cast such that voxel functions need only implement
113  // non-const operator() which is required for parallel_reduce
114  const_cast<OctaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
115  }
116  }
117 
118  /// Process image region using linear index
119  void operator ()(const blocked_range<int> &re) const
120  {
121  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
122  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
123  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
124  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
125  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
126  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
127  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
128  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
129 
130  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) {
131  // const_cast such that voxel functions need only implement
132  // non-const operator() which is required for parallel_reduce
133  const_cast<OctaryForEachVoxelBody_Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
134  }
135  }
136 
137  /// Process 2D image region
138  void operator ()(const blocked_range2d<int> &re) const
139  {
140  const int bi = re.cols().begin();
141  const int bj = re.rows().begin();
142  const int ei = re.cols().end();
143  const int ej = re.rows().end();
144 
145  const int s1 = im8.GetX() - (ei - bi);
146 
147  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
148  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
149  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
150  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
151  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
152  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
153  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
154  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
155 
156  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
157  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
158  // const_cast such that voxel functions need only implement
159  // non-const operator() which is required for parallel_reduce
160  const_cast<OctaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
161  }
162  }
163 
164  /// Process 3D image region
165  void operator ()(const blocked_range3d<int> &re) const
166  {
167  const int bi = re.cols ().begin();
168  const int bj = re.rows ().begin();
169  const int bk = re.pages().begin();
170  const int ei = re.cols ().end();
171  const int ej = re.rows ().end();
172  const int ek = re.pages().end();
173 
174  const int s1 = im8.GetX() - (ei - bi);
175  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
176 
177  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
178  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
179  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
180  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
181  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
182  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
183  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
184  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
185 
186  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
187  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
188  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
189  // const_cast such that voxel functions need only implement
190  // non-const operator() which is required for parallel_reduce
191  const_cast<OctaryForEachVoxelBody_Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
192  }
193  }
194 };
195 
196 // -----------------------------------------------------------------------------
197 /**
198  * ForEachVoxel body for inside and outside unary voxel function of 8 const images
199  */
200 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
201  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
202  class Domain = ForEachVoxelDomain::Foreground>
203 struct OctaryForEachVoxelIfBody_Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
204 {
205  const GenericImage<T1> &im1;
206  const GenericImage<T2> &im2;
207  const GenericImage<T3> &im3;
208  const GenericImage<T4> &im4;
209  const GenericImage<T5> &im5;
210  const GenericImage<T6> &im6;
211  const GenericImage<T7> &im7;
212  const GenericImage<T8> &im8;
213 
214  /// Constructor
216  const GenericImage<T2> &im2,
217  const GenericImage<T3> &im3,
218  const GenericImage<T4> &im4,
219  const GenericImage<T5> &im5,
220  const GenericImage<T6> &im6,
221  const GenericImage<T7> &im7,
222  const GenericImage<T8> &im8,
223  VoxelFunc &vf, OutsideFunc &of)
224  :
225  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
226  {}
227 
228  /// Copy constructor
230  :
231  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)
232  {}
233 
234  /// Split constructor
236  :
237  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)
238  {}
239 
240  /// Process entire image
241  void operator ()(const ImageAttributes &attr) const
242  {
243  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
244  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
245  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
246  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
247  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
248  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
249  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
250  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
251 
252  const int T = (attr._dt ? attr._t : 1);
253 
254  for (int l = 0; l < T; ++l)
255  for (int k = 0; k < attr._z; ++k)
256  for (int j = 0; j < attr._y; ++j)
257  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
258  if (Domain::IsInside(im8, i, j, k, l, p8)) {
259  // const_cast such that voxel functions need only implement
260  // non-const operator() which is required for parallel_reduce
261  const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
262  } else const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
263  }
264  }
265 
266  /// Process image region using linear index
267  void operator ()(const blocked_range<int> &re) const
268  {
269  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
270  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
271  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
272  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
273  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
274  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
275  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
276  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
277 
278  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) {
279  if (Domain::IsInside(im8, idx, p8)) {
280  // const_cast such that voxel functions need only implement
281  // non-const operator() which is required for parallel_reduce
282  const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
283  } else const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
284  }
285  }
286 
287  /// Process 2D image region
288  void operator ()(const blocked_range2d<int> &re) const
289  {
290  const int bi = re.cols().begin();
291  const int bj = re.rows().begin();
292  const int ei = re.cols().end();
293  const int ej = re.rows().end();
294 
295  const int s1 = im8.GetX() - (ei - bi);
296 
297  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
298  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
299  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
300  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
301  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
302  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
303  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
304  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
305 
306  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
307  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
308  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
309  // const_cast such that voxel functions need only implement
310  // non-const operator() which is required for parallel_reduce
311  const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
312  } else const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
313  }
314  }
315 
316  /// Process 3D image region
317  void operator ()(const blocked_range3d<int> &re) const
318  {
319  const int bi = re.cols ().begin();
320  const int bj = re.rows ().begin();
321  const int bk = re.pages().begin();
322  const int ei = re.cols ().end();
323  const int ej = re.rows ().end();
324  const int ek = re.pages().end();
325 
326  const int s1 = im8.GetX() - (ei - bi);
327  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
328 
329  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
330  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
331  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
332  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
333  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
334  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
335  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
336  const T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
337 
338  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
339  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
340  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
341  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
342  // const_cast such that voxel functions need only implement
343  // non-const operator() which is required for parallel_reduce
344  const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
345  } else const_cast<OctaryForEachVoxelIfBody_Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
346  }
347  }
348 };
349 
350 // -----------------------------------------------------------------------------
351 // ForEachVoxel
352 // -----------------------------------------------------------------------------
353 
354 //
355 // Image arguments by pointer
356 //
357 
358 // -----------------------------------------------------------------------------
359 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
360 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, VoxelFunc &vf)
361 {
362  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
364  body(re);
365  vf.join(body._VoxelFunc);
366 }
367 
368 // -----------------------------------------------------------------------------
369 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
370 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)
371 {
372  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
373  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
374 }
375 
376 // -----------------------------------------------------------------------------
377 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
378 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, VoxelFunc &vf)
379 {
380  if (im8->GetTSize()) {
381  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
382  } else {
383  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
384  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
385  body(re);
386  vf.join(body._VoxelFunc);
387  }
388 }
389 
390 // -----------------------------------------------------------------------------
391 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
392 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)
393 {
394  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
395  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
396 }
397 
398 // -----------------------------------------------------------------------------
399 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
400 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, VoxelFunc &vf)
401 {
402  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
403  body(attr);
404  vf.join(body._VoxelFunc);
405 }
406 
407 // -----------------------------------------------------------------------------
408 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
409 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)
410 {
411  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
412  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
413 }
414 
415 // -----------------------------------------------------------------------------
416 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
417 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, VoxelFunc &vf)
418 {
419  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
420  body(re);
421  vf.join(body._VoxelFunc);
422 }
423 
424 // -----------------------------------------------------------------------------
425 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
426 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)
427 {
428  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
429  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
430 }
431 
432 // -----------------------------------------------------------------------------
433 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
434 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, VoxelFunc &vf)
435 {
436  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
437  body(re);
438  vf.join(body._VoxelFunc);
439 }
440 
441 // -----------------------------------------------------------------------------
442 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
443 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)
444 {
445  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
446  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
447 }
448 
449 // -----------------------------------------------------------------------------
450 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
451 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, VoxelFunc &vf)
452 {
453  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
454  body(re);
455  vf.join(body._VoxelFunc);
456 }
457 
458 // -----------------------------------------------------------------------------
459 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
460 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)
461 {
462  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
463  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
464 }
465 
466 //
467 // Image arguments by reference
468 //
469 
470 // -----------------------------------------------------------------------------
471 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
472 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, VoxelFunc &vf)
473 {
474  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
476  body(re);
477  vf.join(body._VoxelFunc);
478 }
479 
480 // -----------------------------------------------------------------------------
481 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
482 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)
483 {
484  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
485  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
486 }
487 
488 // -----------------------------------------------------------------------------
489 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
490 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, VoxelFunc &vf)
491 {
492  if (im8.GetTSize()) {
493  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
494  } else {
495  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
496  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
497  body(re);
498  vf.join(body._VoxelFunc);
499  }
500 }
501 
502 // -----------------------------------------------------------------------------
503 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
504 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)
505 {
506  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
507  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
508 }
509 
510 // -----------------------------------------------------------------------------
511 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
512 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, VoxelFunc &vf)
513 {
514  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
515  body(attr);
516  vf.join(body._VoxelFunc);
517 }
518 
519 // -----------------------------------------------------------------------------
520 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
521 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)
522 {
523  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
524  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
525 }
526 
527 // -----------------------------------------------------------------------------
528 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
529 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, VoxelFunc &vf)
530 {
531  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
532  body(re);
533  vf.join(body._VoxelFunc);
534 }
535 
536 // -----------------------------------------------------------------------------
537 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
538 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)
539 {
540  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
541  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
542 }
543 
544 // -----------------------------------------------------------------------------
545 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
546 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, VoxelFunc &vf)
547 {
548  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
549  body(re);
550  vf.join(body._VoxelFunc);
551 }
552 
553 // -----------------------------------------------------------------------------
554 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
555 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)
556 {
557  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
558  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
559 }
560 
561 // -----------------------------------------------------------------------------
562 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
563 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, VoxelFunc &vf)
564 {
565  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
566  body(re);
567  vf.join(body._VoxelFunc);
568 }
569 
570 // -----------------------------------------------------------------------------
571 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
572 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)
573 {
574  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
575  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
576 }
577 
578 // -----------------------------------------------------------------------------
579 // ForEachVoxelIf
580 // -----------------------------------------------------------------------------
581 
582 //
583 // Image arguments by pointer
584 //
585 
586 // -----------------------------------------------------------------------------
587 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
588 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, VoxelFunc &vf, OutsideFunc &of)
589 {
590  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
592  body(re);
593  vf.join(body._VoxelFunc);
594  of.join(body._OutsideFunc);
595 }
596 
597 // -----------------------------------------------------------------------------
598 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
599 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)
600 {
601  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
602  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
603 }
604 
605 // -----------------------------------------------------------------------------
606 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
607 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, VoxelFunc &vf)
608 {
610  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
611 }
612 
613 // -----------------------------------------------------------------------------
614 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
615 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)
616 {
617  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
618  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
619 }
620 
621 // -----------------------------------------------------------------------------
622 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
623 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, VoxelFunc &vf, OutsideFunc &of)
624 {
625  if (im8->GetTSize()) {
626  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
627  } else {
628  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
629  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
630  body(re);
631  vf.join(body._VoxelFunc);
632  of.join(body._OutsideFunc);
633  }
634 }
635 
636 // -----------------------------------------------------------------------------
637 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
638 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)
639 {
640  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
641  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
642 }
643 
644 // -----------------------------------------------------------------------------
645 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
646 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, VoxelFunc &vf)
647 {
649  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
650 }
651 
652 // -----------------------------------------------------------------------------
653 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
654 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)
655 {
656  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
657  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
658 }
659 
660 // -----------------------------------------------------------------------------
661 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
662 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, VoxelFunc &vf, OutsideFunc &of)
663 {
664  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
665  body(attr);
666  vf.join(body._VoxelFunc);
667  of.join(body._OutsideFunc);
668 }
669 
670 // -----------------------------------------------------------------------------
671 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
672 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)
673 {
674  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
675  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
676 }
677 
678 // -----------------------------------------------------------------------------
679 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
680 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, VoxelFunc &vf)
681 {
683  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
684 }
685 
686 // -----------------------------------------------------------------------------
687 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
688 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)
689 {
690  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
691  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
692 }
693 
694 // -----------------------------------------------------------------------------
695 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
696 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, VoxelFunc &vf, OutsideFunc &of)
697 {
698  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
699  body(re);
700  vf.join(body._VoxelFunc);
701  of.join(body._OutsideFunc);
702 }
703 
704 // -----------------------------------------------------------------------------
705 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
706 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)
707 {
708  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
709  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
710 }
711 
712 // -----------------------------------------------------------------------------
713 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
714 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, VoxelFunc &vf, OutsideFunc &of)
715 {
716  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
717  body(re);
718  vf.join(body._VoxelFunc);
719  of.join(body._OutsideFunc);
720 }
721 
722 // -----------------------------------------------------------------------------
723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
724 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)
725 {
726  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
727  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
728 }
729 
730 // -----------------------------------------------------------------------------
731 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
732 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, VoxelFunc &vf)
733 {
735  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
736 }
737 
738 // -----------------------------------------------------------------------------
739 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
740 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)
741 {
742  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
743  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
744 }
745 
746 // -----------------------------------------------------------------------------
747 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
748 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, VoxelFunc &vf, OutsideFunc &of)
749 {
750  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
751  body(re);
752  vf.join(body._VoxelFunc);
753  of.join(body._OutsideFunc);
754 }
755 
756 // -----------------------------------------------------------------------------
757 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
758 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)
759 {
760  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
761  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
762 }
763 
764 // -----------------------------------------------------------------------------
765 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
766 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, VoxelFunc &vf)
767 {
769  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
770 }
771 
772 // -----------------------------------------------------------------------------
773 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
774 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)
775 {
776  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
777  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
778 }
779 
780 //
781 // Image arguments by reference
782 //
783 
784 // -----------------------------------------------------------------------------
785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
786 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, VoxelFunc &vf, OutsideFunc &of)
787 {
790  body(re);
791  vf.join(body._VoxelFunc);
792  of.join(body._OutsideFunc);
793 }
794 
795 // -----------------------------------------------------------------------------
796 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
797 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)
798 {
799  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
800  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
801 }
802 
803 // -----------------------------------------------------------------------------
804 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
805 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, VoxelFunc &vf)
806 {
808  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
809 }
810 
811 // -----------------------------------------------------------------------------
812 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
813 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)
814 {
815  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
816  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
817 }
818 
819 // -----------------------------------------------------------------------------
820 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
821 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, VoxelFunc &vf, OutsideFunc &of)
822 {
823  if (im8.GetTSize()) {
824  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
825  } else {
827  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
828  body(re);
829  vf.join(body._VoxelFunc);
830  of.join(body._OutsideFunc);
831  }
832 }
833 
834 // -----------------------------------------------------------------------------
835 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
836 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)
837 {
838  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
839  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
840 }
841 
842 // -----------------------------------------------------------------------------
843 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
844 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, VoxelFunc &vf)
845 {
847  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
848 }
849 
850 // -----------------------------------------------------------------------------
851 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
852 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)
853 {
854  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
855  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
856 }
857 
858 // -----------------------------------------------------------------------------
859 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
860 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, VoxelFunc &vf, OutsideFunc &of)
861 {
863  body(attr);
864  vf.join(body._VoxelFunc);
865  of.join(body._OutsideFunc);
866 }
867 
868 // -----------------------------------------------------------------------------
869 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
870 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)
871 {
872  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
873  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
874 }
875 
876 // -----------------------------------------------------------------------------
877 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
878 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, VoxelFunc &vf)
879 {
881  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
882 }
883 
884 // -----------------------------------------------------------------------------
885 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
886 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)
887 {
888  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
889  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
890 }
891 
892 // -----------------------------------------------------------------------------
893 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
894 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, VoxelFunc &vf, OutsideFunc &of)
895 {
897  body(re);
898  vf.join(body._VoxelFunc);
899  of.join(body._OutsideFunc);
900 }
901 
902 // -----------------------------------------------------------------------------
903 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
904 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)
905 {
906  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
907  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
908 }
909 
910 // -----------------------------------------------------------------------------
911 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
912 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, VoxelFunc &vf, OutsideFunc &of)
913 {
915  body(re);
916  vf.join(body._VoxelFunc);
917  of.join(body._OutsideFunc);
918 }
919 
920 // -----------------------------------------------------------------------------
921 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
922 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)
923 {
924  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
925  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
926 }
927 
928 // -----------------------------------------------------------------------------
929 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
930 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, VoxelFunc &vf)
931 {
933  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
934 }
935 
936 // -----------------------------------------------------------------------------
937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
938 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)
939 {
940  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
941  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
942 }
943 
944 // -----------------------------------------------------------------------------
945 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
946 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, VoxelFunc &vf, OutsideFunc &of)
947 {
949  body(re);
950  vf.join(body._VoxelFunc);
951  of.join(body._OutsideFunc);
952 }
953 
954 // -----------------------------------------------------------------------------
955 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
956 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)
957 {
958  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
959  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
960 }
961 
962 // -----------------------------------------------------------------------------
963 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
964 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, VoxelFunc &vf)
965 {
967  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
968 }
969 
970 // -----------------------------------------------------------------------------
971 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
972 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)
973 {
974  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
975  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
976 }
977 
978 // -----------------------------------------------------------------------------
979 // ParallelForEachVoxel
980 // -----------------------------------------------------------------------------
981 
982 //
983 // Image arguments by pointer
984 //
985 
986 // -----------------------------------------------------------------------------
987 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
988 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, VoxelFunc &vf)
989 {
990  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
992  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
993  else parallel_for (re, body);
994 }
995 
996 // -----------------------------------------------------------------------------
997 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
998 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)
999 {
1000  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1001  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1002 }
1003 
1004 // -----------------------------------------------------------------------------
1005 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1006 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, VoxelFunc &vf)
1007 {
1008  if (im8->GetTSize()) {
1009  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1010  } else {
1011  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1012  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
1013  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1014  else parallel_for (re, body);
1015  }
1016 }
1017 
1018 // -----------------------------------------------------------------------------
1019 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1020 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)
1021 {
1022  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1023  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1024 }
1025 
1026 // -----------------------------------------------------------------------------
1027 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1028 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, VoxelFunc &vf)
1029 {
1030  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1031  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1032  if (VoxelFunc::IsReduction()) {
1033  if (attr._dt) {
1034  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1035  } else {
1036  parallel_reduce(re, body);
1037  }
1038  vf.join(body._VoxelFunc);
1039  } else {
1040  if (attr._dt) {
1041  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1042  } else {
1043  parallel_for(re, body);
1044  }
1045  }
1046 }
1047 
1048 // -----------------------------------------------------------------------------
1049 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1050 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)
1051 {
1052  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1053  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1054 }
1055 
1056 // -----------------------------------------------------------------------------
1057 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1058 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, VoxelFunc &vf)
1059 {
1060  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1061  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1062  else parallel_for (re, body);
1063 }
1064 
1065 // -----------------------------------------------------------------------------
1066 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1067 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)
1068 {
1069  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1070  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1071 }
1072 
1073 // -----------------------------------------------------------------------------
1074 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1075 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, VoxelFunc &vf)
1076 {
1077  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1078  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1079  else parallel_for (re, body);
1080 }
1081 
1082 // -----------------------------------------------------------------------------
1083 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1084 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)
1085 {
1086  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1087  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1088 }
1089 
1090 // -----------------------------------------------------------------------------
1091 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1092 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, VoxelFunc &vf)
1093 {
1094  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1095  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1096  else parallel_for (re, body);
1097 }
1098 
1099 // -----------------------------------------------------------------------------
1100 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1101 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)
1102 {
1103  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1104  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1105 }
1106 
1107 //
1108 // Image arguments by reference
1109 //
1110 
1111 // -----------------------------------------------------------------------------
1112 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1113 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, VoxelFunc &vf)
1114 {
1115  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1117  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1118  else parallel_for (re, body);
1119 }
1120 
1121 // -----------------------------------------------------------------------------
1122 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1123 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)
1124 {
1125  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1126  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1127 }
1128 
1129 // -----------------------------------------------------------------------------
1130 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1131 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, VoxelFunc &vf)
1132 {
1133  if (im8.GetTSize()) {
1134  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1135  } else {
1136  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1137  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
1138  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1139  else parallel_for (re, body);
1140  }
1141 }
1142 
1143 // -----------------------------------------------------------------------------
1144 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1145 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)
1146 {
1147  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1148  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1149 }
1150 
1151 // -----------------------------------------------------------------------------
1152 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1153 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, VoxelFunc &vf)
1154 {
1155  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1156  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1157  if (VoxelFunc::IsReduction()) {
1158  if (attr._dt) {
1159  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1160  } else {
1161  parallel_reduce(re, body);
1162  }
1163  vf.join(body._VoxelFunc);
1164  } else {
1165  if (attr._dt) {
1166  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1167  } else {
1168  parallel_for(re, body);
1169  }
1170  }
1171 }
1172 
1173 // -----------------------------------------------------------------------------
1174 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1175 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)
1176 {
1177  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1178  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1179 }
1180 
1181 // -----------------------------------------------------------------------------
1182 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1183 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, VoxelFunc &vf)
1184 {
1185  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1186  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1187  else parallel_for (re, body);
1188 }
1189 
1190 // -----------------------------------------------------------------------------
1191 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1192 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)
1193 {
1194  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1195  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1196 }
1197 
1198 // -----------------------------------------------------------------------------
1199 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1200 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, VoxelFunc &vf)
1201 {
1202  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1203  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1204  else parallel_for (re, body);
1205 }
1206 
1207 // -----------------------------------------------------------------------------
1208 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1209 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)
1210 {
1211  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1212  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1213 }
1214 
1215 // -----------------------------------------------------------------------------
1216 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1217 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, VoxelFunc &vf)
1218 {
1219  OctaryForEachVoxelBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1220  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
1221  else parallel_for (re, body);
1222 }
1223 
1224 // -----------------------------------------------------------------------------
1225 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1226 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)
1227 {
1228  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1229  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1230 }
1231 
1232 // -----------------------------------------------------------------------------
1233 // ParallelForEachVoxelIf
1234 // -----------------------------------------------------------------------------
1235 
1236 //
1237 // Image arguments by pointer
1238 //
1239 
1240 // -----------------------------------------------------------------------------
1241 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1242 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, VoxelFunc &vf, OutsideFunc &of)
1243 {
1244  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1245  blocked_range<int> re(0, im8->GetNumberOfVoxels());
1246  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1247  parallel_reduce(re, body);
1248  vf.join(body._VoxelFunc);
1249  of.join(body._OutsideFunc);
1250  } else {
1251  parallel_for(re, body);
1252  }
1253 }
1254 
1255 // -----------------------------------------------------------------------------
1256 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1257 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)
1258 {
1259  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1260  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1261 }
1262 
1263 // -----------------------------------------------------------------------------
1264 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1265 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, VoxelFunc &vf)
1266 {
1268  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1269 }
1270 
1271 // -----------------------------------------------------------------------------
1272 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1273 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)
1274 {
1275  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1276  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1277 }
1278 
1279 // -----------------------------------------------------------------------------
1280 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1281 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, VoxelFunc &vf, OutsideFunc &of)
1282 {
1283  if (im8->GetTSize()) {
1284  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1285  } else {
1286  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1287  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
1288  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1289  parallel_reduce(re, body);
1290  vf.join(body._VoxelFunc);
1291  of.join(body._OutsideFunc);
1292  } else {
1293  parallel_for(re, body);
1294  }
1295  }
1296 }
1297 
1298 // -----------------------------------------------------------------------------
1299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1300 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)
1301 {
1302  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1303  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1304 }
1305 
1306 // -----------------------------------------------------------------------------
1307 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1308 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, VoxelFunc &vf)
1309 {
1311  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1312 }
1313 
1314 // -----------------------------------------------------------------------------
1315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1316 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)
1317 {
1318  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1319  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1320 }
1321 
1322 // -----------------------------------------------------------------------------
1323 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1324 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, VoxelFunc &vf, OutsideFunc &of)
1325 {
1326  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1327  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1328  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1329  if (attr._dt) {
1330  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1331  } else {
1332  parallel_reduce(re, body);
1333  }
1334  vf.join(body._VoxelFunc);
1335  of.join(body._OutsideFunc);
1336  } else {
1337  if (attr._dt) {
1338  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1339  } else {
1340  parallel_for(re, body);
1341  }
1342  }
1343 }
1344 
1345 // -----------------------------------------------------------------------------
1346 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1347 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)
1348 {
1349  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1350  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1351 }
1352 
1353 // -----------------------------------------------------------------------------
1354 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1355 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, VoxelFunc &vf)
1356 {
1358  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1359 }
1360 
1361 // -----------------------------------------------------------------------------
1362 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1363 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)
1364 {
1365  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1366  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1367 }
1368 
1369 // -----------------------------------------------------------------------------
1370 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1371 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, VoxelFunc &vf, OutsideFunc &of)
1372 {
1373  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1374  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1375  parallel_reduce(re, body);
1376  vf.join(body._VoxelFunc);
1377  of.join(body._OutsideFunc);
1378  } else {
1379  parallel_for(re, body);
1380  }
1381 }
1382 
1383 // -----------------------------------------------------------------------------
1384 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1385 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)
1386 {
1387  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1388  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1389 }
1390 
1391 // -----------------------------------------------------------------------------
1392 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1393 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, VoxelFunc &vf)
1394 {
1396  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1397 }
1398 
1399 // -----------------------------------------------------------------------------
1400 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1401 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)
1402 {
1403  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1404  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1405 }
1406 
1407 // -----------------------------------------------------------------------------
1408 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1409 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, VoxelFunc &vf, OutsideFunc &of)
1410 {
1411  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1412  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1413  parallel_reduce(re, body);
1414  vf.join(body._VoxelFunc);
1415  of.join(body._OutsideFunc);
1416  } else {
1417  parallel_for(re, body);
1418  }
1419 }
1420 
1421 // -----------------------------------------------------------------------------
1422 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1423 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)
1424 {
1425  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1426  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1427 }
1428 
1429 // -----------------------------------------------------------------------------
1430 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1431 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, VoxelFunc &vf)
1432 {
1434  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1435 }
1436 
1437 // -----------------------------------------------------------------------------
1438 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1439 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)
1440 {
1441  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1442  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1443 }
1444 
1445 // -----------------------------------------------------------------------------
1446 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1447 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, VoxelFunc &vf, OutsideFunc &of)
1448 {
1449  OctaryForEachVoxelIfBody_Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1450  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1451  parallel_reduce(re, body);
1452  vf.join(body._VoxelFunc);
1453  of.join(body._OutsideFunc);
1454  } else {
1455  parallel_for(re, body);
1456  }
1457 }
1458 
1459 // -----------------------------------------------------------------------------
1460 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1461 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)
1462 {
1463  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1464  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1465 }
1466 
1467 // -----------------------------------------------------------------------------
1468 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1469 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, VoxelFunc &vf)
1470 {
1472  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
1473 }
1474 
1475 // -----------------------------------------------------------------------------
1476 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1477 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)
1478 {
1479  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1480  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
1481 }
1482 
1483 //
1484 // Image arguments by reference
1485 //
1486 
1487 // -----------------------------------------------------------------------------
1488 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1489 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, VoxelFunc &vf, OutsideFunc &of)
1490 {
1493  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1494  parallel_reduce(re, body);
1495  vf.join(body._VoxelFunc);
1496  of.join(body._OutsideFunc);
1497  } else {
1498  parallel_for(re, body);
1499  }
1500 }
1501 
1502 // -----------------------------------------------------------------------------
1503 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1504 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)
1505 {
1506  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1507  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1508 }
1509 
1510 // -----------------------------------------------------------------------------
1511 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1512 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, VoxelFunc &vf)
1513 {
1515  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1516 }
1517 
1518 // -----------------------------------------------------------------------------
1519 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1520 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)
1521 {
1522  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1523  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1524 }
1525 
1526 // -----------------------------------------------------------------------------
1527 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1528 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, VoxelFunc &vf, OutsideFunc &of)
1529 {
1530  if (im8.GetTSize()) {
1531  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1532  } else {
1534  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
1535  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1536  parallel_reduce(re, body);
1537  vf.join(body._VoxelFunc);
1538  of.join(body._OutsideFunc);
1539  } else {
1540  parallel_for(re, body);
1541  }
1542  }
1543 }
1544 
1545 // -----------------------------------------------------------------------------
1546 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1547 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)
1548 {
1549  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1550  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1551 }
1552 
1553 // -----------------------------------------------------------------------------
1554 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1555 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, VoxelFunc &vf)
1556 {
1558  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1559 }
1560 
1561 // -----------------------------------------------------------------------------
1562 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1563 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)
1564 {
1565  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1566  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
1567 }
1568 
1569 // -----------------------------------------------------------------------------
1570 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1571 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, VoxelFunc &vf, OutsideFunc &of)
1572 {
1574  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
1575  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1576  if (attr._dt) {
1577  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
1578  } else {
1579  parallel_reduce(re, body);
1580  }
1581  vf.join(body._VoxelFunc);
1582  of.join(body._OutsideFunc);
1583  } else {
1584  if (attr._dt) {
1585  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
1586  } else {
1587  parallel_for(re, body);
1588  }
1589  }
1590 }
1591 
1592 // -----------------------------------------------------------------------------
1593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1594 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)
1595 {
1596  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1597  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1598 }
1599 
1600 // -----------------------------------------------------------------------------
1601 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1602 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, VoxelFunc &vf)
1603 {
1605  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1606 }
1607 
1608 // -----------------------------------------------------------------------------
1609 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1610 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)
1611 {
1612  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1613  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1614 }
1615 
1616 // -----------------------------------------------------------------------------
1617 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1618 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, VoxelFunc &vf, OutsideFunc &of)
1619 {
1621  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1622  parallel_reduce(re, body);
1623  vf.join(body._VoxelFunc);
1624  of.join(body._OutsideFunc);
1625  } else {
1626  parallel_for(re, body);
1627  }
1628 }
1629 
1630 // -----------------------------------------------------------------------------
1631 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1632 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)
1633 {
1634  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1635  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1636 }
1637 
1638 // -----------------------------------------------------------------------------
1639 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1640 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, VoxelFunc &vf)
1641 {
1643  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1644 }
1645 
1646 // -----------------------------------------------------------------------------
1647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1648 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)
1649 {
1650  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1651  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1652 }
1653 
1654 // -----------------------------------------------------------------------------
1655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1656 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, VoxelFunc &vf, OutsideFunc &of)
1657 {
1659  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1660  parallel_reduce(re, body);
1661  vf.join(body._VoxelFunc);
1662  of.join(body._OutsideFunc);
1663  } else {
1664  parallel_for(re, body);
1665  }
1666 }
1667 
1668 // -----------------------------------------------------------------------------
1669 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1670 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)
1671 {
1672  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1673  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1674 }
1675 
1676 // -----------------------------------------------------------------------------
1677 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1678 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, VoxelFunc &vf)
1679 {
1681  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1682 }
1683 
1684 // -----------------------------------------------------------------------------
1685 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1686 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)
1687 {
1688  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1689  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1690 }
1691 
1692 // -----------------------------------------------------------------------------
1693 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1694 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, VoxelFunc &vf, OutsideFunc &of)
1695 {
1697  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
1698  parallel_reduce(re, body);
1699  vf.join(body._VoxelFunc);
1700  of.join(body._OutsideFunc);
1701  } else {
1702  parallel_for(re, body);
1703  }
1704 }
1705 
1706 // -----------------------------------------------------------------------------
1707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
1708 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)
1709 {
1710  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1711  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1712 }
1713 
1714 // -----------------------------------------------------------------------------
1715 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1716 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, VoxelFunc &vf)
1717 {
1719  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
1720 }
1721 
1722 // -----------------------------------------------------------------------------
1723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1724 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)
1725 {
1726  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
1727  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
1728 }
1729 
1730 // =============================================================================
1731 // 7 const, 1 non-const images
1732 // =============================================================================
1733 
1734 // -----------------------------------------------------------------------------
1735 /**
1736  * ForEachVoxel body for voxel function of 7 const, 1 non-const images
1737  */
1738 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
1740 {
1741  const GenericImage<T1> &im1;
1742  const GenericImage<T2> &im2;
1743  const GenericImage<T3> &im3;
1744  const GenericImage<T4> &im4;
1745  const GenericImage<T5> &im5;
1746  const GenericImage<T6> &im6;
1747  const GenericImage<T7> &im7;
1748  GenericImage<T8> &im8;
1749 
1750  /// Constructor
1752  const GenericImage<T2> &im2,
1753  const GenericImage<T3> &im3,
1754  const GenericImage<T4> &im4,
1755  const GenericImage<T5> &im5,
1756  const GenericImage<T6> &im6,
1757  const GenericImage<T7> &im7,
1758  GenericImage<T8> &im8,
1759  VoxelFunc &vf)
1760  :
1761  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
1762  {}
1763 
1764  /// Copy constructor
1766  :
1767  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)
1768  {}
1769 
1770  /// Split constructor
1772  :
1773  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)
1774  {}
1775 
1776  /// Process entire image
1777  void operator ()(const ImageAttributes &attr) const
1778  {
1779  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1780  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1781  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1782  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1783  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1784  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1785  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
1786  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
1787 
1788  const int T = (attr._dt ? attr._t : 1);
1789 
1790  for (int l = 0; l < T; ++l)
1791  for (int k = 0; k < attr._z; ++k)
1792  for (int j = 0; j < attr._y; ++j)
1793  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
1794  // const_cast such that voxel functions need only implement
1795  // non-const operator() which is required for parallel_reduce
1796  const_cast<OctaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
1797  }
1798  }
1799 
1800  /// Process image region using linear index
1801  void operator ()(const blocked_range<int> &re) const
1802  {
1803  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1804  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1805  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1806  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1807  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1808  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1809  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
1810  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
1811 
1812  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) {
1813  // const_cast such that voxel functions need only implement
1814  // non-const operator() which is required for parallel_reduce
1815  const_cast<OctaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
1816  }
1817  }
1818 
1819  /// Process 2D image region
1820  void operator ()(const blocked_range2d<int> &re) const
1821  {
1822  const int bi = re.cols().begin();
1823  const int bj = re.rows().begin();
1824  const int ei = re.cols().end();
1825  const int ej = re.rows().end();
1826 
1827  const int s1 = im8.GetX() - (ei - bi);
1828 
1829  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1830  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1831  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1832  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1833  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1834  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1835  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1836  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1837 
1838  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
1839  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
1840  // const_cast such that voxel functions need only implement
1841  // non-const operator() which is required for parallel_reduce
1842  const_cast<OctaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
1843  }
1844  }
1845 
1846  /// Process 3D image region
1847  void operator ()(const blocked_range3d<int> &re) const
1848  {
1849  const int bi = re.cols ().begin();
1850  const int bj = re.rows ().begin();
1851  const int bk = re.pages().begin();
1852  const int ei = re.cols ().end();
1853  const int ej = re.rows ().end();
1854  const int ek = re.pages().end();
1855 
1856  const int s1 = im8.GetX() - (ei - bi);
1857  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
1858 
1859  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
1860  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
1861  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
1862  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
1863  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
1864  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
1865  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
1866  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
1867 
1868  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
1869  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
1870  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
1871  // const_cast such that voxel functions need only implement
1872  // non-const operator() which is required for parallel_reduce
1873  const_cast<OctaryForEachVoxelBody_7Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
1874  }
1875  }
1876 };
1877 
1878 // -----------------------------------------------------------------------------
1879 /**
1880  * ForEachVoxel body for inside and outside unary voxel function of 7 const, 1 non-const images
1881  */
1882 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
1883  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
1884  class Domain = ForEachVoxelDomain::Foreground>
1885 struct OctaryForEachVoxelIfBody_7Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
1886 {
1887  const GenericImage<T1> &im1;
1888  const GenericImage<T2> &im2;
1889  const GenericImage<T3> &im3;
1890  const GenericImage<T4> &im4;
1891  const GenericImage<T5> &im5;
1892  const GenericImage<T6> &im6;
1893  const GenericImage<T7> &im7;
1894  GenericImage<T8> &im8;
1895 
1896  /// Constructor
1898  const GenericImage<T2> &im2,
1899  const GenericImage<T3> &im3,
1900  const GenericImage<T4> &im4,
1901  const GenericImage<T5> &im5,
1902  const GenericImage<T6> &im6,
1903  const GenericImage<T7> &im7,
1904  GenericImage<T8> &im8,
1905  VoxelFunc &vf, OutsideFunc &of)
1906  :
1907  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
1908  {}
1909 
1910  /// Copy constructor
1912  :
1913  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)
1914  {}
1915 
1916  /// Split constructor
1918  :
1919  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)
1920  {}
1921 
1922  /// Process entire image
1923  void operator ()(const ImageAttributes &attr) const
1924  {
1925  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
1926  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
1927  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
1928  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
1929  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
1930  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
1931  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
1932  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
1933 
1934  const int T = (attr._dt ? attr._t : 1);
1935 
1936  for (int l = 0; l < T; ++l)
1937  for (int k = 0; k < attr._z; ++k)
1938  for (int j = 0; j < attr._y; ++j)
1939  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
1940  if (Domain::IsInside(im8, i, j, k, l, p8)) {
1941  // const_cast such that voxel functions need only implement
1942  // non-const operator() which is required for parallel_reduce
1943  const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
1944  } else const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
1945  }
1946  }
1947 
1948  /// Process image region using linear index
1949  void operator ()(const blocked_range<int> &re) const
1950  {
1951  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
1952  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
1953  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
1954  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
1955  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
1956  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
1957  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
1958  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
1959 
1960  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) {
1961  if (Domain::IsInside(im8, idx, p8)) {
1962  // const_cast such that voxel functions need only implement
1963  // non-const operator() which is required for parallel_reduce
1964  const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
1965  } else const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
1966  }
1967  }
1968 
1969  /// Process 2D image region
1970  void operator ()(const blocked_range2d<int> &re) const
1971  {
1972  const int bi = re.cols().begin();
1973  const int bj = re.rows().begin();
1974  const int ei = re.cols().end();
1975  const int ej = re.rows().end();
1976 
1977  const int s1 = im8.GetX() - (ei - bi);
1978 
1979  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1980  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1981  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1982  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1983  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1984  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1985  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1986  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
1987 
1988  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
1989  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
1990  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
1991  // const_cast such that voxel functions need only implement
1992  // non-const operator() which is required for parallel_reduce
1993  const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
1994  } else const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
1995  }
1996  }
1997 
1998  /// Process 3D image region
1999  void operator ()(const blocked_range3d<int> &re) const
2000  {
2001  const int bi = re.cols ().begin();
2002  const int bj = re.rows ().begin();
2003  const int bk = re.pages().begin();
2004  const int ei = re.cols ().end();
2005  const int ej = re.rows ().end();
2006  const int ek = re.pages().end();
2007 
2008  const int s1 = im8.GetX() - (ei - bi);
2009  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
2010 
2011  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
2012  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
2013  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
2014  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
2015  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
2016  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
2017  const T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
2018  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
2019 
2020  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
2021  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
2022  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
2023  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
2024  // const_cast such that voxel functions need only implement
2025  // non-const operator() which is required for parallel_reduce
2026  const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
2027  } else const_cast<OctaryForEachVoxelIfBody_7Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
2028  }
2029  }
2030 };
2031 
2032 // -----------------------------------------------------------------------------
2033 // ForEachVoxel
2034 // -----------------------------------------------------------------------------
2035 
2036 //
2037 // Image arguments by pointer
2038 //
2039 
2040 // -----------------------------------------------------------------------------
2041 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2042 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, VoxelFunc &vf)
2043 {
2044  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2045  blocked_range<int> re(0, im8->GetNumberOfVoxels());
2046  body(re);
2047  vf.join(body._VoxelFunc);
2048 }
2049 
2050 // -----------------------------------------------------------------------------
2051 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2052 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)
2053 {
2054  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2055  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2056 }
2057 
2058 // -----------------------------------------------------------------------------
2059 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2060 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, VoxelFunc &vf)
2061 {
2062  if (im8->GetTSize()) {
2063  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2064  } else {
2065  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2066  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
2067  body(re);
2068  vf.join(body._VoxelFunc);
2069  }
2070 }
2071 
2072 // -----------------------------------------------------------------------------
2073 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2074 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)
2075 {
2076  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2077  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2078 }
2079 
2080 // -----------------------------------------------------------------------------
2081 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2082 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, VoxelFunc &vf)
2083 {
2084  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2085  body(attr);
2086  vf.join(body._VoxelFunc);
2087 }
2088 
2089 // -----------------------------------------------------------------------------
2090 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2091 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)
2092 {
2093  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2094  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2095 }
2096 
2097 // -----------------------------------------------------------------------------
2098 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2099 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, VoxelFunc &vf)
2100 {
2101  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2102  body(re);
2103  vf.join(body._VoxelFunc);
2104 }
2105 
2106 // -----------------------------------------------------------------------------
2107 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2108 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)
2109 {
2110  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2111  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2112 }
2113 
2114 // -----------------------------------------------------------------------------
2115 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2116 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, VoxelFunc &vf)
2117 {
2118  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2119  body(re);
2120  vf.join(body._VoxelFunc);
2121 }
2122 
2123 // -----------------------------------------------------------------------------
2124 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2125 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)
2126 {
2127  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2128  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2129 }
2130 
2131 // -----------------------------------------------------------------------------
2132 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2133 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, VoxelFunc &vf)
2134 {
2135  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2136  body(re);
2137  vf.join(body._VoxelFunc);
2138 }
2139 
2140 // -----------------------------------------------------------------------------
2141 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2142 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)
2143 {
2144  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2145  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2146 }
2147 
2148 //
2149 // Image arguments by reference
2150 //
2151 
2152 // -----------------------------------------------------------------------------
2153 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2154 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, VoxelFunc &vf)
2155 {
2156  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2158  body(re);
2159  vf.join(body._VoxelFunc);
2160 }
2161 
2162 // -----------------------------------------------------------------------------
2163 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2164 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)
2165 {
2166  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2167  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2168 }
2169 
2170 // -----------------------------------------------------------------------------
2171 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2172 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, VoxelFunc &vf)
2173 {
2174  if (im8.GetTSize()) {
2175  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2176  } else {
2177  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2178  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
2179  body(re);
2180  vf.join(body._VoxelFunc);
2181  }
2182 }
2183 
2184 // -----------------------------------------------------------------------------
2185 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2186 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)
2187 {
2188  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2189  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2190 }
2191 
2192 // -----------------------------------------------------------------------------
2193 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2194 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, VoxelFunc &vf)
2195 {
2196  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2197  body(attr);
2198  vf.join(body._VoxelFunc);
2199 }
2200 
2201 // -----------------------------------------------------------------------------
2202 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2203 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)
2204 {
2205  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2206  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2207 }
2208 
2209 // -----------------------------------------------------------------------------
2210 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2211 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, VoxelFunc &vf)
2212 {
2213  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2214  body(re);
2215  vf.join(body._VoxelFunc);
2216 }
2217 
2218 // -----------------------------------------------------------------------------
2219 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2220 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)
2221 {
2222  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2223  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2224 }
2225 
2226 // -----------------------------------------------------------------------------
2227 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2228 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, VoxelFunc &vf)
2229 {
2230  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2231  body(re);
2232  vf.join(body._VoxelFunc);
2233 }
2234 
2235 // -----------------------------------------------------------------------------
2236 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2237 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)
2238 {
2239  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2240  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2241 }
2242 
2243 // -----------------------------------------------------------------------------
2244 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2245 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, VoxelFunc &vf)
2246 {
2247  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2248  body(re);
2249  vf.join(body._VoxelFunc);
2250 }
2251 
2252 // -----------------------------------------------------------------------------
2253 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2254 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)
2255 {
2256  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2257  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2258 }
2259 
2260 // -----------------------------------------------------------------------------
2261 // ForEachVoxelIf
2262 // -----------------------------------------------------------------------------
2263 
2264 //
2265 // Image arguments by pointer
2266 //
2267 
2268 // -----------------------------------------------------------------------------
2269 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2270 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, VoxelFunc &vf, OutsideFunc &of)
2271 {
2272  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2273  blocked_range<int> re(0, im8->GetNumberOfVoxels());
2274  body(re);
2275  vf.join(body._VoxelFunc);
2276  of.join(body._OutsideFunc);
2277 }
2278 
2279 // -----------------------------------------------------------------------------
2280 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2281 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)
2282 {
2283  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2284  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2285 }
2286 
2287 // -----------------------------------------------------------------------------
2288 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2289 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, VoxelFunc &vf)
2290 {
2292  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2293 }
2294 
2295 // -----------------------------------------------------------------------------
2296 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2297 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)
2298 {
2299  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2300  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2301 }
2302 
2303 // -----------------------------------------------------------------------------
2304 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2305 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, VoxelFunc &vf, OutsideFunc &of)
2306 {
2307  if (im8->GetTSize()) {
2308  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2309  } else {
2310  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2311  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
2312  body(re);
2313  vf.join(body._VoxelFunc);
2314  of.join(body._OutsideFunc);
2315  }
2316 }
2317 
2318 // -----------------------------------------------------------------------------
2319 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2320 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)
2321 {
2322  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2323  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2324 }
2325 
2326 // -----------------------------------------------------------------------------
2327 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2328 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, VoxelFunc &vf)
2329 {
2331  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2332 }
2333 
2334 // -----------------------------------------------------------------------------
2335 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2336 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)
2337 {
2338  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2339  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2340 }
2341 
2342 // -----------------------------------------------------------------------------
2343 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2344 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, VoxelFunc &vf, OutsideFunc &of)
2345 {
2346  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2347  body(attr);
2348  vf.join(body._VoxelFunc);
2349  of.join(body._OutsideFunc);
2350 }
2351 
2352 // -----------------------------------------------------------------------------
2353 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2354 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)
2355 {
2356  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2357  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2358 }
2359 
2360 // -----------------------------------------------------------------------------
2361 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2362 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, VoxelFunc &vf)
2363 {
2365  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2366 }
2367 
2368 // -----------------------------------------------------------------------------
2369 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2370 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)
2371 {
2372  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2373  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2374 }
2375 
2376 // -----------------------------------------------------------------------------
2377 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2378 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, VoxelFunc &vf, OutsideFunc &of)
2379 {
2380  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2381  body(re);
2382  vf.join(body._VoxelFunc);
2383  of.join(body._OutsideFunc);
2384 }
2385 
2386 // -----------------------------------------------------------------------------
2387 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2388 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)
2389 {
2390  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2391  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2392 }
2393 
2394 // -----------------------------------------------------------------------------
2395 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2396 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, VoxelFunc &vf, OutsideFunc &of)
2397 {
2398  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2399  body(re);
2400  vf.join(body._VoxelFunc);
2401  of.join(body._OutsideFunc);
2402 }
2403 
2404 // -----------------------------------------------------------------------------
2405 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2406 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)
2407 {
2408  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2409  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2410 }
2411 
2412 // -----------------------------------------------------------------------------
2413 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2414 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, VoxelFunc &vf)
2415 {
2417  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2418 }
2419 
2420 // -----------------------------------------------------------------------------
2421 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2422 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)
2423 {
2424  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2425  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2426 }
2427 
2428 // -----------------------------------------------------------------------------
2429 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2430 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, VoxelFunc &vf, OutsideFunc &of)
2431 {
2432  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2433  body(re);
2434  vf.join(body._VoxelFunc);
2435  of.join(body._OutsideFunc);
2436 }
2437 
2438 // -----------------------------------------------------------------------------
2439 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2440 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)
2441 {
2442  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2443  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2444 }
2445 
2446 // -----------------------------------------------------------------------------
2447 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2448 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, VoxelFunc &vf)
2449 {
2451  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2452 }
2453 
2454 // -----------------------------------------------------------------------------
2455 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2456 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)
2457 {
2458  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2459  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2460 }
2461 
2462 //
2463 // Image arguments by reference
2464 //
2465 
2466 // -----------------------------------------------------------------------------
2467 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2468 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, VoxelFunc &vf, OutsideFunc &of)
2469 {
2472  body(re);
2473  vf.join(body._VoxelFunc);
2474  of.join(body._OutsideFunc);
2475 }
2476 
2477 // -----------------------------------------------------------------------------
2478 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2479 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)
2480 {
2481  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2482  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2483 }
2484 
2485 // -----------------------------------------------------------------------------
2486 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2487 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, VoxelFunc &vf)
2488 {
2490  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2491 }
2492 
2493 // -----------------------------------------------------------------------------
2494 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2495 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)
2496 {
2497  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2498  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2499 }
2500 
2501 // -----------------------------------------------------------------------------
2502 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2503 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, VoxelFunc &vf, OutsideFunc &of)
2504 {
2505  if (im8.GetTSize()) {
2506  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2507  } else {
2509  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
2510  body(re);
2511  vf.join(body._VoxelFunc);
2512  of.join(body._OutsideFunc);
2513  }
2514 }
2515 
2516 // -----------------------------------------------------------------------------
2517 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2518 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)
2519 {
2520  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2521  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2522 }
2523 
2524 // -----------------------------------------------------------------------------
2525 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2526 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, VoxelFunc &vf)
2527 {
2529  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2530 }
2531 
2532 // -----------------------------------------------------------------------------
2533 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2534 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)
2535 {
2536  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2537  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2538 }
2539 
2540 // -----------------------------------------------------------------------------
2541 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2542 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, VoxelFunc &vf, OutsideFunc &of)
2543 {
2545  body(attr);
2546  vf.join(body._VoxelFunc);
2547  of.join(body._OutsideFunc);
2548 }
2549 
2550 // -----------------------------------------------------------------------------
2551 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2552 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)
2553 {
2554  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2555  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2556 }
2557 
2558 // -----------------------------------------------------------------------------
2559 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2560 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, VoxelFunc &vf)
2561 {
2563  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2564 }
2565 
2566 // -----------------------------------------------------------------------------
2567 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2568 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)
2569 {
2570  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2571  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2572 }
2573 
2574 // -----------------------------------------------------------------------------
2575 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2576 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, VoxelFunc &vf, OutsideFunc &of)
2577 {
2579  body(re);
2580  vf.join(body._VoxelFunc);
2581  of.join(body._OutsideFunc);
2582 }
2583 
2584 // -----------------------------------------------------------------------------
2585 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2586 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)
2587 {
2588  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2589  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2590 }
2591 
2592 // -----------------------------------------------------------------------------
2593 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2594 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, VoxelFunc &vf, OutsideFunc &of)
2595 {
2597  body(re);
2598  vf.join(body._VoxelFunc);
2599  of.join(body._OutsideFunc);
2600 }
2601 
2602 // -----------------------------------------------------------------------------
2603 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2604 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)
2605 {
2606  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2607  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2608 }
2609 
2610 // -----------------------------------------------------------------------------
2611 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2612 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, VoxelFunc &vf)
2613 {
2615  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2616 }
2617 
2618 // -----------------------------------------------------------------------------
2619 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2620 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)
2621 {
2622  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2623  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2624 }
2625 
2626 // -----------------------------------------------------------------------------
2627 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2628 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, VoxelFunc &vf, OutsideFunc &of)
2629 {
2631  body(re);
2632  vf.join(body._VoxelFunc);
2633  of.join(body._OutsideFunc);
2634 }
2635 
2636 // -----------------------------------------------------------------------------
2637 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2638 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)
2639 {
2640  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2641  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2642 }
2643 
2644 // -----------------------------------------------------------------------------
2645 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2646 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, VoxelFunc &vf)
2647 {
2649  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
2650 }
2651 
2652 // -----------------------------------------------------------------------------
2653 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2654 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)
2655 {
2656  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2657  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2658 }
2659 
2660 // -----------------------------------------------------------------------------
2661 // ParallelForEachVoxel
2662 // -----------------------------------------------------------------------------
2663 
2664 //
2665 // Image arguments by pointer
2666 //
2667 
2668 // -----------------------------------------------------------------------------
2669 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2670 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, VoxelFunc &vf)
2671 {
2672  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2673  blocked_range<int> re(0, im8->GetNumberOfVoxels());
2674  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2675  else parallel_for (re, body);
2676 }
2677 
2678 // -----------------------------------------------------------------------------
2679 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2680 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)
2681 {
2682  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2683  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2684 }
2685 
2686 // -----------------------------------------------------------------------------
2687 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2688 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, VoxelFunc &vf)
2689 {
2690  if (im8->GetTSize()) {
2691  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2692  } else {
2693  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2694  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
2695  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2696  else parallel_for (re, body);
2697  }
2698 }
2699 
2700 // -----------------------------------------------------------------------------
2701 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2702 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)
2703 {
2704  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2705  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2706 }
2707 
2708 // -----------------------------------------------------------------------------
2709 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2710 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, VoxelFunc &vf)
2711 {
2712  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2713  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2714  if (VoxelFunc::IsReduction()) {
2715  if (attr._dt) {
2716  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2717  } else {
2718  parallel_reduce(re, body);
2719  }
2720  vf.join(body._VoxelFunc);
2721  } else {
2722  if (attr._dt) {
2723  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2724  } else {
2725  parallel_for(re, body);
2726  }
2727  }
2728 }
2729 
2730 // -----------------------------------------------------------------------------
2731 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2732 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)
2733 {
2734  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2735  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2736 }
2737 
2738 // -----------------------------------------------------------------------------
2739 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2740 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, VoxelFunc &vf)
2741 {
2742  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2743  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2744  else parallel_for (re, body);
2745 }
2746 
2747 // -----------------------------------------------------------------------------
2748 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2749 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)
2750 {
2751  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2752  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2753 }
2754 
2755 // -----------------------------------------------------------------------------
2756 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2757 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, VoxelFunc &vf)
2758 {
2759  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2760  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2761  else parallel_for (re, body);
2762 }
2763 
2764 // -----------------------------------------------------------------------------
2765 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2766 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)
2767 {
2768  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2769  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2770 }
2771 
2772 // -----------------------------------------------------------------------------
2773 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2774 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, VoxelFunc &vf)
2775 {
2776  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2777  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2778  else parallel_for (re, body);
2779 }
2780 
2781 // -----------------------------------------------------------------------------
2782 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2783 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)
2784 {
2785  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2786  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2787 }
2788 
2789 //
2790 // Image arguments by reference
2791 //
2792 
2793 // -----------------------------------------------------------------------------
2794 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2795 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, VoxelFunc &vf)
2796 {
2797  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2799  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2800  else parallel_for (re, body);
2801 }
2802 
2803 // -----------------------------------------------------------------------------
2804 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2805 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)
2806 {
2807  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2808  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2809 }
2810 
2811 // -----------------------------------------------------------------------------
2812 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2813 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, VoxelFunc &vf)
2814 {
2815  if (im8.GetTSize()) {
2816  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2817  } else {
2818  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2819  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
2820  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2821  else parallel_for (re, body);
2822  }
2823 }
2824 
2825 // -----------------------------------------------------------------------------
2826 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2827 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)
2828 {
2829  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2830  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2831 }
2832 
2833 // -----------------------------------------------------------------------------
2834 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2835 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, VoxelFunc &vf)
2836 {
2837  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2838  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
2839  if (VoxelFunc::IsReduction()) {
2840  if (attr._dt) {
2841  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
2842  } else {
2843  parallel_reduce(re, body);
2844  }
2845  vf.join(body._VoxelFunc);
2846  } else {
2847  if (attr._dt) {
2848  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
2849  } else {
2850  parallel_for(re, body);
2851  }
2852  }
2853 }
2854 
2855 // -----------------------------------------------------------------------------
2856 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2857 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)
2858 {
2859  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2860  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2861 }
2862 
2863 // -----------------------------------------------------------------------------
2864 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2865 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, VoxelFunc &vf)
2866 {
2867  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2868  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2869  else parallel_for (re, body);
2870 }
2871 
2872 // -----------------------------------------------------------------------------
2873 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2874 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)
2875 {
2876  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2877  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2878 }
2879 
2880 // -----------------------------------------------------------------------------
2881 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2882 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, VoxelFunc &vf)
2883 {
2884  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2885  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2886  else parallel_for (re, body);
2887 }
2888 
2889 // -----------------------------------------------------------------------------
2890 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2891 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)
2892 {
2893  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2894  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2895 }
2896 
2897 // -----------------------------------------------------------------------------
2898 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2899 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, VoxelFunc &vf)
2900 {
2901  OctaryForEachVoxelBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
2902  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
2903  else parallel_for (re, body);
2904 }
2905 
2906 // -----------------------------------------------------------------------------
2907 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2908 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)
2909 {
2910  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2911  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
2912 }
2913 
2914 // -----------------------------------------------------------------------------
2915 // ParallelForEachVoxelIf
2916 // -----------------------------------------------------------------------------
2917 
2918 //
2919 // Image arguments by pointer
2920 //
2921 
2922 // -----------------------------------------------------------------------------
2923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2924 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, VoxelFunc &vf, OutsideFunc &of)
2925 {
2926  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2927  blocked_range<int> re(0, im8->GetNumberOfVoxels());
2928  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2929  parallel_reduce(re, body);
2930  vf.join(body._VoxelFunc);
2931  of.join(body._OutsideFunc);
2932  } else {
2933  parallel_for(re, body);
2934  }
2935 }
2936 
2937 // -----------------------------------------------------------------------------
2938 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2939 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)
2940 {
2941  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2942  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2943 }
2944 
2945 // -----------------------------------------------------------------------------
2946 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2947 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, VoxelFunc &vf)
2948 {
2950  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2951 }
2952 
2953 // -----------------------------------------------------------------------------
2954 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2955 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)
2956 {
2957  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2958  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
2959 }
2960 
2961 // -----------------------------------------------------------------------------
2962 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2963 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, VoxelFunc &vf, OutsideFunc &of)
2964 {
2965  if (im8->GetTSize()) {
2966  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2967  } else {
2968  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2969  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
2970  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
2971  parallel_reduce(re, body);
2972  vf.join(body._VoxelFunc);
2973  of.join(body._OutsideFunc);
2974  } else {
2975  parallel_for(re, body);
2976  }
2977  }
2978 }
2979 
2980 // -----------------------------------------------------------------------------
2981 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
2982 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)
2983 {
2984  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
2985  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2986 }
2987 
2988 // -----------------------------------------------------------------------------
2989 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2990 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, VoxelFunc &vf)
2991 {
2993  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
2994 }
2995 
2996 // -----------------------------------------------------------------------------
2997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
2998 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)
2999 {
3000  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3001  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3002 }
3003 
3004 // -----------------------------------------------------------------------------
3005 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3006 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, VoxelFunc &vf, OutsideFunc &of)
3007 {
3008  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3009  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
3010  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3011  if (attr._dt) {
3012  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
3013  } else {
3014  parallel_reduce(re, body);
3015  }
3016  vf.join(body._VoxelFunc);
3017  of.join(body._OutsideFunc);
3018  } else {
3019  if (attr._dt) {
3020  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
3021  } else {
3022  parallel_for(re, body);
3023  }
3024  }
3025 }
3026 
3027 // -----------------------------------------------------------------------------
3028 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3029 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)
3030 {
3031  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3032  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3033 }
3034 
3035 // -----------------------------------------------------------------------------
3036 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3037 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, VoxelFunc &vf)
3038 {
3040  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3041 }
3042 
3043 // -----------------------------------------------------------------------------
3044 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3045 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)
3046 {
3047  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3048  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3049 }
3050 
3051 // -----------------------------------------------------------------------------
3052 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3053 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, VoxelFunc &vf, OutsideFunc &of)
3054 {
3055  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3056  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3057  parallel_reduce(re, body);
3058  vf.join(body._VoxelFunc);
3059  of.join(body._OutsideFunc);
3060  } else {
3061  parallel_for(re, body);
3062  }
3063 }
3064 
3065 // -----------------------------------------------------------------------------
3066 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3067 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)
3068 {
3069  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3070  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3071 }
3072 
3073 // -----------------------------------------------------------------------------
3074 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3075 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, VoxelFunc &vf)
3076 {
3078  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3079 }
3080 
3081 // -----------------------------------------------------------------------------
3082 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3083 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)
3084 {
3085  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3086  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3087 }
3088 
3089 // -----------------------------------------------------------------------------
3090 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3091 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, VoxelFunc &vf, OutsideFunc &of)
3092 {
3093  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3094  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3095  parallel_reduce(re, body);
3096  vf.join(body._VoxelFunc);
3097  of.join(body._OutsideFunc);
3098  } else {
3099  parallel_for(re, body);
3100  }
3101 }
3102 
3103 // -----------------------------------------------------------------------------
3104 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3105 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)
3106 {
3107  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3108  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3109 }
3110 
3111 // -----------------------------------------------------------------------------
3112 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3113 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, VoxelFunc &vf)
3114 {
3116  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3117 }
3118 
3119 // -----------------------------------------------------------------------------
3120 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3121 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)
3122 {
3123  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3124  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3125 }
3126 
3127 // -----------------------------------------------------------------------------
3128 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3129 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, VoxelFunc &vf, OutsideFunc &of)
3130 {
3131  OctaryForEachVoxelIfBody_7Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3132  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3133  parallel_reduce(re, body);
3134  vf.join(body._VoxelFunc);
3135  of.join(body._OutsideFunc);
3136  } else {
3137  parallel_for(re, body);
3138  }
3139 }
3140 
3141 // -----------------------------------------------------------------------------
3142 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3143 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)
3144 {
3145  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3146  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3147 }
3148 
3149 // -----------------------------------------------------------------------------
3150 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3151 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, VoxelFunc &vf)
3152 {
3154  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3155 }
3156 
3157 // -----------------------------------------------------------------------------
3158 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3159 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)
3160 {
3161  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3162  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3163 }
3164 
3165 //
3166 // Image arguments by reference
3167 //
3168 
3169 // -----------------------------------------------------------------------------
3170 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3171 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, VoxelFunc &vf, OutsideFunc &of)
3172 {
3175  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3176  parallel_reduce(re, body);
3177  vf.join(body._VoxelFunc);
3178  of.join(body._OutsideFunc);
3179  } else {
3180  parallel_for(re, body);
3181  }
3182 }
3183 
3184 // -----------------------------------------------------------------------------
3185 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3186 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)
3187 {
3188  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3189  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3190 }
3191 
3192 // -----------------------------------------------------------------------------
3193 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3194 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, VoxelFunc &vf)
3195 {
3197  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3198 }
3199 
3200 // -----------------------------------------------------------------------------
3201 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3202 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)
3203 {
3204  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3205  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3206 }
3207 
3208 // -----------------------------------------------------------------------------
3209 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3210 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, VoxelFunc &vf, OutsideFunc &of)
3211 {
3212  if (im8.GetTSize()) {
3213  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3214  } else {
3216  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
3217  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3218  parallel_reduce(re, body);
3219  vf.join(body._VoxelFunc);
3220  of.join(body._OutsideFunc);
3221  } else {
3222  parallel_for(re, body);
3223  }
3224  }
3225 }
3226 
3227 // -----------------------------------------------------------------------------
3228 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3229 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)
3230 {
3231  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3232  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3233 }
3234 
3235 // -----------------------------------------------------------------------------
3236 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3237 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, VoxelFunc &vf)
3238 {
3240  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3241 }
3242 
3243 // -----------------------------------------------------------------------------
3244 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3245 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)
3246 {
3247  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3248  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3249 }
3250 
3251 // -----------------------------------------------------------------------------
3252 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3253 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, VoxelFunc &vf, OutsideFunc &of)
3254 {
3256  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
3257  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3258  if (attr._dt) {
3259  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
3260  } else {
3261  parallel_reduce(re, body);
3262  }
3263  vf.join(body._VoxelFunc);
3264  of.join(body._OutsideFunc);
3265  } else {
3266  if (attr._dt) {
3267  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
3268  } else {
3269  parallel_for(re, body);
3270  }
3271  }
3272 }
3273 
3274 // -----------------------------------------------------------------------------
3275 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3276 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)
3277 {
3278  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3279  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3280 }
3281 
3282 // -----------------------------------------------------------------------------
3283 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3284 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, VoxelFunc &vf)
3285 {
3287  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3288 }
3289 
3290 // -----------------------------------------------------------------------------
3291 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3292 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)
3293 {
3294  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3295  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3296 }
3297 
3298 // -----------------------------------------------------------------------------
3299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3300 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, VoxelFunc &vf, OutsideFunc &of)
3301 {
3303  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3304  parallel_reduce(re, body);
3305  vf.join(body._VoxelFunc);
3306  of.join(body._OutsideFunc);
3307  } else {
3308  parallel_for(re, body);
3309  }
3310 }
3311 
3312 // -----------------------------------------------------------------------------
3313 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3314 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)
3315 {
3316  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3317  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3318 }
3319 
3320 // -----------------------------------------------------------------------------
3321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3322 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, VoxelFunc &vf)
3323 {
3325  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3326 }
3327 
3328 // -----------------------------------------------------------------------------
3329 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3330 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)
3331 {
3332  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3333  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3334 }
3335 
3336 // -----------------------------------------------------------------------------
3337 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3338 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, VoxelFunc &vf, OutsideFunc &of)
3339 {
3341  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3342  parallel_reduce(re, body);
3343  vf.join(body._VoxelFunc);
3344  of.join(body._OutsideFunc);
3345  } else {
3346  parallel_for(re, body);
3347  }
3348 }
3349 
3350 // -----------------------------------------------------------------------------
3351 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3352 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)
3353 {
3354  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3355  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3356 }
3357 
3358 // -----------------------------------------------------------------------------
3359 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3360 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, VoxelFunc &vf)
3361 {
3363  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3364 }
3365 
3366 // -----------------------------------------------------------------------------
3367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3368 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)
3369 {
3370  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3371  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3372 }
3373 
3374 // -----------------------------------------------------------------------------
3375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3376 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, VoxelFunc &vf, OutsideFunc &of)
3377 {
3379  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
3380  parallel_reduce(re, body);
3381  vf.join(body._VoxelFunc);
3382  of.join(body._OutsideFunc);
3383  } else {
3384  parallel_for(re, body);
3385  }
3386 }
3387 
3388 // -----------------------------------------------------------------------------
3389 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3390 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)
3391 {
3392  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3393  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3394 }
3395 
3396 // -----------------------------------------------------------------------------
3397 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3398 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, VoxelFunc &vf)
3399 {
3401  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
3402 }
3403 
3404 // -----------------------------------------------------------------------------
3405 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3406 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)
3407 {
3408  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3409  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3410 }
3411 
3412 // =============================================================================
3413 // 6 const, 2 non-const images
3414 // =============================================================================
3415 
3416 // -----------------------------------------------------------------------------
3417 /**
3418  * ForEachVoxel body for voxel function of 6 const, 2 non-const images
3419  */
3420 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3422 {
3423  const GenericImage<T1> &im1;
3424  const GenericImage<T2> &im2;
3425  const GenericImage<T3> &im3;
3426  const GenericImage<T4> &im4;
3427  const GenericImage<T5> &im5;
3428  const GenericImage<T6> &im6;
3429  GenericImage<T7> &im7;
3430  GenericImage<T8> &im8;
3431 
3432  /// Constructor
3434  const GenericImage<T2> &im2,
3435  const GenericImage<T3> &im3,
3436  const GenericImage<T4> &im4,
3437  const GenericImage<T5> &im5,
3438  const GenericImage<T6> &im6,
3439  GenericImage<T7> &im7,
3440  GenericImage<T8> &im8,
3441  VoxelFunc &vf)
3442  :
3443  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
3444  {}
3445 
3446  /// Copy constructor
3448  :
3449  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)
3450  {}
3451 
3452  /// Split constructor
3454  :
3455  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)
3456  {}
3457 
3458  /// Process entire image
3459  void operator ()(const ImageAttributes &attr) const
3460  {
3461  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3462  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3463  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3464  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3465  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3466  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3467  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
3468  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
3469 
3470  const int T = (attr._dt ? attr._t : 1);
3471 
3472  for (int l = 0; l < T; ++l)
3473  for (int k = 0; k < attr._z; ++k)
3474  for (int j = 0; j < attr._y; ++j)
3475  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
3476  // const_cast such that voxel functions need only implement
3477  // non-const operator() which is required for parallel_reduce
3478  const_cast<OctaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
3479  }
3480  }
3481 
3482  /// Process image region using linear index
3483  void operator ()(const blocked_range<int> &re) const
3484  {
3485  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3486  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3487  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3488  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3489  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3490  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3491  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
3492  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
3493 
3494  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) {
3495  // const_cast such that voxel functions need only implement
3496  // non-const operator() which is required for parallel_reduce
3497  const_cast<OctaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
3498  }
3499  }
3500 
3501  /// Process 2D image region
3502  void operator ()(const blocked_range2d<int> &re) const
3503  {
3504  const int bi = re.cols().begin();
3505  const int bj = re.rows().begin();
3506  const int ei = re.cols().end();
3507  const int ej = re.rows().end();
3508 
3509  const int s1 = im8.GetX() - (ei - bi);
3510 
3511  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3512  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3513  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3514  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3515  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3516  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3517  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3518  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3519 
3520  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
3521  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
3522  // const_cast such that voxel functions need only implement
3523  // non-const operator() which is required for parallel_reduce
3524  const_cast<OctaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3525  }
3526  }
3527 
3528  /// Process 3D image region
3529  void operator ()(const blocked_range3d<int> &re) const
3530  {
3531  const int bi = re.cols ().begin();
3532  const int bj = re.rows ().begin();
3533  const int bk = re.pages().begin();
3534  const int ei = re.cols ().end();
3535  const int ej = re.rows ().end();
3536  const int ek = re.pages().end();
3537 
3538  const int s1 = im8.GetX() - (ei - bi);
3539  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
3540 
3541  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3542  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3543  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3544  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3545  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3546  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3547  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
3548  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
3549 
3550  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
3551  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
3552  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
3553  // const_cast such that voxel functions need only implement
3554  // non-const operator() which is required for parallel_reduce
3555  const_cast<OctaryForEachVoxelBody_6Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3556  }
3557  }
3558 };
3559 
3560 // -----------------------------------------------------------------------------
3561 /**
3562  * ForEachVoxel body for inside and outside unary voxel function of 6 const, 2 non-const images
3563  */
3564 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
3565  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
3566  class Domain = ForEachVoxelDomain::Foreground>
3567 struct OctaryForEachVoxelIfBody_6Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
3568 {
3569  const GenericImage<T1> &im1;
3570  const GenericImage<T2> &im2;
3571  const GenericImage<T3> &im3;
3572  const GenericImage<T4> &im4;
3573  const GenericImage<T5> &im5;
3574  const GenericImage<T6> &im6;
3575  GenericImage<T7> &im7;
3576  GenericImage<T8> &im8;
3577 
3578  /// Constructor
3580  const GenericImage<T2> &im2,
3581  const GenericImage<T3> &im3,
3582  const GenericImage<T4> &im4,
3583  const GenericImage<T5> &im5,
3584  const GenericImage<T6> &im6,
3585  GenericImage<T7> &im7,
3586  GenericImage<T8> &im8,
3587  VoxelFunc &vf, OutsideFunc &of)
3588  :
3589  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
3590  {}
3591 
3592  /// Copy constructor
3594  :
3595  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)
3596  {}
3597 
3598  /// Split constructor
3600  :
3601  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)
3602  {}
3603 
3604  /// Process entire image
3605  void operator ()(const ImageAttributes &attr) const
3606  {
3607  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
3608  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
3609  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
3610  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
3611  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
3612  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
3613  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
3614  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
3615 
3616  const int T = (attr._dt ? attr._t : 1);
3617 
3618  for (int l = 0; l < T; ++l)
3619  for (int k = 0; k < attr._z; ++k)
3620  for (int j = 0; j < attr._y; ++j)
3621  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
3622  if (Domain::IsInside(im8, i, j, k, l, p8)) {
3623  // const_cast such that voxel functions need only implement
3624  // non-const operator() which is required for parallel_reduce
3625  const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
3626  } else const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
3627  }
3628  }
3629 
3630  /// Process image region using linear index
3631  void operator ()(const blocked_range<int> &re) const
3632  {
3633  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
3634  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
3635  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
3636  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
3637  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
3638  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
3639  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
3640  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
3641 
3642  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) {
3643  if (Domain::IsInside(im8, idx, p8)) {
3644  // const_cast such that voxel functions need only implement
3645  // non-const operator() which is required for parallel_reduce
3646  const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
3647  } else const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
3648  }
3649  }
3650 
3651  /// Process 2D image region
3652  void operator ()(const blocked_range2d<int> &re) const
3653  {
3654  const int bi = re.cols().begin();
3655  const int bj = re.rows().begin();
3656  const int ei = re.cols().end();
3657  const int ej = re.rows().end();
3658 
3659  const int s1 = im8.GetX() - (ei - bi);
3660 
3661  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3662  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3663  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3664  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3665  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3666  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3667  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3668  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
3669 
3670  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
3671  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
3672  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
3673  // const_cast such that voxel functions need only implement
3674  // non-const operator() which is required for parallel_reduce
3675  const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3676  } else const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3677  }
3678  }
3679 
3680  /// Process 3D image region
3681  void operator ()(const blocked_range3d<int> &re) const
3682  {
3683  const int bi = re.cols ().begin();
3684  const int bj = re.rows ().begin();
3685  const int bk = re.pages().begin();
3686  const int ei = re.cols ().end();
3687  const int ej = re.rows ().end();
3688  const int ek = re.pages().end();
3689 
3690  const int s1 = im8.GetX() - (ei - bi);
3691  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
3692 
3693  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
3694  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
3695  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
3696  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
3697  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
3698  const T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
3699  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
3700  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
3701 
3702  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
3703  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
3704  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
3705  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
3706  // const_cast such that voxel functions need only implement
3707  // non-const operator() which is required for parallel_reduce
3708  const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3709  } else const_cast<OctaryForEachVoxelIfBody_6Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
3710  }
3711  }
3712 };
3713 
3714 // -----------------------------------------------------------------------------
3715 // ForEachVoxel
3716 // -----------------------------------------------------------------------------
3717 
3718 //
3719 // Image arguments by pointer
3720 //
3721 
3722 // -----------------------------------------------------------------------------
3723 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3724 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, VoxelFunc &vf)
3725 {
3726  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3727  blocked_range<int> re(0, im8->GetNumberOfVoxels());
3728  body(re);
3729  vf.join(body._VoxelFunc);
3730 }
3731 
3732 // -----------------------------------------------------------------------------
3733 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3734 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)
3735 {
3736  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3737  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3738 }
3739 
3740 // -----------------------------------------------------------------------------
3741 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3742 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, VoxelFunc &vf)
3743 {
3744  if (im8->GetTSize()) {
3745  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3746  } else {
3747  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3748  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
3749  body(re);
3750  vf.join(body._VoxelFunc);
3751  }
3752 }
3753 
3754 // -----------------------------------------------------------------------------
3755 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3756 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)
3757 {
3758  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3759  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3760 }
3761 
3762 // -----------------------------------------------------------------------------
3763 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3764 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, VoxelFunc &vf)
3765 {
3766  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3767  body(attr);
3768  vf.join(body._VoxelFunc);
3769 }
3770 
3771 // -----------------------------------------------------------------------------
3772 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3773 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)
3774 {
3775  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3776  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3777 }
3778 
3779 // -----------------------------------------------------------------------------
3780 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3781 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, VoxelFunc &vf)
3782 {
3783  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3784  body(re);
3785  vf.join(body._VoxelFunc);
3786 }
3787 
3788 // -----------------------------------------------------------------------------
3789 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3790 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)
3791 {
3792  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3793  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3794 }
3795 
3796 // -----------------------------------------------------------------------------
3797 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3798 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, VoxelFunc &vf)
3799 {
3800  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3801  body(re);
3802  vf.join(body._VoxelFunc);
3803 }
3804 
3805 // -----------------------------------------------------------------------------
3806 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3807 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)
3808 {
3809  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3810  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3811 }
3812 
3813 // -----------------------------------------------------------------------------
3814 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3815 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, VoxelFunc &vf)
3816 {
3817  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3818  body(re);
3819  vf.join(body._VoxelFunc);
3820 }
3821 
3822 // -----------------------------------------------------------------------------
3823 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3824 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)
3825 {
3826  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3827  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3828 }
3829 
3830 //
3831 // Image arguments by reference
3832 //
3833 
3834 // -----------------------------------------------------------------------------
3835 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3836 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, VoxelFunc &vf)
3837 {
3838  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3840  body(re);
3841  vf.join(body._VoxelFunc);
3842 }
3843 
3844 // -----------------------------------------------------------------------------
3845 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3846 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)
3847 {
3848  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3849  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3850 }
3851 
3852 // -----------------------------------------------------------------------------
3853 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3854 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, VoxelFunc &vf)
3855 {
3856  if (im8.GetTSize()) {
3857  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3858  } else {
3859  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3860  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
3861  body(re);
3862  vf.join(body._VoxelFunc);
3863  }
3864 }
3865 
3866 // -----------------------------------------------------------------------------
3867 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3868 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)
3869 {
3870  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3871  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3872 }
3873 
3874 // -----------------------------------------------------------------------------
3875 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3876 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, VoxelFunc &vf)
3877 {
3878  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3879  body(attr);
3880  vf.join(body._VoxelFunc);
3881 }
3882 
3883 // -----------------------------------------------------------------------------
3884 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3885 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)
3886 {
3887  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3888  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3889 }
3890 
3891 // -----------------------------------------------------------------------------
3892 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3893 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, VoxelFunc &vf)
3894 {
3895  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3896  body(re);
3897  vf.join(body._VoxelFunc);
3898 }
3899 
3900 // -----------------------------------------------------------------------------
3901 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3902 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)
3903 {
3904  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3905  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3906 }
3907 
3908 // -----------------------------------------------------------------------------
3909 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3910 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, VoxelFunc &vf)
3911 {
3912  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3913  body(re);
3914  vf.join(body._VoxelFunc);
3915 }
3916 
3917 // -----------------------------------------------------------------------------
3918 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3919 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)
3920 {
3921  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3922  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3923 }
3924 
3925 // -----------------------------------------------------------------------------
3926 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3927 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, VoxelFunc &vf)
3928 {
3929  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
3930  body(re);
3931  vf.join(body._VoxelFunc);
3932 }
3933 
3934 // -----------------------------------------------------------------------------
3935 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3936 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)
3937 {
3938  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3939  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
3940 }
3941 
3942 // -----------------------------------------------------------------------------
3943 // ForEachVoxelIf
3944 // -----------------------------------------------------------------------------
3945 
3946 //
3947 // Image arguments by pointer
3948 //
3949 
3950 // -----------------------------------------------------------------------------
3951 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3952 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, VoxelFunc &vf, OutsideFunc &of)
3953 {
3954  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3955  blocked_range<int> re(0, im8->GetNumberOfVoxels());
3956  body(re);
3957  vf.join(body._VoxelFunc);
3958  of.join(body._OutsideFunc);
3959 }
3960 
3961 // -----------------------------------------------------------------------------
3962 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3963 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)
3964 {
3965  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3966  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3967 }
3968 
3969 // -----------------------------------------------------------------------------
3970 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3971 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, VoxelFunc &vf)
3972 {
3974  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3975 }
3976 
3977 // -----------------------------------------------------------------------------
3978 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
3979 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)
3980 {
3981  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
3982  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
3983 }
3984 
3985 // -----------------------------------------------------------------------------
3986 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
3987 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, VoxelFunc &vf, OutsideFunc &of)
3988 {
3989  if (im8->GetTSize()) {
3990  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3991  } else {
3992  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
3993  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
3994  body(re);
3995  vf.join(body._VoxelFunc);
3996  of.join(body._OutsideFunc);
3997  }
3998 }
3999 
4000 // -----------------------------------------------------------------------------
4001 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4002 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)
4003 {
4004  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4005  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4006 }
4007 
4008 // -----------------------------------------------------------------------------
4009 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4010 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, VoxelFunc &vf)
4011 {
4013  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4014 }
4015 
4016 // -----------------------------------------------------------------------------
4017 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4018 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)
4019 {
4020  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4021  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4022 }
4023 
4024 // -----------------------------------------------------------------------------
4025 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4026 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, VoxelFunc &vf, OutsideFunc &of)
4027 {
4028  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4029  body(attr);
4030  vf.join(body._VoxelFunc);
4031  of.join(body._OutsideFunc);
4032 }
4033 
4034 // -----------------------------------------------------------------------------
4035 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4036 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)
4037 {
4038  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4039  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4040 }
4041 
4042 // -----------------------------------------------------------------------------
4043 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4044 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, VoxelFunc &vf)
4045 {
4047  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4048 }
4049 
4050 // -----------------------------------------------------------------------------
4051 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4052 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)
4053 {
4054  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4055  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4056 }
4057 
4058 // -----------------------------------------------------------------------------
4059 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4060 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, VoxelFunc &vf, OutsideFunc &of)
4061 {
4062  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4063  body(re);
4064  vf.join(body._VoxelFunc);
4065  of.join(body._OutsideFunc);
4066 }
4067 
4068 // -----------------------------------------------------------------------------
4069 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4070 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)
4071 {
4072  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4073  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4074 }
4075 
4076 // -----------------------------------------------------------------------------
4077 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4078 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, VoxelFunc &vf, OutsideFunc &of)
4079 {
4080  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4081  body(re);
4082  vf.join(body._VoxelFunc);
4083  of.join(body._OutsideFunc);
4084 }
4085 
4086 // -----------------------------------------------------------------------------
4087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4088 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)
4089 {
4090  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4091  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4092 }
4093 
4094 // -----------------------------------------------------------------------------
4095 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4096 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, VoxelFunc &vf)
4097 {
4099  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4100 }
4101 
4102 // -----------------------------------------------------------------------------
4103 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4104 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)
4105 {
4106  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4107  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4108 }
4109 
4110 // -----------------------------------------------------------------------------
4111 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4112 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, VoxelFunc &vf, OutsideFunc &of)
4113 {
4114  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4115  body(re);
4116  vf.join(body._VoxelFunc);
4117  of.join(body._OutsideFunc);
4118 }
4119 
4120 // -----------------------------------------------------------------------------
4121 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4122 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)
4123 {
4124  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4125  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4126 }
4127 
4128 // -----------------------------------------------------------------------------
4129 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4130 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, VoxelFunc &vf)
4131 {
4133  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4134 }
4135 
4136 // -----------------------------------------------------------------------------
4137 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4138 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)
4139 {
4140  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4141  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4142 }
4143 
4144 //
4145 // Image arguments by reference
4146 //
4147 
4148 // -----------------------------------------------------------------------------
4149 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4150 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, VoxelFunc &vf, OutsideFunc &of)
4151 {
4154  body(re);
4155  vf.join(body._VoxelFunc);
4156  of.join(body._OutsideFunc);
4157 }
4158 
4159 // -----------------------------------------------------------------------------
4160 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4161 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)
4162 {
4163  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4164  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4165 }
4166 
4167 // -----------------------------------------------------------------------------
4168 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4169 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, VoxelFunc &vf)
4170 {
4172  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4173 }
4174 
4175 // -----------------------------------------------------------------------------
4176 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4177 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)
4178 {
4179  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4180  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4181 }
4182 
4183 // -----------------------------------------------------------------------------
4184 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4185 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, VoxelFunc &vf, OutsideFunc &of)
4186 {
4187  if (im8.GetTSize()) {
4188  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4189  } else {
4191  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
4192  body(re);
4193  vf.join(body._VoxelFunc);
4194  of.join(body._OutsideFunc);
4195  }
4196 }
4197 
4198 // -----------------------------------------------------------------------------
4199 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4200 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)
4201 {
4202  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4203  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4204 }
4205 
4206 // -----------------------------------------------------------------------------
4207 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4208 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, VoxelFunc &vf)
4209 {
4211  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4212 }
4213 
4214 // -----------------------------------------------------------------------------
4215 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4216 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)
4217 {
4218  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4219  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4220 }
4221 
4222 // -----------------------------------------------------------------------------
4223 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4224 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, VoxelFunc &vf, OutsideFunc &of)
4225 {
4227  body(attr);
4228  vf.join(body._VoxelFunc);
4229  of.join(body._OutsideFunc);
4230 }
4231 
4232 // -----------------------------------------------------------------------------
4233 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4234 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)
4235 {
4236  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4237  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4238 }
4239 
4240 // -----------------------------------------------------------------------------
4241 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4242 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, VoxelFunc &vf)
4243 {
4245  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4246 }
4247 
4248 // -----------------------------------------------------------------------------
4249 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4250 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)
4251 {
4252  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4253  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4254 }
4255 
4256 // -----------------------------------------------------------------------------
4257 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4258 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, VoxelFunc &vf, OutsideFunc &of)
4259 {
4261  body(re);
4262  vf.join(body._VoxelFunc);
4263  of.join(body._OutsideFunc);
4264 }
4265 
4266 // -----------------------------------------------------------------------------
4267 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4268 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)
4269 {
4270  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4271  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4272 }
4273 
4274 // -----------------------------------------------------------------------------
4275 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4276 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, VoxelFunc &vf, OutsideFunc &of)
4277 {
4279  body(re);
4280  vf.join(body._VoxelFunc);
4281  of.join(body._OutsideFunc);
4282 }
4283 
4284 // -----------------------------------------------------------------------------
4285 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4286 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)
4287 {
4288  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4289  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4290 }
4291 
4292 // -----------------------------------------------------------------------------
4293 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4294 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, VoxelFunc &vf)
4295 {
4297  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4298 }
4299 
4300 // -----------------------------------------------------------------------------
4301 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4302 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)
4303 {
4304  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4305  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4306 }
4307 
4308 // -----------------------------------------------------------------------------
4309 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4310 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, VoxelFunc &vf, OutsideFunc &of)
4311 {
4313  body(re);
4314  vf.join(body._VoxelFunc);
4315  of.join(body._OutsideFunc);
4316 }
4317 
4318 // -----------------------------------------------------------------------------
4319 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4320 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)
4321 {
4322  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4323  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4324 }
4325 
4326 // -----------------------------------------------------------------------------
4327 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4328 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, VoxelFunc &vf)
4329 {
4331  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4332 }
4333 
4334 // -----------------------------------------------------------------------------
4335 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4336 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)
4337 {
4338  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4339  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4340 }
4341 
4342 // -----------------------------------------------------------------------------
4343 // ParallelForEachVoxel
4344 // -----------------------------------------------------------------------------
4345 
4346 //
4347 // Image arguments by pointer
4348 //
4349 
4350 // -----------------------------------------------------------------------------
4351 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4352 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, VoxelFunc &vf)
4353 {
4354  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4355  blocked_range<int> re(0, im8->GetNumberOfVoxels());
4356  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4357  else parallel_for (re, body);
4358 }
4359 
4360 // -----------------------------------------------------------------------------
4361 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4362 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)
4363 {
4364  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4365  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4366 }
4367 
4368 // -----------------------------------------------------------------------------
4369 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4370 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, VoxelFunc &vf)
4371 {
4372  if (im8->GetTSize()) {
4373  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4374  } else {
4375  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4376  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
4377  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4378  else parallel_for (re, body);
4379  }
4380 }
4381 
4382 // -----------------------------------------------------------------------------
4383 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4384 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)
4385 {
4386  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4387  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4388 }
4389 
4390 // -----------------------------------------------------------------------------
4391 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4392 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, VoxelFunc &vf)
4393 {
4394  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4395  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4396  if (VoxelFunc::IsReduction()) {
4397  if (attr._dt) {
4398  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4399  } else {
4400  parallel_reduce(re, body);
4401  }
4402  vf.join(body._VoxelFunc);
4403  } else {
4404  if (attr._dt) {
4405  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4406  } else {
4407  parallel_for(re, body);
4408  }
4409  }
4410 }
4411 
4412 // -----------------------------------------------------------------------------
4413 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4414 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)
4415 {
4416  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4417  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4418 }
4419 
4420 // -----------------------------------------------------------------------------
4421 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4422 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, VoxelFunc &vf)
4423 {
4424  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4425  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4426  else parallel_for (re, body);
4427 }
4428 
4429 // -----------------------------------------------------------------------------
4430 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4431 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)
4432 {
4433  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4434  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4435 }
4436 
4437 // -----------------------------------------------------------------------------
4438 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4439 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, VoxelFunc &vf)
4440 {
4441  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4442  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4443  else parallel_for (re, body);
4444 }
4445 
4446 // -----------------------------------------------------------------------------
4447 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4448 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)
4449 {
4450  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4451  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4452 }
4453 
4454 // -----------------------------------------------------------------------------
4455 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4456 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, VoxelFunc &vf)
4457 {
4458  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4459  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4460  else parallel_for (re, body);
4461 }
4462 
4463 // -----------------------------------------------------------------------------
4464 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4465 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)
4466 {
4467  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4468  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4469 }
4470 
4471 //
4472 // Image arguments by reference
4473 //
4474 
4475 // -----------------------------------------------------------------------------
4476 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4477 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, VoxelFunc &vf)
4478 {
4479  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4481  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4482  else parallel_for (re, body);
4483 }
4484 
4485 // -----------------------------------------------------------------------------
4486 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4487 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)
4488 {
4489  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4490  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4491 }
4492 
4493 // -----------------------------------------------------------------------------
4494 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4495 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, VoxelFunc &vf)
4496 {
4497  if (im8.GetTSize()) {
4498  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4499  } else {
4500  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4501  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
4502  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4503  else parallel_for (re, body);
4504  }
4505 }
4506 
4507 // -----------------------------------------------------------------------------
4508 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4509 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)
4510 {
4511  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4512  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4513 }
4514 
4515 // -----------------------------------------------------------------------------
4516 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4517 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, VoxelFunc &vf)
4518 {
4519  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4520  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4521  if (VoxelFunc::IsReduction()) {
4522  if (attr._dt) {
4523  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4524  } else {
4525  parallel_reduce(re, body);
4526  }
4527  vf.join(body._VoxelFunc);
4528  } else {
4529  if (attr._dt) {
4530  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4531  } else {
4532  parallel_for(re, body);
4533  }
4534  }
4535 }
4536 
4537 // -----------------------------------------------------------------------------
4538 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4539 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)
4540 {
4541  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4542  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4543 }
4544 
4545 // -----------------------------------------------------------------------------
4546 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4547 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, VoxelFunc &vf)
4548 {
4549  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4550  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4551  else parallel_for (re, body);
4552 }
4553 
4554 // -----------------------------------------------------------------------------
4555 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4556 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)
4557 {
4558  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4559  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4560 }
4561 
4562 // -----------------------------------------------------------------------------
4563 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4564 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, VoxelFunc &vf)
4565 {
4566  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4567  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4568  else parallel_for (re, body);
4569 }
4570 
4571 // -----------------------------------------------------------------------------
4572 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4573 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)
4574 {
4575  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4576  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4577 }
4578 
4579 // -----------------------------------------------------------------------------
4580 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4581 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, VoxelFunc &vf)
4582 {
4583  OctaryForEachVoxelBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4584  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
4585  else parallel_for (re, body);
4586 }
4587 
4588 // -----------------------------------------------------------------------------
4589 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4590 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)
4591 {
4592  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4593  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4594 }
4595 
4596 // -----------------------------------------------------------------------------
4597 // ParallelForEachVoxelIf
4598 // -----------------------------------------------------------------------------
4599 
4600 //
4601 // Image arguments by pointer
4602 //
4603 
4604 // -----------------------------------------------------------------------------
4605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4606 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, VoxelFunc &vf, OutsideFunc &of)
4607 {
4608  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4609  blocked_range<int> re(0, im8->GetNumberOfVoxels());
4610  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4611  parallel_reduce(re, body);
4612  vf.join(body._VoxelFunc);
4613  of.join(body._OutsideFunc);
4614  } else {
4615  parallel_for(re, body);
4616  }
4617 }
4618 
4619 // -----------------------------------------------------------------------------
4620 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4621 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)
4622 {
4623  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4624  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4625 }
4626 
4627 // -----------------------------------------------------------------------------
4628 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4629 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, VoxelFunc &vf)
4630 {
4632  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4633 }
4634 
4635 // -----------------------------------------------------------------------------
4636 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4637 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)
4638 {
4639  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4640  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4641 }
4642 
4643 // -----------------------------------------------------------------------------
4644 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4645 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, VoxelFunc &vf, OutsideFunc &of)
4646 {
4647  if (im8->GetTSize()) {
4648  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4649  } else {
4650  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4651  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
4652  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4653  parallel_reduce(re, body);
4654  vf.join(body._VoxelFunc);
4655  of.join(body._OutsideFunc);
4656  } else {
4657  parallel_for(re, body);
4658  }
4659  }
4660 }
4661 
4662 // -----------------------------------------------------------------------------
4663 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4664 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)
4665 {
4666  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4667  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4668 }
4669 
4670 // -----------------------------------------------------------------------------
4671 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4672 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, VoxelFunc &vf)
4673 {
4675  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4676 }
4677 
4678 // -----------------------------------------------------------------------------
4679 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4680 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)
4681 {
4682  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4683  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4684 }
4685 
4686 // -----------------------------------------------------------------------------
4687 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4688 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, VoxelFunc &vf, OutsideFunc &of)
4689 {
4690  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4691  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4692  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4693  if (attr._dt) {
4694  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4695  } else {
4696  parallel_reduce(re, body);
4697  }
4698  vf.join(body._VoxelFunc);
4699  of.join(body._OutsideFunc);
4700  } else {
4701  if (attr._dt) {
4702  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4703  } else {
4704  parallel_for(re, body);
4705  }
4706  }
4707 }
4708 
4709 // -----------------------------------------------------------------------------
4710 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4711 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)
4712 {
4713  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4714  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4715 }
4716 
4717 // -----------------------------------------------------------------------------
4718 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4719 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, VoxelFunc &vf)
4720 {
4722  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4723 }
4724 
4725 // -----------------------------------------------------------------------------
4726 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4727 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)
4728 {
4729  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4730  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4731 }
4732 
4733 // -----------------------------------------------------------------------------
4734 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4735 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, VoxelFunc &vf, OutsideFunc &of)
4736 {
4737  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4738  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4739  parallel_reduce(re, body);
4740  vf.join(body._VoxelFunc);
4741  of.join(body._OutsideFunc);
4742  } else {
4743  parallel_for(re, body);
4744  }
4745 }
4746 
4747 // -----------------------------------------------------------------------------
4748 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4749 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)
4750 {
4751  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4752  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4753 }
4754 
4755 // -----------------------------------------------------------------------------
4756 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4757 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, VoxelFunc &vf)
4758 {
4760  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4761 }
4762 
4763 // -----------------------------------------------------------------------------
4764 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4765 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)
4766 {
4767  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4768  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4769 }
4770 
4771 // -----------------------------------------------------------------------------
4772 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4773 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, VoxelFunc &vf, OutsideFunc &of)
4774 {
4775  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4776  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4777  parallel_reduce(re, body);
4778  vf.join(body._VoxelFunc);
4779  of.join(body._OutsideFunc);
4780  } else {
4781  parallel_for(re, body);
4782  }
4783 }
4784 
4785 // -----------------------------------------------------------------------------
4786 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4787 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)
4788 {
4789  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4790  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4791 }
4792 
4793 // -----------------------------------------------------------------------------
4794 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4795 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, VoxelFunc &vf)
4796 {
4798  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4799 }
4800 
4801 // -----------------------------------------------------------------------------
4802 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4803 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)
4804 {
4805  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4806  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4807 }
4808 
4809 // -----------------------------------------------------------------------------
4810 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4811 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, VoxelFunc &vf, OutsideFunc &of)
4812 {
4813  OctaryForEachVoxelIfBody_6Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4814  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4815  parallel_reduce(re, body);
4816  vf.join(body._VoxelFunc);
4817  of.join(body._OutsideFunc);
4818  } else {
4819  parallel_for(re, body);
4820  }
4821 }
4822 
4823 // -----------------------------------------------------------------------------
4824 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4825 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)
4826 {
4827  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4828  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4829 }
4830 
4831 // -----------------------------------------------------------------------------
4832 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4833 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, VoxelFunc &vf)
4834 {
4836  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
4837 }
4838 
4839 // -----------------------------------------------------------------------------
4840 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4841 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)
4842 {
4843  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4844  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
4845 }
4846 
4847 //
4848 // Image arguments by reference
4849 //
4850 
4851 // -----------------------------------------------------------------------------
4852 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4853 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, VoxelFunc &vf, OutsideFunc &of)
4854 {
4857  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4858  parallel_reduce(re, body);
4859  vf.join(body._VoxelFunc);
4860  of.join(body._OutsideFunc);
4861  } else {
4862  parallel_for(re, body);
4863  }
4864 }
4865 
4866 // -----------------------------------------------------------------------------
4867 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4868 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)
4869 {
4870  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4871  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4872 }
4873 
4874 // -----------------------------------------------------------------------------
4875 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4876 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, VoxelFunc &vf)
4877 {
4879  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4880 }
4881 
4882 // -----------------------------------------------------------------------------
4883 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4884 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)
4885 {
4886  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4887  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4888 }
4889 
4890 // -----------------------------------------------------------------------------
4891 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4892 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, VoxelFunc &vf, OutsideFunc &of)
4893 {
4894  if (im8.GetTSize()) {
4895  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4896  } else {
4898  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
4899  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4900  parallel_reduce(re, body);
4901  vf.join(body._VoxelFunc);
4902  of.join(body._OutsideFunc);
4903  } else {
4904  parallel_for(re, body);
4905  }
4906  }
4907 }
4908 
4909 // -----------------------------------------------------------------------------
4910 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4911 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)
4912 {
4913  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4914  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4915 }
4916 
4917 // -----------------------------------------------------------------------------
4918 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4919 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, VoxelFunc &vf)
4920 {
4922  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4923 }
4924 
4925 // -----------------------------------------------------------------------------
4926 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4927 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)
4928 {
4929  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4930  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
4931 }
4932 
4933 // -----------------------------------------------------------------------------
4934 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4935 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, VoxelFunc &vf, OutsideFunc &of)
4936 {
4938  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
4939  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4940  if (attr._dt) {
4941  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
4942  } else {
4943  parallel_reduce(re, body);
4944  }
4945  vf.join(body._VoxelFunc);
4946  of.join(body._OutsideFunc);
4947  } else {
4948  if (attr._dt) {
4949  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
4950  } else {
4951  parallel_for(re, body);
4952  }
4953  }
4954 }
4955 
4956 // -----------------------------------------------------------------------------
4957 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4958 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)
4959 {
4960  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4961  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4962 }
4963 
4964 // -----------------------------------------------------------------------------
4965 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4966 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, VoxelFunc &vf)
4967 {
4969  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
4970 }
4971 
4972 // -----------------------------------------------------------------------------
4973 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
4974 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)
4975 {
4976  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4977  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
4978 }
4979 
4980 // -----------------------------------------------------------------------------
4981 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4982 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, VoxelFunc &vf, OutsideFunc &of)
4983 {
4985  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
4986  parallel_reduce(re, body);
4987  vf.join(body._VoxelFunc);
4988  of.join(body._OutsideFunc);
4989  } else {
4990  parallel_for(re, body);
4991  }
4992 }
4993 
4994 // -----------------------------------------------------------------------------
4995 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
4996 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)
4997 {
4998  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
4999  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5000 }
5001 
5002 // -----------------------------------------------------------------------------
5003 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5004 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, VoxelFunc &vf)
5005 {
5007  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5008 }
5009 
5010 // -----------------------------------------------------------------------------
5011 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5012 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)
5013 {
5014  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5015  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5016 }
5017 
5018 // -----------------------------------------------------------------------------
5019 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5020 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, VoxelFunc &vf, OutsideFunc &of)
5021 {
5023  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
5024  parallel_reduce(re, body);
5025  vf.join(body._VoxelFunc);
5026  of.join(body._OutsideFunc);
5027  } else {
5028  parallel_for(re, body);
5029  }
5030 }
5031 
5032 // -----------------------------------------------------------------------------
5033 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5034 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)
5035 {
5036  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5037  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5038 }
5039 
5040 // -----------------------------------------------------------------------------
5041 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5042 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, VoxelFunc &vf)
5043 {
5045  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5046 }
5047 
5048 // -----------------------------------------------------------------------------
5049 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5050 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)
5051 {
5052  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5053  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5054 }
5055 
5056 // -----------------------------------------------------------------------------
5057 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5058 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, VoxelFunc &vf, OutsideFunc &of)
5059 {
5061  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
5062  parallel_reduce(re, body);
5063  vf.join(body._VoxelFunc);
5064  of.join(body._OutsideFunc);
5065  } else {
5066  parallel_for(re, body);
5067  }
5068 }
5069 
5070 // -----------------------------------------------------------------------------
5071 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5072 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)
5073 {
5074  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5075  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5076 }
5077 
5078 // -----------------------------------------------------------------------------
5079 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5080 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, VoxelFunc &vf)
5081 {
5083  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5084 }
5085 
5086 // -----------------------------------------------------------------------------
5087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5088 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)
5089 {
5090  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5091  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5092 }
5093 
5094 // =============================================================================
5095 // 5 const, 3 non-const images
5096 // =============================================================================
5097 
5098 // -----------------------------------------------------------------------------
5099 /**
5100  * ForEachVoxel body for voxel function of 5 const, 3 non-const images
5101  */
5102 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5104 {
5105  const GenericImage<T1> &im1;
5106  const GenericImage<T2> &im2;
5107  const GenericImage<T3> &im3;
5108  const GenericImage<T4> &im4;
5109  const GenericImage<T5> &im5;
5110  GenericImage<T6> &im6;
5111  GenericImage<T7> &im7;
5112  GenericImage<T8> &im8;
5113 
5114  /// Constructor
5116  const GenericImage<T2> &im2,
5117  const GenericImage<T3> &im3,
5118  const GenericImage<T4> &im4,
5119  const GenericImage<T5> &im5,
5120  GenericImage<T6> &im6,
5121  GenericImage<T7> &im7,
5122  GenericImage<T8> &im8,
5123  VoxelFunc &vf)
5124  :
5125  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
5126  {}
5127 
5128  /// Copy constructor
5130  :
5131  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)
5132  {}
5133 
5134  /// Split constructor
5136  :
5137  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)
5138  {}
5139 
5140  /// Process entire image
5141  void operator ()(const ImageAttributes &attr) const
5142  {
5143  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5144  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5145  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5146  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5147  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5148  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5149  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
5150  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
5151 
5152  const int T = (attr._dt ? attr._t : 1);
5153 
5154  for (int l = 0; l < T; ++l)
5155  for (int k = 0; k < attr._z; ++k)
5156  for (int j = 0; j < attr._y; ++j)
5157  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
5158  // const_cast such that voxel functions need only implement
5159  // non-const operator() which is required for parallel_reduce
5160  const_cast<OctaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
5161  }
5162  }
5163 
5164  /// Process image region using linear index
5165  void operator ()(const blocked_range<int> &re) const
5166  {
5167  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5168  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5169  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5170  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5171  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5172  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5173  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
5174  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
5175 
5176  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) {
5177  // const_cast such that voxel functions need only implement
5178  // non-const operator() which is required for parallel_reduce
5179  const_cast<OctaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
5180  }
5181  }
5182 
5183  /// Process 2D image region
5184  void operator ()(const blocked_range2d<int> &re) const
5185  {
5186  const int bi = re.cols().begin();
5187  const int bj = re.rows().begin();
5188  const int ei = re.cols().end();
5189  const int ej = re.rows().end();
5190 
5191  const int s1 = im8.GetX() - (ei - bi);
5192 
5193  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5194  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5195  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5196  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5197  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5198  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5199  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5200  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5201 
5202  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
5203  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
5204  // const_cast such that voxel functions need only implement
5205  // non-const operator() which is required for parallel_reduce
5206  const_cast<OctaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5207  }
5208  }
5209 
5210  /// Process 3D image region
5211  void operator ()(const blocked_range3d<int> &re) const
5212  {
5213  const int bi = re.cols ().begin();
5214  const int bj = re.rows ().begin();
5215  const int bk = re.pages().begin();
5216  const int ei = re.cols ().end();
5217  const int ej = re.rows ().end();
5218  const int ek = re.pages().end();
5219 
5220  const int s1 = im8.GetX() - (ei - bi);
5221  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
5222 
5223  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5224  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5225  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5226  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5227  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5228  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5229  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
5230  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
5231 
5232  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
5233  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
5234  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
5235  // const_cast such that voxel functions need only implement
5236  // non-const operator() which is required for parallel_reduce
5237  const_cast<OctaryForEachVoxelBody_5Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5238  }
5239  }
5240 };
5241 
5242 // -----------------------------------------------------------------------------
5243 /**
5244  * ForEachVoxel body for inside and outside unary voxel function of 5 const, 3 non-const images
5245  */
5246 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
5247  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
5248  class Domain = ForEachVoxelDomain::Foreground>
5249 struct OctaryForEachVoxelIfBody_5Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
5250 {
5251  const GenericImage<T1> &im1;
5252  const GenericImage<T2> &im2;
5253  const GenericImage<T3> &im3;
5254  const GenericImage<T4> &im4;
5255  const GenericImage<T5> &im5;
5256  GenericImage<T6> &im6;
5257  GenericImage<T7> &im7;
5258  GenericImage<T8> &im8;
5259 
5260  /// Constructor
5262  const GenericImage<T2> &im2,
5263  const GenericImage<T3> &im3,
5264  const GenericImage<T4> &im4,
5265  const GenericImage<T5> &im5,
5266  GenericImage<T6> &im6,
5267  GenericImage<T7> &im7,
5268  GenericImage<T8> &im8,
5269  VoxelFunc &vf, OutsideFunc &of)
5270  :
5271  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
5272  {}
5273 
5274  /// Copy constructor
5276  :
5277  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)
5278  {}
5279 
5280  /// Split constructor
5282  :
5283  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)
5284  {}
5285 
5286  /// Process entire image
5287  void operator ()(const ImageAttributes &attr) const
5288  {
5289  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
5290  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
5291  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
5292  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
5293  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
5294  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
5295  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
5296  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
5297 
5298  const int T = (attr._dt ? attr._t : 1);
5299 
5300  for (int l = 0; l < T; ++l)
5301  for (int k = 0; k < attr._z; ++k)
5302  for (int j = 0; j < attr._y; ++j)
5303  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
5304  if (Domain::IsInside(im8, i, j, k, l, p8)) {
5305  // const_cast such that voxel functions need only implement
5306  // non-const operator() which is required for parallel_reduce
5307  const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
5308  } else const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
5309  }
5310  }
5311 
5312  /// Process image region using linear index
5313  void operator ()(const blocked_range<int> &re) const
5314  {
5315  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
5316  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
5317  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
5318  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
5319  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
5320  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
5321  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
5322  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
5323 
5324  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) {
5325  if (Domain::IsInside(im8, idx, p8)) {
5326  // const_cast such that voxel functions need only implement
5327  // non-const operator() which is required for parallel_reduce
5328  const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
5329  } else const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
5330  }
5331  }
5332 
5333  /// Process 2D image region
5334  void operator ()(const blocked_range2d<int> &re) const
5335  {
5336  const int bi = re.cols().begin();
5337  const int bj = re.rows().begin();
5338  const int ei = re.cols().end();
5339  const int ej = re.rows().end();
5340 
5341  const int s1 = im8.GetX() - (ei - bi);
5342 
5343  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5344  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5345  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5346  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5347  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5348  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5349  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5350  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
5351 
5352  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
5353  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
5354  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
5355  // const_cast such that voxel functions need only implement
5356  // non-const operator() which is required for parallel_reduce
5357  const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5358  } else const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5359  }
5360  }
5361 
5362  /// Process 3D image region
5363  void operator ()(const blocked_range3d<int> &re) const
5364  {
5365  const int bi = re.cols ().begin();
5366  const int bj = re.rows ().begin();
5367  const int bk = re.pages().begin();
5368  const int ei = re.cols ().end();
5369  const int ej = re.rows ().end();
5370  const int ek = re.pages().end();
5371 
5372  const int s1 = im8.GetX() - (ei - bi);
5373  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
5374 
5375  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
5376  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
5377  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
5378  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
5379  const T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
5380  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
5381  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
5382  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
5383 
5384  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
5385  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
5386  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
5387  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
5388  // const_cast such that voxel functions need only implement
5389  // non-const operator() which is required for parallel_reduce
5390  const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5391  } else const_cast<OctaryForEachVoxelIfBody_5Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
5392  }
5393  }
5394 };
5395 
5396 // -----------------------------------------------------------------------------
5397 // ForEachVoxel
5398 // -----------------------------------------------------------------------------
5399 
5400 //
5401 // Image arguments by pointer
5402 //
5403 
5404 // -----------------------------------------------------------------------------
5405 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5406 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, VoxelFunc &vf)
5407 {
5408  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5409  blocked_range<int> re(0, im8->GetNumberOfVoxels());
5410  body(re);
5411  vf.join(body._VoxelFunc);
5412 }
5413 
5414 // -----------------------------------------------------------------------------
5415 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5416 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)
5417 {
5418  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5419  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5420 }
5421 
5422 // -----------------------------------------------------------------------------
5423 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5424 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, VoxelFunc &vf)
5425 {
5426  if (im8->GetTSize()) {
5427  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5428  } else {
5429  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5430  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
5431  body(re);
5432  vf.join(body._VoxelFunc);
5433  }
5434 }
5435 
5436 // -----------------------------------------------------------------------------
5437 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5438 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)
5439 {
5440  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5441  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5442 }
5443 
5444 // -----------------------------------------------------------------------------
5445 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5446 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, VoxelFunc &vf)
5447 {
5448  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5449  body(attr);
5450  vf.join(body._VoxelFunc);
5451 }
5452 
5453 // -----------------------------------------------------------------------------
5454 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5455 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)
5456 {
5457  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5458  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5459 }
5460 
5461 // -----------------------------------------------------------------------------
5462 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5463 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, VoxelFunc &vf)
5464 {
5465  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5466  body(re);
5467  vf.join(body._VoxelFunc);
5468 }
5469 
5470 // -----------------------------------------------------------------------------
5471 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5472 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)
5473 {
5474  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5475  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5476 }
5477 
5478 // -----------------------------------------------------------------------------
5479 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5480 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, VoxelFunc &vf)
5481 {
5482  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5483  body(re);
5484  vf.join(body._VoxelFunc);
5485 }
5486 
5487 // -----------------------------------------------------------------------------
5488 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5489 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)
5490 {
5491  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5492  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5493 }
5494 
5495 // -----------------------------------------------------------------------------
5496 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5497 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, VoxelFunc &vf)
5498 {
5499  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5500  body(re);
5501  vf.join(body._VoxelFunc);
5502 }
5503 
5504 // -----------------------------------------------------------------------------
5505 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5506 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)
5507 {
5508  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5509  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5510 }
5511 
5512 //
5513 // Image arguments by reference
5514 //
5515 
5516 // -----------------------------------------------------------------------------
5517 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5518 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, VoxelFunc &vf)
5519 {
5520  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5522  body(re);
5523  vf.join(body._VoxelFunc);
5524 }
5525 
5526 // -----------------------------------------------------------------------------
5527 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5528 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)
5529 {
5530  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5531  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5532 }
5533 
5534 // -----------------------------------------------------------------------------
5535 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5536 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, VoxelFunc &vf)
5537 {
5538  if (im8.GetTSize()) {
5539  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5540  } else {
5541  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5542  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
5543  body(re);
5544  vf.join(body._VoxelFunc);
5545  }
5546 }
5547 
5548 // -----------------------------------------------------------------------------
5549 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5550 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)
5551 {
5552  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5553  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5554 }
5555 
5556 // -----------------------------------------------------------------------------
5557 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5558 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, VoxelFunc &vf)
5559 {
5560  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5561  body(attr);
5562  vf.join(body._VoxelFunc);
5563 }
5564 
5565 // -----------------------------------------------------------------------------
5566 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5567 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)
5568 {
5569  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5570  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5571 }
5572 
5573 // -----------------------------------------------------------------------------
5574 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5575 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, VoxelFunc &vf)
5576 {
5577  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5578  body(re);
5579  vf.join(body._VoxelFunc);
5580 }
5581 
5582 // -----------------------------------------------------------------------------
5583 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5584 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)
5585 {
5586  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5587  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5588 }
5589 
5590 // -----------------------------------------------------------------------------
5591 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5592 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, VoxelFunc &vf)
5593 {
5594  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5595  body(re);
5596  vf.join(body._VoxelFunc);
5597 }
5598 
5599 // -----------------------------------------------------------------------------
5600 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5601 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)
5602 {
5603  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5604  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5605 }
5606 
5607 // -----------------------------------------------------------------------------
5608 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5609 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, VoxelFunc &vf)
5610 {
5611  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5612  body(re);
5613  vf.join(body._VoxelFunc);
5614 }
5615 
5616 // -----------------------------------------------------------------------------
5617 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5618 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)
5619 {
5620  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5621  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5622 }
5623 
5624 // -----------------------------------------------------------------------------
5625 // ForEachVoxelIf
5626 // -----------------------------------------------------------------------------
5627 
5628 //
5629 // Image arguments by pointer
5630 //
5631 
5632 // -----------------------------------------------------------------------------
5633 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5634 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, VoxelFunc &vf, OutsideFunc &of)
5635 {
5636  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5637  blocked_range<int> re(0, im8->GetNumberOfVoxels());
5638  body(re);
5639  vf.join(body._VoxelFunc);
5640  of.join(body._OutsideFunc);
5641 }
5642 
5643 // -----------------------------------------------------------------------------
5644 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5645 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)
5646 {
5647  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5648  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5649 }
5650 
5651 // -----------------------------------------------------------------------------
5652 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5653 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, VoxelFunc &vf)
5654 {
5656  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5657 }
5658 
5659 // -----------------------------------------------------------------------------
5660 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5661 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)
5662 {
5663  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5664  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5665 }
5666 
5667 // -----------------------------------------------------------------------------
5668 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5669 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, VoxelFunc &vf, OutsideFunc &of)
5670 {
5671  if (im8->GetTSize()) {
5672  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5673  } else {
5674  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5675  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
5676  body(re);
5677  vf.join(body._VoxelFunc);
5678  of.join(body._OutsideFunc);
5679  }
5680 }
5681 
5682 // -----------------------------------------------------------------------------
5683 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5684 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)
5685 {
5686  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5687  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5688 }
5689 
5690 // -----------------------------------------------------------------------------
5691 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5692 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, VoxelFunc &vf)
5693 {
5695  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5696 }
5697 
5698 // -----------------------------------------------------------------------------
5699 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5700 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)
5701 {
5702  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5703  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5704 }
5705 
5706 // -----------------------------------------------------------------------------
5707 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5708 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, VoxelFunc &vf, OutsideFunc &of)
5709 {
5710  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5711  body(attr);
5712  vf.join(body._VoxelFunc);
5713  of.join(body._OutsideFunc);
5714 }
5715 
5716 // -----------------------------------------------------------------------------
5717 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5718 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)
5719 {
5720  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5721  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5722 }
5723 
5724 // -----------------------------------------------------------------------------
5725 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5726 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, VoxelFunc &vf)
5727 {
5729  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5730 }
5731 
5732 // -----------------------------------------------------------------------------
5733 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5734 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)
5735 {
5736  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5737  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5738 }
5739 
5740 // -----------------------------------------------------------------------------
5741 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5742 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, VoxelFunc &vf, OutsideFunc &of)
5743 {
5744  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5745  body(re);
5746  vf.join(body._VoxelFunc);
5747  of.join(body._OutsideFunc);
5748 }
5749 
5750 // -----------------------------------------------------------------------------
5751 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5752 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)
5753 {
5754  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5755  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5756 }
5757 
5758 // -----------------------------------------------------------------------------
5759 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5760 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, VoxelFunc &vf, OutsideFunc &of)
5761 {
5762  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5763  body(re);
5764  vf.join(body._VoxelFunc);
5765  of.join(body._OutsideFunc);
5766 }
5767 
5768 // -----------------------------------------------------------------------------
5769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5770 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)
5771 {
5772  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5773  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5774 }
5775 
5776 // -----------------------------------------------------------------------------
5777 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5778 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, VoxelFunc &vf)
5779 {
5781  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5782 }
5783 
5784 // -----------------------------------------------------------------------------
5785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5786 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)
5787 {
5788  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5789  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5790 }
5791 
5792 // -----------------------------------------------------------------------------
5793 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5794 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, VoxelFunc &vf, OutsideFunc &of)
5795 {
5796  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5797  body(re);
5798  vf.join(body._VoxelFunc);
5799  of.join(body._OutsideFunc);
5800 }
5801 
5802 // -----------------------------------------------------------------------------
5803 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5804 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)
5805 {
5806  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5807  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5808 }
5809 
5810 // -----------------------------------------------------------------------------
5811 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5812 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, VoxelFunc &vf)
5813 {
5815  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
5816 }
5817 
5818 // -----------------------------------------------------------------------------
5819 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5820 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)
5821 {
5822  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5823  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
5824 }
5825 
5826 //
5827 // Image arguments by reference
5828 //
5829 
5830 // -----------------------------------------------------------------------------
5831 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5832 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, VoxelFunc &vf, OutsideFunc &of)
5833 {
5836  body(re);
5837  vf.join(body._VoxelFunc);
5838  of.join(body._OutsideFunc);
5839 }
5840 
5841 // -----------------------------------------------------------------------------
5842 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5843 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)
5844 {
5845  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5846  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5847 }
5848 
5849 // -----------------------------------------------------------------------------
5850 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5851 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, VoxelFunc &vf)
5852 {
5854  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5855 }
5856 
5857 // -----------------------------------------------------------------------------
5858 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5859 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)
5860 {
5861  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5862  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5863 }
5864 
5865 // -----------------------------------------------------------------------------
5866 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5867 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, VoxelFunc &vf, OutsideFunc &of)
5868 {
5869  if (im8.GetTSize()) {
5870  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5871  } else {
5873  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
5874  body(re);
5875  vf.join(body._VoxelFunc);
5876  of.join(body._OutsideFunc);
5877  }
5878 }
5879 
5880 // -----------------------------------------------------------------------------
5881 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5882 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)
5883 {
5884  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5885  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5886 }
5887 
5888 // -----------------------------------------------------------------------------
5889 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5890 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, VoxelFunc &vf)
5891 {
5893  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5894 }
5895 
5896 // -----------------------------------------------------------------------------
5897 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5898 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)
5899 {
5900  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5901  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
5902 }
5903 
5904 // -----------------------------------------------------------------------------
5905 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5906 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, VoxelFunc &vf, OutsideFunc &of)
5907 {
5909  body(attr);
5910  vf.join(body._VoxelFunc);
5911  of.join(body._OutsideFunc);
5912 }
5913 
5914 // -----------------------------------------------------------------------------
5915 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5916 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)
5917 {
5918  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5919  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5920 }
5921 
5922 // -----------------------------------------------------------------------------
5923 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5924 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, VoxelFunc &vf)
5925 {
5927  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5928 }
5929 
5930 // -----------------------------------------------------------------------------
5931 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5932 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)
5933 {
5934  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5935  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5936 }
5937 
5938 // -----------------------------------------------------------------------------
5939 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5940 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, VoxelFunc &vf, OutsideFunc &of)
5941 {
5943  body(re);
5944  vf.join(body._VoxelFunc);
5945  of.join(body._OutsideFunc);
5946 }
5947 
5948 // -----------------------------------------------------------------------------
5949 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5950 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)
5951 {
5952  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5953  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5954 }
5955 
5956 // -----------------------------------------------------------------------------
5957 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5958 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, VoxelFunc &vf, OutsideFunc &of)
5959 {
5961  body(re);
5962  vf.join(body._VoxelFunc);
5963  of.join(body._OutsideFunc);
5964 }
5965 
5966 // -----------------------------------------------------------------------------
5967 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5968 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)
5969 {
5970  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5971  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5972 }
5973 
5974 // -----------------------------------------------------------------------------
5975 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5976 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, VoxelFunc &vf)
5977 {
5979  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
5980 }
5981 
5982 // -----------------------------------------------------------------------------
5983 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
5984 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)
5985 {
5986  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
5987  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
5988 }
5989 
5990 // -----------------------------------------------------------------------------
5991 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
5992 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, VoxelFunc &vf, OutsideFunc &of)
5993 {
5995  body(re);
5996  vf.join(body._VoxelFunc);
5997  of.join(body._OutsideFunc);
5998 }
5999 
6000 // -----------------------------------------------------------------------------
6001 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6002 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)
6003 {
6004  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6005  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6006 }
6007 
6008 // -----------------------------------------------------------------------------
6009 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6010 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, VoxelFunc &vf)
6011 {
6013  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6014 }
6015 
6016 // -----------------------------------------------------------------------------
6017 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6018 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)
6019 {
6020  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6021  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6022 }
6023 
6024 // -----------------------------------------------------------------------------
6025 // ParallelForEachVoxel
6026 // -----------------------------------------------------------------------------
6027 
6028 //
6029 // Image arguments by pointer
6030 //
6031 
6032 // -----------------------------------------------------------------------------
6033 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6034 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, VoxelFunc &vf)
6035 {
6036  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6037  blocked_range<int> re(0, im8->GetNumberOfVoxels());
6038  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6039  else parallel_for (re, body);
6040 }
6041 
6042 // -----------------------------------------------------------------------------
6043 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6044 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)
6045 {
6046  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6047  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6048 }
6049 
6050 // -----------------------------------------------------------------------------
6051 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6052 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, VoxelFunc &vf)
6053 {
6054  if (im8->GetTSize()) {
6055  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6056  } else {
6057  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6058  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
6059  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6060  else parallel_for (re, body);
6061  }
6062 }
6063 
6064 // -----------------------------------------------------------------------------
6065 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6066 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)
6067 {
6068  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6069  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6070 }
6071 
6072 // -----------------------------------------------------------------------------
6073 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6074 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, VoxelFunc &vf)
6075 {
6076  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6077  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6078  if (VoxelFunc::IsReduction()) {
6079  if (attr._dt) {
6080  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6081  } else {
6082  parallel_reduce(re, body);
6083  }
6084  vf.join(body._VoxelFunc);
6085  } else {
6086  if (attr._dt) {
6087  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6088  } else {
6089  parallel_for(re, body);
6090  }
6091  }
6092 }
6093 
6094 // -----------------------------------------------------------------------------
6095 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6096 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)
6097 {
6098  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6099  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6100 }
6101 
6102 // -----------------------------------------------------------------------------
6103 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6104 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, VoxelFunc &vf)
6105 {
6106  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6107  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6108  else parallel_for (re, body);
6109 }
6110 
6111 // -----------------------------------------------------------------------------
6112 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6113 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)
6114 {
6115  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6116  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6117 }
6118 
6119 // -----------------------------------------------------------------------------
6120 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6121 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, VoxelFunc &vf)
6122 {
6123  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6124  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6125  else parallel_for (re, body);
6126 }
6127 
6128 // -----------------------------------------------------------------------------
6129 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6130 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)
6131 {
6132  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6133  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6134 }
6135 
6136 // -----------------------------------------------------------------------------
6137 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6138 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, VoxelFunc &vf)
6139 {
6140  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6141  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6142  else parallel_for (re, body);
6143 }
6144 
6145 // -----------------------------------------------------------------------------
6146 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6147 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)
6148 {
6149  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6150  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6151 }
6152 
6153 //
6154 // Image arguments by reference
6155 //
6156 
6157 // -----------------------------------------------------------------------------
6158 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6159 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, VoxelFunc &vf)
6160 {
6161  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6163  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6164  else parallel_for (re, body);
6165 }
6166 
6167 // -----------------------------------------------------------------------------
6168 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6169 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)
6170 {
6171  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6172  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6173 }
6174 
6175 // -----------------------------------------------------------------------------
6176 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6177 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, VoxelFunc &vf)
6178 {
6179  if (im8.GetTSize()) {
6180  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6181  } else {
6182  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6183  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
6184  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6185  else parallel_for (re, body);
6186  }
6187 }
6188 
6189 // -----------------------------------------------------------------------------
6190 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6191 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)
6192 {
6193  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6194  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6195 }
6196 
6197 // -----------------------------------------------------------------------------
6198 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6199 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, VoxelFunc &vf)
6200 {
6201  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6202  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6203  if (VoxelFunc::IsReduction()) {
6204  if (attr._dt) {
6205  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6206  } else {
6207  parallel_reduce(re, body);
6208  }
6209  vf.join(body._VoxelFunc);
6210  } else {
6211  if (attr._dt) {
6212  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6213  } else {
6214  parallel_for(re, body);
6215  }
6216  }
6217 }
6218 
6219 // -----------------------------------------------------------------------------
6220 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6221 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)
6222 {
6223  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6224  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6225 }
6226 
6227 // -----------------------------------------------------------------------------
6228 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6229 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, VoxelFunc &vf)
6230 {
6231  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6232  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6233  else parallel_for (re, body);
6234 }
6235 
6236 // -----------------------------------------------------------------------------
6237 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6238 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)
6239 {
6240  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6241  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6242 }
6243 
6244 // -----------------------------------------------------------------------------
6245 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6246 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, VoxelFunc &vf)
6247 {
6248  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6249  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6250  else parallel_for (re, body);
6251 }
6252 
6253 // -----------------------------------------------------------------------------
6254 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6255 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)
6256 {
6257  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6258  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6259 }
6260 
6261 // -----------------------------------------------------------------------------
6262 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6263 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, VoxelFunc &vf)
6264 {
6265  OctaryForEachVoxelBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6266  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
6267  else parallel_for (re, body);
6268 }
6269 
6270 // -----------------------------------------------------------------------------
6271 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6272 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)
6273 {
6274  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6275  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6276 }
6277 
6278 // -----------------------------------------------------------------------------
6279 // ParallelForEachVoxelIf
6280 // -----------------------------------------------------------------------------
6281 
6282 //
6283 // Image arguments by pointer
6284 //
6285 
6286 // -----------------------------------------------------------------------------
6287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6288 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, VoxelFunc &vf, OutsideFunc &of)
6289 {
6290  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6291  blocked_range<int> re(0, im8->GetNumberOfVoxels());
6292  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6293  parallel_reduce(re, body);
6294  vf.join(body._VoxelFunc);
6295  of.join(body._OutsideFunc);
6296  } else {
6297  parallel_for(re, body);
6298  }
6299 }
6300 
6301 // -----------------------------------------------------------------------------
6302 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6303 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)
6304 {
6305  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6306  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6307 }
6308 
6309 // -----------------------------------------------------------------------------
6310 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6311 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, VoxelFunc &vf)
6312 {
6314  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6315 }
6316 
6317 // -----------------------------------------------------------------------------
6318 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6319 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)
6320 {
6321  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6322  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6323 }
6324 
6325 // -----------------------------------------------------------------------------
6326 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6327 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, VoxelFunc &vf, OutsideFunc &of)
6328 {
6329  if (im8->GetTSize()) {
6330  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6331  } else {
6332  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6333  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
6334  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6335  parallel_reduce(re, body);
6336  vf.join(body._VoxelFunc);
6337  of.join(body._OutsideFunc);
6338  } else {
6339  parallel_for(re, body);
6340  }
6341  }
6342 }
6343 
6344 // -----------------------------------------------------------------------------
6345 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6346 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)
6347 {
6348  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6349  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6350 }
6351 
6352 // -----------------------------------------------------------------------------
6353 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6354 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, VoxelFunc &vf)
6355 {
6357  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6358 }
6359 
6360 // -----------------------------------------------------------------------------
6361 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6362 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)
6363 {
6364  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6365  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6366 }
6367 
6368 // -----------------------------------------------------------------------------
6369 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6370 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, VoxelFunc &vf, OutsideFunc &of)
6371 {
6372  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6373  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6374  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6375  if (attr._dt) {
6376  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6377  } else {
6378  parallel_reduce(re, body);
6379  }
6380  vf.join(body._VoxelFunc);
6381  of.join(body._OutsideFunc);
6382  } else {
6383  if (attr._dt) {
6384  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6385  } else {
6386  parallel_for(re, body);
6387  }
6388  }
6389 }
6390 
6391 // -----------------------------------------------------------------------------
6392 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6393 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)
6394 {
6395  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6396  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6397 }
6398 
6399 // -----------------------------------------------------------------------------
6400 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6401 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, VoxelFunc &vf)
6402 {
6404  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6405 }
6406 
6407 // -----------------------------------------------------------------------------
6408 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6409 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)
6410 {
6411  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6412  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6413 }
6414 
6415 // -----------------------------------------------------------------------------
6416 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6417 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, VoxelFunc &vf, OutsideFunc &of)
6418 {
6419  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6420  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6421  parallel_reduce(re, body);
6422  vf.join(body._VoxelFunc);
6423  of.join(body._OutsideFunc);
6424  } else {
6425  parallel_for(re, body);
6426  }
6427 }
6428 
6429 // -----------------------------------------------------------------------------
6430 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6431 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)
6432 {
6433  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6434  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6435 }
6436 
6437 // -----------------------------------------------------------------------------
6438 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6439 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, VoxelFunc &vf)
6440 {
6442  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6443 }
6444 
6445 // -----------------------------------------------------------------------------
6446 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6447 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)
6448 {
6449  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6450  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6451 }
6452 
6453 // -----------------------------------------------------------------------------
6454 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6455 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, VoxelFunc &vf, OutsideFunc &of)
6456 {
6457  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6458  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6459  parallel_reduce(re, body);
6460  vf.join(body._VoxelFunc);
6461  of.join(body._OutsideFunc);
6462  } else {
6463  parallel_for(re, body);
6464  }
6465 }
6466 
6467 // -----------------------------------------------------------------------------
6468 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6469 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)
6470 {
6471  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6472  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6473 }
6474 
6475 // -----------------------------------------------------------------------------
6476 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6477 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, VoxelFunc &vf)
6478 {
6480  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6481 }
6482 
6483 // -----------------------------------------------------------------------------
6484 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6485 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)
6486 {
6487  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6488  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6489 }
6490 
6491 // -----------------------------------------------------------------------------
6492 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6493 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, VoxelFunc &vf, OutsideFunc &of)
6494 {
6495  OctaryForEachVoxelIfBody_5Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6496  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6497  parallel_reduce(re, body);
6498  vf.join(body._VoxelFunc);
6499  of.join(body._OutsideFunc);
6500  } else {
6501  parallel_for(re, body);
6502  }
6503 }
6504 
6505 // -----------------------------------------------------------------------------
6506 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6507 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)
6508 {
6509  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6510  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6511 }
6512 
6513 // -----------------------------------------------------------------------------
6514 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6515 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, VoxelFunc &vf)
6516 {
6518  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
6519 }
6520 
6521 // -----------------------------------------------------------------------------
6522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6523 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)
6524 {
6525  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6526  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
6527 }
6528 
6529 //
6530 // Image arguments by reference
6531 //
6532 
6533 // -----------------------------------------------------------------------------
6534 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6535 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, VoxelFunc &vf, OutsideFunc &of)
6536 {
6539  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6540  parallel_reduce(re, body);
6541  vf.join(body._VoxelFunc);
6542  of.join(body._OutsideFunc);
6543  } else {
6544  parallel_for(re, body);
6545  }
6546 }
6547 
6548 // -----------------------------------------------------------------------------
6549 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6550 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)
6551 {
6552  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6553  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6554 }
6555 
6556 // -----------------------------------------------------------------------------
6557 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6558 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, VoxelFunc &vf)
6559 {
6561  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6562 }
6563 
6564 // -----------------------------------------------------------------------------
6565 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6566 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)
6567 {
6568  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6569  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6570 }
6571 
6572 // -----------------------------------------------------------------------------
6573 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6574 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, VoxelFunc &vf, OutsideFunc &of)
6575 {
6576  if (im8.GetTSize()) {
6577  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6578  } else {
6580  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
6581  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6582  parallel_reduce(re, body);
6583  vf.join(body._VoxelFunc);
6584  of.join(body._OutsideFunc);
6585  } else {
6586  parallel_for(re, body);
6587  }
6588  }
6589 }
6590 
6591 // -----------------------------------------------------------------------------
6592 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6593 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)
6594 {
6595  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6596  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6597 }
6598 
6599 // -----------------------------------------------------------------------------
6600 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6601 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, VoxelFunc &vf)
6602 {
6604  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6605 }
6606 
6607 // -----------------------------------------------------------------------------
6608 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6609 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)
6610 {
6611  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6612  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
6613 }
6614 
6615 // -----------------------------------------------------------------------------
6616 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6617 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, VoxelFunc &vf, OutsideFunc &of)
6618 {
6620  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
6621  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6622  if (attr._dt) {
6623  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
6624  } else {
6625  parallel_reduce(re, body);
6626  }
6627  vf.join(body._VoxelFunc);
6628  of.join(body._OutsideFunc);
6629  } else {
6630  if (attr._dt) {
6631  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
6632  } else {
6633  parallel_for(re, body);
6634  }
6635  }
6636 }
6637 
6638 // -----------------------------------------------------------------------------
6639 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6640 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)
6641 {
6642  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6643  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6644 }
6645 
6646 // -----------------------------------------------------------------------------
6647 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6648 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, VoxelFunc &vf)
6649 {
6651  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6652 }
6653 
6654 // -----------------------------------------------------------------------------
6655 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6656 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)
6657 {
6658  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6659  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6660 }
6661 
6662 // -----------------------------------------------------------------------------
6663 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6664 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, VoxelFunc &vf, OutsideFunc &of)
6665 {
6667  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6668  parallel_reduce(re, body);
6669  vf.join(body._VoxelFunc);
6670  of.join(body._OutsideFunc);
6671  } else {
6672  parallel_for(re, body);
6673  }
6674 }
6675 
6676 // -----------------------------------------------------------------------------
6677 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6678 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)
6679 {
6680  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6681  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6682 }
6683 
6684 // -----------------------------------------------------------------------------
6685 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6686 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, VoxelFunc &vf)
6687 {
6689  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6690 }
6691 
6692 // -----------------------------------------------------------------------------
6693 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6694 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)
6695 {
6696  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6697  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6698 }
6699 
6700 // -----------------------------------------------------------------------------
6701 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6702 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, VoxelFunc &vf, OutsideFunc &of)
6703 {
6705  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6706  parallel_reduce(re, body);
6707  vf.join(body._VoxelFunc);
6708  of.join(body._OutsideFunc);
6709  } else {
6710  parallel_for(re, body);
6711  }
6712 }
6713 
6714 // -----------------------------------------------------------------------------
6715 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6716 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)
6717 {
6718  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6719  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6720 }
6721 
6722 // -----------------------------------------------------------------------------
6723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6724 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, VoxelFunc &vf)
6725 {
6727  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6728 }
6729 
6730 // -----------------------------------------------------------------------------
6731 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6732 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)
6733 {
6734  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6735  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6736 }
6737 
6738 // -----------------------------------------------------------------------------
6739 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6740 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, VoxelFunc &vf, OutsideFunc &of)
6741 {
6743  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
6744  parallel_reduce(re, body);
6745  vf.join(body._VoxelFunc);
6746  of.join(body._OutsideFunc);
6747  } else {
6748  parallel_for(re, body);
6749  }
6750 }
6751 
6752 // -----------------------------------------------------------------------------
6753 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
6754 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)
6755 {
6756  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6757  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6758 }
6759 
6760 // -----------------------------------------------------------------------------
6761 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6762 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, VoxelFunc &vf)
6763 {
6765  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
6766 }
6767 
6768 // -----------------------------------------------------------------------------
6769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6770 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)
6771 {
6772  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
6773  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
6774 }
6775 
6776 // =============================================================================
6777 // 4 const, 4 non-const images
6778 // =============================================================================
6779 
6780 // -----------------------------------------------------------------------------
6781 /**
6782  * ForEachVoxel body for voxel function of 4 const, 4 non-const images
6783  */
6784 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
6786 {
6787  const GenericImage<T1> &im1;
6788  const GenericImage<T2> &im2;
6789  const GenericImage<T3> &im3;
6790  const GenericImage<T4> &im4;
6791  GenericImage<T5> &im5;
6792  GenericImage<T6> &im6;
6793  GenericImage<T7> &im7;
6794  GenericImage<T8> &im8;
6795 
6796  /// Constructor
6798  const GenericImage<T2> &im2,
6799  const GenericImage<T3> &im3,
6800  const GenericImage<T4> &im4,
6801  GenericImage<T5> &im5,
6802  GenericImage<T6> &im6,
6803  GenericImage<T7> &im7,
6804  GenericImage<T8> &im8,
6805  VoxelFunc &vf)
6806  :
6807  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
6808  {}
6809 
6810  /// Copy constructor
6812  :
6813  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)
6814  {}
6815 
6816  /// Split constructor
6818  :
6819  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)
6820  {}
6821 
6822  /// Process entire image
6823  void operator ()(const ImageAttributes &attr) const
6824  {
6825  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
6826  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
6827  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
6828  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
6829  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
6830  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
6831  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
6832  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
6833 
6834  const int T = (attr._dt ? attr._t : 1);
6835 
6836  for (int l = 0; l < T; ++l)
6837  for (int k = 0; k < attr._z; ++k)
6838  for (int j = 0; j < attr._y; ++j)
6839  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
6840  // const_cast such that voxel functions need only implement
6841  // non-const operator() which is required for parallel_reduce
6842  const_cast<OctaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
6843  }
6844  }
6845 
6846  /// Process image region using linear index
6847  void operator ()(const blocked_range<int> &re) const
6848  {
6849  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
6850  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
6851  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
6852  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
6853  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
6854  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
6855  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
6856  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
6857 
6858  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) {
6859  // const_cast such that voxel functions need only implement
6860  // non-const operator() which is required for parallel_reduce
6861  const_cast<OctaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
6862  }
6863  }
6864 
6865  /// Process 2D image region
6866  void operator ()(const blocked_range2d<int> &re) const
6867  {
6868  const int bi = re.cols().begin();
6869  const int bj = re.rows().begin();
6870  const int ei = re.cols().end();
6871  const int ej = re.rows().end();
6872 
6873  const int s1 = im8.GetX() - (ei - bi);
6874 
6875  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6876  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6877  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6878  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6879  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6880  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6881  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6882  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
6883 
6884  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
6885  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
6886  // const_cast such that voxel functions need only implement
6887  // non-const operator() which is required for parallel_reduce
6888  const_cast<OctaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
6889  }
6890  }
6891 
6892  /// Process 3D image region
6893  void operator ()(const blocked_range3d<int> &re) const
6894  {
6895  const int bi = re.cols ().begin();
6896  const int bj = re.rows ().begin();
6897  const int bk = re.pages().begin();
6898  const int ei = re.cols ().end();
6899  const int ej = re.rows ().end();
6900  const int ek = re.pages().end();
6901 
6902  const int s1 = im8.GetX() - (ei - bi);
6903  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
6904 
6905  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
6906  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
6907  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
6908  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
6909  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
6910  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
6911  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
6912  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
6913 
6914  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
6915  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
6916  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
6917  // const_cast such that voxel functions need only implement
6918  // non-const operator() which is required for parallel_reduce
6919  const_cast<OctaryForEachVoxelBody_4Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
6920  }
6921  }
6922 };
6923 
6924 // -----------------------------------------------------------------------------
6925 /**
6926  * ForEachVoxel body for inside and outside unary voxel function of 4 const, 4 non-const images
6927  */
6928 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
6929  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
6930  class Domain = ForEachVoxelDomain::Foreground>
6931 struct OctaryForEachVoxelIfBody_4Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
6932 {
6933  const GenericImage<T1> &im1;
6934  const GenericImage<T2> &im2;
6935  const GenericImage<T3> &im3;
6936  const GenericImage<T4> &im4;
6937  GenericImage<T5> &im5;
6938  GenericImage<T6> &im6;
6939  GenericImage<T7> &im7;
6940  GenericImage<T8> &im8;
6941 
6942  /// Constructor
6944  const GenericImage<T2> &im2,
6945  const GenericImage<T3> &im3,
6946  const GenericImage<T4> &im4,
6947  GenericImage<T5> &im5,
6948  GenericImage<T6> &im6,
6949  GenericImage<T7> &im7,
6950  GenericImage<T8> &im8,
6951  VoxelFunc &vf, OutsideFunc &of)
6952  :
6953  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
6954  {}
6955 
6956  /// Copy constructor
6958  :
6959  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)
6960  {}
6961 
6962  /// Split constructor
6964  :
6965  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)
6966  {}
6967 
6968  /// Process entire image
6969  void operator ()(const ImageAttributes &attr) const
6970  {
6971  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
6972  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
6973  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
6974  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
6975  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
6976  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
6977  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
6978  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
6979 
6980  const int T = (attr._dt ? attr._t : 1);
6981 
6982  for (int l = 0; l < T; ++l)
6983  for (int k = 0; k < attr._z; ++k)
6984  for (int j = 0; j < attr._y; ++j)
6985  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
6986  if (Domain::IsInside(im8, i, j, k, l, p8)) {
6987  // const_cast such that voxel functions need only implement
6988  // non-const operator() which is required for parallel_reduce
6989  const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
6990  } else const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
6991  }
6992  }
6993 
6994  /// Process image region using linear index
6995  void operator ()(const blocked_range<int> &re) const
6996  {
6997  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
6998  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
6999  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
7000  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
7001  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
7002  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
7003  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
7004  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
7005 
7006  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) {
7007  if (Domain::IsInside(im8, idx, p8)) {
7008  // const_cast such that voxel functions need only implement
7009  // non-const operator() which is required for parallel_reduce
7010  const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
7011  } else const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
7012  }
7013  }
7014 
7015  /// Process 2D image region
7016  void operator ()(const blocked_range2d<int> &re) const
7017  {
7018  const int bi = re.cols().begin();
7019  const int bj = re.rows().begin();
7020  const int ei = re.cols().end();
7021  const int ej = re.rows().end();
7022 
7023  const int s1 = im8.GetX() - (ei - bi);
7024 
7025  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7026  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7027  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7028  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7029  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7030  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7031  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7032  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
7033 
7034  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
7035  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
7036  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
7037  // const_cast such that voxel functions need only implement
7038  // non-const operator() which is required for parallel_reduce
7039  const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
7040  } else const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
7041  }
7042  }
7043 
7044  /// Process 3D image region
7045  void operator ()(const blocked_range3d<int> &re) const
7046  {
7047  const int bi = re.cols ().begin();
7048  const int bj = re.rows ().begin();
7049  const int bk = re.pages().begin();
7050  const int ei = re.cols ().end();
7051  const int ej = re.rows ().end();
7052  const int ek = re.pages().end();
7053 
7054  const int s1 = im8.GetX() - (ei - bi);
7055  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
7056 
7057  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
7058  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
7059  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
7060  const T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
7061  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
7062  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
7063  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
7064  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
7065 
7066  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
7067  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
7068  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
7069  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
7070  // const_cast such that voxel functions need only implement
7071  // non-const operator() which is required for parallel_reduce
7072  const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
7073  } else const_cast<OctaryForEachVoxelIfBody_4Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
7074  }
7075  }
7076 };
7077 
7078 // -----------------------------------------------------------------------------
7079 // ForEachVoxel
7080 // -----------------------------------------------------------------------------
7081 
7082 //
7083 // Image arguments by pointer
7084 //
7085 
7086 // -----------------------------------------------------------------------------
7087 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7088 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, VoxelFunc &vf)
7089 {
7090  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7091  blocked_range<int> re(0, im8->GetNumberOfVoxels());
7092  body(re);
7093  vf.join(body._VoxelFunc);
7094 }
7095 
7096 // -----------------------------------------------------------------------------
7097 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7098 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)
7099 {
7100  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7101  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7102 }
7103 
7104 // -----------------------------------------------------------------------------
7105 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7106 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, VoxelFunc &vf)
7107 {
7108  if (im8->GetTSize()) {
7109  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7110  } else {
7111  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7112  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
7113  body(re);
7114  vf.join(body._VoxelFunc);
7115  }
7116 }
7117 
7118 // -----------------------------------------------------------------------------
7119 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7120 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)
7121 {
7122  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7123  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7124 }
7125 
7126 // -----------------------------------------------------------------------------
7127 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7128 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, VoxelFunc &vf)
7129 {
7130  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7131  body(attr);
7132  vf.join(body._VoxelFunc);
7133 }
7134 
7135 // -----------------------------------------------------------------------------
7136 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7137 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)
7138 {
7139  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7140  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7141 }
7142 
7143 // -----------------------------------------------------------------------------
7144 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7145 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, VoxelFunc &vf)
7146 {
7147  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7148  body(re);
7149  vf.join(body._VoxelFunc);
7150 }
7151 
7152 // -----------------------------------------------------------------------------
7153 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7154 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)
7155 {
7156  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7157  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7158 }
7159 
7160 // -----------------------------------------------------------------------------
7161 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7162 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, VoxelFunc &vf)
7163 {
7164  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7165  body(re);
7166  vf.join(body._VoxelFunc);
7167 }
7168 
7169 // -----------------------------------------------------------------------------
7170 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7171 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)
7172 {
7173  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7174  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7175 }
7176 
7177 // -----------------------------------------------------------------------------
7178 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7179 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, VoxelFunc &vf)
7180 {
7181  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7182  body(re);
7183  vf.join(body._VoxelFunc);
7184 }
7185 
7186 // -----------------------------------------------------------------------------
7187 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7188 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)
7189 {
7190  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7191  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7192 }
7193 
7194 //
7195 // Image arguments by reference
7196 //
7197 
7198 // -----------------------------------------------------------------------------
7199 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7200 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, VoxelFunc &vf)
7201 {
7202  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7204  body(re);
7205  vf.join(body._VoxelFunc);
7206 }
7207 
7208 // -----------------------------------------------------------------------------
7209 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7210 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)
7211 {
7212  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7213  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7214 }
7215 
7216 // -----------------------------------------------------------------------------
7217 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7218 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, VoxelFunc &vf)
7219 {
7220  if (im8.GetTSize()) {
7221  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7222  } else {
7223  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7224  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
7225  body(re);
7226  vf.join(body._VoxelFunc);
7227  }
7228 }
7229 
7230 // -----------------------------------------------------------------------------
7231 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7232 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)
7233 {
7234  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7235  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7236 }
7237 
7238 // -----------------------------------------------------------------------------
7239 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7240 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, VoxelFunc &vf)
7241 {
7242  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7243  body(attr);
7244  vf.join(body._VoxelFunc);
7245 }
7246 
7247 // -----------------------------------------------------------------------------
7248 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7249 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)
7250 {
7251  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7252  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7253 }
7254 
7255 // -----------------------------------------------------------------------------
7256 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7257 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, VoxelFunc &vf)
7258 {
7259  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7260  body(re);
7261  vf.join(body._VoxelFunc);
7262 }
7263 
7264 // -----------------------------------------------------------------------------
7265 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7266 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)
7267 {
7268  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7269  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7270 }
7271 
7272 // -----------------------------------------------------------------------------
7273 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7274 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, VoxelFunc &vf)
7275 {
7276  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7277  body(re);
7278  vf.join(body._VoxelFunc);
7279 }
7280 
7281 // -----------------------------------------------------------------------------
7282 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7283 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)
7284 {
7285  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7286  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7287 }
7288 
7289 // -----------------------------------------------------------------------------
7290 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7291 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, VoxelFunc &vf)
7292 {
7293  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7294  body(re);
7295  vf.join(body._VoxelFunc);
7296 }
7297 
7298 // -----------------------------------------------------------------------------
7299 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7300 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)
7301 {
7302  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7303  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7304 }
7305 
7306 // -----------------------------------------------------------------------------
7307 // ForEachVoxelIf
7308 // -----------------------------------------------------------------------------
7309 
7310 //
7311 // Image arguments by pointer
7312 //
7313 
7314 // -----------------------------------------------------------------------------
7315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7316 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, VoxelFunc &vf, OutsideFunc &of)
7317 {
7318  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7319  blocked_range<int> re(0, im8->GetNumberOfVoxels());
7320  body(re);
7321  vf.join(body._VoxelFunc);
7322  of.join(body._OutsideFunc);
7323 }
7324 
7325 // -----------------------------------------------------------------------------
7326 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7327 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)
7328 {
7329  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7330  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7331 }
7332 
7333 // -----------------------------------------------------------------------------
7334 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7335 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, VoxelFunc &vf)
7336 {
7338  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7339 }
7340 
7341 // -----------------------------------------------------------------------------
7342 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7343 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)
7344 {
7345  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7346  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7347 }
7348 
7349 // -----------------------------------------------------------------------------
7350 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7351 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, VoxelFunc &vf, OutsideFunc &of)
7352 {
7353  if (im8->GetTSize()) {
7354  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7355  } else {
7356  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7357  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
7358  body(re);
7359  vf.join(body._VoxelFunc);
7360  of.join(body._OutsideFunc);
7361  }
7362 }
7363 
7364 // -----------------------------------------------------------------------------
7365 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7366 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)
7367 {
7368  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7369  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7370 }
7371 
7372 // -----------------------------------------------------------------------------
7373 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7374 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, VoxelFunc &vf)
7375 {
7377  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7378 }
7379 
7380 // -----------------------------------------------------------------------------
7381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7382 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)
7383 {
7384  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7385  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7386 }
7387 
7388 // -----------------------------------------------------------------------------
7389 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7390 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, VoxelFunc &vf, OutsideFunc &of)
7391 {
7392  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7393  body(attr);
7394  vf.join(body._VoxelFunc);
7395  of.join(body._OutsideFunc);
7396 }
7397 
7398 // -----------------------------------------------------------------------------
7399 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7400 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)
7401 {
7402  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7403  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7404 }
7405 
7406 // -----------------------------------------------------------------------------
7407 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7408 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, VoxelFunc &vf)
7409 {
7411  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7412 }
7413 
7414 // -----------------------------------------------------------------------------
7415 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7416 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)
7417 {
7418  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7419  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7420 }
7421 
7422 // -----------------------------------------------------------------------------
7423 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7424 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, VoxelFunc &vf, OutsideFunc &of)
7425 {
7426  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7427  body(re);
7428  vf.join(body._VoxelFunc);
7429  of.join(body._OutsideFunc);
7430 }
7431 
7432 // -----------------------------------------------------------------------------
7433 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7434 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)
7435 {
7436  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7437  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, 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 VoxelFunc, class OutsideFunc>
7442 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, VoxelFunc &vf, OutsideFunc &of)
7443 {
7444  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7445  body(re);
7446  vf.join(body._VoxelFunc);
7447  of.join(body._OutsideFunc);
7448 }
7449 
7450 // -----------------------------------------------------------------------------
7451 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7452 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)
7453 {
7454  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7455  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7456 }
7457 
7458 // -----------------------------------------------------------------------------
7459 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7460 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, VoxelFunc &vf)
7461 {
7463  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, 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 VoxelFunc>
7468 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)
7469 {
7470  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7471  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7472 }
7473 
7474 // -----------------------------------------------------------------------------
7475 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7476 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, VoxelFunc &vf, OutsideFunc &of)
7477 {
7478  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7479  body(re);
7480  vf.join(body._VoxelFunc);
7481  of.join(body._OutsideFunc);
7482 }
7483 
7484 // -----------------------------------------------------------------------------
7485 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7486 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)
7487 {
7488  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7489  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7490 }
7491 
7492 // -----------------------------------------------------------------------------
7493 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7494 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, VoxelFunc &vf)
7495 {
7497  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, 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 VoxelFunc>
7502 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)
7503 {
7504  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7505  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7506 }
7507 
7508 //
7509 // Image arguments by reference
7510 //
7511 
7512 // -----------------------------------------------------------------------------
7513 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7514 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, VoxelFunc &vf, OutsideFunc &of)
7515 {
7518  body(re);
7519  vf.join(body._VoxelFunc);
7520  of.join(body._OutsideFunc);
7521 }
7522 
7523 // -----------------------------------------------------------------------------
7524 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7525 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)
7526 {
7527  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7528  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7529 }
7530 
7531 // -----------------------------------------------------------------------------
7532 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7533 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, VoxelFunc &vf)
7534 {
7536  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7537 }
7538 
7539 // -----------------------------------------------------------------------------
7540 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7541 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)
7542 {
7543  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7544  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7545 }
7546 
7547 // -----------------------------------------------------------------------------
7548 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7549 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, VoxelFunc &vf, OutsideFunc &of)
7550 {
7551  if (im8.GetTSize()) {
7552  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7553  } else {
7555  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
7556  body(re);
7557  vf.join(body._VoxelFunc);
7558  of.join(body._OutsideFunc);
7559  }
7560 }
7561 
7562 // -----------------------------------------------------------------------------
7563 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7564 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)
7565 {
7566  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7567  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7568 }
7569 
7570 // -----------------------------------------------------------------------------
7571 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7572 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, VoxelFunc &vf)
7573 {
7575  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7576 }
7577 
7578 // -----------------------------------------------------------------------------
7579 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7580 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)
7581 {
7582  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7583  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7584 }
7585 
7586 // -----------------------------------------------------------------------------
7587 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7588 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, VoxelFunc &vf, OutsideFunc &of)
7589 {
7591  body(attr);
7592  vf.join(body._VoxelFunc);
7593  of.join(body._OutsideFunc);
7594 }
7595 
7596 // -----------------------------------------------------------------------------
7597 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7598 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)
7599 {
7600  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7601  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7602 }
7603 
7604 // -----------------------------------------------------------------------------
7605 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7606 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, VoxelFunc &vf)
7607 {
7609  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7610 }
7611 
7612 // -----------------------------------------------------------------------------
7613 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7614 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)
7615 {
7616  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7617  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7618 }
7619 
7620 // -----------------------------------------------------------------------------
7621 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7622 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, VoxelFunc &vf, OutsideFunc &of)
7623 {
7625  body(re);
7626  vf.join(body._VoxelFunc);
7627  of.join(body._OutsideFunc);
7628 }
7629 
7630 // -----------------------------------------------------------------------------
7631 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7632 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)
7633 {
7634  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7635  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc, class OutsideFunc>
7640 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, VoxelFunc &vf, OutsideFunc &of)
7641 {
7643  body(re);
7644  vf.join(body._VoxelFunc);
7645  of.join(body._OutsideFunc);
7646 }
7647 
7648 // -----------------------------------------------------------------------------
7649 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7650 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)
7651 {
7652  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7653  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7654 }
7655 
7656 // -----------------------------------------------------------------------------
7657 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7658 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, VoxelFunc &vf)
7659 {
7661  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
7666 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)
7667 {
7668  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7669  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7670 }
7671 
7672 // -----------------------------------------------------------------------------
7673 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7674 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, VoxelFunc &vf, OutsideFunc &of)
7675 {
7677  body(re);
7678  vf.join(body._VoxelFunc);
7679  of.join(body._OutsideFunc);
7680 }
7681 
7682 // -----------------------------------------------------------------------------
7683 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7684 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)
7685 {
7686  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7687  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
7688 }
7689 
7690 // -----------------------------------------------------------------------------
7691 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7692 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, VoxelFunc &vf)
7693 {
7695  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
7700 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)
7701 {
7702  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7703  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7704 }
7705 
7706 // -----------------------------------------------------------------------------
7707 // ParallelForEachVoxel
7708 // -----------------------------------------------------------------------------
7709 
7710 //
7711 // Image arguments by pointer
7712 //
7713 
7714 // -----------------------------------------------------------------------------
7715 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7716 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, VoxelFunc &vf)
7717 {
7718  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7719  blocked_range<int> re(0, im8->GetNumberOfVoxels());
7720  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7721  else parallel_for (re, body);
7722 }
7723 
7724 // -----------------------------------------------------------------------------
7725 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7726 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)
7727 {
7728  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7729  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7730 }
7731 
7732 // -----------------------------------------------------------------------------
7733 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7734 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, VoxelFunc &vf)
7735 {
7736  if (im8->GetTSize()) {
7737  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7738  } else {
7739  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7740  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
7741  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7742  else parallel_for (re, body);
7743  }
7744 }
7745 
7746 // -----------------------------------------------------------------------------
7747 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7748 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)
7749 {
7750  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7751  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7752 }
7753 
7754 // -----------------------------------------------------------------------------
7755 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7756 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, VoxelFunc &vf)
7757 {
7758  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7759  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7760  if (VoxelFunc::IsReduction()) {
7761  if (attr._dt) {
7762  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7763  } else {
7764  parallel_reduce(re, body);
7765  }
7766  vf.join(body._VoxelFunc);
7767  } else {
7768  if (attr._dt) {
7769  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7770  } else {
7771  parallel_for(re, body);
7772  }
7773  }
7774 }
7775 
7776 // -----------------------------------------------------------------------------
7777 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7778 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)
7779 {
7780  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7781  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7782 }
7783 
7784 // -----------------------------------------------------------------------------
7785 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7786 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, VoxelFunc &vf)
7787 {
7788  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7789  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7790  else parallel_for (re, body);
7791 }
7792 
7793 // -----------------------------------------------------------------------------
7794 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7795 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)
7796 {
7797  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7798  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7799 }
7800 
7801 // -----------------------------------------------------------------------------
7802 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7803 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, VoxelFunc &vf)
7804 {
7805  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7806  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7807  else parallel_for (re, body);
7808 }
7809 
7810 // -----------------------------------------------------------------------------
7811 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7812 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)
7813 {
7814  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7815  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7816 }
7817 
7818 // -----------------------------------------------------------------------------
7819 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7820 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, VoxelFunc &vf)
7821 {
7822  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7823  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7824  else parallel_for (re, body);
7825 }
7826 
7827 // -----------------------------------------------------------------------------
7828 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7829 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)
7830 {
7831  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7832  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
7833 }
7834 
7835 //
7836 // Image arguments by reference
7837 //
7838 
7839 // -----------------------------------------------------------------------------
7840 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7841 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, VoxelFunc &vf)
7842 {
7843  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7845  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7846  else parallel_for (re, body);
7847 }
7848 
7849 // -----------------------------------------------------------------------------
7850 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7851 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)
7852 {
7853  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7854  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7855 }
7856 
7857 // -----------------------------------------------------------------------------
7858 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7859 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, VoxelFunc &vf)
7860 {
7861  if (im8.GetTSize()) {
7862  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7863  } else {
7864  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7865  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
7866  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7867  else parallel_for (re, body);
7868  }
7869 }
7870 
7871 // -----------------------------------------------------------------------------
7872 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7873 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)
7874 {
7875  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7876  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7877 }
7878 
7879 // -----------------------------------------------------------------------------
7880 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7881 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, VoxelFunc &vf)
7882 {
7883  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7884  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
7885  if (VoxelFunc::IsReduction()) {
7886  if (attr._dt) {
7887  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
7888  } else {
7889  parallel_reduce(re, body);
7890  }
7891  vf.join(body._VoxelFunc);
7892  } else {
7893  if (attr._dt) {
7894  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
7895  } else {
7896  parallel_for(re, body);
7897  }
7898  }
7899 }
7900 
7901 // -----------------------------------------------------------------------------
7902 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7903 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)
7904 {
7905  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7906  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7907 }
7908 
7909 // -----------------------------------------------------------------------------
7910 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7911 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, VoxelFunc &vf)
7912 {
7913  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7914  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7915  else parallel_for (re, body);
7916 }
7917 
7918 // -----------------------------------------------------------------------------
7919 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7920 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)
7921 {
7922  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7923  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7924 }
7925 
7926 // -----------------------------------------------------------------------------
7927 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7928 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, VoxelFunc &vf)
7929 {
7930  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7931  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7932  else parallel_for (re, body);
7933 }
7934 
7935 // -----------------------------------------------------------------------------
7936 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7937 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)
7938 {
7939  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7940  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7941 }
7942 
7943 // -----------------------------------------------------------------------------
7944 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7945 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, VoxelFunc &vf)
7946 {
7947  OctaryForEachVoxelBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
7948  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
7949  else parallel_for (re, body);
7950 }
7951 
7952 // -----------------------------------------------------------------------------
7953 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7954 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)
7955 {
7956  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7957  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
7958 }
7959 
7960 // -----------------------------------------------------------------------------
7961 // ParallelForEachVoxelIf
7962 // -----------------------------------------------------------------------------
7963 
7964 //
7965 // Image arguments by pointer
7966 //
7967 
7968 // -----------------------------------------------------------------------------
7969 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7970 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, VoxelFunc &vf, OutsideFunc &of)
7971 {
7972  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7973  blocked_range<int> re(0, im8->GetNumberOfVoxels());
7974  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
7975  parallel_reduce(re, body);
7976  vf.join(body._VoxelFunc);
7977  of.join(body._OutsideFunc);
7978  } else {
7979  parallel_for(re, body);
7980  }
7981 }
7982 
7983 // -----------------------------------------------------------------------------
7984 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
7985 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)
7986 {
7987  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
7988  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7989 }
7990 
7991 // -----------------------------------------------------------------------------
7992 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
7993 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, VoxelFunc &vf)
7994 {
7996  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
7997 }
7998 
7999 // -----------------------------------------------------------------------------
8000 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8001 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)
8002 {
8003  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8004  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8005 }
8006 
8007 // -----------------------------------------------------------------------------
8008 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8009 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, VoxelFunc &vf, OutsideFunc &of)
8010 {
8011  if (im8->GetTSize()) {
8012  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8013  } else {
8014  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8015  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
8016  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8017  parallel_reduce(re, body);
8018  vf.join(body._VoxelFunc);
8019  of.join(body._OutsideFunc);
8020  } else {
8021  parallel_for(re, body);
8022  }
8023  }
8024 }
8025 
8026 // -----------------------------------------------------------------------------
8027 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8028 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)
8029 {
8030  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8031  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8032 }
8033 
8034 // -----------------------------------------------------------------------------
8035 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8036 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, VoxelFunc &vf)
8037 {
8039  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8040 }
8041 
8042 // -----------------------------------------------------------------------------
8043 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8044 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)
8045 {
8046  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8047  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8048 }
8049 
8050 // -----------------------------------------------------------------------------
8051 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8052 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, VoxelFunc &vf, OutsideFunc &of)
8053 {
8054  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8055  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
8056  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8057  if (attr._dt) {
8058  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
8059  } else {
8060  parallel_reduce(re, body);
8061  }
8062  vf.join(body._VoxelFunc);
8063  of.join(body._OutsideFunc);
8064  } else {
8065  if (attr._dt) {
8066  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
8067  } else {
8068  parallel_for(re, body);
8069  }
8070  }
8071 }
8072 
8073 // -----------------------------------------------------------------------------
8074 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8075 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)
8076 {
8077  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8078  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8079 }
8080 
8081 // -----------------------------------------------------------------------------
8082 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8083 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, VoxelFunc &vf)
8084 {
8086  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8087 }
8088 
8089 // -----------------------------------------------------------------------------
8090 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8091 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)
8092 {
8093  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8094  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8095 }
8096 
8097 // -----------------------------------------------------------------------------
8098 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8099 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, VoxelFunc &vf, OutsideFunc &of)
8100 {
8101  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8102  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8103  parallel_reduce(re, body);
8104  vf.join(body._VoxelFunc);
8105  of.join(body._OutsideFunc);
8106  } else {
8107  parallel_for(re, body);
8108  }
8109 }
8110 
8111 // -----------------------------------------------------------------------------
8112 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8113 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)
8114 {
8115  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8116  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8117 }
8118 
8119 // -----------------------------------------------------------------------------
8120 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8121 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, VoxelFunc &vf)
8122 {
8124  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8125 }
8126 
8127 // -----------------------------------------------------------------------------
8128 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8129 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)
8130 {
8131  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8132  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8133 }
8134 
8135 // -----------------------------------------------------------------------------
8136 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8137 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, VoxelFunc &vf, OutsideFunc &of)
8138 {
8139  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8140  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8141  parallel_reduce(re, body);
8142  vf.join(body._VoxelFunc);
8143  of.join(body._OutsideFunc);
8144  } else {
8145  parallel_for(re, body);
8146  }
8147 }
8148 
8149 // -----------------------------------------------------------------------------
8150 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8151 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)
8152 {
8153  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8154  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8155 }
8156 
8157 // -----------------------------------------------------------------------------
8158 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8159 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, VoxelFunc &vf)
8160 {
8162  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8163 }
8164 
8165 // -----------------------------------------------------------------------------
8166 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8167 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)
8168 {
8169  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8170  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8171 }
8172 
8173 // -----------------------------------------------------------------------------
8174 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8175 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, VoxelFunc &vf, OutsideFunc &of)
8176 {
8177  OctaryForEachVoxelIfBody_4Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8178  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8179  parallel_reduce(re, body);
8180  vf.join(body._VoxelFunc);
8181  of.join(body._OutsideFunc);
8182  } else {
8183  parallel_for(re, body);
8184  }
8185 }
8186 
8187 // -----------------------------------------------------------------------------
8188 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8189 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)
8190 {
8191  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8192  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8193 }
8194 
8195 // -----------------------------------------------------------------------------
8196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8197 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, VoxelFunc &vf)
8198 {
8200  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
8201 }
8202 
8203 // -----------------------------------------------------------------------------
8204 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8205 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)
8206 {
8207  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8208  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8209 }
8210 
8211 //
8212 // Image arguments by reference
8213 //
8214 
8215 // -----------------------------------------------------------------------------
8216 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8217 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, VoxelFunc &vf, OutsideFunc &of)
8218 {
8221  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8222  parallel_reduce(re, body);
8223  vf.join(body._VoxelFunc);
8224  of.join(body._OutsideFunc);
8225  } else {
8226  parallel_for(re, body);
8227  }
8228 }
8229 
8230 // -----------------------------------------------------------------------------
8231 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8232 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)
8233 {
8234  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8235  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8236 }
8237 
8238 // -----------------------------------------------------------------------------
8239 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8240 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, VoxelFunc &vf)
8241 {
8243  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8244 }
8245 
8246 // -----------------------------------------------------------------------------
8247 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8248 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)
8249 {
8250  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8251  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8252 }
8253 
8254 // -----------------------------------------------------------------------------
8255 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8256 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, VoxelFunc &vf, OutsideFunc &of)
8257 {
8258  if (im8.GetTSize()) {
8259  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8260  } else {
8262  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
8263  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8264  parallel_reduce(re, body);
8265  vf.join(body._VoxelFunc);
8266  of.join(body._OutsideFunc);
8267  } else {
8268  parallel_for(re, body);
8269  }
8270  }
8271 }
8272 
8273 // -----------------------------------------------------------------------------
8274 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8275 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)
8276 {
8277  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8278  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8279 }
8280 
8281 // -----------------------------------------------------------------------------
8282 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8283 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, VoxelFunc &vf)
8284 {
8286  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8287 }
8288 
8289 // -----------------------------------------------------------------------------
8290 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8291 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)
8292 {
8293  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8294  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8295 }
8296 
8297 // -----------------------------------------------------------------------------
8298 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8299 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, VoxelFunc &vf, OutsideFunc &of)
8300 {
8302  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
8303  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8304  if (attr._dt) {
8305  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
8306  } else {
8307  parallel_reduce(re, body);
8308  }
8309  vf.join(body._VoxelFunc);
8310  of.join(body._OutsideFunc);
8311  } else {
8312  if (attr._dt) {
8313  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
8314  } else {
8315  parallel_for(re, body);
8316  }
8317  }
8318 }
8319 
8320 // -----------------------------------------------------------------------------
8321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8322 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)
8323 {
8324  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8325  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8326 }
8327 
8328 // -----------------------------------------------------------------------------
8329 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8330 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, VoxelFunc &vf)
8331 {
8333  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8334 }
8335 
8336 // -----------------------------------------------------------------------------
8337 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8338 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)
8339 {
8340  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8341  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8342 }
8343 
8344 // -----------------------------------------------------------------------------
8345 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8346 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, VoxelFunc &vf, OutsideFunc &of)
8347 {
8349  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8350  parallel_reduce(re, body);
8351  vf.join(body._VoxelFunc);
8352  of.join(body._OutsideFunc);
8353  } else {
8354  parallel_for(re, body);
8355  }
8356 }
8357 
8358 // -----------------------------------------------------------------------------
8359 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8360 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)
8361 {
8362  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8363  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8364 }
8365 
8366 // -----------------------------------------------------------------------------
8367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8368 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, VoxelFunc &vf)
8369 {
8371  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8372 }
8373 
8374 // -----------------------------------------------------------------------------
8375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8376 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)
8377 {
8378  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8379  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8380 }
8381 
8382 // -----------------------------------------------------------------------------
8383 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8384 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, VoxelFunc &vf, OutsideFunc &of)
8385 {
8387  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8388  parallel_reduce(re, body);
8389  vf.join(body._VoxelFunc);
8390  of.join(body._OutsideFunc);
8391  } else {
8392  parallel_for(re, body);
8393  }
8394 }
8395 
8396 // -----------------------------------------------------------------------------
8397 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8398 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)
8399 {
8400  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8401  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8402 }
8403 
8404 // -----------------------------------------------------------------------------
8405 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8406 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, VoxelFunc &vf)
8407 {
8409  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8410 }
8411 
8412 // -----------------------------------------------------------------------------
8413 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8414 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)
8415 {
8416  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8417  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8418 }
8419 
8420 // -----------------------------------------------------------------------------
8421 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8422 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, VoxelFunc &vf, OutsideFunc &of)
8423 {
8425  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
8426  parallel_reduce(re, body);
8427  vf.join(body._VoxelFunc);
8428  of.join(body._OutsideFunc);
8429  } else {
8430  parallel_for(re, body);
8431  }
8432 }
8433 
8434 // -----------------------------------------------------------------------------
8435 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8436 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)
8437 {
8438  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8439  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8440 }
8441 
8442 // -----------------------------------------------------------------------------
8443 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8444 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, VoxelFunc &vf)
8445 {
8447  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
8448 }
8449 
8450 // -----------------------------------------------------------------------------
8451 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8452 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)
8453 {
8454  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8455  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8456 }
8457 
8458 // =============================================================================
8459 // 3 const, 5 non-const images
8460 // =============================================================================
8461 
8462 // -----------------------------------------------------------------------------
8463 /**
8464  * ForEachVoxel body for voxel function of 3 const, 5 non-const images
8465  */
8466 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8468 {
8469  const GenericImage<T1> &im1;
8470  const GenericImage<T2> &im2;
8471  const GenericImage<T3> &im3;
8472  GenericImage<T4> &im4;
8473  GenericImage<T5> &im5;
8474  GenericImage<T6> &im6;
8475  GenericImage<T7> &im7;
8476  GenericImage<T8> &im8;
8477 
8478  /// Constructor
8480  const GenericImage<T2> &im2,
8481  const GenericImage<T3> &im3,
8482  GenericImage<T4> &im4,
8483  GenericImage<T5> &im5,
8484  GenericImage<T6> &im6,
8485  GenericImage<T7> &im7,
8486  GenericImage<T8> &im8,
8487  VoxelFunc &vf)
8488  :
8489  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
8490  {}
8491 
8492  /// Copy constructor
8494  :
8495  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)
8496  {}
8497 
8498  /// Split constructor
8500  :
8501  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)
8502  {}
8503 
8504  /// Process entire image
8505  void operator ()(const ImageAttributes &attr) const
8506  {
8507  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8508  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8509  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8510  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8511  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8512  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8513  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
8514  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
8515 
8516  const int T = (attr._dt ? attr._t : 1);
8517 
8518  for (int l = 0; l < T; ++l)
8519  for (int k = 0; k < attr._z; ++k)
8520  for (int j = 0; j < attr._y; ++j)
8521  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
8522  // const_cast such that voxel functions need only implement
8523  // non-const operator() which is required for parallel_reduce
8524  const_cast<OctaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
8525  }
8526  }
8527 
8528  /// Process image region using linear index
8529  void operator ()(const blocked_range<int> &re) const
8530  {
8531  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8532  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8533  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8534  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8535  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8536  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8537  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
8538  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
8539 
8540  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) {
8541  // const_cast such that voxel functions need only implement
8542  // non-const operator() which is required for parallel_reduce
8543  const_cast<OctaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
8544  }
8545  }
8546 
8547  /// Process 2D image region
8548  void operator ()(const blocked_range2d<int> &re) const
8549  {
8550  const int bi = re.cols().begin();
8551  const int bj = re.rows().begin();
8552  const int ei = re.cols().end();
8553  const int ej = re.rows().end();
8554 
8555  const int s1 = im8.GetX() - (ei - bi);
8556 
8557  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8558  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8559  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8560  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8561  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8562  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8563  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8564  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8565 
8566  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
8567  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
8568  // const_cast such that voxel functions need only implement
8569  // non-const operator() which is required for parallel_reduce
8570  const_cast<OctaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8571  }
8572  }
8573 
8574  /// Process 3D image region
8575  void operator ()(const blocked_range3d<int> &re) const
8576  {
8577  const int bi = re.cols ().begin();
8578  const int bj = re.rows ().begin();
8579  const int bk = re.pages().begin();
8580  const int ei = re.cols ().end();
8581  const int ej = re.rows ().end();
8582  const int ek = re.pages().end();
8583 
8584  const int s1 = im8.GetX() - (ei - bi);
8585  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
8586 
8587  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8588  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8589  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8590  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8591  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8592  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8593  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
8594  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
8595 
8596  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
8597  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
8598  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
8599  // const_cast such that voxel functions need only implement
8600  // non-const operator() which is required for parallel_reduce
8601  const_cast<OctaryForEachVoxelBody_3Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8602  }
8603  }
8604 };
8605 
8606 // -----------------------------------------------------------------------------
8607 /**
8608  * ForEachVoxel body for inside and outside unary voxel function of 3 const, 5 non-const images
8609  */
8610 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
8611  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
8612  class Domain = ForEachVoxelDomain::Foreground>
8613 struct OctaryForEachVoxelIfBody_3Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
8614 {
8615  const GenericImage<T1> &im1;
8616  const GenericImage<T2> &im2;
8617  const GenericImage<T3> &im3;
8618  GenericImage<T4> &im4;
8619  GenericImage<T5> &im5;
8620  GenericImage<T6> &im6;
8621  GenericImage<T7> &im7;
8622  GenericImage<T8> &im8;
8623 
8624  /// Constructor
8626  const GenericImage<T2> &im2,
8627  const GenericImage<T3> &im3,
8628  GenericImage<T4> &im4,
8629  GenericImage<T5> &im5,
8630  GenericImage<T6> &im6,
8631  GenericImage<T7> &im7,
8632  GenericImage<T8> &im8,
8633  VoxelFunc &vf, OutsideFunc &of)
8634  :
8635  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
8636  {}
8637 
8638  /// Copy constructor
8640  :
8641  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)
8642  {}
8643 
8644  /// Split constructor
8646  :
8647  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)
8648  {}
8649 
8650  /// Process entire image
8651  void operator ()(const ImageAttributes &attr) const
8652  {
8653  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
8654  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
8655  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
8656  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
8657  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
8658  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
8659  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
8660  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
8661 
8662  const int T = (attr._dt ? attr._t : 1);
8663 
8664  for (int l = 0; l < T; ++l)
8665  for (int k = 0; k < attr._z; ++k)
8666  for (int j = 0; j < attr._y; ++j)
8667  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
8668  if (Domain::IsInside(im8, i, j, k, l, p8)) {
8669  // const_cast such that voxel functions need only implement
8670  // non-const operator() which is required for parallel_reduce
8671  const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
8672  } else const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
8673  }
8674  }
8675 
8676  /// Process image region using linear index
8677  void operator ()(const blocked_range<int> &re) const
8678  {
8679  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
8680  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
8681  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
8682  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
8683  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
8684  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
8685  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
8686  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
8687 
8688  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) {
8689  if (Domain::IsInside(im8, idx, p8)) {
8690  // const_cast such that voxel functions need only implement
8691  // non-const operator() which is required for parallel_reduce
8692  const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
8693  } else const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
8694  }
8695  }
8696 
8697  /// Process 2D image region
8698  void operator ()(const blocked_range2d<int> &re) const
8699  {
8700  const int bi = re.cols().begin();
8701  const int bj = re.rows().begin();
8702  const int ei = re.cols().end();
8703  const int ej = re.rows().end();
8704 
8705  const int s1 = im8.GetX() - (ei - bi);
8706 
8707  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8708  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8709  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8710  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8711  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8712  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8713  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8714  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
8715 
8716  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
8717  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
8718  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
8719  // const_cast such that voxel functions need only implement
8720  // non-const operator() which is required for parallel_reduce
8721  const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8722  } else const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8723  }
8724  }
8725 
8726  /// Process 3D image region
8727  void operator ()(const blocked_range3d<int> &re) const
8728  {
8729  const int bi = re.cols ().begin();
8730  const int bj = re.rows ().begin();
8731  const int bk = re.pages().begin();
8732  const int ei = re.cols ().end();
8733  const int ej = re.rows ().end();
8734  const int ek = re.pages().end();
8735 
8736  const int s1 = im8.GetX() - (ei - bi);
8737  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
8738 
8739  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
8740  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
8741  const T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
8742  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
8743  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
8744  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
8745  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
8746  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
8747 
8748  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
8749  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
8750  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
8751  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
8752  // const_cast such that voxel functions need only implement
8753  // non-const operator() which is required for parallel_reduce
8754  const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8755  } else const_cast<OctaryForEachVoxelIfBody_3Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
8756  }
8757  }
8758 };
8759 
8760 // -----------------------------------------------------------------------------
8761 // ForEachVoxel
8762 // -----------------------------------------------------------------------------
8763 
8764 //
8765 // Image arguments by pointer
8766 //
8767 
8768 // -----------------------------------------------------------------------------
8769 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8770 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, VoxelFunc &vf)
8771 {
8772  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8773  blocked_range<int> re(0, im8->GetNumberOfVoxels());
8774  body(re);
8775  vf.join(body._VoxelFunc);
8776 }
8777 
8778 // -----------------------------------------------------------------------------
8779 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8780 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)
8781 {
8782  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8783  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8784 }
8785 
8786 // -----------------------------------------------------------------------------
8787 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8788 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, VoxelFunc &vf)
8789 {
8790  if (im8->GetTSize()) {
8791  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8792  } else {
8793  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8794  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
8795  body(re);
8796  vf.join(body._VoxelFunc);
8797  }
8798 }
8799 
8800 // -----------------------------------------------------------------------------
8801 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8802 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)
8803 {
8804  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8805  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8806 }
8807 
8808 // -----------------------------------------------------------------------------
8809 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8810 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, VoxelFunc &vf)
8811 {
8812  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8813  body(attr);
8814  vf.join(body._VoxelFunc);
8815 }
8816 
8817 // -----------------------------------------------------------------------------
8818 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8819 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)
8820 {
8821  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8822  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8823 }
8824 
8825 // -----------------------------------------------------------------------------
8826 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8827 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, VoxelFunc &vf)
8828 {
8829  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8830  body(re);
8831  vf.join(body._VoxelFunc);
8832 }
8833 
8834 // -----------------------------------------------------------------------------
8835 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8836 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)
8837 {
8838  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8839  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8840 }
8841 
8842 // -----------------------------------------------------------------------------
8843 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8844 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, VoxelFunc &vf)
8845 {
8846  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8847  body(re);
8848  vf.join(body._VoxelFunc);
8849 }
8850 
8851 // -----------------------------------------------------------------------------
8852 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8853 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)
8854 {
8855  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8856  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8857 }
8858 
8859 // -----------------------------------------------------------------------------
8860 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8861 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, VoxelFunc &vf)
8862 {
8863  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8864  body(re);
8865  vf.join(body._VoxelFunc);
8866 }
8867 
8868 // -----------------------------------------------------------------------------
8869 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8870 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)
8871 {
8872  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8873  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
8874 }
8875 
8876 //
8877 // Image arguments by reference
8878 //
8879 
8880 // -----------------------------------------------------------------------------
8881 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8882 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, VoxelFunc &vf)
8883 {
8884  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8886  body(re);
8887  vf.join(body._VoxelFunc);
8888 }
8889 
8890 // -----------------------------------------------------------------------------
8891 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8892 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)
8893 {
8894  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8895  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8896 }
8897 
8898 // -----------------------------------------------------------------------------
8899 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8900 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, VoxelFunc &vf)
8901 {
8902  if (im8.GetTSize()) {
8903  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8904  } else {
8905  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8906  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
8907  body(re);
8908  vf.join(body._VoxelFunc);
8909  }
8910 }
8911 
8912 // -----------------------------------------------------------------------------
8913 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8914 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)
8915 {
8916  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8917  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8918 }
8919 
8920 // -----------------------------------------------------------------------------
8921 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8922 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, VoxelFunc &vf)
8923 {
8924  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8925  body(attr);
8926  vf.join(body._VoxelFunc);
8927 }
8928 
8929 // -----------------------------------------------------------------------------
8930 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8931 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)
8932 {
8933  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8934  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8935 }
8936 
8937 // -----------------------------------------------------------------------------
8938 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8939 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, VoxelFunc &vf)
8940 {
8941  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8942  body(re);
8943  vf.join(body._VoxelFunc);
8944 }
8945 
8946 // -----------------------------------------------------------------------------
8947 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8948 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)
8949 {
8950  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8951  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8952 }
8953 
8954 // -----------------------------------------------------------------------------
8955 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8956 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, VoxelFunc &vf)
8957 {
8958  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8959  body(re);
8960  vf.join(body._VoxelFunc);
8961 }
8962 
8963 // -----------------------------------------------------------------------------
8964 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8965 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)
8966 {
8967  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8968  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8969 }
8970 
8971 // -----------------------------------------------------------------------------
8972 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8973 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, VoxelFunc &vf)
8974 {
8975  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
8976  body(re);
8977  vf.join(body._VoxelFunc);
8978 }
8979 
8980 // -----------------------------------------------------------------------------
8981 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
8982 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)
8983 {
8984  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
8985  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
8986 }
8987 
8988 // -----------------------------------------------------------------------------
8989 // ForEachVoxelIf
8990 // -----------------------------------------------------------------------------
8991 
8992 //
8993 // Image arguments by pointer
8994 //
8995 
8996 // -----------------------------------------------------------------------------
8997 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
8998 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, VoxelFunc &vf, OutsideFunc &of)
8999 {
9000  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9001  blocked_range<int> re(0, im8->GetNumberOfVoxels());
9002  body(re);
9003  vf.join(body._VoxelFunc);
9004  of.join(body._OutsideFunc);
9005 }
9006 
9007 // -----------------------------------------------------------------------------
9008 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9009 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)
9010 {
9011  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9012  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9013 }
9014 
9015 // -----------------------------------------------------------------------------
9016 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9017 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, VoxelFunc &vf)
9018 {
9020  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9021 }
9022 
9023 // -----------------------------------------------------------------------------
9024 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9025 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)
9026 {
9027  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9028  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9029 }
9030 
9031 // -----------------------------------------------------------------------------
9032 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9033 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, VoxelFunc &vf, OutsideFunc &of)
9034 {
9035  if (im8->GetTSize()) {
9036  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9037  } else {
9038  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9039  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
9040  body(re);
9041  vf.join(body._VoxelFunc);
9042  of.join(body._OutsideFunc);
9043  }
9044 }
9045 
9046 // -----------------------------------------------------------------------------
9047 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9048 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)
9049 {
9050  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9051  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9052 }
9053 
9054 // -----------------------------------------------------------------------------
9055 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9056 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, VoxelFunc &vf)
9057 {
9059  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9060 }
9061 
9062 // -----------------------------------------------------------------------------
9063 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9064 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)
9065 {
9066  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9067  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9068 }
9069 
9070 // -----------------------------------------------------------------------------
9071 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9072 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, VoxelFunc &vf, OutsideFunc &of)
9073 {
9074  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9075  body(attr);
9076  vf.join(body._VoxelFunc);
9077  of.join(body._OutsideFunc);
9078 }
9079 
9080 // -----------------------------------------------------------------------------
9081 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9082 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)
9083 {
9084  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9085  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9086 }
9087 
9088 // -----------------------------------------------------------------------------
9089 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9090 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, VoxelFunc &vf)
9091 {
9093  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9094 }
9095 
9096 // -----------------------------------------------------------------------------
9097 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9098 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)
9099 {
9100  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9101  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9102 }
9103 
9104 // -----------------------------------------------------------------------------
9105 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9106 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, VoxelFunc &vf, OutsideFunc &of)
9107 {
9108  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9109  body(re);
9110  vf.join(body._VoxelFunc);
9111  of.join(body._OutsideFunc);
9112 }
9113 
9114 // -----------------------------------------------------------------------------
9115 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9116 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)
9117 {
9118  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9119  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9120 }
9121 
9122 // -----------------------------------------------------------------------------
9123 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9124 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, VoxelFunc &vf, OutsideFunc &of)
9125 {
9126  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9127  body(re);
9128  vf.join(body._VoxelFunc);
9129  of.join(body._OutsideFunc);
9130 }
9131 
9132 // -----------------------------------------------------------------------------
9133 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9134 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)
9135 {
9136  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9137  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9138 }
9139 
9140 // -----------------------------------------------------------------------------
9141 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9142 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, VoxelFunc &vf)
9143 {
9145  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9146 }
9147 
9148 // -----------------------------------------------------------------------------
9149 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9150 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)
9151 {
9152  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9153  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9154 }
9155 
9156 // -----------------------------------------------------------------------------
9157 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9158 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, VoxelFunc &vf, OutsideFunc &of)
9159 {
9160  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9161  body(re);
9162  vf.join(body._VoxelFunc);
9163  of.join(body._OutsideFunc);
9164 }
9165 
9166 // -----------------------------------------------------------------------------
9167 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9168 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)
9169 {
9170  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9171  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9172 }
9173 
9174 // -----------------------------------------------------------------------------
9175 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9176 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, VoxelFunc &vf)
9177 {
9179  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9180 }
9181 
9182 // -----------------------------------------------------------------------------
9183 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9184 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)
9185 {
9186  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9187  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9188 }
9189 
9190 //
9191 // Image arguments by reference
9192 //
9193 
9194 // -----------------------------------------------------------------------------
9195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9196 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, VoxelFunc &vf, OutsideFunc &of)
9197 {
9200  body(re);
9201  vf.join(body._VoxelFunc);
9202  of.join(body._OutsideFunc);
9203 }
9204 
9205 // -----------------------------------------------------------------------------
9206 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9207 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)
9208 {
9209  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9210  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9211 }
9212 
9213 // -----------------------------------------------------------------------------
9214 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9215 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, VoxelFunc &vf)
9216 {
9218  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9219 }
9220 
9221 // -----------------------------------------------------------------------------
9222 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9223 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)
9224 {
9225  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9226  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9227 }
9228 
9229 // -----------------------------------------------------------------------------
9230 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9231 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, VoxelFunc &vf, OutsideFunc &of)
9232 {
9233  if (im8.GetTSize()) {
9234  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9235  } else {
9237  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
9238  body(re);
9239  vf.join(body._VoxelFunc);
9240  of.join(body._OutsideFunc);
9241  }
9242 }
9243 
9244 // -----------------------------------------------------------------------------
9245 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9246 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)
9247 {
9248  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9249  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9250 }
9251 
9252 // -----------------------------------------------------------------------------
9253 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9254 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, VoxelFunc &vf)
9255 {
9257  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9258 }
9259 
9260 // -----------------------------------------------------------------------------
9261 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9262 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)
9263 {
9264  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9265  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9266 }
9267 
9268 // -----------------------------------------------------------------------------
9269 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9270 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, VoxelFunc &vf, OutsideFunc &of)
9271 {
9273  body(attr);
9274  vf.join(body._VoxelFunc);
9275  of.join(body._OutsideFunc);
9276 }
9277 
9278 // -----------------------------------------------------------------------------
9279 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9280 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)
9281 {
9282  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9283  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9284 }
9285 
9286 // -----------------------------------------------------------------------------
9287 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9288 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, VoxelFunc &vf)
9289 {
9291  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9292 }
9293 
9294 // -----------------------------------------------------------------------------
9295 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9296 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)
9297 {
9298  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9299  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9300 }
9301 
9302 // -----------------------------------------------------------------------------
9303 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9304 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, VoxelFunc &vf, OutsideFunc &of)
9305 {
9307  body(re);
9308  vf.join(body._VoxelFunc);
9309  of.join(body._OutsideFunc);
9310 }
9311 
9312 // -----------------------------------------------------------------------------
9313 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9314 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)
9315 {
9316  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9317  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9318 }
9319 
9320 // -----------------------------------------------------------------------------
9321 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9322 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, VoxelFunc &vf, OutsideFunc &of)
9323 {
9325  body(re);
9326  vf.join(body._VoxelFunc);
9327  of.join(body._OutsideFunc);
9328 }
9329 
9330 // -----------------------------------------------------------------------------
9331 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9332 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)
9333 {
9334  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9335  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9336 }
9337 
9338 // -----------------------------------------------------------------------------
9339 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9340 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, VoxelFunc &vf)
9341 {
9343  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9344 }
9345 
9346 // -----------------------------------------------------------------------------
9347 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9348 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)
9349 {
9350  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9351  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9352 }
9353 
9354 // -----------------------------------------------------------------------------
9355 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9356 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, VoxelFunc &vf, OutsideFunc &of)
9357 {
9359  body(re);
9360  vf.join(body._VoxelFunc);
9361  of.join(body._OutsideFunc);
9362 }
9363 
9364 // -----------------------------------------------------------------------------
9365 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9366 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)
9367 {
9368  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9369  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9370 }
9371 
9372 // -----------------------------------------------------------------------------
9373 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9374 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, VoxelFunc &vf)
9375 {
9377  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9378 }
9379 
9380 // -----------------------------------------------------------------------------
9381 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9382 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)
9383 {
9384  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9385  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9386 }
9387 
9388 // -----------------------------------------------------------------------------
9389 // ParallelForEachVoxel
9390 // -----------------------------------------------------------------------------
9391 
9392 //
9393 // Image arguments by pointer
9394 //
9395 
9396 // -----------------------------------------------------------------------------
9397 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9398 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, VoxelFunc &vf)
9399 {
9400  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9401  blocked_range<int> re(0, im8->GetNumberOfVoxels());
9402  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9403  else parallel_for (re, body);
9404 }
9405 
9406 // -----------------------------------------------------------------------------
9407 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9408 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)
9409 {
9410  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9411  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9412 }
9413 
9414 // -----------------------------------------------------------------------------
9415 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9416 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, VoxelFunc &vf)
9417 {
9418  if (im8->GetTSize()) {
9419  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9420  } else {
9421  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9422  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
9423  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9424  else parallel_for (re, body);
9425  }
9426 }
9427 
9428 // -----------------------------------------------------------------------------
9429 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9430 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)
9431 {
9432  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9433  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9434 }
9435 
9436 // -----------------------------------------------------------------------------
9437 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9438 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, VoxelFunc &vf)
9439 {
9440  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9441  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9442  if (VoxelFunc::IsReduction()) {
9443  if (attr._dt) {
9444  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9445  } else {
9446  parallel_reduce(re, body);
9447  }
9448  vf.join(body._VoxelFunc);
9449  } else {
9450  if (attr._dt) {
9451  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9452  } else {
9453  parallel_for(re, body);
9454  }
9455  }
9456 }
9457 
9458 // -----------------------------------------------------------------------------
9459 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9460 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)
9461 {
9462  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9463  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9464 }
9465 
9466 // -----------------------------------------------------------------------------
9467 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9468 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, VoxelFunc &vf)
9469 {
9470  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9471  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9472  else parallel_for (re, body);
9473 }
9474 
9475 // -----------------------------------------------------------------------------
9476 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9477 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)
9478 {
9479  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9480  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9481 }
9482 
9483 // -----------------------------------------------------------------------------
9484 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9485 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, VoxelFunc &vf)
9486 {
9487  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9488  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9489  else parallel_for (re, body);
9490 }
9491 
9492 // -----------------------------------------------------------------------------
9493 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9494 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)
9495 {
9496  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9497  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9498 }
9499 
9500 // -----------------------------------------------------------------------------
9501 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9502 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, VoxelFunc &vf)
9503 {
9504  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9505  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9506  else parallel_for (re, body);
9507 }
9508 
9509 // -----------------------------------------------------------------------------
9510 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9511 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)
9512 {
9513  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9514  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9515 }
9516 
9517 //
9518 // Image arguments by reference
9519 //
9520 
9521 // -----------------------------------------------------------------------------
9522 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9523 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, VoxelFunc &vf)
9524 {
9525  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9527  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9528  else parallel_for (re, body);
9529 }
9530 
9531 // -----------------------------------------------------------------------------
9532 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9533 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)
9534 {
9535  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9536  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9537 }
9538 
9539 // -----------------------------------------------------------------------------
9540 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9541 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, VoxelFunc &vf)
9542 {
9543  if (im8.GetTSize()) {
9544  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9545  } else {
9546  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9547  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
9548  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9549  else parallel_for (re, body);
9550  }
9551 }
9552 
9553 // -----------------------------------------------------------------------------
9554 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9555 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)
9556 {
9557  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9558  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9559 }
9560 
9561 // -----------------------------------------------------------------------------
9562 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9563 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, VoxelFunc &vf)
9564 {
9565  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9566  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9567  if (VoxelFunc::IsReduction()) {
9568  if (attr._dt) {
9569  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9570  } else {
9571  parallel_reduce(re, body);
9572  }
9573  vf.join(body._VoxelFunc);
9574  } else {
9575  if (attr._dt) {
9576  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9577  } else {
9578  parallel_for(re, body);
9579  }
9580  }
9581 }
9582 
9583 // -----------------------------------------------------------------------------
9584 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9585 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)
9586 {
9587  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9588  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9589 }
9590 
9591 // -----------------------------------------------------------------------------
9592 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9593 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, VoxelFunc &vf)
9594 {
9595  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9596  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9597  else parallel_for (re, body);
9598 }
9599 
9600 // -----------------------------------------------------------------------------
9601 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9602 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)
9603 {
9604  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9605  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9606 }
9607 
9608 // -----------------------------------------------------------------------------
9609 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9610 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, VoxelFunc &vf)
9611 {
9612  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9613  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9614  else parallel_for (re, body);
9615 }
9616 
9617 // -----------------------------------------------------------------------------
9618 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9619 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)
9620 {
9621  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9622  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9623 }
9624 
9625 // -----------------------------------------------------------------------------
9626 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9627 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, VoxelFunc &vf)
9628 {
9629  OctaryForEachVoxelBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9630  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
9631  else parallel_for (re, body);
9632 }
9633 
9634 // -----------------------------------------------------------------------------
9635 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9636 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)
9637 {
9638  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9639  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
9640 }
9641 
9642 // -----------------------------------------------------------------------------
9643 // ParallelForEachVoxelIf
9644 // -----------------------------------------------------------------------------
9645 
9646 //
9647 // Image arguments by pointer
9648 //
9649 
9650 // -----------------------------------------------------------------------------
9651 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9652 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, VoxelFunc &vf, OutsideFunc &of)
9653 {
9654  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9655  blocked_range<int> re(0, im8->GetNumberOfVoxels());
9656  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9657  parallel_reduce(re, body);
9658  vf.join(body._VoxelFunc);
9659  of.join(body._OutsideFunc);
9660  } else {
9661  parallel_for(re, body);
9662  }
9663 }
9664 
9665 // -----------------------------------------------------------------------------
9666 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9667 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)
9668 {
9669  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9670  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9671 }
9672 
9673 // -----------------------------------------------------------------------------
9674 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9675 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, VoxelFunc &vf)
9676 {
9678  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9679 }
9680 
9681 // -----------------------------------------------------------------------------
9682 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9683 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)
9684 {
9685  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9686  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9687 }
9688 
9689 // -----------------------------------------------------------------------------
9690 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9691 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, VoxelFunc &vf, OutsideFunc &of)
9692 {
9693  if (im8->GetTSize()) {
9694  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9695  } else {
9696  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9697  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
9698  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9699  parallel_reduce(re, body);
9700  vf.join(body._VoxelFunc);
9701  of.join(body._OutsideFunc);
9702  } else {
9703  parallel_for(re, body);
9704  }
9705  }
9706 }
9707 
9708 // -----------------------------------------------------------------------------
9709 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9710 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)
9711 {
9712  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9713  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9714 }
9715 
9716 // -----------------------------------------------------------------------------
9717 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9718 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, VoxelFunc &vf)
9719 {
9721  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9722 }
9723 
9724 // -----------------------------------------------------------------------------
9725 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9726 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)
9727 {
9728  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9729  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9730 }
9731 
9732 // -----------------------------------------------------------------------------
9733 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9734 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, VoxelFunc &vf, OutsideFunc &of)
9735 {
9736  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9737  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9738  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9739  if (attr._dt) {
9740  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9741  } else {
9742  parallel_reduce(re, body);
9743  }
9744  vf.join(body._VoxelFunc);
9745  of.join(body._OutsideFunc);
9746  } else {
9747  if (attr._dt) {
9748  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9749  } else {
9750  parallel_for(re, body);
9751  }
9752  }
9753 }
9754 
9755 // -----------------------------------------------------------------------------
9756 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9757 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)
9758 {
9759  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9760  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9761 }
9762 
9763 // -----------------------------------------------------------------------------
9764 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9765 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, VoxelFunc &vf)
9766 {
9768  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9769 }
9770 
9771 // -----------------------------------------------------------------------------
9772 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9773 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)
9774 {
9775  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9776  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9777 }
9778 
9779 // -----------------------------------------------------------------------------
9780 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9781 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, VoxelFunc &vf, OutsideFunc &of)
9782 {
9783  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9784  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9785  parallel_reduce(re, body);
9786  vf.join(body._VoxelFunc);
9787  of.join(body._OutsideFunc);
9788  } else {
9789  parallel_for(re, body);
9790  }
9791 }
9792 
9793 // -----------------------------------------------------------------------------
9794 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9795 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)
9796 {
9797  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9798  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9799 }
9800 
9801 // -----------------------------------------------------------------------------
9802 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9803 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, VoxelFunc &vf)
9804 {
9806  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9807 }
9808 
9809 // -----------------------------------------------------------------------------
9810 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9811 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)
9812 {
9813  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9814  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9815 }
9816 
9817 // -----------------------------------------------------------------------------
9818 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9819 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, VoxelFunc &vf, OutsideFunc &of)
9820 {
9821  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9822  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9823  parallel_reduce(re, body);
9824  vf.join(body._VoxelFunc);
9825  of.join(body._OutsideFunc);
9826  } else {
9827  parallel_for(re, body);
9828  }
9829 }
9830 
9831 // -----------------------------------------------------------------------------
9832 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9833 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)
9834 {
9835  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9836  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9837 }
9838 
9839 // -----------------------------------------------------------------------------
9840 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9841 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, VoxelFunc &vf)
9842 {
9844  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9845 }
9846 
9847 // -----------------------------------------------------------------------------
9848 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9849 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)
9850 {
9851  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9852  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9853 }
9854 
9855 // -----------------------------------------------------------------------------
9856 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9857 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, VoxelFunc &vf, OutsideFunc &of)
9858 {
9859  OctaryForEachVoxelIfBody_3Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9860  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9861  parallel_reduce(re, body);
9862  vf.join(body._VoxelFunc);
9863  of.join(body._OutsideFunc);
9864  } else {
9865  parallel_for(re, body);
9866  }
9867 }
9868 
9869 // -----------------------------------------------------------------------------
9870 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9871 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)
9872 {
9873  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9874  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9875 }
9876 
9877 // -----------------------------------------------------------------------------
9878 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9879 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, VoxelFunc &vf)
9880 {
9882  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
9883 }
9884 
9885 // -----------------------------------------------------------------------------
9886 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9887 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)
9888 {
9889  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9890  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
9891 }
9892 
9893 //
9894 // Image arguments by reference
9895 //
9896 
9897 // -----------------------------------------------------------------------------
9898 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9899 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, VoxelFunc &vf, OutsideFunc &of)
9900 {
9903  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9904  parallel_reduce(re, body);
9905  vf.join(body._VoxelFunc);
9906  of.join(body._OutsideFunc);
9907  } else {
9908  parallel_for(re, body);
9909  }
9910 }
9911 
9912 // -----------------------------------------------------------------------------
9913 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9914 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)
9915 {
9916  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9917  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9918 }
9919 
9920 // -----------------------------------------------------------------------------
9921 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9922 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, VoxelFunc &vf)
9923 {
9925  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9926 }
9927 
9928 // -----------------------------------------------------------------------------
9929 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9930 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)
9931 {
9932  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9933  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9934 }
9935 
9936 // -----------------------------------------------------------------------------
9937 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9938 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, VoxelFunc &vf, OutsideFunc &of)
9939 {
9940  if (im8.GetTSize()) {
9941  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9942  } else {
9944  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
9945  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9946  parallel_reduce(re, body);
9947  vf.join(body._VoxelFunc);
9948  of.join(body._OutsideFunc);
9949  } else {
9950  parallel_for(re, body);
9951  }
9952  }
9953 }
9954 
9955 // -----------------------------------------------------------------------------
9956 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9957 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)
9958 {
9959  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9960  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9961 }
9962 
9963 // -----------------------------------------------------------------------------
9964 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9965 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, VoxelFunc &vf)
9966 {
9968  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
9969 }
9970 
9971 // -----------------------------------------------------------------------------
9972 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
9973 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)
9974 {
9975  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
9976  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
9977 }
9978 
9979 // -----------------------------------------------------------------------------
9980 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
9981 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, VoxelFunc &vf, OutsideFunc &of)
9982 {
9984  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
9985  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
9986  if (attr._dt) {
9987  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
9988  } else {
9989  parallel_reduce(re, body);
9990  }
9991  vf.join(body._VoxelFunc);
9992  of.join(body._OutsideFunc);
9993  } else {
9994  if (attr._dt) {
9995  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
9996  } else {
9997  parallel_for(re, body);
9998  }
9999  }
10000 }
10001 
10002 // -----------------------------------------------------------------------------
10003 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10004 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)
10005 {
10006  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10007  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10008 }
10009 
10010 // -----------------------------------------------------------------------------
10011 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10012 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, VoxelFunc &vf)
10013 {
10015  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10016 }
10017 
10018 // -----------------------------------------------------------------------------
10019 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10020 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)
10021 {
10022  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10023  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10024 }
10025 
10026 // -----------------------------------------------------------------------------
10027 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10028 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, VoxelFunc &vf, OutsideFunc &of)
10029 {
10031  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10032  parallel_reduce(re, body);
10033  vf.join(body._VoxelFunc);
10034  of.join(body._OutsideFunc);
10035  } else {
10036  parallel_for(re, body);
10037  }
10038 }
10039 
10040 // -----------------------------------------------------------------------------
10041 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10042 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)
10043 {
10044  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10045  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10046 }
10047 
10048 // -----------------------------------------------------------------------------
10049 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10050 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, VoxelFunc &vf)
10051 {
10053  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10054 }
10055 
10056 // -----------------------------------------------------------------------------
10057 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10058 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)
10059 {
10060  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10061  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10062 }
10063 
10064 // -----------------------------------------------------------------------------
10065 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10066 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, VoxelFunc &vf, OutsideFunc &of)
10067 {
10069  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10070  parallel_reduce(re, body);
10071  vf.join(body._VoxelFunc);
10072  of.join(body._OutsideFunc);
10073  } else {
10074  parallel_for(re, body);
10075  }
10076 }
10077 
10078 // -----------------------------------------------------------------------------
10079 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10080 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)
10081 {
10082  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10083  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10084 }
10085 
10086 // -----------------------------------------------------------------------------
10087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10088 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, VoxelFunc &vf)
10089 {
10091  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10092 }
10093 
10094 // -----------------------------------------------------------------------------
10095 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10096 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)
10097 {
10098  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10099  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10100 }
10101 
10102 // -----------------------------------------------------------------------------
10103 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10104 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, VoxelFunc &vf, OutsideFunc &of)
10105 {
10107  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
10108  parallel_reduce(re, body);
10109  vf.join(body._VoxelFunc);
10110  of.join(body._OutsideFunc);
10111  } else {
10112  parallel_for(re, body);
10113  }
10114 }
10115 
10116 // -----------------------------------------------------------------------------
10117 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10118 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)
10119 {
10120  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10121  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10122 }
10123 
10124 // -----------------------------------------------------------------------------
10125 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10126 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, VoxelFunc &vf)
10127 {
10129  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10130 }
10131 
10132 // -----------------------------------------------------------------------------
10133 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10134 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)
10135 {
10136  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10137  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10138 }
10139 
10140 // =============================================================================
10141 // 2 const, 6 non-const images
10142 // =============================================================================
10143 
10144 // -----------------------------------------------------------------------------
10145 /**
10146  * ForEachVoxel body for voxel function of 2 const, 6 non-const images
10147  */
10148 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10150 {
10151  const GenericImage<T1> &im1;
10152  const GenericImage<T2> &im2;
10153  GenericImage<T3> &im3;
10154  GenericImage<T4> &im4;
10155  GenericImage<T5> &im5;
10156  GenericImage<T6> &im6;
10157  GenericImage<T7> &im7;
10158  GenericImage<T8> &im8;
10159 
10160  /// Constructor
10162  const GenericImage<T2> &im2,
10163  GenericImage<T3> &im3,
10164  GenericImage<T4> &im4,
10165  GenericImage<T5> &im5,
10166  GenericImage<T6> &im6,
10167  GenericImage<T7> &im7,
10168  GenericImage<T8> &im8,
10169  VoxelFunc &vf)
10170  :
10171  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
10172  {}
10173 
10174  /// Copy constructor
10176  :
10177  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)
10178  {}
10179 
10180  /// Split constructor
10182  :
10183  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)
10184  {}
10185 
10186  /// Process entire image
10187  void operator ()(const ImageAttributes &attr) const
10188  {
10189  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10190  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10191  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10192  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10193  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10194  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10195  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
10196  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
10197 
10198  const int T = (attr._dt ? attr._t : 1);
10199 
10200  for (int l = 0; l < T; ++l)
10201  for (int k = 0; k < attr._z; ++k)
10202  for (int j = 0; j < attr._y; ++j)
10203  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
10204  // const_cast such that voxel functions need only implement
10205  // non-const operator() which is required for parallel_reduce
10206  const_cast<OctaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
10207  }
10208  }
10209 
10210  /// Process image region using linear index
10211  void operator ()(const blocked_range<int> &re) const
10212  {
10213  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10214  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10215  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10216  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10217  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10218  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10219  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
10220  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
10221 
10222  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) {
10223  // const_cast such that voxel functions need only implement
10224  // non-const operator() which is required for parallel_reduce
10225  const_cast<OctaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
10226  }
10227  }
10228 
10229  /// Process 2D image region
10230  void operator ()(const blocked_range2d<int> &re) const
10231  {
10232  const int bi = re.cols().begin();
10233  const int bj = re.rows().begin();
10234  const int ei = re.cols().end();
10235  const int ej = re.rows().end();
10236 
10237  const int s1 = im8.GetX() - (ei - bi);
10238 
10239  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10240  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10241  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10242  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10243  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10244  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10245  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10246  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10247 
10248  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
10249  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
10250  // const_cast such that voxel functions need only implement
10251  // non-const operator() which is required for parallel_reduce
10252  const_cast<OctaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10253  }
10254  }
10255 
10256  /// Process 3D image region
10257  void operator ()(const blocked_range3d<int> &re) const
10258  {
10259  const int bi = re.cols ().begin();
10260  const int bj = re.rows ().begin();
10261  const int bk = re.pages().begin();
10262  const int ei = re.cols ().end();
10263  const int ej = re.rows ().end();
10264  const int ek = re.pages().end();
10265 
10266  const int s1 = im8.GetX() - (ei - bi);
10267  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
10268 
10269  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10270  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10271  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10272  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10273  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10274  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10275  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
10276  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
10277 
10278  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
10279  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
10280  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
10281  // const_cast such that voxel functions need only implement
10282  // non-const operator() which is required for parallel_reduce
10283  const_cast<OctaryForEachVoxelBody_2Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10284  }
10285  }
10286 };
10287 
10288 // -----------------------------------------------------------------------------
10289 /**
10290  * ForEachVoxel body for inside and outside unary voxel function of 2 const, 6 non-const images
10291  */
10292 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
10293  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
10294  class Domain = ForEachVoxelDomain::Foreground>
10295 struct OctaryForEachVoxelIfBody_2Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
10296 {
10297  const GenericImage<T1> &im1;
10298  const GenericImage<T2> &im2;
10299  GenericImage<T3> &im3;
10300  GenericImage<T4> &im4;
10301  GenericImage<T5> &im5;
10302  GenericImage<T6> &im6;
10303  GenericImage<T7> &im7;
10304  GenericImage<T8> &im8;
10305 
10306  /// Constructor
10308  const GenericImage<T2> &im2,
10309  GenericImage<T3> &im3,
10310  GenericImage<T4> &im4,
10311  GenericImage<T5> &im5,
10312  GenericImage<T6> &im6,
10313  GenericImage<T7> &im7,
10314  GenericImage<T8> &im8,
10315  VoxelFunc &vf, OutsideFunc &of)
10316  :
10317  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
10318  {}
10319 
10320  /// Copy constructor
10322  :
10323  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)
10324  {}
10325 
10326  /// Split constructor
10328  :
10329  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)
10330  {}
10331 
10332  /// Process entire image
10333  void operator ()(const ImageAttributes &attr) const
10334  {
10335  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
10336  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
10337  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
10338  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
10339  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
10340  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
10341  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
10342  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
10343 
10344  const int T = (attr._dt ? attr._t : 1);
10345 
10346  for (int l = 0; l < T; ++l)
10347  for (int k = 0; k < attr._z; ++k)
10348  for (int j = 0; j < attr._y; ++j)
10349  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
10350  if (Domain::IsInside(im8, i, j, k, l, p8)) {
10351  // const_cast such that voxel functions need only implement
10352  // non-const operator() which is required for parallel_reduce
10353  const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
10354  } else const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
10355  }
10356  }
10357 
10358  /// Process image region using linear index
10359  void operator ()(const blocked_range<int> &re) const
10360  {
10361  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
10362  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
10363  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
10364  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
10365  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
10366  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
10367  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
10368  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
10369 
10370  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) {
10371  if (Domain::IsInside(im8, idx, p8)) {
10372  // const_cast such that voxel functions need only implement
10373  // non-const operator() which is required for parallel_reduce
10374  const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
10375  } else const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
10376  }
10377  }
10378 
10379  /// Process 2D image region
10380  void operator ()(const blocked_range2d<int> &re) const
10381  {
10382  const int bi = re.cols().begin();
10383  const int bj = re.rows().begin();
10384  const int ei = re.cols().end();
10385  const int ej = re.rows().end();
10386 
10387  const int s1 = im8.GetX() - (ei - bi);
10388 
10389  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10390  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10391  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10392  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10393  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10394  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10395  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10396  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
10397 
10398  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
10399  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
10400  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
10401  // const_cast such that voxel functions need only implement
10402  // non-const operator() which is required for parallel_reduce
10403  const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10404  } else const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10405  }
10406  }
10407 
10408  /// Process 3D image region
10409  void operator ()(const blocked_range3d<int> &re) const
10410  {
10411  const int bi = re.cols ().begin();
10412  const int bj = re.rows ().begin();
10413  const int bk = re.pages().begin();
10414  const int ei = re.cols ().end();
10415  const int ej = re.rows ().end();
10416  const int ek = re.pages().end();
10417 
10418  const int s1 = im8.GetX() - (ei - bi);
10419  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
10420 
10421  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
10422  const T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
10423  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
10424  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
10425  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
10426  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
10427  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
10428  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
10429 
10430  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
10431  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
10432  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
10433  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
10434  // const_cast such that voxel functions need only implement
10435  // non-const operator() which is required for parallel_reduce
10436  const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10437  } else const_cast<OctaryForEachVoxelIfBody_2Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
10438  }
10439  }
10440 };
10441 
10442 // -----------------------------------------------------------------------------
10443 // ForEachVoxel
10444 // -----------------------------------------------------------------------------
10445 
10446 //
10447 // Image arguments by pointer
10448 //
10449 
10450 // -----------------------------------------------------------------------------
10451 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10452 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, VoxelFunc &vf)
10453 {
10454  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10455  blocked_range<int> re(0, im8->GetNumberOfVoxels());
10456  body(re);
10457  vf.join(body._VoxelFunc);
10458 }
10459 
10460 // -----------------------------------------------------------------------------
10461 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10462 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)
10463 {
10464  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10465  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10466 }
10467 
10468 // -----------------------------------------------------------------------------
10469 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10470 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, VoxelFunc &vf)
10471 {
10472  if (im8->GetTSize()) {
10473  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10474  } else {
10475  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10476  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
10477  body(re);
10478  vf.join(body._VoxelFunc);
10479  }
10480 }
10481 
10482 // -----------------------------------------------------------------------------
10483 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10484 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)
10485 {
10486  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10487  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10488 }
10489 
10490 // -----------------------------------------------------------------------------
10491 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10492 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, VoxelFunc &vf)
10493 {
10494  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10495  body(attr);
10496  vf.join(body._VoxelFunc);
10497 }
10498 
10499 // -----------------------------------------------------------------------------
10500 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10501 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)
10502 {
10503  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10504  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10505 }
10506 
10507 // -----------------------------------------------------------------------------
10508 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10509 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, VoxelFunc &vf)
10510 {
10511  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10512  body(re);
10513  vf.join(body._VoxelFunc);
10514 }
10515 
10516 // -----------------------------------------------------------------------------
10517 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10518 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)
10519 {
10520  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10521  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10522 }
10523 
10524 // -----------------------------------------------------------------------------
10525 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10526 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, VoxelFunc &vf)
10527 {
10528  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10529  body(re);
10530  vf.join(body._VoxelFunc);
10531 }
10532 
10533 // -----------------------------------------------------------------------------
10534 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10535 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)
10536 {
10537  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10538  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10539 }
10540 
10541 // -----------------------------------------------------------------------------
10542 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10543 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, VoxelFunc &vf)
10544 {
10545  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10546  body(re);
10547  vf.join(body._VoxelFunc);
10548 }
10549 
10550 // -----------------------------------------------------------------------------
10551 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10552 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)
10553 {
10554  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10555  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10556 }
10557 
10558 //
10559 // Image arguments by reference
10560 //
10561 
10562 // -----------------------------------------------------------------------------
10563 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10564 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, VoxelFunc &vf)
10565 {
10566  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10568  body(re);
10569  vf.join(body._VoxelFunc);
10570 }
10571 
10572 // -----------------------------------------------------------------------------
10573 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10574 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)
10575 {
10576  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10577  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10578 }
10579 
10580 // -----------------------------------------------------------------------------
10581 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10582 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, VoxelFunc &vf)
10583 {
10584  if (im8.GetTSize()) {
10585  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10586  } else {
10587  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10588  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
10589  body(re);
10590  vf.join(body._VoxelFunc);
10591  }
10592 }
10593 
10594 // -----------------------------------------------------------------------------
10595 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10596 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)
10597 {
10598  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10599  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10600 }
10601 
10602 // -----------------------------------------------------------------------------
10603 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10604 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, VoxelFunc &vf)
10605 {
10606  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10607  body(attr);
10608  vf.join(body._VoxelFunc);
10609 }
10610 
10611 // -----------------------------------------------------------------------------
10612 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10613 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)
10614 {
10615  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10616  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10617 }
10618 
10619 // -----------------------------------------------------------------------------
10620 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10621 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, VoxelFunc &vf)
10622 {
10623  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10624  body(re);
10625  vf.join(body._VoxelFunc);
10626 }
10627 
10628 // -----------------------------------------------------------------------------
10629 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10630 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)
10631 {
10632  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10633  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10634 }
10635 
10636 // -----------------------------------------------------------------------------
10637 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10638 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, VoxelFunc &vf)
10639 {
10640  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10641  body(re);
10642  vf.join(body._VoxelFunc);
10643 }
10644 
10645 // -----------------------------------------------------------------------------
10646 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10647 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)
10648 {
10649  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10650  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10651 }
10652 
10653 // -----------------------------------------------------------------------------
10654 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10655 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, VoxelFunc &vf)
10656 {
10657  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10658  body(re);
10659  vf.join(body._VoxelFunc);
10660 }
10661 
10662 // -----------------------------------------------------------------------------
10663 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10664 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)
10665 {
10666  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10667  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10668 }
10669 
10670 // -----------------------------------------------------------------------------
10671 // ForEachVoxelIf
10672 // -----------------------------------------------------------------------------
10673 
10674 //
10675 // Image arguments by pointer
10676 //
10677 
10678 // -----------------------------------------------------------------------------
10679 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10680 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, VoxelFunc &vf, OutsideFunc &of)
10681 {
10682  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10683  blocked_range<int> re(0, im8->GetNumberOfVoxels());
10684  body(re);
10685  vf.join(body._VoxelFunc);
10686  of.join(body._OutsideFunc);
10687 }
10688 
10689 // -----------------------------------------------------------------------------
10690 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10691 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)
10692 {
10693  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10694  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10695 }
10696 
10697 // -----------------------------------------------------------------------------
10698 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10699 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, VoxelFunc &vf)
10700 {
10702  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10703 }
10704 
10705 // -----------------------------------------------------------------------------
10706 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10707 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)
10708 {
10709  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10710  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10711 }
10712 
10713 // -----------------------------------------------------------------------------
10714 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10715 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, VoxelFunc &vf, OutsideFunc &of)
10716 {
10717  if (im8->GetTSize()) {
10718  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10719  } else {
10720  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10721  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
10722  body(re);
10723  vf.join(body._VoxelFunc);
10724  of.join(body._OutsideFunc);
10725  }
10726 }
10727 
10728 // -----------------------------------------------------------------------------
10729 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10730 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)
10731 {
10732  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10733  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10734 }
10735 
10736 // -----------------------------------------------------------------------------
10737 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10738 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, VoxelFunc &vf)
10739 {
10741  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10742 }
10743 
10744 // -----------------------------------------------------------------------------
10745 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10746 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)
10747 {
10748  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10749  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10750 }
10751 
10752 // -----------------------------------------------------------------------------
10753 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10754 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, VoxelFunc &vf, OutsideFunc &of)
10755 {
10756  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10757  body(attr);
10758  vf.join(body._VoxelFunc);
10759  of.join(body._OutsideFunc);
10760 }
10761 
10762 // -----------------------------------------------------------------------------
10763 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10764 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)
10765 {
10766  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10767  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10768 }
10769 
10770 // -----------------------------------------------------------------------------
10771 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10772 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, VoxelFunc &vf)
10773 {
10775  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10776 }
10777 
10778 // -----------------------------------------------------------------------------
10779 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10780 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)
10781 {
10782  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10783  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10784 }
10785 
10786 // -----------------------------------------------------------------------------
10787 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10788 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, VoxelFunc &vf, OutsideFunc &of)
10789 {
10790  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10791  body(re);
10792  vf.join(body._VoxelFunc);
10793  of.join(body._OutsideFunc);
10794 }
10795 
10796 // -----------------------------------------------------------------------------
10797 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10798 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)
10799 {
10800  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10801  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10802 }
10803 
10804 // -----------------------------------------------------------------------------
10805 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10806 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, VoxelFunc &vf, OutsideFunc &of)
10807 {
10808  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10809  body(re);
10810  vf.join(body._VoxelFunc);
10811  of.join(body._OutsideFunc);
10812 }
10813 
10814 // -----------------------------------------------------------------------------
10815 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10816 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)
10817 {
10818  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10819  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10820 }
10821 
10822 // -----------------------------------------------------------------------------
10823 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10824 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, VoxelFunc &vf)
10825 {
10827  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10828 }
10829 
10830 // -----------------------------------------------------------------------------
10831 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10832 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)
10833 {
10834  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10835  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10836 }
10837 
10838 // -----------------------------------------------------------------------------
10839 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10840 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, VoxelFunc &vf, OutsideFunc &of)
10841 {
10842  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10843  body(re);
10844  vf.join(body._VoxelFunc);
10845  of.join(body._OutsideFunc);
10846 }
10847 
10848 // -----------------------------------------------------------------------------
10849 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10850 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)
10851 {
10852  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10853  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10854 }
10855 
10856 // -----------------------------------------------------------------------------
10857 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10858 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, VoxelFunc &vf)
10859 {
10861  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
10862 }
10863 
10864 // -----------------------------------------------------------------------------
10865 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10866 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)
10867 {
10868  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10869  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
10870 }
10871 
10872 //
10873 // Image arguments by reference
10874 //
10875 
10876 // -----------------------------------------------------------------------------
10877 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10878 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, VoxelFunc &vf, OutsideFunc &of)
10879 {
10882  body(re);
10883  vf.join(body._VoxelFunc);
10884  of.join(body._OutsideFunc);
10885 }
10886 
10887 // -----------------------------------------------------------------------------
10888 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10889 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)
10890 {
10891  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10892  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10893 }
10894 
10895 // -----------------------------------------------------------------------------
10896 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10897 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, VoxelFunc &vf)
10898 {
10900  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10901 }
10902 
10903 // -----------------------------------------------------------------------------
10904 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10905 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)
10906 {
10907  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10908  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10909 }
10910 
10911 // -----------------------------------------------------------------------------
10912 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10913 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, VoxelFunc &vf, OutsideFunc &of)
10914 {
10915  if (im8.GetTSize()) {
10916  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10917  } else {
10919  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
10920  body(re);
10921  vf.join(body._VoxelFunc);
10922  of.join(body._OutsideFunc);
10923  }
10924 }
10925 
10926 // -----------------------------------------------------------------------------
10927 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10928 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)
10929 {
10930  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10931  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10932 }
10933 
10934 // -----------------------------------------------------------------------------
10935 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10936 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, VoxelFunc &vf)
10937 {
10939  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10940 }
10941 
10942 // -----------------------------------------------------------------------------
10943 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10944 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)
10945 {
10946  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10947  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
10948 }
10949 
10950 // -----------------------------------------------------------------------------
10951 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10952 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, VoxelFunc &vf, OutsideFunc &of)
10953 {
10955  body(attr);
10956  vf.join(body._VoxelFunc);
10957  of.join(body._OutsideFunc);
10958 }
10959 
10960 // -----------------------------------------------------------------------------
10961 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10962 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)
10963 {
10964  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10965  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10966 }
10967 
10968 // -----------------------------------------------------------------------------
10969 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10970 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, VoxelFunc &vf)
10971 {
10973  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
10974 }
10975 
10976 // -----------------------------------------------------------------------------
10977 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
10978 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)
10979 {
10980  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10981  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
10982 }
10983 
10984 // -----------------------------------------------------------------------------
10985 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10986 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, VoxelFunc &vf, OutsideFunc &of)
10987 {
10989  body(re);
10990  vf.join(body._VoxelFunc);
10991  of.join(body._OutsideFunc);
10992 }
10993 
10994 // -----------------------------------------------------------------------------
10995 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
10996 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)
10997 {
10998  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
10999  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11000 }
11001 
11002 // -----------------------------------------------------------------------------
11003 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11004 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, VoxelFunc &vf, OutsideFunc &of)
11005 {
11007  body(re);
11008  vf.join(body._VoxelFunc);
11009  of.join(body._OutsideFunc);
11010 }
11011 
11012 // -----------------------------------------------------------------------------
11013 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11014 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)
11015 {
11016  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11017  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11018 }
11019 
11020 // -----------------------------------------------------------------------------
11021 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11022 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, VoxelFunc &vf)
11023 {
11025  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11026 }
11027 
11028 // -----------------------------------------------------------------------------
11029 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11030 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)
11031 {
11032  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11033  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11034 }
11035 
11036 // -----------------------------------------------------------------------------
11037 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11038 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, VoxelFunc &vf, OutsideFunc &of)
11039 {
11041  body(re);
11042  vf.join(body._VoxelFunc);
11043  of.join(body._OutsideFunc);
11044 }
11045 
11046 // -----------------------------------------------------------------------------
11047 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11048 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)
11049 {
11050  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11051  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11052 }
11053 
11054 // -----------------------------------------------------------------------------
11055 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11056 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, VoxelFunc &vf)
11057 {
11059  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11060 }
11061 
11062 // -----------------------------------------------------------------------------
11063 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11064 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)
11065 {
11066  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11067  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11068 }
11069 
11070 // -----------------------------------------------------------------------------
11071 // ParallelForEachVoxel
11072 // -----------------------------------------------------------------------------
11073 
11074 //
11075 // Image arguments by pointer
11076 //
11077 
11078 // -----------------------------------------------------------------------------
11079 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11080 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, VoxelFunc &vf)
11081 {
11082  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11083  blocked_range<int> re(0, im8->GetNumberOfVoxels());
11084  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11085  else parallel_for (re, body);
11086 }
11087 
11088 // -----------------------------------------------------------------------------
11089 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11090 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)
11091 {
11092  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11093  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11094 }
11095 
11096 // -----------------------------------------------------------------------------
11097 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11098 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, VoxelFunc &vf)
11099 {
11100  if (im8->GetTSize()) {
11101  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11102  } else {
11103  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11104  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
11105  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11106  else parallel_for (re, body);
11107  }
11108 }
11109 
11110 // -----------------------------------------------------------------------------
11111 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11112 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)
11113 {
11114  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11115  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11116 }
11117 
11118 // -----------------------------------------------------------------------------
11119 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11120 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, VoxelFunc &vf)
11121 {
11122  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11123  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11124  if (VoxelFunc::IsReduction()) {
11125  if (attr._dt) {
11126  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11127  } else {
11128  parallel_reduce(re, body);
11129  }
11130  vf.join(body._VoxelFunc);
11131  } else {
11132  if (attr._dt) {
11133  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11134  } else {
11135  parallel_for(re, body);
11136  }
11137  }
11138 }
11139 
11140 // -----------------------------------------------------------------------------
11141 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11142 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)
11143 {
11144  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11145  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11146 }
11147 
11148 // -----------------------------------------------------------------------------
11149 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11150 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, VoxelFunc &vf)
11151 {
11152  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11153  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11154  else parallel_for (re, body);
11155 }
11156 
11157 // -----------------------------------------------------------------------------
11158 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11159 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)
11160 {
11161  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11162  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11163 }
11164 
11165 // -----------------------------------------------------------------------------
11166 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11167 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, VoxelFunc &vf)
11168 {
11169  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11170  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11171  else parallel_for (re, body);
11172 }
11173 
11174 // -----------------------------------------------------------------------------
11175 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11176 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)
11177 {
11178  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11179  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11180 }
11181 
11182 // -----------------------------------------------------------------------------
11183 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11184 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, VoxelFunc &vf)
11185 {
11186  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11187  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11188  else parallel_for (re, body);
11189 }
11190 
11191 // -----------------------------------------------------------------------------
11192 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11193 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)
11194 {
11195  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11196  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11197 }
11198 
11199 //
11200 // Image arguments by reference
11201 //
11202 
11203 // -----------------------------------------------------------------------------
11204 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11205 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, VoxelFunc &vf)
11206 {
11207  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11209  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11210  else parallel_for (re, body);
11211 }
11212 
11213 // -----------------------------------------------------------------------------
11214 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11215 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)
11216 {
11217  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11218  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11219 }
11220 
11221 // -----------------------------------------------------------------------------
11222 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11223 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, VoxelFunc &vf)
11224 {
11225  if (im8.GetTSize()) {
11226  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11227  } else {
11228  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11229  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
11230  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11231  else parallel_for (re, body);
11232  }
11233 }
11234 
11235 // -----------------------------------------------------------------------------
11236 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11237 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)
11238 {
11239  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11240  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11241 }
11242 
11243 // -----------------------------------------------------------------------------
11244 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11245 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, VoxelFunc &vf)
11246 {
11247  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11248  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11249  if (VoxelFunc::IsReduction()) {
11250  if (attr._dt) {
11251  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11252  } else {
11253  parallel_reduce(re, body);
11254  }
11255  vf.join(body._VoxelFunc);
11256  } else {
11257  if (attr._dt) {
11258  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11259  } else {
11260  parallel_for(re, body);
11261  }
11262  }
11263 }
11264 
11265 // -----------------------------------------------------------------------------
11266 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11267 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)
11268 {
11269  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11270  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11271 }
11272 
11273 // -----------------------------------------------------------------------------
11274 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11275 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, VoxelFunc &vf)
11276 {
11277  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11278  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11279  else parallel_for (re, body);
11280 }
11281 
11282 // -----------------------------------------------------------------------------
11283 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11284 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)
11285 {
11286  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11287  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11288 }
11289 
11290 // -----------------------------------------------------------------------------
11291 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11292 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, VoxelFunc &vf)
11293 {
11294  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11295  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11296  else parallel_for (re, body);
11297 }
11298 
11299 // -----------------------------------------------------------------------------
11300 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11301 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)
11302 {
11303  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11304  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11305 }
11306 
11307 // -----------------------------------------------------------------------------
11308 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11309 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, VoxelFunc &vf)
11310 {
11311  OctaryForEachVoxelBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11312  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
11313  else parallel_for (re, body);
11314 }
11315 
11316 // -----------------------------------------------------------------------------
11317 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11318 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)
11319 {
11320  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11321  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11322 }
11323 
11324 // -----------------------------------------------------------------------------
11325 // ParallelForEachVoxelIf
11326 // -----------------------------------------------------------------------------
11327 
11328 //
11329 // Image arguments by pointer
11330 //
11331 
11332 // -----------------------------------------------------------------------------
11333 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11334 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, VoxelFunc &vf, OutsideFunc &of)
11335 {
11336  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11337  blocked_range<int> re(0, im8->GetNumberOfVoxels());
11338  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11339  parallel_reduce(re, body);
11340  vf.join(body._VoxelFunc);
11341  of.join(body._OutsideFunc);
11342  } else {
11343  parallel_for(re, body);
11344  }
11345 }
11346 
11347 // -----------------------------------------------------------------------------
11348 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11349 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)
11350 {
11351  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11352  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11353 }
11354 
11355 // -----------------------------------------------------------------------------
11356 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11357 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, VoxelFunc &vf)
11358 {
11360  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11361 }
11362 
11363 // -----------------------------------------------------------------------------
11364 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11365 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)
11366 {
11367  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11368  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11369 }
11370 
11371 // -----------------------------------------------------------------------------
11372 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11373 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, VoxelFunc &vf, OutsideFunc &of)
11374 {
11375  if (im8->GetTSize()) {
11376  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11377  } else {
11378  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11379  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
11380  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11381  parallel_reduce(re, body);
11382  vf.join(body._VoxelFunc);
11383  of.join(body._OutsideFunc);
11384  } else {
11385  parallel_for(re, body);
11386  }
11387  }
11388 }
11389 
11390 // -----------------------------------------------------------------------------
11391 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11392 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)
11393 {
11394  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11395  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11396 }
11397 
11398 // -----------------------------------------------------------------------------
11399 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11400 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, VoxelFunc &vf)
11401 {
11403  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11404 }
11405 
11406 // -----------------------------------------------------------------------------
11407 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11408 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)
11409 {
11410  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11411  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11412 }
11413 
11414 // -----------------------------------------------------------------------------
11415 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11416 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, VoxelFunc &vf, OutsideFunc &of)
11417 {
11418  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11419  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11420  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11421  if (attr._dt) {
11422  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11423  } else {
11424  parallel_reduce(re, body);
11425  }
11426  vf.join(body._VoxelFunc);
11427  of.join(body._OutsideFunc);
11428  } else {
11429  if (attr._dt) {
11430  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11431  } else {
11432  parallel_for(re, body);
11433  }
11434  }
11435 }
11436 
11437 // -----------------------------------------------------------------------------
11438 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11439 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)
11440 {
11441  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11442  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11443 }
11444 
11445 // -----------------------------------------------------------------------------
11446 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11447 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, VoxelFunc &vf)
11448 {
11450  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11451 }
11452 
11453 // -----------------------------------------------------------------------------
11454 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11455 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)
11456 {
11457  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11458  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11459 }
11460 
11461 // -----------------------------------------------------------------------------
11462 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11463 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, VoxelFunc &vf, OutsideFunc &of)
11464 {
11465  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11466  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11467  parallel_reduce(re, body);
11468  vf.join(body._VoxelFunc);
11469  of.join(body._OutsideFunc);
11470  } else {
11471  parallel_for(re, body);
11472  }
11473 }
11474 
11475 // -----------------------------------------------------------------------------
11476 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11477 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)
11478 {
11479  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11480  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11481 }
11482 
11483 // -----------------------------------------------------------------------------
11484 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11485 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, VoxelFunc &vf)
11486 {
11488  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11489 }
11490 
11491 // -----------------------------------------------------------------------------
11492 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11493 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)
11494 {
11495  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11496  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11497 }
11498 
11499 // -----------------------------------------------------------------------------
11500 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11501 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, VoxelFunc &vf, OutsideFunc &of)
11502 {
11503  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11504  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11505  parallel_reduce(re, body);
11506  vf.join(body._VoxelFunc);
11507  of.join(body._OutsideFunc);
11508  } else {
11509  parallel_for(re, body);
11510  }
11511 }
11512 
11513 // -----------------------------------------------------------------------------
11514 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11515 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)
11516 {
11517  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11518  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11519 }
11520 
11521 // -----------------------------------------------------------------------------
11522 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11523 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, VoxelFunc &vf)
11524 {
11526  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, 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 VoxelFunc>
11531 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)
11532 {
11533  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11534  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11535 }
11536 
11537 // -----------------------------------------------------------------------------
11538 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11539 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, VoxelFunc &vf, OutsideFunc &of)
11540 {
11541  OctaryForEachVoxelIfBody_2Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11542  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11543  parallel_reduce(re, body);
11544  vf.join(body._VoxelFunc);
11545  of.join(body._OutsideFunc);
11546  } else {
11547  parallel_for(re, body);
11548  }
11549 }
11550 
11551 // -----------------------------------------------------------------------------
11552 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11553 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)
11554 {
11555  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11556  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
11557 }
11558 
11559 // -----------------------------------------------------------------------------
11560 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11561 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, VoxelFunc &vf)
11562 {
11564  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, 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 VoxelFunc>
11569 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)
11570 {
11571  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11572  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
11573 }
11574 
11575 //
11576 // Image arguments by reference
11577 //
11578 
11579 // -----------------------------------------------------------------------------
11580 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11581 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, VoxelFunc &vf, OutsideFunc &of)
11582 {
11585  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11586  parallel_reduce(re, body);
11587  vf.join(body._VoxelFunc);
11588  of.join(body._OutsideFunc);
11589  } else {
11590  parallel_for(re, body);
11591  }
11592 }
11593 
11594 // -----------------------------------------------------------------------------
11595 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11596 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)
11597 {
11598  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11599  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11600 }
11601 
11602 // -----------------------------------------------------------------------------
11603 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11604 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, VoxelFunc &vf)
11605 {
11607  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11608 }
11609 
11610 // -----------------------------------------------------------------------------
11611 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11612 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)
11613 {
11614  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11615  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11616 }
11617 
11618 // -----------------------------------------------------------------------------
11619 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11620 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, VoxelFunc &vf, OutsideFunc &of)
11621 {
11622  if (im8.GetTSize()) {
11623  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11624  } else {
11626  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
11627  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11628  parallel_reduce(re, body);
11629  vf.join(body._VoxelFunc);
11630  of.join(body._OutsideFunc);
11631  } else {
11632  parallel_for(re, body);
11633  }
11634  }
11635 }
11636 
11637 // -----------------------------------------------------------------------------
11638 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11639 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)
11640 {
11641  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11642  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11643 }
11644 
11645 // -----------------------------------------------------------------------------
11646 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11647 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, VoxelFunc &vf)
11648 {
11650  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11651 }
11652 
11653 // -----------------------------------------------------------------------------
11654 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11655 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)
11656 {
11657  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11658  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
11659 }
11660 
11661 // -----------------------------------------------------------------------------
11662 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11663 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, VoxelFunc &vf, OutsideFunc &of)
11664 {
11666  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
11667  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11668  if (attr._dt) {
11669  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
11670  } else {
11671  parallel_reduce(re, body);
11672  }
11673  vf.join(body._VoxelFunc);
11674  of.join(body._OutsideFunc);
11675  } else {
11676  if (attr._dt) {
11677  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
11678  } else {
11679  parallel_for(re, body);
11680  }
11681  }
11682 }
11683 
11684 // -----------------------------------------------------------------------------
11685 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11686 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)
11687 {
11688  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11689  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11690 }
11691 
11692 // -----------------------------------------------------------------------------
11693 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11694 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, VoxelFunc &vf)
11695 {
11697  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11698 }
11699 
11700 // -----------------------------------------------------------------------------
11701 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11702 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)
11703 {
11704  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11705  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11706 }
11707 
11708 // -----------------------------------------------------------------------------
11709 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11710 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, VoxelFunc &vf, OutsideFunc &of)
11711 {
11713  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11714  parallel_reduce(re, body);
11715  vf.join(body._VoxelFunc);
11716  of.join(body._OutsideFunc);
11717  } else {
11718  parallel_for(re, body);
11719  }
11720 }
11721 
11722 // -----------------------------------------------------------------------------
11723 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11724 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)
11725 {
11726  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11727  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11728 }
11729 
11730 // -----------------------------------------------------------------------------
11731 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11732 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, VoxelFunc &vf)
11733 {
11735  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11736 }
11737 
11738 // -----------------------------------------------------------------------------
11739 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11740 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)
11741 {
11742  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11743  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11744 }
11745 
11746 // -----------------------------------------------------------------------------
11747 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11748 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, VoxelFunc &vf, OutsideFunc &of)
11749 {
11751  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11752  parallel_reduce(re, body);
11753  vf.join(body._VoxelFunc);
11754  of.join(body._OutsideFunc);
11755  } else {
11756  parallel_for(re, body);
11757  }
11758 }
11759 
11760 // -----------------------------------------------------------------------------
11761 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11762 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)
11763 {
11764  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11765  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11766 }
11767 
11768 // -----------------------------------------------------------------------------
11769 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11770 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, VoxelFunc &vf)
11771 {
11773  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
11778 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)
11779 {
11780  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11781  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11782 }
11783 
11784 // -----------------------------------------------------------------------------
11785 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11786 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, VoxelFunc &vf, OutsideFunc &of)
11787 {
11789  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
11790  parallel_reduce(re, body);
11791  vf.join(body._VoxelFunc);
11792  of.join(body._OutsideFunc);
11793  } else {
11794  parallel_for(re, body);
11795  }
11796 }
11797 
11798 // -----------------------------------------------------------------------------
11799 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
11800 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)
11801 {
11802  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11803  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
11804 }
11805 
11806 // -----------------------------------------------------------------------------
11807 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11808 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, VoxelFunc &vf)
11809 {
11811  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
11816 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)
11817 {
11818  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
11819  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
11820 }
11821 
11822 // =============================================================================
11823 // 1 const, 7 non-const images
11824 // =============================================================================
11825 
11826 // -----------------------------------------------------------------------------
11827 /**
11828  * ForEachVoxel body for voxel function of 1 const, 7 non-const images
11829  */
11830 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
11832 {
11833  const GenericImage<T1> &im1;
11834  GenericImage<T2> &im2;
11835  GenericImage<T3> &im3;
11836  GenericImage<T4> &im4;
11837  GenericImage<T5> &im5;
11838  GenericImage<T6> &im6;
11839  GenericImage<T7> &im7;
11840  GenericImage<T8> &im8;
11841 
11842  /// Constructor
11844  GenericImage<T2> &im2,
11845  GenericImage<T3> &im3,
11846  GenericImage<T4> &im4,
11847  GenericImage<T5> &im5,
11848  GenericImage<T6> &im6,
11849  GenericImage<T7> &im7,
11850  GenericImage<T8> &im8,
11851  VoxelFunc &vf)
11852  :
11853  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
11854  {}
11855 
11856  /// Copy constructor
11858  :
11859  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)
11860  {}
11861 
11862  /// Split constructor
11864  :
11865  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)
11866  {}
11867 
11868  /// Process entire image
11869  void operator ()(const ImageAttributes &attr) const
11870  {
11871  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
11872  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
11873  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
11874  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
11875  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
11876  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
11877  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
11878  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
11879 
11880  const int T = (attr._dt ? attr._t : 1);
11881 
11882  for (int l = 0; l < T; ++l)
11883  for (int k = 0; k < attr._z; ++k)
11884  for (int j = 0; j < attr._y; ++j)
11885  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
11886  // const_cast such that voxel functions need only implement
11887  // non-const operator() which is required for parallel_reduce
11888  const_cast<OctaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
11889  }
11890  }
11891 
11892  /// Process image region using linear index
11893  void operator ()(const blocked_range<int> &re) const
11894  {
11895  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
11896  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
11897  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
11898  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
11899  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
11900  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
11901  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
11902  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
11903 
11904  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) {
11905  // const_cast such that voxel functions need only implement
11906  // non-const operator() which is required for parallel_reduce
11907  const_cast<OctaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
11908  }
11909  }
11910 
11911  /// Process 2D image region
11912  void operator ()(const blocked_range2d<int> &re) const
11913  {
11914  const int bi = re.cols().begin();
11915  const int bj = re.rows().begin();
11916  const int ei = re.cols().end();
11917  const int ej = re.rows().end();
11918 
11919  const int s1 = im8.GetX() - (ei - bi);
11920 
11921  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11922  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11923  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11924  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11925  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11926  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11927  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11928  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
11929 
11930  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
11931  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
11932  // const_cast such that voxel functions need only implement
11933  // non-const operator() which is required for parallel_reduce
11934  const_cast<OctaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
11935  }
11936  }
11937 
11938  /// Process 3D image region
11939  void operator ()(const blocked_range3d<int> &re) const
11940  {
11941  const int bi = re.cols ().begin();
11942  const int bj = re.rows ().begin();
11943  const int bk = re.pages().begin();
11944  const int ei = re.cols ().end();
11945  const int ej = re.rows ().end();
11946  const int ek = re.pages().end();
11947 
11948  const int s1 = im8.GetX() - (ei - bi);
11949  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
11950 
11951  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
11952  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
11953  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
11954  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
11955  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
11956  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
11957  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
11958  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
11959 
11960  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
11961  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
11962  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
11963  // const_cast such that voxel functions need only implement
11964  // non-const operator() which is required for parallel_reduce
11965  const_cast<OctaryForEachVoxelBody_1Const *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
11966  }
11967  }
11968 };
11969 
11970 // -----------------------------------------------------------------------------
11971 /**
11972  * ForEachVoxel body for inside and outside unary voxel function of 1 const, 7 non-const images
11973  */
11974 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
11975  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
11976  class Domain = ForEachVoxelDomain::Foreground>
11977 struct OctaryForEachVoxelIfBody_1Const : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
11978 {
11979  const GenericImage<T1> &im1;
11980  GenericImage<T2> &im2;
11981  GenericImage<T3> &im3;
11982  GenericImage<T4> &im4;
11983  GenericImage<T5> &im5;
11984  GenericImage<T6> &im6;
11985  GenericImage<T7> &im7;
11986  GenericImage<T8> &im8;
11987 
11988  /// Constructor
11990  GenericImage<T2> &im2,
11991  GenericImage<T3> &im3,
11992  GenericImage<T4> &im4,
11993  GenericImage<T5> &im5,
11994  GenericImage<T6> &im6,
11995  GenericImage<T7> &im7,
11996  GenericImage<T8> &im8,
11997  VoxelFunc &vf, OutsideFunc &of)
11998  :
11999  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
12000  {}
12001 
12002  /// Copy constructor
12004  :
12005  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)
12006  {}
12007 
12008  /// Split constructor
12010  :
12011  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)
12012  {}
12013 
12014  /// Process entire image
12015  void operator ()(const ImageAttributes &attr) const
12016  {
12017  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
12018  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
12019  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
12020  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
12021  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
12022  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
12023  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
12024  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
12025 
12026  const int T = (attr._dt ? attr._t : 1);
12027 
12028  for (int l = 0; l < T; ++l)
12029  for (int k = 0; k < attr._z; ++k)
12030  for (int j = 0; j < attr._y; ++j)
12031  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
12032  if (Domain::IsInside(im8, i, j, k, l, p8)) {
12033  // const_cast such that voxel functions need only implement
12034  // non-const operator() which is required for parallel_reduce
12035  const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
12036  } else const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
12037  }
12038  }
12039 
12040  /// Process image region using linear index
12041  void operator ()(const blocked_range<int> &re) const
12042  {
12043  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
12044  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
12045  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
12046  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
12047  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
12048  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
12049  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
12050  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
12051 
12052  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) {
12053  if (Domain::IsInside(im8, idx, p8)) {
12054  // const_cast such that voxel functions need only implement
12055  // non-const operator() which is required for parallel_reduce
12056  const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
12057  } else const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
12058  }
12059  }
12060 
12061  /// Process 2D image region
12062  void operator ()(const blocked_range2d<int> &re) const
12063  {
12064  const int bi = re.cols().begin();
12065  const int bj = re.rows().begin();
12066  const int ei = re.cols().end();
12067  const int ej = re.rows().end();
12068 
12069  const int s1 = im8.GetX() - (ei - bi);
12070 
12071  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12072  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12073  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12074  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12075  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12076  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12077  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12078  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
12079 
12080  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
12081  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
12082  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
12083  // const_cast such that voxel functions need only implement
12084  // non-const operator() which is required for parallel_reduce
12085  const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
12086  } else const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
12087  }
12088  }
12089 
12090  /// Process 3D image region
12091  void operator ()(const blocked_range3d<int> &re) const
12092  {
12093  const int bi = re.cols ().begin();
12094  const int bj = re.rows ().begin();
12095  const int bk = re.pages().begin();
12096  const int ei = re.cols ().end();
12097  const int ej = re.rows ().end();
12098  const int ek = re.pages().end();
12099 
12100  const int s1 = im8.GetX() - (ei - bi);
12101  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
12102 
12103  const T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
12104  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
12105  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
12106  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
12107  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
12108  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
12109  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
12110  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
12111 
12112  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
12113  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
12114  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
12115  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
12116  // const_cast such that voxel functions need only implement
12117  // non-const operator() which is required for parallel_reduce
12118  const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
12119  } else const_cast<OctaryForEachVoxelIfBody_1Const *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
12120  }
12121  }
12122 };
12123 
12124 // -----------------------------------------------------------------------------
12125 // ForEachVoxel
12126 // -----------------------------------------------------------------------------
12127 
12128 //
12129 // Image arguments by pointer
12130 //
12131 
12132 // -----------------------------------------------------------------------------
12133 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12134 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, VoxelFunc &vf)
12135 {
12136  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12137  blocked_range<int> re(0, im8->GetNumberOfVoxels());
12138  body(re);
12139  vf.join(body._VoxelFunc);
12140 }
12141 
12142 // -----------------------------------------------------------------------------
12143 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12144 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)
12145 {
12146  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12147  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12148 }
12149 
12150 // -----------------------------------------------------------------------------
12151 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12152 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, VoxelFunc &vf)
12153 {
12154  if (im8->GetTSize()) {
12155  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12156  } else {
12157  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12158  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
12159  body(re);
12160  vf.join(body._VoxelFunc);
12161  }
12162 }
12163 
12164 // -----------------------------------------------------------------------------
12165 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12166 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)
12167 {
12168  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12169  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12170 }
12171 
12172 // -----------------------------------------------------------------------------
12173 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12174 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, VoxelFunc &vf)
12175 {
12176  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12177  body(attr);
12178  vf.join(body._VoxelFunc);
12179 }
12180 
12181 // -----------------------------------------------------------------------------
12182 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12183 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)
12184 {
12185  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12186  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12187 }
12188 
12189 // -----------------------------------------------------------------------------
12190 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12191 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, VoxelFunc &vf)
12192 {
12193  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12194  body(re);
12195  vf.join(body._VoxelFunc);
12196 }
12197 
12198 // -----------------------------------------------------------------------------
12199 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12200 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)
12201 {
12202  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12203  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12204 }
12205 
12206 // -----------------------------------------------------------------------------
12207 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12208 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, VoxelFunc &vf)
12209 {
12210  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12211  body(re);
12212  vf.join(body._VoxelFunc);
12213 }
12214 
12215 // -----------------------------------------------------------------------------
12216 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12217 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)
12218 {
12219  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12220  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12221 }
12222 
12223 // -----------------------------------------------------------------------------
12224 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12225 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, VoxelFunc &vf)
12226 {
12227  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12228  body(re);
12229  vf.join(body._VoxelFunc);
12230 }
12231 
12232 // -----------------------------------------------------------------------------
12233 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12234 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)
12235 {
12236  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12237  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12238 }
12239 
12240 //
12241 // Image arguments by reference
12242 //
12243 
12244 // -----------------------------------------------------------------------------
12245 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12246 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, VoxelFunc &vf)
12247 {
12248  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12250  body(re);
12251  vf.join(body._VoxelFunc);
12252 }
12253 
12254 // -----------------------------------------------------------------------------
12255 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12256 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)
12257 {
12258  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12259  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12260 }
12261 
12262 // -----------------------------------------------------------------------------
12263 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12264 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, VoxelFunc &vf)
12265 {
12266  if (im8.GetTSize()) {
12267  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12268  } else {
12269  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12270  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
12271  body(re);
12272  vf.join(body._VoxelFunc);
12273  }
12274 }
12275 
12276 // -----------------------------------------------------------------------------
12277 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12278 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)
12279 {
12280  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12281  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12282 }
12283 
12284 // -----------------------------------------------------------------------------
12285 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12286 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, VoxelFunc &vf)
12287 {
12288  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12289  body(attr);
12290  vf.join(body._VoxelFunc);
12291 }
12292 
12293 // -----------------------------------------------------------------------------
12294 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12295 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)
12296 {
12297  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12298  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12299 }
12300 
12301 // -----------------------------------------------------------------------------
12302 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12303 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, VoxelFunc &vf)
12304 {
12305  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12306  body(re);
12307  vf.join(body._VoxelFunc);
12308 }
12309 
12310 // -----------------------------------------------------------------------------
12311 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12312 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)
12313 {
12314  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12315  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12316 }
12317 
12318 // -----------------------------------------------------------------------------
12319 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12320 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, VoxelFunc &vf)
12321 {
12322  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12323  body(re);
12324  vf.join(body._VoxelFunc);
12325 }
12326 
12327 // -----------------------------------------------------------------------------
12328 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12329 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)
12330 {
12331  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12332  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12333 }
12334 
12335 // -----------------------------------------------------------------------------
12336 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12337 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, VoxelFunc &vf)
12338 {
12339  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12340  body(re);
12341  vf.join(body._VoxelFunc);
12342 }
12343 
12344 // -----------------------------------------------------------------------------
12345 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12346 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)
12347 {
12348  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12349  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12350 }
12351 
12352 // -----------------------------------------------------------------------------
12353 // ForEachVoxelIf
12354 // -----------------------------------------------------------------------------
12355 
12356 //
12357 // Image arguments by pointer
12358 //
12359 
12360 // -----------------------------------------------------------------------------
12361 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12362 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, VoxelFunc &vf, OutsideFunc &of)
12363 {
12364  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12365  blocked_range<int> re(0, im8->GetNumberOfVoxels());
12366  body(re);
12367  vf.join(body._VoxelFunc);
12368  of.join(body._OutsideFunc);
12369 }
12370 
12371 // -----------------------------------------------------------------------------
12372 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12373 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)
12374 {
12375  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12376  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12377 }
12378 
12379 // -----------------------------------------------------------------------------
12380 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12381 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, VoxelFunc &vf)
12382 {
12384  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12385 }
12386 
12387 // -----------------------------------------------------------------------------
12388 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12389 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)
12390 {
12391  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12392  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12393 }
12394 
12395 // -----------------------------------------------------------------------------
12396 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12397 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, VoxelFunc &vf, OutsideFunc &of)
12398 {
12399  if (im8->GetTSize()) {
12400  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12401  } else {
12402  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12403  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
12404  body(re);
12405  vf.join(body._VoxelFunc);
12406  of.join(body._OutsideFunc);
12407  }
12408 }
12409 
12410 // -----------------------------------------------------------------------------
12411 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12412 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)
12413 {
12414  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12415  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12416 }
12417 
12418 // -----------------------------------------------------------------------------
12419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12420 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, VoxelFunc &vf)
12421 {
12423  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12424 }
12425 
12426 // -----------------------------------------------------------------------------
12427 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12428 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)
12429 {
12430  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12431  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12432 }
12433 
12434 // -----------------------------------------------------------------------------
12435 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12436 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, VoxelFunc &vf, OutsideFunc &of)
12437 {
12438  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12439  body(attr);
12440  vf.join(body._VoxelFunc);
12441  of.join(body._OutsideFunc);
12442 }
12443 
12444 // -----------------------------------------------------------------------------
12445 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12446 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)
12447 {
12448  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12449  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12450 }
12451 
12452 // -----------------------------------------------------------------------------
12453 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12454 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, VoxelFunc &vf)
12455 {
12457  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12458 }
12459 
12460 // -----------------------------------------------------------------------------
12461 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12462 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)
12463 {
12464  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12465  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12466 }
12467 
12468 // -----------------------------------------------------------------------------
12469 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12470 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, VoxelFunc &vf, OutsideFunc &of)
12471 {
12472  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12473  body(re);
12474  vf.join(body._VoxelFunc);
12475  of.join(body._OutsideFunc);
12476 }
12477 
12478 // -----------------------------------------------------------------------------
12479 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12480 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)
12481 {
12482  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12483  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12484 }
12485 
12486 // -----------------------------------------------------------------------------
12487 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12488 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, VoxelFunc &vf, OutsideFunc &of)
12489 {
12490  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12491  body(re);
12492  vf.join(body._VoxelFunc);
12493  of.join(body._OutsideFunc);
12494 }
12495 
12496 // -----------------------------------------------------------------------------
12497 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12498 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)
12499 {
12500  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12501  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12502 }
12503 
12504 // -----------------------------------------------------------------------------
12505 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12506 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, VoxelFunc &vf)
12507 {
12509  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12510 }
12511 
12512 // -----------------------------------------------------------------------------
12513 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12514 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)
12515 {
12516  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12517  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12518 }
12519 
12520 // -----------------------------------------------------------------------------
12521 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12522 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, VoxelFunc &vf, OutsideFunc &of)
12523 {
12524  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12525  body(re);
12526  vf.join(body._VoxelFunc);
12527  of.join(body._OutsideFunc);
12528 }
12529 
12530 // -----------------------------------------------------------------------------
12531 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12532 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)
12533 {
12534  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12535  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12536 }
12537 
12538 // -----------------------------------------------------------------------------
12539 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12540 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, VoxelFunc &vf)
12541 {
12543  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
12544 }
12545 
12546 // -----------------------------------------------------------------------------
12547 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12548 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)
12549 {
12550  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12551  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12552 }
12553 
12554 //
12555 // Image arguments by reference
12556 //
12557 
12558 // -----------------------------------------------------------------------------
12559 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12560 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, VoxelFunc &vf, OutsideFunc &of)
12561 {
12564  body(re);
12565  vf.join(body._VoxelFunc);
12566  of.join(body._OutsideFunc);
12567 }
12568 
12569 // -----------------------------------------------------------------------------
12570 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12571 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)
12572 {
12573  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12574  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12575 }
12576 
12577 // -----------------------------------------------------------------------------
12578 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12579 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, VoxelFunc &vf)
12580 {
12582  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12583 }
12584 
12585 // -----------------------------------------------------------------------------
12586 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12587 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)
12588 {
12589  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12590  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12591 }
12592 
12593 // -----------------------------------------------------------------------------
12594 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12595 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, VoxelFunc &vf, OutsideFunc &of)
12596 {
12597  if (im8.GetTSize()) {
12598  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12599  } else {
12601  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
12602  body(re);
12603  vf.join(body._VoxelFunc);
12604  of.join(body._OutsideFunc);
12605  }
12606 }
12607 
12608 // -----------------------------------------------------------------------------
12609 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12610 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)
12611 {
12612  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12613  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12614 }
12615 
12616 // -----------------------------------------------------------------------------
12617 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12618 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, VoxelFunc &vf)
12619 {
12621  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12622 }
12623 
12624 // -----------------------------------------------------------------------------
12625 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12626 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)
12627 {
12628  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12629  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12630 }
12631 
12632 // -----------------------------------------------------------------------------
12633 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12634 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, VoxelFunc &vf, OutsideFunc &of)
12635 {
12637  body(attr);
12638  vf.join(body._VoxelFunc);
12639  of.join(body._OutsideFunc);
12640 }
12641 
12642 // -----------------------------------------------------------------------------
12643 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12644 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)
12645 {
12646  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12647  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12648 }
12649 
12650 // -----------------------------------------------------------------------------
12651 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12652 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, VoxelFunc &vf)
12653 {
12655  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12656 }
12657 
12658 // -----------------------------------------------------------------------------
12659 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12660 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)
12661 {
12662  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12663  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12664 }
12665 
12666 // -----------------------------------------------------------------------------
12667 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12668 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, VoxelFunc &vf, OutsideFunc &of)
12669 {
12671  body(re);
12672  vf.join(body._VoxelFunc);
12673  of.join(body._OutsideFunc);
12674 }
12675 
12676 // -----------------------------------------------------------------------------
12677 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12678 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)
12679 {
12680  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12681  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12682 }
12683 
12684 // -----------------------------------------------------------------------------
12685 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12686 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, VoxelFunc &vf, OutsideFunc &of)
12687 {
12689  body(re);
12690  vf.join(body._VoxelFunc);
12691  of.join(body._OutsideFunc);
12692 }
12693 
12694 // -----------------------------------------------------------------------------
12695 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12696 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)
12697 {
12698  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12699  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12700 }
12701 
12702 // -----------------------------------------------------------------------------
12703 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12704 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, VoxelFunc &vf)
12705 {
12707  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12708 }
12709 
12710 // -----------------------------------------------------------------------------
12711 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12712 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)
12713 {
12714  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12715  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12716 }
12717 
12718 // -----------------------------------------------------------------------------
12719 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12720 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, VoxelFunc &vf, OutsideFunc &of)
12721 {
12723  body(re);
12724  vf.join(body._VoxelFunc);
12725  of.join(body._OutsideFunc);
12726 }
12727 
12728 // -----------------------------------------------------------------------------
12729 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
12730 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)
12731 {
12732  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12733  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12734 }
12735 
12736 // -----------------------------------------------------------------------------
12737 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12738 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, VoxelFunc &vf)
12739 {
12741  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
12742 }
12743 
12744 // -----------------------------------------------------------------------------
12745 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12746 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)
12747 {
12748  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12749  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12750 }
12751 
12752 // -----------------------------------------------------------------------------
12753 // ParallelForEachVoxel
12754 // -----------------------------------------------------------------------------
12755 
12756 //
12757 // Image arguments by pointer
12758 //
12759 
12760 // -----------------------------------------------------------------------------
12761 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12762 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, VoxelFunc &vf)
12763 {
12764  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12765  blocked_range<int> re(0, im8->GetNumberOfVoxels());
12766  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12767  else parallel_for (re, body);
12768 }
12769 
12770 // -----------------------------------------------------------------------------
12771 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12772 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)
12773 {
12774  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12775  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12776 }
12777 
12778 // -----------------------------------------------------------------------------
12779 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12780 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, VoxelFunc &vf)
12781 {
12782  if (im8->GetTSize()) {
12783  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12784  } else {
12785  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12786  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
12787  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12788  else parallel_for (re, body);
12789  }
12790 }
12791 
12792 // -----------------------------------------------------------------------------
12793 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12794 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)
12795 {
12796  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12797  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12798 }
12799 
12800 // -----------------------------------------------------------------------------
12801 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12802 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, VoxelFunc &vf)
12803 {
12804  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12805  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
12806  if (VoxelFunc::IsReduction()) {
12807  if (attr._dt) {
12808  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
12809  } else {
12810  parallel_reduce(re, body);
12811  }
12812  vf.join(body._VoxelFunc);
12813  } else {
12814  if (attr._dt) {
12815  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
12816  } else {
12817  parallel_for(re, body);
12818  }
12819  }
12820 }
12821 
12822 // -----------------------------------------------------------------------------
12823 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12824 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)
12825 {
12826  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12827  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12828 }
12829 
12830 // -----------------------------------------------------------------------------
12831 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12832 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, VoxelFunc &vf)
12833 {
12834  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12835  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12836  else parallel_for (re, body);
12837 }
12838 
12839 // -----------------------------------------------------------------------------
12840 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12841 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)
12842 {
12843  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12844  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12845 }
12846 
12847 // -----------------------------------------------------------------------------
12848 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12849 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, VoxelFunc &vf)
12850 {
12851  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12852  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12853  else parallel_for (re, body);
12854 }
12855 
12856 // -----------------------------------------------------------------------------
12857 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12858 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)
12859 {
12860  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12861  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12862 }
12863 
12864 // -----------------------------------------------------------------------------
12865 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12866 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, VoxelFunc &vf)
12867 {
12868  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12869  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12870  else parallel_for (re, body);
12871 }
12872 
12873 // -----------------------------------------------------------------------------
12874 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12875 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)
12876 {
12877  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12878  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
12879 }
12880 
12881 //
12882 // Image arguments by reference
12883 //
12884 
12885 // -----------------------------------------------------------------------------
12886 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12887 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, VoxelFunc &vf)
12888 {
12889  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12891  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12892  else parallel_for (re, body);
12893 }
12894 
12895 // -----------------------------------------------------------------------------
12896 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12897 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)
12898 {
12899  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12900  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12901 }
12902 
12903 // -----------------------------------------------------------------------------
12904 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12905 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, VoxelFunc &vf)
12906 {
12907  if (im8.GetTSize()) {
12908  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12909  } else {
12910  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12911  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
12912  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12913  else parallel_for (re, body);
12914  }
12915 }
12916 
12917 // -----------------------------------------------------------------------------
12918 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12919 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)
12920 {
12921  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12922  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12923 }
12924 
12925 // -----------------------------------------------------------------------------
12926 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12927 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, VoxelFunc &vf)
12928 {
12929  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12930  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
12931  if (VoxelFunc::IsReduction()) {
12932  if (attr._dt) {
12933  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
12934  } else {
12935  parallel_reduce(re, body);
12936  }
12937  vf.join(body._VoxelFunc);
12938  } else {
12939  if (attr._dt) {
12940  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
12941  } else {
12942  parallel_for(re, body);
12943  }
12944  }
12945 }
12946 
12947 // -----------------------------------------------------------------------------
12948 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12949 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)
12950 {
12951  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12952  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12953 }
12954 
12955 // -----------------------------------------------------------------------------
12956 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12957 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, VoxelFunc &vf)
12958 {
12959  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12960  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12961  else parallel_for (re, body);
12962 }
12963 
12964 // -----------------------------------------------------------------------------
12965 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12966 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)
12967 {
12968  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12969  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12970 }
12971 
12972 // -----------------------------------------------------------------------------
12973 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12974 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, VoxelFunc &vf)
12975 {
12976  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12977  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12978  else parallel_for (re, body);
12979 }
12980 
12981 // -----------------------------------------------------------------------------
12982 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12983 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)
12984 {
12985  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
12986  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
12987 }
12988 
12989 // -----------------------------------------------------------------------------
12990 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
12991 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, VoxelFunc &vf)
12992 {
12993  OctaryForEachVoxelBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
12994  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
12995  else parallel_for (re, body);
12996 }
12997 
12998 // -----------------------------------------------------------------------------
12999 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13000 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)
13001 {
13002  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13003  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13004 }
13005 
13006 // -----------------------------------------------------------------------------
13007 // ParallelForEachVoxelIf
13008 // -----------------------------------------------------------------------------
13009 
13010 //
13011 // Image arguments by pointer
13012 //
13013 
13014 // -----------------------------------------------------------------------------
13015 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13016 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, VoxelFunc &vf, OutsideFunc &of)
13017 {
13018  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13019  blocked_range<int> re(0, im8->GetNumberOfVoxels());
13020  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13021  parallel_reduce(re, body);
13022  vf.join(body._VoxelFunc);
13023  of.join(body._OutsideFunc);
13024  } else {
13025  parallel_for(re, body);
13026  }
13027 }
13028 
13029 // -----------------------------------------------------------------------------
13030 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13031 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)
13032 {
13033  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13034  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13035 }
13036 
13037 // -----------------------------------------------------------------------------
13038 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13039 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, VoxelFunc &vf)
13040 {
13042  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13043 }
13044 
13045 // -----------------------------------------------------------------------------
13046 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13047 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)
13048 {
13049  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13050  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13051 }
13052 
13053 // -----------------------------------------------------------------------------
13054 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13055 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, VoxelFunc &vf, OutsideFunc &of)
13056 {
13057  if (im8->GetTSize()) {
13058  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13059  } else {
13060  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13061  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
13062  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13063  parallel_reduce(re, body);
13064  vf.join(body._VoxelFunc);
13065  of.join(body._OutsideFunc);
13066  } else {
13067  parallel_for(re, body);
13068  }
13069  }
13070 }
13071 
13072 // -----------------------------------------------------------------------------
13073 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13074 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)
13075 {
13076  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13077  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13078 }
13079 
13080 // -----------------------------------------------------------------------------
13081 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13082 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, VoxelFunc &vf)
13083 {
13085  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13086 }
13087 
13088 // -----------------------------------------------------------------------------
13089 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13090 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)
13091 {
13092  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13093  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13094 }
13095 
13096 // -----------------------------------------------------------------------------
13097 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13098 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, VoxelFunc &vf, OutsideFunc &of)
13099 {
13100  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13101  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
13102  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13103  if (attr._dt) {
13104  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
13105  } else {
13106  parallel_reduce(re, body);
13107  }
13108  vf.join(body._VoxelFunc);
13109  of.join(body._OutsideFunc);
13110  } else {
13111  if (attr._dt) {
13112  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
13113  } else {
13114  parallel_for(re, body);
13115  }
13116  }
13117 }
13118 
13119 // -----------------------------------------------------------------------------
13120 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13121 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)
13122 {
13123  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13124  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13125 }
13126 
13127 // -----------------------------------------------------------------------------
13128 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13129 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, VoxelFunc &vf)
13130 {
13132  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13133 }
13134 
13135 // -----------------------------------------------------------------------------
13136 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13137 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)
13138 {
13139  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13140  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13141 }
13142 
13143 // -----------------------------------------------------------------------------
13144 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13145 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, VoxelFunc &vf, OutsideFunc &of)
13146 {
13147  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13148  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13149  parallel_reduce(re, body);
13150  vf.join(body._VoxelFunc);
13151  of.join(body._OutsideFunc);
13152  } else {
13153  parallel_for(re, body);
13154  }
13155 }
13156 
13157 // -----------------------------------------------------------------------------
13158 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13159 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)
13160 {
13161  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13162  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13163 }
13164 
13165 // -----------------------------------------------------------------------------
13166 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13167 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, VoxelFunc &vf)
13168 {
13170  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13171 }
13172 
13173 // -----------------------------------------------------------------------------
13174 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13175 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)
13176 {
13177  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13178  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13179 }
13180 
13181 // -----------------------------------------------------------------------------
13182 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13183 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, VoxelFunc &vf, OutsideFunc &of)
13184 {
13185  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13186  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13187  parallel_reduce(re, body);
13188  vf.join(body._VoxelFunc);
13189  of.join(body._OutsideFunc);
13190  } else {
13191  parallel_for(re, body);
13192  }
13193 }
13194 
13195 // -----------------------------------------------------------------------------
13196 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13197 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)
13198 {
13199  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13200  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13201 }
13202 
13203 // -----------------------------------------------------------------------------
13204 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13205 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, VoxelFunc &vf)
13206 {
13208  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13209 }
13210 
13211 // -----------------------------------------------------------------------------
13212 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13213 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)
13214 {
13215  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13216  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13217 }
13218 
13219 // -----------------------------------------------------------------------------
13220 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13221 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, VoxelFunc &vf, OutsideFunc &of)
13222 {
13223  OctaryForEachVoxelIfBody_1Const<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13224  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13225  parallel_reduce(re, body);
13226  vf.join(body._VoxelFunc);
13227  of.join(body._OutsideFunc);
13228  } else {
13229  parallel_for(re, body);
13230  }
13231 }
13232 
13233 // -----------------------------------------------------------------------------
13234 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13235 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)
13236 {
13237  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13238  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13239 }
13240 
13241 // -----------------------------------------------------------------------------
13242 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13243 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, VoxelFunc &vf)
13244 {
13246  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
13247 }
13248 
13249 // -----------------------------------------------------------------------------
13250 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13251 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)
13252 {
13253  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13254  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13255 }
13256 
13257 //
13258 // Image arguments by reference
13259 //
13260 
13261 // -----------------------------------------------------------------------------
13262 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13263 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, VoxelFunc &vf, OutsideFunc &of)
13264 {
13267  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13268  parallel_reduce(re, body);
13269  vf.join(body._VoxelFunc);
13270  of.join(body._OutsideFunc);
13271  } else {
13272  parallel_for(re, body);
13273  }
13274 }
13275 
13276 // -----------------------------------------------------------------------------
13277 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13278 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)
13279 {
13280  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13281  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13282 }
13283 
13284 // -----------------------------------------------------------------------------
13285 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13286 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, VoxelFunc &vf)
13287 {
13289  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13290 }
13291 
13292 // -----------------------------------------------------------------------------
13293 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13294 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)
13295 {
13296  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13297  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13298 }
13299 
13300 // -----------------------------------------------------------------------------
13301 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13302 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, VoxelFunc &vf, OutsideFunc &of)
13303 {
13304  if (im8.GetTSize()) {
13305  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13306  } else {
13308  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
13309  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13310  parallel_reduce(re, body);
13311  vf.join(body._VoxelFunc);
13312  of.join(body._OutsideFunc);
13313  } else {
13314  parallel_for(re, body);
13315  }
13316  }
13317 }
13318 
13319 // -----------------------------------------------------------------------------
13320 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13321 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)
13322 {
13323  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13324  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13325 }
13326 
13327 // -----------------------------------------------------------------------------
13328 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13329 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, VoxelFunc &vf)
13330 {
13332  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13333 }
13334 
13335 // -----------------------------------------------------------------------------
13336 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13337 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)
13338 {
13339  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13340  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13341 }
13342 
13343 // -----------------------------------------------------------------------------
13344 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13345 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, VoxelFunc &vf, OutsideFunc &of)
13346 {
13348  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
13349  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13350  if (attr._dt) {
13351  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
13352  } else {
13353  parallel_reduce(re, body);
13354  }
13355  vf.join(body._VoxelFunc);
13356  of.join(body._OutsideFunc);
13357  } else {
13358  if (attr._dt) {
13359  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
13360  } else {
13361  parallel_for(re, body);
13362  }
13363  }
13364 }
13365 
13366 // -----------------------------------------------------------------------------
13367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13368 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)
13369 {
13370  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13371  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13372 }
13373 
13374 // -----------------------------------------------------------------------------
13375 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13376 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, VoxelFunc &vf)
13377 {
13379  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13380 }
13381 
13382 // -----------------------------------------------------------------------------
13383 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13384 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)
13385 {
13386  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13387  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13388 }
13389 
13390 // -----------------------------------------------------------------------------
13391 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13392 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, VoxelFunc &vf, OutsideFunc &of)
13393 {
13395  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13396  parallel_reduce(re, body);
13397  vf.join(body._VoxelFunc);
13398  of.join(body._OutsideFunc);
13399  } else {
13400  parallel_for(re, body);
13401  }
13402 }
13403 
13404 // -----------------------------------------------------------------------------
13405 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13406 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)
13407 {
13408  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13409  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13410 }
13411 
13412 // -----------------------------------------------------------------------------
13413 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13414 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, VoxelFunc &vf)
13415 {
13417  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13418 }
13419 
13420 // -----------------------------------------------------------------------------
13421 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13422 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)
13423 {
13424  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13425  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13426 }
13427 
13428 // -----------------------------------------------------------------------------
13429 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13430 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, VoxelFunc &vf, OutsideFunc &of)
13431 {
13433  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13434  parallel_reduce(re, body);
13435  vf.join(body._VoxelFunc);
13436  of.join(body._OutsideFunc);
13437  } else {
13438  parallel_for(re, body);
13439  }
13440 }
13441 
13442 // -----------------------------------------------------------------------------
13443 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13444 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)
13445 {
13446  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13447  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13448 }
13449 
13450 // -----------------------------------------------------------------------------
13451 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13452 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, VoxelFunc &vf)
13453 {
13455  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13456 }
13457 
13458 // -----------------------------------------------------------------------------
13459 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13460 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)
13461 {
13462  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13463  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13464 }
13465 
13466 // -----------------------------------------------------------------------------
13467 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13468 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, VoxelFunc &vf, OutsideFunc &of)
13469 {
13471  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
13472  parallel_reduce(re, body);
13473  vf.join(body._VoxelFunc);
13474  of.join(body._OutsideFunc);
13475  } else {
13476  parallel_for(re, body);
13477  }
13478 }
13479 
13480 // -----------------------------------------------------------------------------
13481 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
13482 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)
13483 {
13484  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13485  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13486 }
13487 
13488 // -----------------------------------------------------------------------------
13489 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13490 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, VoxelFunc &vf)
13491 {
13493  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
13494 }
13495 
13496 // -----------------------------------------------------------------------------
13497 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13498 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)
13499 {
13500  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13501  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13502 }
13503 
13504 // =============================================================================
13505 // 8 non-const images
13506 // =============================================================================
13507 
13508 // -----------------------------------------------------------------------------
13509 /**
13510  * ForEachVoxel body for voxel function of 8 non-const images
13511  */
13512 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13513 struct OctaryForEachVoxelBody : public ForEachVoxelBody<VoxelFunc>
13514 {
13515  GenericImage<T1> &im1;
13516  GenericImage<T2> &im2;
13517  GenericImage<T3> &im3;
13518  GenericImage<T4> &im4;
13519  GenericImage<T5> &im5;
13520  GenericImage<T6> &im6;
13521  GenericImage<T7> &im7;
13522  GenericImage<T8> &im8;
13523 
13524  /// Constructor
13526  GenericImage<T2> &im2,
13527  GenericImage<T3> &im3,
13528  GenericImage<T4> &im4,
13529  GenericImage<T5> &im5,
13530  GenericImage<T6> &im6,
13531  GenericImage<T7> &im7,
13532  GenericImage<T8> &im8,
13533  VoxelFunc &vf)
13534  :
13535  ForEachVoxelBody<VoxelFunc>(vf, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
13536  {}
13537 
13538  /// Copy constructor
13540  :
13541  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)
13542  {}
13543 
13544  /// Split constructor
13546  :
13547  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)
13548  {}
13549 
13550  /// Process entire image
13551  void operator ()(const ImageAttributes &attr) const
13552  {
13553  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
13554  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
13555  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
13556  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
13557  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
13558  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
13559  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
13560  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
13561 
13562  const int T = (attr._dt ? attr._t : 1);
13563 
13564  for (int l = 0; l < T; ++l)
13565  for (int k = 0; k < attr._z; ++k)
13566  for (int j = 0; j < attr._y; ++j)
13567  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
13568  // const_cast such that voxel functions need only implement
13569  // non-const operator() which is required for parallel_reduce
13570  const_cast<OctaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
13571  }
13572  }
13573 
13574  /// Process image region using linear index
13575  void operator ()(const blocked_range<int> &re) const
13576  {
13577  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
13578  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
13579  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
13580  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
13581  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
13582  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
13583  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
13584  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
13585 
13586  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) {
13587  // const_cast such that voxel functions need only implement
13588  // non-const operator() which is required for parallel_reduce
13589  const_cast<OctaryForEachVoxelBody *>(this)->_VoxelFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
13590  }
13591  }
13592 
13593  /// Process 2D image region
13594  void operator ()(const blocked_range2d<int> &re) const
13595  {
13596  const int bi = re.cols().begin();
13597  const int bj = re.rows().begin();
13598  const int ei = re.cols().end();
13599  const int ej = re.rows().end();
13600 
13601  const int s1 = im8.GetX() - (ei - bi);
13602 
13603  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13604  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13605  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13606  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13607  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13608  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13609  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13610  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13611 
13612  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
13613  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
13614  // const_cast such that voxel functions need only implement
13615  // non-const operator() which is required for parallel_reduce
13616  const_cast<OctaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13617  }
13618  }
13619 
13620  /// Process 3D image region
13621  void operator ()(const blocked_range3d<int> &re) const
13622  {
13623  const int bi = re.cols ().begin();
13624  const int bj = re.rows ().begin();
13625  const int bk = re.pages().begin();
13626  const int ei = re.cols ().end();
13627  const int ej = re.rows ().end();
13628  const int ek = re.pages().end();
13629 
13630  const int s1 = im8.GetX() - (ei - bi);
13631  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
13632 
13633  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
13634  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
13635  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
13636  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
13637  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
13638  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
13639  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
13640  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
13641 
13642  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
13643  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
13644  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
13645  // const_cast such that voxel functions need only implement
13646  // non-const operator() which is required for parallel_reduce
13647  const_cast<OctaryForEachVoxelBody *>(this)->_VoxelFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13648  }
13649  }
13650 };
13651 
13652 // -----------------------------------------------------------------------------
13653 /**
13654  * ForEachVoxel body for inside and outside unary voxel function of 8 non-const images
13655  */
13656 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8,
13657  class VoxelFunc, class OutsideFunc = NaryVoxelFunction::NOP,
13658  class Domain = ForEachVoxelDomain::Foreground>
13659 struct OctaryForEachVoxelIfBody : public ForEachVoxelIfBody<VoxelFunc, OutsideFunc>
13660 {
13661  GenericImage<T1> &im1;
13662  GenericImage<T2> &im2;
13663  GenericImage<T3> &im3;
13664  GenericImage<T4> &im4;
13665  GenericImage<T5> &im5;
13666  GenericImage<T6> &im6;
13667  GenericImage<T7> &im7;
13668  GenericImage<T8> &im8;
13669 
13670  /// Constructor
13672  GenericImage<T2> &im2,
13673  GenericImage<T3> &im3,
13674  GenericImage<T4> &im4,
13675  GenericImage<T5> &im5,
13676  GenericImage<T6> &im6,
13677  GenericImage<T7> &im7,
13678  GenericImage<T8> &im8,
13679  VoxelFunc &vf, OutsideFunc &of)
13680  :
13681  ForEachVoxelIfBody<VoxelFunc, OutsideFunc>(vf, of, im1.Attributes()), im1(im1), im2(im2), im3(im3), im4(im4), im5(im5), im6(im6), im7(im7), im8(im8)
13682  {}
13683 
13684  /// Copy constructor
13686  :
13687  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)
13688  {}
13689 
13690  /// Split constructor
13692  :
13693  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)
13694  {}
13695 
13696  /// Process entire image
13697  void operator ()(const ImageAttributes &attr) const
13698  {
13699  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels();
13700  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels();
13701  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels();
13702  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels();
13703  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels();
13704  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels();
13705  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels();
13706  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels();
13707 
13708  const int T = (attr._dt ? attr._t : 1);
13709 
13710  for (int l = 0; l < T; ++l)
13711  for (int k = 0; k < attr._z; ++k)
13712  for (int j = 0; j < attr._y; ++j)
13713  for (int i = 0; i < attr._x; ++i, ++p1, ++p2, ++p3, ++p4, ++p5, ++p6, ++p7, ++p8) {
13714  if (Domain::IsInside(im8, i, j, k, l, p8)) {
13715  // const_cast such that voxel functions need only implement
13716  // non-const operator() which is required for parallel_reduce
13717  const_cast<OctaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
13718  } else const_cast<OctaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, l, p1, p2, p3, p4, p5, p6, p7, p8);
13719  }
13720  }
13721 
13722  /// Process image region using linear index
13723  void operator ()(const blocked_range<int> &re) const
13724  {
13725  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels() + re.begin();
13726  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels() + re.begin();
13727  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels() + re.begin();
13728  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels() + re.begin();
13729  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels() + re.begin();
13730  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels() + re.begin();
13731  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels() + re.begin();
13732  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels() + re.begin();
13733 
13734  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) {
13735  if (Domain::IsInside(im8, idx, p8)) {
13736  // const_cast such that voxel functions need only implement
13737  // non-const operator() which is required for parallel_reduce
13738  const_cast<OctaryForEachVoxelIfBody *>(this)->_VoxelFunc (im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
13739  } else const_cast<OctaryForEachVoxelIfBody *>(this)->_OutsideFunc(im8, idx, p1, p2, p3, p4, p5, p6, p7, p8);
13740  }
13741  }
13742 
13743  /// Process 2D image region
13744  void operator ()(const blocked_range2d<int> &re) const
13745  {
13746  const int bi = re.cols().begin();
13747  const int bj = re.rows().begin();
13748  const int ei = re.cols().end();
13749  const int ej = re.rows().end();
13750 
13751  const int s1 = im8.GetX() - (ei - bi);
13752 
13753  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13754  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13755  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13756  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13757  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13758  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13759  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13760  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, this->_k, this->_l);
13761 
13762  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
13763  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
13764  if (Domain::IsInside(im8, i, j, this->_k, this->_l, p8)) {
13765  // const_cast such that voxel functions need only implement
13766  // non-const operator() which is required for parallel_reduce
13767  const_cast<OctaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13768  } else const_cast<OctaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, this->_k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13769  }
13770  }
13771 
13772  /// Process 3D image region
13773  void operator ()(const blocked_range3d<int> &re) const
13774  {
13775  const int bi = re.cols ().begin();
13776  const int bj = re.rows ().begin();
13777  const int bk = re.pages().begin();
13778  const int ei = re.cols ().end();
13779  const int ej = re.rows ().end();
13780  const int ek = re.pages().end();
13781 
13782  const int s1 = im8.GetX() - (ei - bi);
13783  const int s2 = (im8.GetY() - (ej - bj)) * im8.GetX();
13784 
13785  T1 *p1 = im1.IsEmpty() ? NULL : im1.GetPointerToVoxels(bi, bj, bk, this->_l);
13786  T2 *p2 = im2.IsEmpty() ? NULL : im2.GetPointerToVoxels(bi, bj, bk, this->_l);
13787  T3 *p3 = im3.IsEmpty() ? NULL : im3.GetPointerToVoxels(bi, bj, bk, this->_l);
13788  T4 *p4 = im4.IsEmpty() ? NULL : im4.GetPointerToVoxels(bi, bj, bk, this->_l);
13789  T5 *p5 = im5.IsEmpty() ? NULL : im5.GetPointerToVoxels(bi, bj, bk, this->_l);
13790  T6 *p6 = im6.IsEmpty() ? NULL : im6.GetPointerToVoxels(bi, bj, bk, this->_l);
13791  T7 *p7 = im7.IsEmpty() ? NULL : im7.GetPointerToVoxels(bi, bj, bk, this->_l);
13792  T8 *p8 = im8.IsEmpty() ? NULL : im8.GetPointerToVoxels(bi, bj, bk, this->_l);
13793 
13794  for (int k = bk; k < ek; ++k, p1 += s2, p2 += s2, p3 += s2, p4 += s2, p5 += s2, p6 += s2, p7 += s2, p8 += s2)
13795  for (int j = bj; j < ej; ++j, p1 += s1, p2 += s1, p3 += s1, p4 += s1, p5 += s1, p6 += s1, p7 += s1, p8 += s1)
13796  for (int i = bi; i < ei; ++i, p1 += 1, p2 += 1, p3 += 1, p4 += 1, p5 += 1, p6 += 1, p7 += 1, p8 += 1) {
13797  if (Domain::IsInside(im8, i, j, k, this->_l, p8)) {
13798  // const_cast such that voxel functions need only implement
13799  // non-const operator() which is required for parallel_reduce
13800  const_cast<OctaryForEachVoxelIfBody *>(this)->_VoxelFunc (i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13801  } else const_cast<OctaryForEachVoxelIfBody *>(this)->_OutsideFunc(i, j, k, this->_l, p1, p2, p3, p4, p5, p6, p7, p8);
13802  }
13803  }
13804 };
13805 
13806 // -----------------------------------------------------------------------------
13807 // ForEachVoxel
13808 // -----------------------------------------------------------------------------
13809 
13810 //
13811 // Image arguments by pointer
13812 //
13813 
13814 // -----------------------------------------------------------------------------
13815 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13816 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, VoxelFunc &vf)
13817 {
13818  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13819  blocked_range<int> re(0, im8->GetNumberOfVoxels());
13820  body(re);
13821  vf.join(body._VoxelFunc);
13822 }
13823 
13824 // -----------------------------------------------------------------------------
13825 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13826 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)
13827 {
13828  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13829  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13830 }
13831 
13832 // -----------------------------------------------------------------------------
13833 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13834 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, VoxelFunc &vf)
13835 {
13836  if (im8->GetTSize()) {
13837  ForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13838  } else {
13839  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13840  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
13841  body(re);
13842  vf.join(body._VoxelFunc);
13843  }
13844 }
13845 
13846 // -----------------------------------------------------------------------------
13847 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13848 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)
13849 {
13850  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13851  ForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13852 }
13853 
13854 // -----------------------------------------------------------------------------
13855 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13856 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, VoxelFunc &vf)
13857 {
13858  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13859  body(attr);
13860  vf.join(body._VoxelFunc);
13861 }
13862 
13863 // -----------------------------------------------------------------------------
13864 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13865 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)
13866 {
13867  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13868  ForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13869 }
13870 
13871 // -----------------------------------------------------------------------------
13872 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13873 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, VoxelFunc &vf)
13874 {
13875  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13876  body(re);
13877  vf.join(body._VoxelFunc);
13878 }
13879 
13880 // -----------------------------------------------------------------------------
13881 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13882 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)
13883 {
13884  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13885  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13886 }
13887 
13888 // -----------------------------------------------------------------------------
13889 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13890 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, VoxelFunc &vf)
13891 {
13892  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13893  body(re);
13894  vf.join(body._VoxelFunc);
13895 }
13896 
13897 // -----------------------------------------------------------------------------
13898 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13899 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)
13900 {
13901  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13902  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13903 }
13904 
13905 // -----------------------------------------------------------------------------
13906 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13907 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, VoxelFunc &vf)
13908 {
13909  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13910  body(re);
13911  vf.join(body._VoxelFunc);
13912 }
13913 
13914 // -----------------------------------------------------------------------------
13915 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13916 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)
13917 {
13918  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13919  ForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
13920 }
13921 
13922 //
13923 // Image arguments by reference
13924 //
13925 
13926 // -----------------------------------------------------------------------------
13927 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13928 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, VoxelFunc &vf)
13929 {
13930  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13932  body(re);
13933  vf.join(body._VoxelFunc);
13934 }
13935 
13936 // -----------------------------------------------------------------------------
13937 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13938 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)
13939 {
13940  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13941  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13942 }
13943 
13944 // -----------------------------------------------------------------------------
13945 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13946 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, VoxelFunc &vf)
13947 {
13948  if (im8.GetTSize()) {
13949  ForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13950  } else {
13951  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13952  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
13953  body(re);
13954  vf.join(body._VoxelFunc);
13955  }
13956 }
13957 
13958 // -----------------------------------------------------------------------------
13959 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13960 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)
13961 {
13962  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13963  ForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13964 }
13965 
13966 // -----------------------------------------------------------------------------
13967 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13968 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, VoxelFunc &vf)
13969 {
13970  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13971  body(attr);
13972  vf.join(body._VoxelFunc);
13973 }
13974 
13975 // -----------------------------------------------------------------------------
13976 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13977 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)
13978 {
13979  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13980  ForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13981 }
13982 
13983 // -----------------------------------------------------------------------------
13984 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13985 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, VoxelFunc &vf)
13986 {
13987  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
13988  body(re);
13989  vf.join(body._VoxelFunc);
13990 }
13991 
13992 // -----------------------------------------------------------------------------
13993 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
13994 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)
13995 {
13996  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
13997  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
13998 }
13999 
14000 // -----------------------------------------------------------------------------
14001 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14002 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, VoxelFunc &vf)
14003 {
14004  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14005  body(re);
14006  vf.join(body._VoxelFunc);
14007 }
14008 
14009 // -----------------------------------------------------------------------------
14010 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14011 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)
14012 {
14013  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14014  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14015 }
14016 
14017 // -----------------------------------------------------------------------------
14018 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14019 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, VoxelFunc &vf)
14020 {
14021  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14022  body(re);
14023  vf.join(body._VoxelFunc);
14024 }
14025 
14026 // -----------------------------------------------------------------------------
14027 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14028 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)
14029 {
14030  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14031  ForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14032 }
14033 
14034 // -----------------------------------------------------------------------------
14035 // ForEachVoxelIf
14036 // -----------------------------------------------------------------------------
14037 
14038 //
14039 // Image arguments by pointer
14040 //
14041 
14042 // -----------------------------------------------------------------------------
14043 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14044 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, VoxelFunc &vf, OutsideFunc &of)
14045 {
14046  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14047  blocked_range<int> re(0, im8->GetNumberOfVoxels());
14048  body(re);
14049  vf.join(body._VoxelFunc);
14050  of.join(body._OutsideFunc);
14051 }
14052 
14053 // -----------------------------------------------------------------------------
14054 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14055 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)
14056 {
14057  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14058  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14059 }
14060 
14061 // -----------------------------------------------------------------------------
14062 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14063 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, VoxelFunc &vf)
14064 {
14066  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14067 }
14068 
14069 // -----------------------------------------------------------------------------
14070 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14071 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)
14072 {
14073  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14074  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14075 }
14076 
14077 // -----------------------------------------------------------------------------
14078 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14079 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, VoxelFunc &vf, OutsideFunc &of)
14080 {
14081  if (im8->GetTSize()) {
14082  ForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14083  } else {
14084  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14085  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
14086  body(re);
14087  vf.join(body._VoxelFunc);
14088  of.join(body._OutsideFunc);
14089  }
14090 }
14091 
14092 // -----------------------------------------------------------------------------
14093 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14094 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)
14095 {
14096  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14097  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14098 }
14099 
14100 // -----------------------------------------------------------------------------
14101 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14102 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, VoxelFunc &vf)
14103 {
14105  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14106 }
14107 
14108 // -----------------------------------------------------------------------------
14109 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14110 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)
14111 {
14112  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14113  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14114 }
14115 
14116 // -----------------------------------------------------------------------------
14117 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14118 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, VoxelFunc &vf, OutsideFunc &of)
14119 {
14120  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14121  body(attr);
14122  vf.join(body._VoxelFunc);
14123  of.join(body._OutsideFunc);
14124 }
14125 
14126 // -----------------------------------------------------------------------------
14127 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14128 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)
14129 {
14130  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14131  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14132 }
14133 
14134 // -----------------------------------------------------------------------------
14135 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14136 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, VoxelFunc &vf)
14137 {
14139  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14140 }
14141 
14142 // -----------------------------------------------------------------------------
14143 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14144 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)
14145 {
14146  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14147  ForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14148 }
14149 
14150 // -----------------------------------------------------------------------------
14151 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14152 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, VoxelFunc &vf, OutsideFunc &of)
14153 {
14154  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14155  body(re);
14156  vf.join(body._VoxelFunc);
14157  of.join(body._OutsideFunc);
14158 }
14159 
14160 // -----------------------------------------------------------------------------
14161 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14162 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)
14163 {
14164  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14165  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14166 }
14167 
14168 // -----------------------------------------------------------------------------
14169 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14170 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, VoxelFunc &vf, OutsideFunc &of)
14171 {
14172  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14173  body(re);
14174  vf.join(body._VoxelFunc);
14175  of.join(body._OutsideFunc);
14176 }
14177 
14178 // -----------------------------------------------------------------------------
14179 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14180 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)
14181 {
14182  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14183  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14184 }
14185 
14186 // -----------------------------------------------------------------------------
14187 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14188 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, VoxelFunc &vf)
14189 {
14191  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14192 }
14193 
14194 // -----------------------------------------------------------------------------
14195 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14196 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)
14197 {
14198  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14199  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14200 }
14201 
14202 // -----------------------------------------------------------------------------
14203 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14204 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, VoxelFunc &vf, OutsideFunc &of)
14205 {
14206  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14207  body(re);
14208  vf.join(body._VoxelFunc);
14209  of.join(body._OutsideFunc);
14210 }
14211 
14212 // -----------------------------------------------------------------------------
14213 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14214 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)
14215 {
14216  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14217  ForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14218 }
14219 
14220 // -----------------------------------------------------------------------------
14221 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14222 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, VoxelFunc &vf)
14223 {
14225  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14226 }
14227 
14228 // -----------------------------------------------------------------------------
14229 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14230 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)
14231 {
14232  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14233  ForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14234 }
14235 
14236 //
14237 // Image arguments by reference
14238 //
14239 
14240 // -----------------------------------------------------------------------------
14241 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14242 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, VoxelFunc &vf, OutsideFunc &of)
14243 {
14244  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14246  body(re);
14247  vf.join(body._VoxelFunc);
14248  of.join(body._OutsideFunc);
14249 }
14250 
14251 // -----------------------------------------------------------------------------
14252 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14253 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)
14254 {
14255  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14256  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14257 }
14258 
14259 // -----------------------------------------------------------------------------
14260 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14261 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, VoxelFunc &vf)
14262 {
14264  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14265 }
14266 
14267 // -----------------------------------------------------------------------------
14268 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14269 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)
14270 {
14271  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14272  ForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14273 }
14274 
14275 // -----------------------------------------------------------------------------
14276 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14277 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, VoxelFunc &vf, OutsideFunc &of)
14278 {
14279  if (im8.GetTSize()) {
14280  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14281  } else {
14282  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14283  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
14284  body(re);
14285  vf.join(body._VoxelFunc);
14286  of.join(body._OutsideFunc);
14287  }
14288 }
14289 
14290 // -----------------------------------------------------------------------------
14291 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14292 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)
14293 {
14294  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14295  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14296 }
14297 
14298 // -----------------------------------------------------------------------------
14299 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14300 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, VoxelFunc &vf)
14301 {
14303  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14304 }
14305 
14306 // -----------------------------------------------------------------------------
14307 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14308 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)
14309 {
14310  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14311  ForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14312 }
14313 
14314 // -----------------------------------------------------------------------------
14315 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14316 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, VoxelFunc &vf, OutsideFunc &of)
14317 {
14318  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14319  body(attr);
14320  vf.join(body._VoxelFunc);
14321  of.join(body._OutsideFunc);
14322 }
14323 
14324 // -----------------------------------------------------------------------------
14325 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14326 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)
14327 {
14328  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14329  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14330 }
14331 
14332 // -----------------------------------------------------------------------------
14333 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14334 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, VoxelFunc &vf)
14335 {
14337  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14338 }
14339 
14340 // -----------------------------------------------------------------------------
14341 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14342 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)
14343 {
14344  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14345  ForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14346 }
14347 
14348 // -----------------------------------------------------------------------------
14349 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14350 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, VoxelFunc &vf, OutsideFunc &of)
14351 {
14352  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14353  body(re);
14354  vf.join(body._VoxelFunc);
14355  of.join(body._OutsideFunc);
14356 }
14357 
14358 // -----------------------------------------------------------------------------
14359 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14360 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)
14361 {
14362  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14363  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14364 }
14365 
14366 // -----------------------------------------------------------------------------
14367 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14368 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, VoxelFunc &vf, OutsideFunc &of)
14369 {
14370  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14371  body(re);
14372  vf.join(body._VoxelFunc);
14373  of.join(body._OutsideFunc);
14374 }
14375 
14376 // -----------------------------------------------------------------------------
14377 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14378 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)
14379 {
14380  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14381  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14382 }
14383 
14384 // -----------------------------------------------------------------------------
14385 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14386 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, VoxelFunc &vf)
14387 {
14389  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14390 }
14391 
14392 // -----------------------------------------------------------------------------
14393 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14394 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)
14395 {
14396  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14397  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14398 }
14399 
14400 // -----------------------------------------------------------------------------
14401 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14402 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, VoxelFunc &vf, OutsideFunc &of)
14403 {
14404  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14405  body(re);
14406  vf.join(body._VoxelFunc);
14407  of.join(body._OutsideFunc);
14408 }
14409 
14410 // -----------------------------------------------------------------------------
14411 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14412 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)
14413 {
14414  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14415  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14416 }
14417 
14418 // -----------------------------------------------------------------------------
14419 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14420 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, VoxelFunc &vf)
14421 {
14423  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14424 }
14425 
14426 // -----------------------------------------------------------------------------
14427 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14428 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)
14429 {
14430  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14431  ForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14432 }
14433 
14434 // -----------------------------------------------------------------------------
14435 // ParallelForEachVoxel
14436 // -----------------------------------------------------------------------------
14437 
14438 //
14439 // Image arguments by pointer
14440 //
14441 
14442 // -----------------------------------------------------------------------------
14443 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14444 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, VoxelFunc &vf)
14445 {
14446  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14447  blocked_range<int> re(0, im8->GetNumberOfVoxels());
14448  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14449  else parallel_for (re, body);
14450 }
14451 
14452 // -----------------------------------------------------------------------------
14453 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14454 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)
14455 {
14456  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14457  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14458 }
14459 
14460 // -----------------------------------------------------------------------------
14461 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14462 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, VoxelFunc &vf)
14463 {
14464  if (im8->GetTSize()) {
14465  ParallelForEachScalar(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14466  } else {
14467  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14468  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
14469  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14470  else parallel_for (re, body);
14471  }
14472 }
14473 
14474 // -----------------------------------------------------------------------------
14475 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14476 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)
14477 {
14478  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14479  ParallelForEachVoxel(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14480 }
14481 
14482 // -----------------------------------------------------------------------------
14483 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14484 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, VoxelFunc &vf)
14485 {
14486  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14487  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14488  if (VoxelFunc::IsReduction()) {
14489  if (attr._dt) {
14490  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14491  } else {
14492  parallel_reduce(re, body);
14493  }
14494  vf.join(body._VoxelFunc);
14495  } else {
14496  if (attr._dt) {
14497  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14498  } else {
14499  parallel_for(re, body);
14500  }
14501  }
14502 }
14503 
14504 // -----------------------------------------------------------------------------
14505 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14506 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)
14507 {
14508  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14509  ParallelForEachVoxel(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14510 }
14511 
14512 // -----------------------------------------------------------------------------
14513 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14514 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, VoxelFunc &vf)
14515 {
14516  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14517  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14518  else parallel_for (re, body);
14519 }
14520 
14521 // -----------------------------------------------------------------------------
14522 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14523 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)
14524 {
14525  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14526  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14527 }
14528 
14529 // -----------------------------------------------------------------------------
14530 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14531 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, VoxelFunc &vf)
14532 {
14533  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14534  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14535  else parallel_for (re, body);
14536 }
14537 
14538 // -----------------------------------------------------------------------------
14539 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14540 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)
14541 {
14542  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14543  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14544 }
14545 
14546 // -----------------------------------------------------------------------------
14547 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14548 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, VoxelFunc &vf)
14549 {
14550  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14551  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14552  else parallel_for (re, body);
14553 }
14554 
14555 // -----------------------------------------------------------------------------
14556 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14557 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)
14558 {
14559  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14560  ParallelForEachVoxel(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14561 }
14562 
14563 //
14564 // Image arguments by reference
14565 //
14566 
14567 // -----------------------------------------------------------------------------
14568 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14569 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, VoxelFunc &vf)
14570 {
14571  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14573  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14574  else parallel_for (re, body);
14575 }
14576 
14577 // -----------------------------------------------------------------------------
14578 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14579 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)
14580 {
14581  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14582  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14583 }
14584 
14585 // -----------------------------------------------------------------------------
14586 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14587 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, VoxelFunc &vf)
14588 {
14589  if (im8.GetTSize()) {
14590  ParallelForEachScalar(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14591  } else {
14592  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14593  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
14594  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14595  else parallel_for (re, body);
14596  }
14597 }
14598 
14599 // -----------------------------------------------------------------------------
14600 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14601 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)
14602 {
14603  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14604  ParallelForEachVoxel(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14605 }
14606 
14607 // -----------------------------------------------------------------------------
14608 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14609 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, VoxelFunc &vf)
14610 {
14611  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14612  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14613  if (VoxelFunc::IsReduction()) {
14614  if (attr._dt) {
14615  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14616  } else {
14617  parallel_reduce(re, body);
14618  }
14619  vf.join(body._VoxelFunc);
14620  } else {
14621  if (attr._dt) {
14622  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14623  } else {
14624  parallel_for(re, body);
14625  }
14626  }
14627 }
14628 
14629 // -----------------------------------------------------------------------------
14630 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14631 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)
14632 {
14633  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14634  ParallelForEachVoxel(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14635 }
14636 
14637 // -----------------------------------------------------------------------------
14638 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14639 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, VoxelFunc &vf)
14640 {
14641  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
14648 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)
14649 {
14650  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14651  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14652 }
14653 
14654 // -----------------------------------------------------------------------------
14655 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14656 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, VoxelFunc &vf)
14657 {
14658  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, 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 VoxelFunc>
14665 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)
14666 {
14667  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14668  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14669 }
14670 
14671 // -----------------------------------------------------------------------------
14672 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14673 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, VoxelFunc &vf)
14674 {
14675  OctaryForEachVoxelBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc> body(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14676  if (VoxelFunc::IsReduction()) { parallel_reduce(re, body); vf.join(body._VoxelFunc); }
14677  else parallel_for (re, body);
14678 }
14679 
14680 // -----------------------------------------------------------------------------
14681 template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14682 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)
14683 {
14684  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14685  ParallelForEachVoxel(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
14686 }
14687 
14688 // -----------------------------------------------------------------------------
14689 // ParallelForEachVoxelIf
14690 // -----------------------------------------------------------------------------
14691 
14692 //
14693 // Image arguments by pointer
14694 //
14695 
14696 // -----------------------------------------------------------------------------
14697 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14698 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, VoxelFunc &vf, OutsideFunc &of)
14699 {
14700  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14701  blocked_range<int> re(0, im8->GetNumberOfVoxels());
14702  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14703  parallel_reduce(re, body);
14704  vf.join(body._VoxelFunc);
14705  of.join(body._OutsideFunc);
14706  } else {
14707  parallel_for(re, body);
14708  }
14709 }
14710 
14711 // -----------------------------------------------------------------------------
14712 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14713 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)
14714 {
14715  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14716  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14717 }
14718 
14719 // -----------------------------------------------------------------------------
14720 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14721 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, VoxelFunc &vf)
14722 {
14724  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14725 }
14726 
14727 // -----------------------------------------------------------------------------
14728 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14729 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)
14730 {
14731  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14732  ParallelForEachScalarIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14733 }
14734 
14735 // -----------------------------------------------------------------------------
14736 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14737 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, VoxelFunc &vf, OutsideFunc &of)
14738 {
14739  if (im8->GetTSize()) {
14740  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14741  } else {
14742  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14743  blocked_range<int> re(0, im8->GetNumberOfVoxels() / im8->GetT());
14744  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14745  parallel_reduce(re, body);
14746  vf.join(body._VoxelFunc);
14747  of.join(body._OutsideFunc);
14748  } else {
14749  parallel_for(re, body);
14750  }
14751  }
14752 }
14753 
14754 // -----------------------------------------------------------------------------
14755 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14756 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)
14757 {
14758  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14759  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14760 }
14761 
14762 // -----------------------------------------------------------------------------
14763 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14764 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, VoxelFunc &vf)
14765 {
14767  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14768 }
14769 
14770 // -----------------------------------------------------------------------------
14771 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14772 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)
14773 {
14774  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14775  ParallelForEachVoxelIf<Domain>(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14776 }
14777 
14778 // -----------------------------------------------------------------------------
14779 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14780 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, VoxelFunc &vf, OutsideFunc &of)
14781 {
14782  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14783  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
14784  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14785  if (attr._dt) {
14786  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
14787  } else {
14788  parallel_reduce(re, body);
14789  }
14790  vf.join(body._VoxelFunc);
14791  of.join(body._OutsideFunc);
14792  } else {
14793  if (attr._dt) {
14794  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
14795  } else {
14796  parallel_for(re, body);
14797  }
14798  }
14799 }
14800 
14801 // -----------------------------------------------------------------------------
14802 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14803 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)
14804 {
14805  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14806  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14807 }
14808 
14809 // -----------------------------------------------------------------------------
14810 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14811 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, VoxelFunc &vf)
14812 {
14814  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14815 }
14816 
14817 // -----------------------------------------------------------------------------
14818 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14819 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)
14820 {
14821  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14822  ParallelForEachVoxelIf<Domain>(attr, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14823 }
14824 
14825 // -----------------------------------------------------------------------------
14826 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14827 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, VoxelFunc &vf, OutsideFunc &of)
14828 {
14829  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14830  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14831  parallel_reduce(re, body);
14832  vf.join(body._VoxelFunc);
14833  of.join(body._OutsideFunc);
14834  } else {
14835  parallel_for(re, body);
14836  }
14837 }
14838 
14839 // -----------------------------------------------------------------------------
14840 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14841 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)
14842 {
14843  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14844  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14845 }
14846 
14847 // -----------------------------------------------------------------------------
14848 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14849 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, VoxelFunc &vf)
14850 {
14852  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14853 }
14854 
14855 // -----------------------------------------------------------------------------
14856 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14857 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)
14858 {
14859  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14860  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14861 }
14862 
14863 // -----------------------------------------------------------------------------
14864 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14865 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, VoxelFunc &vf, OutsideFunc &of)
14866 {
14867  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14868  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14869  parallel_reduce(re, body);
14870  vf.join(body._VoxelFunc);
14871  of.join(body._OutsideFunc);
14872  } else {
14873  parallel_for(re, body);
14874  }
14875 }
14876 
14877 // -----------------------------------------------------------------------------
14878 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14879 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)
14880 {
14881  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14882  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14883 }
14884 
14885 // -----------------------------------------------------------------------------
14886 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14887 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, VoxelFunc &vf)
14888 {
14890  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14891 }
14892 
14893 // -----------------------------------------------------------------------------
14894 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14895 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)
14896 {
14897  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14898  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14899 }
14900 
14901 // -----------------------------------------------------------------------------
14902 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14903 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, VoxelFunc &vf, OutsideFunc &of)
14904 {
14905  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(*im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14906  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14907  parallel_reduce(re, body);
14908  vf.join(body._VoxelFunc);
14909  of.join(body._OutsideFunc);
14910  } else {
14911  parallel_for(re, body);
14912  }
14913 }
14914 
14915 // -----------------------------------------------------------------------------
14916 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14917 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)
14918 {
14919  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14920  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14921 }
14922 
14923 // -----------------------------------------------------------------------------
14924 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14925 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, VoxelFunc &vf)
14926 {
14928  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf, of);
14929 }
14930 
14931 // -----------------------------------------------------------------------------
14932 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14933 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)
14934 {
14935  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14936  ParallelForEachVoxelIf<Domain>(re, *im1, *im2, *im3, *im4, *im5, *im6, *im7, *im8, vf);
14937 }
14938 
14939 //
14940 // Image arguments by reference
14941 //
14942 
14943 // -----------------------------------------------------------------------------
14944 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14945 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, VoxelFunc &vf, OutsideFunc &of)
14946 {
14947  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14949  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14950  parallel_reduce(re, body);
14951  vf.join(body._VoxelFunc);
14952  of.join(body._OutsideFunc);
14953  } else {
14954  parallel_for(re, body);
14955  }
14956 }
14957 
14958 // -----------------------------------------------------------------------------
14959 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14960 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)
14961 {
14962  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14963  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14964 }
14965 
14966 // -----------------------------------------------------------------------------
14967 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14968 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, VoxelFunc &vf)
14969 {
14971  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14972 }
14973 
14974 // -----------------------------------------------------------------------------
14975 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
14976 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)
14977 {
14978  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
14979  ParallelForEachScalarIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
14980 }
14981 
14982 // -----------------------------------------------------------------------------
14983 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
14984 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, VoxelFunc &vf, OutsideFunc &of)
14985 {
14986  if (im8.GetTSize()) {
14987  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14988  } else {
14989  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
14990  blocked_range<int> re(0, im8.GetNumberOfVoxels() / im8.GetT());
14991  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
14992  parallel_reduce(re, body);
14993  vf.join(body._VoxelFunc);
14994  of.join(body._OutsideFunc);
14995  } else {
14996  parallel_for(re, body);
14997  }
14998  }
14999 }
15000 
15001 // -----------------------------------------------------------------------------
15002 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15003 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)
15004 {
15005  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15006  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15007 }
15008 
15009 // -----------------------------------------------------------------------------
15010 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15011 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, VoxelFunc &vf)
15012 {
15014  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15015 }
15016 
15017 // -----------------------------------------------------------------------------
15018 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15019 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)
15020 {
15021  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15022  ParallelForEachVoxelIf<Domain>(im1, im2, im3, im4, im5, im6, im7, im8, vf);
15023 }
15024 
15025 // -----------------------------------------------------------------------------
15026 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15027 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, VoxelFunc &vf, OutsideFunc &of)
15028 {
15029  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15030  blocked_range3d<int> re(0, attr._z, 0, attr._y, 0, attr._x);
15031  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15032  if (attr._dt) {
15033  for (body._l = 0; body._l < attr._t; ++body._l) parallel_reduce(re, body);
15034  } else {
15035  parallel_reduce(re, body);
15036  }
15037  vf.join(body._VoxelFunc);
15038  of.join(body._OutsideFunc);
15039  } else {
15040  if (attr._dt) {
15041  for (body._l = 0; body._l < attr._t; ++body._l) parallel_for(re, body);
15042  } else {
15043  parallel_for(re, body);
15044  }
15045  }
15046 }
15047 
15048 // -----------------------------------------------------------------------------
15049 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15050 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)
15051 {
15052  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15053  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15054 }
15055 
15056 // -----------------------------------------------------------------------------
15057 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15058 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, VoxelFunc &vf)
15059 {
15061  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15062 }
15063 
15064 // -----------------------------------------------------------------------------
15065 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15066 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)
15067 {
15068  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15069  ParallelForEachVoxelIf<Domain>(attr, im1, im2, im3, im4, im5, im6, im7, im8, vf);
15070 }
15071 
15072 // -----------------------------------------------------------------------------
15073 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15074 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, VoxelFunc &vf, OutsideFunc &of)
15075 {
15076  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15077  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15078  parallel_reduce(re, body);
15079  vf.join(body._VoxelFunc);
15080  of.join(body._OutsideFunc);
15081  } else {
15082  parallel_for(re, body);
15083  }
15084 }
15085 
15086 // -----------------------------------------------------------------------------
15087 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15088 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)
15089 {
15090  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15091  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15092 }
15093 
15094 // -----------------------------------------------------------------------------
15095 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15096 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, VoxelFunc &vf)
15097 {
15099  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15100 }
15101 
15102 // -----------------------------------------------------------------------------
15103 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15104 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)
15105 {
15106  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15107  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
15108 }
15109 
15110 // -----------------------------------------------------------------------------
15111 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15112 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, VoxelFunc &vf, OutsideFunc &of)
15113 {
15114  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15115  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15116  parallel_reduce(re, body);
15117  vf.join(body._VoxelFunc);
15118  of.join(body._OutsideFunc);
15119  } else {
15120  parallel_for(re, body);
15121  }
15122 }
15123 
15124 // -----------------------------------------------------------------------------
15125 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15126 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)
15127 {
15128  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15129  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15130 }
15131 
15132 // -----------------------------------------------------------------------------
15133 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15134 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, VoxelFunc &vf)
15135 {
15137  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15138 }
15139 
15140 // -----------------------------------------------------------------------------
15141 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15142 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)
15143 {
15144  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15145  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
15146 }
15147 
15148 // -----------------------------------------------------------------------------
15149 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15150 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, VoxelFunc &vf, OutsideFunc &of)
15151 {
15152  OctaryForEachVoxelIfBody<T1, T2, T3, T4, T5, T6, T7, T8, VoxelFunc, OutsideFunc, Domain> body(im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15153  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) {
15154  parallel_reduce(re, body);
15155  vf.join(body._VoxelFunc);
15156  of.join(body._OutsideFunc);
15157  } else {
15158  parallel_for(re, body);
15159  }
15160 }
15161 
15162 // -----------------------------------------------------------------------------
15163 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc, class OutsideFunc>
15164 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)
15165 {
15166  if (VoxelFunc::IsReduction() || OutsideFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15167  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15168 }
15169 
15170 // -----------------------------------------------------------------------------
15171 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15172 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, VoxelFunc &vf)
15173 {
15175  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf, of);
15176 }
15177 
15178 // -----------------------------------------------------------------------------
15179 template <class Domain, class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class VoxelFunc>
15180 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)
15181 {
15182  if (VoxelFunc::IsReduction()) _foreachoctaryvoxelfunction_must_not_be_reduction();
15183  ParallelForEachVoxelIf<Domain>(re, im1, im2, im3, im4, im5, im6, im7, im8, vf);
15184 }
15185 
15186 
15187 } // namespace mirtk
15188 
15189 #endif
OctaryForEachVoxelBody_2Const(const OctaryForEachVoxelBody_2Const &o)
Copy constructor.
double _dt
Voxel t-dimensions (in ms)
OctaryForEachVoxelIfBody_Const(const OctaryForEachVoxelIfBody_Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_5Const(OctaryForEachVoxelIfBody_5Const &o, split s)
Split constructor.
Dummy type used to distinguish split constructor from copy constructor.
Definition: Parallel.h:143
OctaryForEachVoxelIfBody_2Const(const OctaryForEachVoxelIfBody_2Const &o)
Copy constructor.
OctaryForEachVoxelBody_6Const(OctaryForEachVoxelBody_6Const &o, split s)
Split constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OctaryForEachVoxelBody_6Const(const OctaryForEachVoxelBody_6Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelBody_4Const(const OctaryForEachVoxelBody_4Const &o)
Copy constructor.
Two-dimensional range.
Definition: Parallel.h:168
bool IsEmpty() const
Whether image is uninitialized.
Definition: BaseImage.h:1283
OctaryForEachVoxelIfBody_Const(OctaryForEachVoxelIfBody_Const &o, split s)
Split constructor.
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelBody(const OctaryForEachVoxelBody &o)
Copy constructor.
OctaryForEachVoxelIfBody_6Const(OctaryForEachVoxelIfBody_6Const &o, split s)
Split constructor.
OctaryForEachVoxelBody_1Const(OctaryForEachVoxelBody_1Const &o, split s)
Split constructor.
int _y
Image y-dimension (in voxels)
OctaryForEachVoxelIfBody_4Const(OctaryForEachVoxelIfBody_4Const &o, split s)
Split constructor.
OctaryForEachVoxelIfBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, VoxelFunc &vf, OutsideFunc &of)
Constructor.
void operator()(const ImageAttributes &attr) const
Process entire image.
OctaryForEachVoxelBody_7Const(const OctaryForEachVoxelBody_7Const &o)
Copy constructor.
One-dimensional range.
Definition: Parallel.h:155
VoxelFunc _VoxelFunc
Functor executed for each voxel.
OctaryForEachVoxelIfBody(const OctaryForEachVoxelIfBody &o)
Copy constructor.
OctaryForEachVoxelBody_7Const(OctaryForEachVoxelBody_7Const &o, split s)
Split constructor.
OctaryForEachVoxelBody(GenericImage< T1 > &im1, GenericImage< T2 > &im2, GenericImage< T3 > &im3, GenericImage< T4 > &im4, GenericImage< T5 > &im5, GenericImage< T6 > &im6, GenericImage< T7 > &im7, GenericImage< T8 > &im8, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelBody_Const(const OctaryForEachVoxelBody_Const &o)
Copy constructor.
OctaryForEachVoxelBody_3Const(OctaryForEachVoxelBody_3Const &o, split s)
Split constructor.
Definition: IOConfig.h:41
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
OctaryForEachVoxelIfBody_6Const(const OctaryForEachVoxelIfBody_6Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_3Const(OctaryForEachVoxelIfBody_3Const &o, split s)
Split constructor.
int _z
Image z-dimension (in voxels)
int _l
Indices for fixed dimensions.
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
int _t
Image t-dimension (in voxels)
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
int GetT() const
Returns the number of voxels in the t-direction.
Definition: BaseImage.h:922
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
int GetY() const
Returns the number of voxels in the y-direction.
Definition: BaseImage.h:910
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelBody_Const(OctaryForEachVoxelBody_Const &o, split s)
Split constructor.
Three-dimensional range.
Definition: Parallel.h:197
OctaryForEachVoxelBody_2Const(OctaryForEachVoxelBody_2Const &o, split s)
Split constructor.
OctaryForEachVoxelBody_4Const(OctaryForEachVoxelBody_4Const &o, split s)
Split constructor.
int GetNumberOfVoxels() const
Definition: BaseImage.h:1741
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelIfBody_1Const(const OctaryForEachVoxelIfBody_1Const &o)
Copy constructor.
OctaryForEachVoxelBody_5Const(const OctaryForEachVoxelBody_5Const &o)
Copy constructor.
OutsideFunc _OutsideFunc
Functor executed for each background voxel.
OctaryForEachVoxelIfBody_7Const(OctaryForEachVoxelIfBody_7Const &o, split s)
Split constructor.
OctaryForEachVoxelBody(OctaryForEachVoxelBody &o, split s)
Split constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OctaryForEachVoxelIfBody_4Const(const OctaryForEachVoxelIfBody_4Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_5Const(const OctaryForEachVoxelIfBody_5Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_2Const(OctaryForEachVoxelIfBody_2Const &o, split s)
Split constructor.
OctaryForEachVoxelBody_1Const(const OctaryForEachVoxelBody_1Const &o)
Copy constructor.
double GetTSize() const
Returns the size of a voxel in the t-direction.
Definition: BaseImage.h:970
OctaryForEachVoxelBody_5Const(OctaryForEachVoxelBody_5Const &o, split s)
Split constructor.
OctaryForEachVoxelIfBody(OctaryForEachVoxelIfBody &o, split s)
Split constructor.
int _x
Image x-dimension (in voxels)
OctaryForEachVoxelBody_3Const(const OctaryForEachVoxelBody_3Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_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, 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
OctaryForEachVoxelIfBody_3Const(const OctaryForEachVoxelIfBody_3Const &o)
Copy constructor.
OctaryForEachVoxelIfBody_7Const(const OctaryForEachVoxelIfBody_7Const &o)
Copy constructor.
OctaryForEachVoxelBody_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, VoxelFunc &vf)
Constructor.
OctaryForEachVoxelIfBody_1Const(OctaryForEachVoxelIfBody_1Const &o, split s)
Split constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OctaryForEachVoxelIfBody_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, VoxelFunc &vf, OutsideFunc &of)
Constructor.
OctaryForEachVoxelBody_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, 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