MeVisLab Toolbox Reference
mlITKSupport.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#pragma once
14
16// Include dll-specific settings.
18
20#include "mlModuleIncludes.h"
21
23#include "mlTools.h"
24
26#include "mlITKSupportMacrosP.h"
27
30
31//---------------------------------------------------------------------------
33//---------------------------------------------------------------------------
34inline void ML_ITK_ML_PRINT_ERROR(const std::string &className,
36 std::string reason,
37 const std::string &strParam1="",
38 MLint intParam1=-965386,
39 const std::string &strParam2="",
40 MLint intParam2=-965386,
41 const std::string &strParam3="",
42 MLint intParam3=-965386,
43 const std::string &strParam4="",
44 MLint intParam4=-965386){
45 reason += strParam1;
46 if (intParam1 != -965386){
47 char strBuf[512]="";
48 snprintf(strBuf, 511, "%lld", intParam1);
49 reason += strBuf;
50 }
51 reason += strParam2;
52 if (intParam2 != -965386){
53 char strBuf[512]="";
54 snprintf(strBuf, 511, "%lld", intParam2);
55 reason += strBuf;
56 }
57 reason += strParam3;
58 if (intParam3 != -965386){
59 char strBuf[512]="";
60 snprintf(strBuf, 511, "%lld", intParam3);
61 reason += strBuf;
62 }
63 reason += strParam4;
64 if (intParam4 != -965386){
65 char strBuf[512]="";
66 snprintf(strBuf, 511, "%lld", intParam4);
67 reason += strBuf;
68 }
69
71}
72
73
74//---------------------------------------------------------------------------
76//---------------------------------------------------------------------------
78#define ML_ITK_WRAPPER_0_2D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
79 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_0, \
80 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_0, \
81 ML_IMPLEMENT_ALL_ITK_2D_CASES, _ML_ITK_DETERMINE_OUT_REGION_0)
82
84#define ML_ITK_WRAPPER_1_2D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
85 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
86 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_1, \
87 ML_IMPLEMENT_ALL_ITK_2D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
88
90#define ML_ITK_WRAPPER_2_2D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
91 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
92 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_2, \
93 ML_IMPLEMENT_ALL_ITK_2D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
94
96#define ML_ITK_WRAPPER_3_2D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
97 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
98 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_3, \
99 ML_IMPLEMENT_ALL_ITK_2D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
101
102
103//---------------------------------------------------------------------------
105//---------------------------------------------------------------------------
107#define ML_ITK_WRAPPER_0_3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
108 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_0, \
109 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_0, \
110 ML_IMPLEMENT_ALL_ITK_3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_0)
111
113#define ML_ITK_WRAPPER_1_3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
114 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
115 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_1, \
116 ML_IMPLEMENT_ALL_ITK_3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
117
119#define ML_ITK_WRAPPER_2_3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
120 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
121 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_2, \
122 ML_IMPLEMENT_ALL_ITK_3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
123
125#define ML_ITK_WRAPPER_3_3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
126 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
127 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_3, \
128 ML_IMPLEMENT_ALL_ITK_3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
130
131
132//---------------------------------------------------------------------------
134//---------------------------------------------------------------------------
136#define ML_ITK_WRAPPER_0_2D3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
137 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_0, \
138 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_0, \
139 ML_IMPLEMENT_ALL_ITK_2D3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_0)
140
142#define ML_ITK_WRAPPER_1_2D3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
143 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
144 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_1, \
145 ML_IMPLEMENT_ALL_ITK_2D3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
146
148#define ML_ITK_WRAPPER_2_2D3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
149 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
150 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_2, \
151 ML_IMPLEMENT_ALL_ITK_2D3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
152
154#define ML_ITK_WRAPPER_3_2D3D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
155 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
156 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_3, \
157 ML_IMPLEMENT_ALL_ITK_2D3D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
159
160//---------------------------------------------------------------------------
162//---------------------------------------------------------------------------
164#define ML_ITK_WRAPPER_0_6D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
165 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_0, \
166 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_0, \
167 ML_IMPLEMENT_ALL_ITK_6D_CASES, _ML_ITK_DETERMINE_OUT_REGION_0)
168
170#define ML_ITK_WRAPPER_1_6D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
171 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
172 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_1, \
173 ML_IMPLEMENT_ALL_ITK_6D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
174
176#define ML_ITK_WRAPPER_2_6D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
177 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
178 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_2, \
179 ML_IMPLEMENT_ALL_ITK_6D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
180
182#define ML_ITK_WRAPPER_3_6D(PROJECT_PREFIX, CLASS_NAME, NAMESPACE) \
183 _ML_ITK_WRAPPER(PROJECT_PREFIX, CLASS_NAME, NAMESPACE, _ML_ITK_DETERMINE_IN_REGION_N, \
184 ML_ITK_DEFAULT_WRAPPER_TYPEDEFS_3, \
185 ML_IMPLEMENT_ALL_ITK_6D_CASES, _ML_ITK_DETERMINE_OUT_REGION_N)
187
188
189
190//---------------------------------------------------------------------------
193//---------------------------------------------------------------------------
195{
196 public:
199
202
204 inline void* voidFilterPtr(){ return _m_Filter; }
205
206 protected:
210 void * _m_Filter;
211};
212
213//---------------------------------------------------------------------------
215//---------------------------------------------------------------------------
216template <typename FILTER_TYPE>
218{
219 public:
221 typedef typename FILTER_TYPE::Pointer ItkObjPtrType;
222
225 {
226 // Store the untyped void pointer to the typed itk object in the base class object.
228 }
229
232
233 protected:
234
237};
238
239
240
241//---------------------------------------------------------------------------
244//---------------------------------------------------------------------------
245#define IMPLEMENT_ITK_INTERFACE_H(CLASS_NAME) \
246 \
247 protected: \
248 \
249 \
250 \
251 void calculateOutputSubImage(SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override;\
252 \
253 \
254 \
255 TypedObjectHolderBase *_itkObj; \
256 \
257 \
258 MLint _m_Dimension; \
259 \
260 \
261 MLDataType _m_PixelType; \
262 \
263 \
264 \
265 ImageVector _m_Shift[5]; \
266 \
267 \
268 \
269 bool _isValidFilter(){ return _itkObj && _itkObj->voidFilterPtr(); } \
270 \
271 \
272 \
273 void _createITKFilter(MLDataType dataType, MLint dim); \
274 \
275 \
276 void _destroyITKFilter(); \
277 \
278 \
279 SubImageBox _determineInRegion(MLint inIndex, const SubImageBox &outBox, MLint outIndex, MLint numActiveInputs); \
280 \
281 \
282 \
283 SubImageBox _getOutImageRegion(int numImageInputs); \
284 \
285 \
286 MLErrorCode _setFilterParameters(); \
287 \
288 \
289 MLErrorCode _getFilterParameters(); \
290
Base class for all derived classes containing an itk object type pointer and some of its basic inform...
void * voidFilterPtr()
Access method to access the filter as a void pointer.
virtual ~TypedObjectHolderBase()
Virtual destructor implicitly destroying the typed object in the derived class.
TypedObjectHolderBase()
Constructor for the itk object's base information.
Typed version of a mini class containing an itkObject smart pointer.
TypedObjectHolderT()
Construction and storing of the itk object managed by the smart pointer.
ItkObjPtrType _typedFilterSmartPtr
The typed version of the itk object as smart pointer.
FILTER_TYPE::Pointer ItkObjPtrType
The type of the pointer to the itk object.
ItkObjPtrType ptr()
Returns the smart pointer to the itk object.
MLint32 MLErrorCode
Type of an ML Error code.
Definition mlTypeDefs.h:716
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.
void ML_ITK_ML_PRINT_ERROR(const std::string &className, MLErrorCode errCode, std::string reason, const std::string &strParam1="", MLint intParam1=-965386, const std::string &strParam2="", MLint intParam2=-965386, const std::string &strParam3="", MLint intParam3=-965386, const std::string &strParam4="", MLint intParam4=-965386)
Include most ml specific things.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490