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://www.centreleonberard.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 ===========================================================================**/
19 #ifndef CLITKIMAGETOIMAGEGENERICFILTERBASE_H
20 #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H
23 #include "clitkImageCommon.h"
24 #include "clitkCommonGenericFilter.h"
25 #include "clitkFilterBase.h"
32 #include "vvFromITK.h"
37 //--------------------------------------------------------------------
38 class ImageToImageGenericFilterBase: public itk::Object {
41 // constructor - destructor
42 ImageToImageGenericFilterBase(std::string filterName);
43 virtual ~ImageToImageGenericFilterBase();
46 typedef ImageToImageGenericFilterBase Self;
47 typedef Object Superclass;
48 typedef itk::SmartPointer<Self> Pointer;
49 typedef itk::SmartPointer<const Self> ConstPointer;
51 // Filters information
52 const std::string & GetFilterName();
53 void SetFilterName(std::string & n);
56 /// Returns the dimension and pixel type of the *first* input
57 void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,
58 unsigned int & components);
60 void SetInputFilename(const std::string & filename);
61 void AddInputFilename(const std::string & filename);
62 void SetInputFilenames(const std::vector<std::string> & filenames);
63 void EnableReadOnDisk(bool b);
64 void EnableWriteOnDisk(bool b);
65 void EnableWriteCompression(bool b);
66 void SetOutputFilename(const std::string & filename);
67 void AddOutputFilename(const std::string filename);
68 void SetOutputFilenames(const std::vector<std::string> & filenames);
69 std::string GetOutputFilename();
70 void SetIOVerbose(bool b);
73 void SetInputVVImage (vvImage::Pointer input);
74 void SetInputVVImages (std::vector<vvImage::Pointer> input);
75 void AddInputVVImage (vvImage::Pointer input);
76 vvImage::Pointer GetOutputVVImage ();
77 std::vector<vvImage::Pointer> GetOutputVVImages ();
79 // Information on available image types
80 void PrintAvailableImageTypes();
81 virtual std::string GetAvailableImageTypes() = 0;
83 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
84 virtual bool CheckImageType() = 0;
86 // Main function to call for using the filter.
87 virtual bool Update() = 0;
89 // Get the associated filter
90 FilterBase * GetFilterBase() { return m_FilterBase; }
92 // Indicate that the filter must stop as soon as possible (if threaded)
93 void DeleteLastOutputImage();
98 bool m_WriteCompression;
100 /// Call this function to dispatch an output towards the correct sink
101 template<class ImageType>
102 void SetNextOutput(typename ImageType::Pointer output);
104 /// Call this function to get the nth itk input image, regardless of input source
105 template<class ImageType>
106 typename ImageType::Pointer GetInput(unsigned int n);
108 std::vector<std::string> m_InputFilenames;
109 std::list<std::string> m_OutputFilenames;
113 std::string m_PixelTypeName;
114 unsigned int m_NbOfComponents;
115 std::string m_FilterName;
117 std::vector<vvImage::Pointer> m_InputVVImages;
118 std::vector<vvImage::Pointer> m_OutputVVImages;
120 void ImageTypeError();
121 void SetImageTypeError();
122 bool m_FailOnImageTypeError;
124 // std::string m_LastError;
125 void SetFilterBase(FilterBase * f) { m_FilterBase = f; }
126 FilterBase * m_FilterBase;
127 // bool m_StopOnError;
129 }; // end class clitk::ImageToImageGenericFilter
131 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
132 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
133 #define ADD_DEFAULT_IMAGE_TYPES(DIM) ADD_IMAGE_TYPE(DIM, char); \
134 ADD_IMAGE_TYPE(DIM, uchar); \
135 ADD_IMAGE_TYPE(DIM, short); \
136 ADD_IMAGE_TYPE(DIM, ushort); \
137 ADD_IMAGE_TYPE(DIM, int); \
138 ADD_IMAGE_TYPE(DIM, float); \
139 ADD_IMAGE_TYPE(DIM, double);
140 #define ADD_DEFAULT_VEC_IMAGE_TYPES ADD_VEC_IMAGE_TYPE(2,2,float); \
141 ADD_VEC_IMAGE_TYPE(2,3,float); \
142 ADD_VEC_IMAGE_TYPE(3,3,float);
144 //#include "clitkImageToImageGenericFilterBase.txx"
148 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H */