Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkEndoMacros.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 mitkEndoMacros_h
17 #define mitkEndoMacros_h
18 
22 
26 #define endoAccessCvMat(function, T, arg1, arg2) \
27 if( arg2.type() == cv::DataType<float>::type ) \
28  function<float, T>( arg1, arg2 ); \
29 else if( arg2.type() == cv::DataType<double>::type ) \
30  function<double, T>( arg1, arg2 ); \
31 else if( arg2.type() == cv::DataType<unsigned int>::type ) \
32  function<unsigned int, T>( arg1, arg2 ); \
33 else if( arg2.type() == cv::DataType<unsigned short>::type ) \
34  function<unsigned short, T>( arg1, arg2 ); \
35 else if( arg2.type() == cv::DataType<unsigned char>::type ) \
36  function<unsigned char, T>( arg1, arg2 ); \
37 else if( arg2.type() == cv::DataType<int>::type ) \
38  function<int, T>( arg1, arg2 ); \
39 else if( arg2.type() == cv::DataType<short>::type ) \
40  function<short, T>( arg1, arg2 ); \
41 else if( arg2.type() == cv::DataType<char>::type ) \
42  function<char, T>( arg1, arg2 ); \
43 else \
44  throw std::invalid_argument("Unknown type for cv::Mat");
45 
49 #define endoExec(macroAlgName, macroOutputType, macroOutputVarName, ...)\
50  macroOutputType macroOutputVarName;\
51  { \
52  macroAlgName _macroAlgName(__VA_ARGS__, &macroOutputVarName);\
53  _macroAlgName.Update();\
54  }
55 
59 #define endoExec2(macroAlgName, macroOutputType1, macroOutputVarName1, macroOutputType2, macroOutputVarName2, ...)\
60  macroOutputType1 macroOutputVarName1;\
61  macroOutputType1 macroOutputVarName1;\
62  { \
63  macroAlgName _macroAlgName(__VA_ARGS__, &macroOutputVarName1, &macroOutputVarName2);\
64  _macroAlgName.Update();\
65  }
66 
70 #ifdef WIN32
71  static const std::string DIR_SEPARATOR = "\\";
72 #else
73  static const std::string DIR_SEPARATOR = "/";
74 #endif
75 
76 #define endoSetInput(name, type) \
77 public: \
78  virtual void Set##name (const type _arg) \
79  { \
80  if ( this->m_##name != _arg ) \
81  { \
82  this->m_##name = _arg; \
83  } \
84  } \
85 protected: \
86  const type m_##name;
87 
88 #define endoSetOutput(name, type) \
89 public: \
90  virtual void Set##name (type _arg) \
91  { \
92  if ( this->m_##name != _arg ) \
93  { \
94  this->m_##name = _arg; \
95  } \
96  } \
97 protected: \
98  type m_##name;
99 
100 #endif // mitkEndoMacros_h
static const std::string DIR_SEPARATOR