Medical Imaging Interaction Toolkit  2024.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 #ifndef mitkPixelTypeMultiplex_h
13 #define mitkPixelTypeMultiplex_h
14 
15 #define mitkPixelTypeMultiplex0(function, ptype) \
16  \
17  { \
18  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
19  function<char>(ptype); \
20  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
21  function<unsigned char>(ptype); \
22  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
23  function<short>(ptype); \
24  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
25  function<unsigned short>(ptype); \
26  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
27  function<int>(ptype); \
28  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
29  function<unsigned int>(ptype); \
30  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
31  function<long int>(ptype); \
32  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
33  function<unsigned long int>(ptype); \
34  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
35  function<float>(ptype); \
36  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
37  function<double>(ptype); \
38  }
39 
40 #define mitkPixelTypeMultiplex1(function, ptype, param1) \
41  \
42  { \
43  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
44  function<char>(ptype, param1); \
45  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
46  function<unsigned char>(ptype, param1); \
47  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
48  function<short>(ptype, param1); \
49  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
50  function<unsigned short>(ptype, param1); \
51  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
52  function<int>(ptype, param1); \
53  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
54  function<unsigned int>(ptype, param1); \
55  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
56  function<long int>(ptype, param1); \
57  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
58  function<unsigned long int>(ptype, param1); \
59  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
60  function<float>(ptype, param1); \
61  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
62  function<double>(ptype, param1); \
63  }
64 
65 #define mitkPixelTypeMultiplex2(function, ptype, param1, param2) \
66  \
67  { \
68  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
69  function<char>(ptype, param1, param2); \
70  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
71  function<unsigned char>(ptype, param1, param2); \
72  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
73  function<short>(ptype, param1, param2); \
74  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
75  function<unsigned short>(ptype, param1, param2); \
76  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
77  function<int>(ptype, param1, param2); \
78  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
79  function<unsigned int>(ptype, param1, param2); \
80  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
81  function<long int>(ptype, param1, param2); \
82  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
83  function<unsigned long int>(ptype, param1, param2); \
84  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
85  function<float>(ptype, param1, param2); \
86  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
87  function<double>(ptype, param1, param2); \
88  }
89 
90 #define mitkPixelTypeMultiplex3(function, ptype, param1, param2, param3) \
91  \
92  { \
93  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
94  function<char>(ptype, param1, param2, param3); \
95  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
96  function<unsigned char>(ptype, param1, param2, param3); \
97  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
98  function<short>(ptype, param1, param2, param3); \
99  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
100  function<unsigned short>(ptype, param1, param2, param3); \
101  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
102  function<int>(ptype, param1, param2, param3); \
103  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
104  function<unsigned int>(ptype, param1, param2, param3); \
105  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
106  function<long int>(ptype, param1, param2, param3); \
107  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
108  function<unsigned long int>(ptype, param1, param2, param3); \
109  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
110  function<float>(ptype, param1, param2, param3); \
111  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
112  function<double>(ptype, param1, param2, param3); \
113  }
114 
115 // we have to have a default for, else Clang 3.6.1 complains about problems if 'if evaluates to false'
116 // therefore if type does not match double is assumed
117 #define mitkPixelTypeMultiplex4(function, ptype, param1, param2, param3, param4) \
118  \
119  { \
120  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
121  function<char>(ptype, param1, param2, param3, param4); \
122  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
123  function<unsigned char>(ptype, param1, param2, param3, param4); \
124  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
125  function<short>(ptype, param1, param2, param3, param4); \
126  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
127  function<unsigned short>(ptype, param1, param2, param3, param4); \
128  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
129  function<int>(ptype, param1, param2, param3, param4); \
130  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
131  function<unsigned int>(ptype, param1, param2, param3, param4); \
132  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
133  function<long int>(ptype, param1, param2, param3, param4); \
134  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
135  function<unsigned long int>(ptype, param1, param2, param3, param4); \
136  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
137  function<float>(ptype, param1, param2, param3, param4); \
138  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
139  function<double>(ptype, param1, param2, param3, param4); \
140  else if (true) \
141  function<double>(ptype, param1, param2, param3, param4); \
142  }
143 
144 // we have to have a default for, else Clang 3.6.1 complains about problems if 'if evaluates to false'
145 // therefore if type does not match double is assumed
146 #define mitkPixelTypeMultiplex5(function, ptype, param1, param2, param3, param4, param5) \
147  \
148  { \
149  if (ptype.GetComponentType() == itk::IOComponentEnum::CHAR) \
150  function<char>(ptype, param1, param2, param3, param4, param5); \
151  else if (ptype.GetComponentType() == itk::IOComponentEnum::UCHAR) \
152  function<unsigned char>(ptype, param1, param2, param3, param4, param5); \
153  else if (ptype.GetComponentType() == itk::IOComponentEnum::SHORT) \
154  function<short>(ptype, param1, param2, param3, param4, param5); \
155  else if (ptype.GetComponentType() == itk::IOComponentEnum::USHORT) \
156  function<unsigned short>(ptype, param1, param2, param3, param4, param5); \
157  else if (ptype.GetComponentType() == itk::IOComponentEnum::INT) \
158  function<int>(ptype, param1, param2, param3, param4, param5); \
159  else if (ptype.GetComponentType() == itk::IOComponentEnum::UINT) \
160  function<unsigned int>(ptype, param1, param2, param3, param4, param5); \
161  else if (ptype.GetComponentType() == itk::IOComponentEnum::LONG) \
162  function<long int>(ptype, param1, param2, param3, param4, param5); \
163  else if (ptype.GetComponentType() == itk::IOComponentEnum::ULONG) \
164  function<unsigned long int>(ptype, param1, param2, param3, param4, param5); \
165  else if (ptype.GetComponentType() == itk::IOComponentEnum::FLOAT) \
166  function<float>(ptype, param1, param2, param3, param4, param5); \
167  else if (ptype.GetComponentType() == itk::IOComponentEnum::DOUBLE) \
168  function<double>(ptype, param1, param2, param3, param4, param5); \
169  else \
170  function<double>(ptype, param1, param2, param3, param4, param5); \
171  }
172 
173 #endif