MeVisLab Toolbox Reference
mlITKSpecialInputsSupport.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 "mlInitSystemITKSupport.h"
17 
18 // Include most ML specific things.
19 #include "mlModuleIncludes.h"
20 #include "mlITKNonScalarSupport.h"
21 
22 ML_START_NAMESPACE
23 
24 
25 //---------------------------------------------------------------------------
36 //---------------------------------------------------------------------------
37 template <typename ITK_INDATATYPE, unsigned int DIM>
38 typename itk::ImportImageFilter<ITK_INDATATYPE, DIM>::Pointer getITKSpecialInImg(const SubImage &inSubImg, const PagedImage &inImg)
39 {
40  typename itk::ImportImageFilter<ITK_INDATATYPE, DIM>::Pointer itkSpecialImporter;
41 
42  try{
43  // Get data from specialized image input.
44  itkSpecialImporter = getITKImportImageFromSubImg<ITK_INDATATYPE, DIM>(inSubImg, inImg);
45  }
46  catch( itk::ExceptionObject & e ){
47  // Send error to ML error handler.
48  postITKException(e, NULL, ML_ERROR, "Trying to continue without incomplete input(s).");
49  }
50 
51  return itkSpecialImporter;
52 }
53 
54 
55 //---------------------------------------------------------------------------
74 //---------------------------------------------------------------------------
75 #define ImplementAndSetSpecialInputImage(ITK_SPECIAL_IN_IMAGE, IN_IDX, FUNC_CALL, PRE_PARAMS, POST_PARAMS, ML_PIX_TYPE, ITK_PIX_TYPE, DIMENSION) \
76  \
77  /* Get an ImportImageFilter from special input subimage. */ \
78  typename itk::ImportImageFilter<ITK_PIX_TYPE, DIMENSION>::Pointer \
79  ITK_SPECIAL_IN_IMAGE##Importer = \
80  getITKSpecialInImg<ITK_PIX_TYPE, DIMENSION>(inSubImgs[IN_IDX], *getInputImage(IN_IDX)); \
81  \
82  /* Get output image from the created importer. */ \
83  typedef typename itk::Image<ITK_PIX_TYPE, DIMENSION> ITK_SPECIAL_IN_IMAGE##Type; \
84  typename ITK_SPECIAL_IN_IMAGE##Type::Pointer ITK_SPECIAL_IN_IMAGE = \
85  ITK_SPECIAL_IN_IMAGE##Importer ? ITK_SPECIAL_IN_IMAGE##Importer->GetOutput() : NULL; \
86  \
87  /* If the output image is valid the call Set function; otherwise print error. */ \
88  if (ITK_SPECIAL_IN_IMAGE){ \
89  FUNC_CALL( PRE_PARAMS ITK_SPECIAL_IN_IMAGE POST_PARAMS ); \
90  } \
91  else { \
92  MLPrintAndNotify(ML_ERROR, "ML_","", \
93  "Could not create special itk input image","","Not setting special image", \
94  __FILE__, __LINE__, ML_BAD_PARAMETER); \
95  } \
96 
97 //---------------------------------------------------------------------------
108 //---------------------------------------------------------------------------
109 #define ImplementAndSetSpecialInputBase(ITK_SPECIAL_IN_IMAGE, IN_IDX, FUNC_CALL, MEMBER_NAME, DIMENSION) \
110  \
111  /* Call the set function of the itk object with the pointer from the base object wrapper. */ \
112  FUNC_CALL(MEMBER_NAME.getWrappedInputObject(MEMBER_NAME.getTypeId())); \
113  \
114 
115 
116 ML_END_NAMESPACE
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition: mlSubImage.h:75
@ ML_ERROR
Definition: mlTypeDefs.h:799
itk::ImportImageFilter< ITK_INDATATYPE, DIM >::Pointer getITKSpecialInImg(const SubImage &inSubImg, const PagedImage &inImg)
Takes a SubImage and returns the ImportImageFilter managing the inSubImg as ITK object.
MLITK_SUPPORT_EXPORT void postITKException(const itk::ExceptionObject &e, const Module *module, MLMessageType messageType, const std::string &handling="")
Sends all available information from the ITKException itkException to the ML error handler.