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