1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef CLITKIMAGETOIMAGEGENERICFILTERBASE_H
19 #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H
22 #include "clitkCommon.h"
23 #include "clitkImageCommon.h"
24 #include "clitkCommonGenericFilter.h"
31 #include "vvFromITK.h"
36 //--------------------------------------------------------------------
37 class ImageToImageGenericFilterBase: public itk::Object {
40 // constructor - destructor
41 ImageToImageGenericFilterBase(std::string filterName);
42 virtual ~ImageToImageGenericFilterBase();
45 typedef ImageToImageGenericFilterBase Self;
46 typedef Object Superclass;
47 typedef itk::SmartPointer<Self> Pointer;
48 typedef itk::SmartPointer<const Self> ConstPointer;
50 // Filters information
51 const std::string & GetFilterName();
52 void SetFilterName(std::string & n);
55 itkSetMacro(LastError, std::string);
56 itkGetConstMacro(LastError, std::string);
57 bool HasError() { return (GetLastError() != ""); }
60 /// Returns the dimension and pixel type of the *first* input
61 void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,
62 unsigned int & components);
65 void SetInputFilename(const std::string & filename);
66 void AddInputFilename(const std::string & filename);
67 void SetInputFilenames(const std::vector<std::string> & filenames);
68 void EnableReadOnDisk(bool b);
69 void SetOutputFilename(const std::string & filename);
70 void AddOutputFilename(const std::string & filename);
71 void SetOutputFilenames(const std::vector<std::string> & filenames);
72 std::string GetOutputFilename();
73 void SetIOVerbose(bool b);
76 void SetInputVVImage (vvImage::Pointer input);
77 void SetInputVVImages (std::vector<vvImage::Pointer> input);
78 void AddInputVVImage (vvImage::Pointer input);
79 vvImage::Pointer GetOutputVVImage ();
80 std::vector<vvImage::Pointer> GetOutputVVImages ();
82 // Information on available image types
83 void PrintAvailableImageTypes();
84 virtual std::string GetAvailableImageTypes() = 0;
86 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
87 virtual bool CheckImageType() = 0;
89 // Main function to call for using the filter.
90 virtual bool Update() = 0;
94 /// Call this function to dispatch an output towards the correct sink
95 template<class ImageType>
96 void SetNextOutput(typename ImageType::Pointer output);
98 /// Call this function to get the nth itk input image, regardless of input source
99 template<class ImageType>
100 typename ImageType::Pointer GetInput(unsigned int n);
102 std::vector<std::string> m_InputFilenames;
103 std::list<std::string> m_OutputFilenames;
107 std::string m_PixelTypeName;
108 unsigned int m_NbOfComponents;
109 std::string m_FilterName;
111 std::vector<vvImage::Pointer> m_InputVVImages;
112 std::vector<vvImage::Pointer> m_OutputVVImages;
114 void ImageTypeError();
115 void SetImageTypeError();
116 bool m_FailOnImageTypeError;
118 std::string m_LastError;
120 }; // end class clitk::ImageToImageGenericFilter
122 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
123 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
124 #define ADD_DEFAULT_IMAGE_TYPES(DIM) ADD_IMAGE_TYPE(DIM, char); \
125 ADD_IMAGE_TYPE(DIM, uchar); \
126 ADD_IMAGE_TYPE(DIM, short); \
127 ADD_IMAGE_TYPE(DIM, ushort); \
128 ADD_IMAGE_TYPE(DIM, int); \
129 ADD_IMAGE_TYPE(DIM, float); \
130 ADD_IMAGE_TYPE(DIM, double);
132 //#include "clitkImageToImageGenericFilterBase.txx"
136 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H */