]> Creatis software - clitk.git/blob - common/clitkImageToImageGenericFilterBase.h
added the new headers
[clitk.git] / common / clitkImageToImageGenericFilterBase.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
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
8
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.
12
13   It is distributed under dual licence
14
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
20 #include "clitkCommon.h"
21 #include "clitkImageCommon.h"
22 #include "clitkCommonGenericFilter.h"
23
24 // itk include
25 #include <itkImage.h>
26
27 // vv include
28 #include "vvImage.h"
29 #include "vvFromITK.h"
30 #include "vvToITK.h"
31
32 namespace clitk {
33   
34   //--------------------------------------------------------------------
35   class ImageToImageGenericFilterBase: public itk::Object {
36     
37   public: 
38     // constructor - destructor
39     ImageToImageGenericFilterBase(std::string filterName);
40     virtual ~ImageToImageGenericFilterBase();
41
42     // Types
43     typedef ImageToImageGenericFilterBase Self;
44     typedef Object                        Superclass;
45     typedef itk::SmartPointer<Self>       Pointer;
46     typedef itk::SmartPointer<const Self> ConstPointer;
47
48     // Filters information
49     const std::string & GetFilterName();
50     void SetFilterName(std::string & n);
51
52     // Generic IO
53     /// Returns the dimension and pixel type of the *first* input
54     void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,
55                                             unsigned int & components);
56
57     // File IO
58     void SetInputFilename(const std::string & filename);
59     void AddInputFilename(const std::string & filename);
60     void SetInputFilenames(const std::vector<std::string> & filenames);
61     void EnableReadOnDisk(bool b);
62     void SetOutputFilename(const std::string & filename);
63     void AddOutputFilename(const std::string & filename);
64     void SetOutputFilenames(const std::vector<std::string> & filenames);
65     std::string GetOutputFilename();
66     void SetIOVerbose(bool b);
67
68     // VVImage IO
69     void SetInputVVImage (vvImage::Pointer input);
70     void SetInputVVImages (std::vector<vvImage::Pointer> input);
71     void AddInputVVImage (vvImage::Pointer input);
72     vvImage::Pointer GetOutputVVImage ();
73     std::vector<vvImage::Pointer> GetOutputVVImages ();
74
75     // Information on available image types
76     void PrintAvailableImageTypes();
77     virtual std::string GetAvailableImageTypes() = 0;
78
79     virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
80     virtual bool CheckImageType() = 0;
81
82     // Main function to call for using the filter. 
83     virtual bool Update() = 0;
84
85   protected:  
86     bool mReadOnDisk;
87     /// Call this function to dispatch an output towards the correct sink
88     template<class ImageType> 
89     void SetNextOutput(typename ImageType::Pointer output);
90
91     /// Call this function to get the nth itk input image, regardless of input source
92     template<class ImageType> 
93     typename ImageType::Pointer GetInput(unsigned int n);
94
95     std::vector<std::string> mInputFilenames;
96     std::list<std::string> mOutputFilenames;
97
98     bool mIOVerbose;
99     unsigned int mDim;
100     std::string mPixelTypeName;
101     unsigned int mNbOfComponents;
102     std::string mFilterName;
103
104     std::vector<vvImage::Pointer> mInputVVImages;
105     std::vector<vvImage::Pointer> mOutputVVImages;
106
107     void ImageTypeError();
108     void SetImageTypeError();
109     bool mFailOnImageTypeError;
110
111   }; // end class clitk::ImageToImageGenericFilter
112
113 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
114 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
115
116   //#include "clitkImageToImageGenericFilterBase.txx"
117
118 } // end namespace
119
120 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTERBASE_H */
121