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 ======================================================================-====*/
19 #ifndef CLITKIMAGETOIMAGEGENERICFILTERBASE_H
20 #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H
23 #include "clitkCommon.h"
24 #include "clitkImageCommon.h"
25 #include "clitkCommonGenericFilter.h"
26 #include "clitkFilterBase.h"
33 #include "vvFromITK.h"
38 //--------------------------------------------------------------------
39 class ImageToImageGenericFilterBase: public itk::Object {
42 // constructor - destructor
43 ImageToImageGenericFilterBase(std::string filterName);
44 virtual ~ImageToImageGenericFilterBase();
47 typedef ImageToImageGenericFilterBase Self;
48 typedef Object Superclass;
49 typedef itk::SmartPointer<Self> Pointer;
50 typedef itk::SmartPointer<const Self> ConstPointer;
52 // Filters information
53 const std::string & GetFilterName();
54 void SetFilterName(std::string & n);
57 itkSetMacro(LastError, std::string);
58 itkGetConstMacro(LastError, std::string);
59 bool HasError() { return (GetLastError() != ""); }
62 /// Returns the dimension and pixel type of the *first* input
63 void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,
64 unsigned int & components);
66 void SetInputFilename(const std::string & filename);
67 void AddInputFilename(const std::string & filename);
68 void SetInputFilenames(const std::vector<std::string> & filenames);
69 void EnableReadOnDisk(bool b);
70 void SetOutputFilename(const std::string & filename);
71 void AddOutputFilename(const std::string & filename);
72 void SetOutputFilenames(const std::vector<std::string> & filenames);
73 std::string GetOutputFilename();
74 void SetIOVerbose(bool b);
77 void SetInputVVImage (vvImage::Pointer input);
78 void SetInputVVImages (std::vector<vvImage::Pointer> input);
79 void AddInputVVImage (vvImage::Pointer input);
80 vvImage::Pointer GetOutputVVImage ();
81 std::vector<vvImage::Pointer> GetOutputVVImages ();
83 // Information on available image types
84 void PrintAvailableImageTypes();
85 virtual std::string GetAvailableImageTypes() = 0;
87 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
88 virtual bool CheckImageType() = 0;
90 // Main function to call for using the filter.
91 virtual bool Update() = 0;
93 // Get the associated filter
94 FilterBase * GetFilterBase() { return m_FilterBase; }
96 // Indicate that the filter must stop as soon as possible (if threaded)
98 void DeleteLastOutputImage();
99 itkSetMacro(StopOnError, bool);
100 itkGetConstMacro(StopOnError, bool);
101 itkBooleanMacro(StopOnError);
105 /// Call this function to dispatch an output towards the correct sink
106 template<class ImageType>
107 void SetNextOutput(typename ImageType::Pointer output);
109 /// Call this function to get the nth itk input image, regardless of input source
110 template<class ImageType>
111 typename ImageType::Pointer GetInput(unsigned int n);
113 std::vector<std::string> m_InputFilenames;
114 std::list<std::string> m_OutputFilenames;
118 std::string m_PixelTypeName;
119 unsigned int m_NbOfComponents;
120 std::string m_FilterName;
122 std::vector<vvImage::Pointer> m_InputVVImages;
123 std::vector<vvImage::Pointer> m_OutputVVImages;
125 void ImageTypeError();
126 void SetImageTypeError();
127 bool m_FailOnImageTypeError;
129 std::string m_LastError;
130 void SetFilterBase(FilterBase * f) { m_FilterBase = f; }
131 FilterBase * m_FilterBase;
134 }; // end class clitk::ImageToImageGenericFilter
136 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
137 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
138 #define ADD_DEFAULT_IMAGE_TYPES(DIM) ADD_IMAGE_TYPE(DIM, char); \
139 ADD_IMAGE_TYPE(DIM, uchar); \
140 ADD_IMAGE_TYPE(DIM, short); \
141 ADD_IMAGE_TYPE(DIM, ushort); \
142 ADD_IMAGE_TYPE(DIM, int); \
143 ADD_IMAGE_TYPE(DIM, float); \
144 ADD_IMAGE_TYPE(DIM, double);
146 //#include "clitkImageToImageGenericFilterBase.txx"
150 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H */