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 SetOutputFilename(const std::string & filename);
66 void AddOutputFilename(const std::string filename);
67 void SetOutputFilenames(const std::vector<std::string> & filenames);
68 std::string GetOutputFilename();
69 void SetIOVerbose(bool b);
72 void SetInputVVImage (vvImage::Pointer input);
73 void SetInputVVImages (std::vector<vvImage::Pointer> input);
74 void AddInputVVImage (vvImage::Pointer input);
75 vvImage::Pointer GetOutputVVImage ();
76 std::vector<vvImage::Pointer> GetOutputVVImages ();
78 // Information on available image types
79 void PrintAvailableImageTypes();
80 virtual std::string GetAvailableImageTypes() = 0;
82 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
83 virtual bool CheckImageType() = 0;
85 // Main function to call for using the filter.
86 virtual bool Update() = 0;
88 // Get the associated filter
89 FilterBase * GetFilterBase() { return m_FilterBase; }
91 // Indicate that the filter must stop as soon as possible (if threaded)
92 void DeleteLastOutputImage();
97 /// Call this function to dispatch an output towards the correct sink
98 template<class ImageType>
99 void SetNextOutput(typename ImageType::Pointer output);
101 /// Call this function to get the nth itk input image, regardless of input source
102 template<class ImageType>
103 typename ImageType::Pointer GetInput(unsigned int n);
105 std::vector<std::string> m_InputFilenames;
106 std::list<std::string> m_OutputFilenames;
110 std::string m_PixelTypeName;
111 unsigned int m_NbOfComponents;
112 std::string m_FilterName;
114 std::vector<vvImage::Pointer> m_InputVVImages;
115 std::vector<vvImage::Pointer> m_OutputVVImages;
117 void ImageTypeError();
118 void SetImageTypeError();
119 bool m_FailOnImageTypeError;
121 // std::string m_LastError;
122 void SetFilterBase(FilterBase * f) { m_FilterBase = f; }
123 FilterBase * m_FilterBase;
124 // bool m_StopOnError;
126 }; // end class clitk::ImageToImageGenericFilter
128 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
129 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
130 #define ADD_DEFAULT_IMAGE_TYPES(DIM) ADD_IMAGE_TYPE(DIM, char); \
131 ADD_IMAGE_TYPE(DIM, uchar); \
132 ADD_IMAGE_TYPE(DIM, short); \
133 ADD_IMAGE_TYPE(DIM, ushort); \
134 ADD_IMAGE_TYPE(DIM, int); \
135 ADD_IMAGE_TYPE(DIM, float); \
136 ADD_IMAGE_TYPE(DIM, double);
138 //#include "clitkImageToImageGenericFilterBase.txx"
142 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H */