Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkPixelTypeMultiplex.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
35 #ifndef mitkPixelTypeMultiplex_h
36 #define mitkPixelTypeMultiplex_h
37 
44 #define mitkPixelTypeMultiplex0(function, ptype) \
45  \
46  { \
47  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
48  function<char>(ptype); \
49  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
50  function<unsigned char>(ptype); \
51  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
52  function<short>(ptype); \
53  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
54  function<unsigned short>(ptype); \
55  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
56  function<int>(ptype); \
57  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
58  function<unsigned int>(ptype); \
59  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
60  function<long int>(ptype); \
61  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
62  function<unsigned long int>(ptype); \
63  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
64  function<float>(ptype); \
65  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
66  function<double>(ptype); \
67  }
68 
76 #define mitkPixelTypeMultiplex1(function, ptype, param1) \
77  \
78  { \
79  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
80  function<char>(ptype, param1); \
81  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
82  function<unsigned char>(ptype, param1); \
83  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
84  function<short>(ptype, param1); \
85  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
86  function<unsigned short>(ptype, param1); \
87  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
88  function<int>(ptype, param1); \
89  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
90  function<unsigned int>(ptype, param1); \
91  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
92  function<long int>(ptype, param1); \
93  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
94  function<unsigned long int>(ptype, param1); \
95  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
96  function<float>(ptype, param1); \
97  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
98  function<double>(ptype, param1); \
99  }
100 
109 #define mitkPixelTypeMultiplex2(function, ptype, param1, param2) \
110  \
111  { \
112  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
113  function<char>(ptype, param1, param2); \
114  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
115  function<unsigned char>(ptype, param1, param2); \
116  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
117  function<short>(ptype, param1, param2); \
118  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
119  function<unsigned short>(ptype, param1, param2); \
120  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
121  function<int>(ptype, param1, param2); \
122  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
123  function<unsigned int>(ptype, param1, param2); \
124  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
125  function<long int>(ptype, param1, param2); \
126  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
127  function<unsigned long int>(ptype, param1, param2); \
128  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
129  function<float>(ptype, param1, param2); \
130  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
131  function<double>(ptype, param1, param2); \
132  }
133 
143 #define mitkPixelTypeMultiplex3(function, ptype, param1, param2, param3) \
144  \
145  { \
146  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
147  function<char>(ptype, param1, param2, param3); \
148  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
149  function<unsigned char>(ptype, param1, param2, param3); \
150  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
151  function<short>(ptype, param1, param2, param3); \
152  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
153  function<unsigned short>(ptype, param1, param2, param3); \
154  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
155  function<int>(ptype, param1, param2, param3); \
156  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
157  function<unsigned int>(ptype, param1, param2, param3); \
158  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
159  function<long int>(ptype, param1, param2, param3); \
160  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
161  function<unsigned long int>(ptype, param1, param2, param3); \
162  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
163  function<float>(ptype, param1, param2, param3); \
164  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
165  function<double>(ptype, param1, param2, param3); \
166  }
167 
180 // we have to have a default for, else Clang 3.6.1 complains about problems if 'if evaluates to false'
181 // therefore if type does not match double is assumed
182 #define mitkPixelTypeMultiplex4(function, ptype, param1, param2, param3, param4) \
183  \
184  { \
185  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
186  function<char>(ptype, param1, param2, param3, param4); \
187  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
188  function<unsigned char>(ptype, param1, param2, param3, param4); \
189  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
190  function<short>(ptype, param1, param2, param3, param4); \
191  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
192  function<unsigned short>(ptype, param1, param2, param3, param4); \
193  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
194  function<int>(ptype, param1, param2, param3, param4); \
195  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
196  function<unsigned int>(ptype, param1, param2, param3, param4); \
197  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
198  function<long int>(ptype, param1, param2, param3, param4); \
199  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
200  function<unsigned long int>(ptype, param1, param2, param3, param4); \
201  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
202  function<float>(ptype, param1, param2, param3, param4); \
203  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
204  function<double>(ptype, param1, param2, param3, param4); \
205  else if (true) \
206  function<double>(ptype, param1, param2, param3, param4); \
207  }
208 
222 // we have to have a default for, else Clang 3.6.1 complains about problems if 'if evaluates to false'
223 // therefore if type does not match double is assumed
224 #define mitkPixelTypeMultiplex5(function, ptype, param1, param2, param3, param4, param5) \
225  \
226  { \
227  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
228  function<char>(ptype, param1, param2, param3, param4, param5); \
229  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
230  function<unsigned char>(ptype, param1, param2, param3, param4, param5); \
231  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
232  function<short>(ptype, param1, param2, param3, param4, param5); \
233  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
234  function<unsigned short>(ptype, param1, param2, param3, param4, param5); \
235  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
236  function<int>(ptype, param1, param2, param3, param4, param5); \
237  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
238  function<unsigned int>(ptype, param1, param2, param3, param4, param5); \
239  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
240  function<long int>(ptype, param1, param2, param3, param4, param5); \
241  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
242  function<unsigned long int>(ptype, param1, param2, param3, param4, param5); \
243  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
244  function<float>(ptype, param1, param2, param3, param4, param5); \
245  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
246  function<double>(ptype, param1, param2, param3, param4, param5); \
247  else \
248  function<double>(ptype, param1, param2, param3, param4, param5); \
249  }
250 
251 #endif