DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
utlITKMacro.h
Go to the documentation of this file.
1 
18 #ifndef __utlITKMacro_h
19 #define __utlITKMacro_h
20 
21 #include "itkMacro.h"
22 
23 
28 enum{
37 };
38 
39 #ifndef ITK_OVERRIDE
40 
41 // Copied from itkMacro.h. It is used for old version of ITK without definition of the macros.
42 #if __cplusplus >= 201103L
43 // In c++11 the override keyword allows you to explicity define that a function
44 // is intended to override the base-class version. This makes the code more
45 // managable and fixes a set of common hard-to-find bugs.
46 #define ITK_OVERRIDE override
47 // In functions that should not be implemented, use the C++11 mechanism
48 // to ensure that thye are purposely not implemented
49 #define ITK_DELETE_FUNCTION =delete
50 // In c++11 there is an explicit nullptr type that introduces a new keyword to
51 // serve as a distinguished null pointer constant: nullptr. It is of type
52 // nullptr_t, which is implicitly convertible and comparable to any pointer type
53 // or pointer-to-member type. It is not implicitly convertible or comparable to
54 // integral types, except for bool.
55 #define ITK_NULLPTR nullptr
56 // In C++11 the throw-list specification has been deprecated,
57 // replaces with the noexcept specifier. Using this function
58 // specification adds the run-time check that the method does not
59 // throw, if it does throw then std::terminate will be called.
60 // Use cautiously.
61 #define ITK_NOEXCEPT noexcept
62 #define ITK_HAS_CXX11_STATIC_ASSERT
63 #define ITK_HAS_CXX11_RVREF
64 #else
65 #define ITK_OVERRIDE
66 #define ITK_DELETE_FUNCTION
67 #define ITK_NULLPTR NULL
68 #define ITK_NOEXCEPT throw()
69 #endif
70 
71 #endif
72 
73 
74 #define itkSetNoConstMacro(name, type) \
75  virtual void Set##name (type _arg) \
76  { \
77  itkDebugMacro("setting " #name " to " << _arg); \
78  if ( this->m_##name != _arg ) \
79  { \
80  this->m_##name = _arg; \
81  this->Modified(); \
82  } \
83  }
84 
85 
86 #define itkGetPointerMacro(name, type) \
87  virtual type * Get##name () \
88  { \
89  return &(m_##name); \
90  }
91 
92 
93 #define itkGetConstPointerMacro(name, type) \
94  virtual const type * Get##name () const \
95  { \
96  return &(m_##name); \
97  }
98 
99 
100 #define itkSetNDebugMacro(name, type) \
101  virtual void Set##name (const type _arg) \
102  { \
103  if ( this->m_##name != _arg ) \
104  { \
105  this->m_##name = _arg; \
106  this->Modified(); \
107  } \
108  }
109 
110 
111 #define itkSetNDebugByConstReferenceMacro(name, type) \
112  virtual void Set##name (const type& _arg) \
113  { \
114  if ( this->m_##name != _arg ) \
115  { \
116  this->m_##name = _arg; \
117  this->Modified(); \
118  } \
119  }
120 
121 
122 #define itkSetByConstReferenceMacro(name, type) \
123  virtual void Set##name (const type& _arg) \
124  { \
125  itkDebugMacro("setting " #name " to " << _arg); \
126  if ( this->m_##name != _arg ) \
127  { \
128  this->m_##name = _arg; \
129  this->Modified(); \
130  } \
131  }
132 
133 
134 #define itkSetGetMacro(name, type) \
135  itkSetMacro(name, type); \
136  itkGetMacro(name, type);
137 
138 
139 #define itkSetGetBooleanMacro(name) \
140  itkSetMacro(name,bool); \
141  itkGetMacro(name,bool); \
142  itkBooleanMacro(name);
143 
144 
145 #define itkFunctorSetMacro(name, type) \
146 void Set##name(type name) \
147  { \
148  this->GetFunctor().Set##name(name); \
149  this->Modified(); \
150  }
151 
152 
153 #define itkFunctorGetMacro(name, type) \
154 type Get##name() const \
155 { \
156  return this->GetFunctor().Get##name(); \
157 }
158 
159 
160 #define itkFunctorSetGetMacro(name, type) \
161  itkFunctorSetMacro(name, type); \
162  itkFunctorGetMacro(name, type);
163 
164 
165 #define itkTypedefMaskedImageToImageMacro(Superclass) \
166  typedef typename Superclass::InputImageType InputImageType; \
167  typedef typename Superclass::InputImagePointer InputImagePointer; \
168  typedef typename Superclass::InputImageConstPointer InputImageConstPointer; \
169  typedef typename Superclass::InputImageIndexType InputImageIndexType; \
170  typedef typename Superclass::InputImageSizeType InputImageSizeType; \
171  typedef typename Superclass::InputImageSpacingType InputImageSpacingType; \
172  typedef typename Superclass::InputImagePixelType InputImagePixelType; \
173  typedef typename Superclass::InputImageRegionType InputImageRegionType; \
174  \
175  typedef typename Superclass::OutputImageType OutputImageType; \
176  typedef typename Superclass::OutputImagePointer OutputImagePointer; \
177  typedef typename Superclass::OutputImageIndexType OutputImageIndexType; \
178  typedef typename Superclass::OutputImageSizeType OutputImageSizeType; \
179  typedef typename Superclass::OutputImageSpacingType OutputImageSpacingType; \
180  typedef typename Superclass::OutputImagePixelType OutputImagePixelType; \
181  typedef typename Superclass::OutputImageRegionType OutputImageRegionType; \
182  \
183  typedef typename Superclass::MaskImageType MaskImageType; \
184  typedef typename MaskImageType::Pointer MaskImagePointer; \
185  \
186  typedef typename itk::Image<double,3> ScalarImageType; \
187  typedef typename ScalarImageType::Pointer ScalarImagePointer;
188 
189 
190 
192 #define itkShowPositionThreadedLogger(cond) \
193 do \
194 { \
195  if ((cond)) \
196  { \
197  if (this->m_ThreadID>=0 && this->GetDebug() && this->GetNumberOfThreads()>1) \
198  { \
199  std::string __threadIDStr = this->ThreadIDToString(); \
200  std::ostringstream __msg; \
201  __msg << "\n" << __threadIDStr << "Work Flow Position: In File: " <<__FILE__<< ", Line: " << __LINE__ << "\n" \
202  << __threadIDStr << "Function: " << __utl_LOCATION__ << "\n" << std::flush; \
203  this->WriteLogger(__msg.str()); \
204  } \
205  else \
206  utlOSShowPosition(cond, std::cout); \
207  } \
208 } while(0)
209 
210 
211 #define itkThreadedLogger(cond, msgStr) \
212 do \
213  { \
214  if ((cond)) \
215  { \
216  std::ostringstream __msg; \
217  __msg << (msgStr) << std::endl << std::flush; \
218  this->WriteLogger(__msg.str()); \
219  } \
220  } while ( 0 )
221 
222 
225 #define itkVectorImageFilterComposeMacro(VectorImageType, ScalarImageFilterType, scalarImageFilter, input, output) \
226  do { \
227  typedef typename itk::VectorImageChannelFilter<VectorImageType, VectorImageType, ScalarImageFilterType> FilterType; \
228  typename FilterType::Pointer filter = FilterType::New(); \
229  utlException(std::string(input->GetNameOfClass())!="VectorImage", "input should be VectorImage"); \
230  filter->SetInput(input); \
231  filter->SetFilter(scalarImageFilter); \
232  filter->Update(); \
233  output = filter->GetOutput(); \
234  } while(0) \
235 
236 
238 #endif
239