ANIMA  4.0
animaRetrieveImageTypeMacros.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <itkImageIOBase.h>
4 #include <itkMacro.h>
5 #include <itkImage.h>
6 #include <itkVectorImage.h>
7 #include <itkVector.h>
16 #define ANIMA_RETRIEVE_COMPONENT_TYPE(imageIO, function, ...) \
17 switch (imageIO->GetComponentType())\
18 {\
19  case itk::ImageIOBase::UCHAR:\
20  function<unsigned char>(__VA_ARGS__);\
21  break;\
22  case itk::ImageIOBase::CHAR:\
23  function<char>(__VA_ARGS__);\
24  break;\
25  case itk::ImageIOBase::USHORT:\
26  function<unsigned short>(__VA_ARGS__);\
27  break;\
28  case itk::ImageIOBase::SHORT:\
29  function<short>(__VA_ARGS__);\
30  break;\
31  case itk::ImageIOBase::UINT:\
32  std::cerr << "Component type detected is 'unsigned int', anima will use 'double' instead." << std::endl;\
33  function<double>(__VA_ARGS__);\
34  break;\
35  case itk::ImageIOBase::INT:\
36  std::cerr << "Component type detected is 'int', anima will use 'double' instead." << std::endl;\
37  function<double>(__VA_ARGS__);\
38  break;\
39  case itk::ImageIOBase::FLOAT:\
40  function<float>(__VA_ARGS__);\
41  break;\
42  case itk::ImageIOBase::DOUBLE:\
43  function<double>(__VA_ARGS__);\
44  break;\
45  default:\
46  itk::ExceptionObject excp(__FILE__, __LINE__, "Component type not supported.", ITK_LOCATION);\
47  throw excp;\
48 }
49 
60 #define ANIMA_RETRIEVE_NUMBER_OF_DIMENSIONS(imageIO, ComponentType, function, ...) \
61 switch (imageIO->GetNumberOfDimensions())\
62 {\
63  case 3:\
64  function<ComponentType, 3>(__VA_ARGS__);\
65  break;\
66  case 4:\
67  function<ComponentType, 4>(__VA_ARGS__);\
68  break;\
69  default:\
70  itk::ExceptionObject excp(__FILE__, __LINE__, "Number of type not supported.", ITK_LOCATION);\
71  throw excp;\
72 }
73 
74 
88 #define ANIMA_CHECK_IF_COMPONENTS_ARE_VECTORS(imageIO, ComponentType, Dimension, function, ...) \
89 switch (imageIO->GetNumberOfComponents())\
90 {\
91 case 0:\
92  {\
93  itk::ExceptionObject excp(__FILE__, __LINE__, "Number of Component not supported.", ITK_LOCATION);\
94  throw excp;\
95  break;\
96  }\
97 case 1:\
98  {\
99  typedef itk::Image<ComponentType, Dimension> ImageType;\
100  function<ImageType>(__VA_ARGS__);\
101  break;\
102  }\
103 default:\
104  {\
105  typedef itk::VectorImage<ComponentType, Dimension> VectorImageType;\
106  function<VectorImageType>(__VA_ARGS__);\
107  }\
108 }
109 
121 #define ANIMA_RETRIEVE_NUMBER_OF_COMPONENTS(imageIO, ComponentType, dimension, function, ...) \
122 switch (imageIO->GetNumberOfComponents())\
123 {\
124 case 1:\
125  function<itk::Image<ComponentType, dimension>(__VA_ARGS__);\
126  break;\
127 case 3:\
128  function<itk::Image<itk::Vector<ComponentType, 3>, 1>(__VA_ARGS__);\
129 case 6:\
130  function<itk::Image<itk::Vector<ComponentType, 6>, 1>(__VA_ARGS__);\
131 default:\
132  itk::ExceptionObject excp(__FILE__, __LINE__, "Number of Component not supported.", ITK_LOCATION);\
133  throw excp;\
134 }