1 /*=========================================================================
4 Module: $RCSfile: clitkImageToImageGenericFilter.h,v $
6 Date: $Date: 2010/02/09 14:40:55 $
7 Version: $Revision: 1.7 $
8 Author : Joel Schaerer <joel.schaerer@creatis.insa-lyon.fr>
9 David Sarrut <david.sarrut@creatis.insa-lyon.fr>
12 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
13 CREATIS-LRMN http://www.creatis.insa-lyon.fr
15 This program is free software: you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation, version 3 of the License.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 =========================================================================*/
29 #ifndef CLITKIMAGETOIMAGEGENERICFILTER_H
30 #define CLITKIMAGETOIMAGEGENERICFILTER_H
33 #include "clitkCommon.h"
34 #include "clitkImageCommon.h"
35 #include "clitkCommonGenericFilter.h"
40 #include <vvFromITK.h>
47 //--------------------------------------------------------------------
48 class ImageToImageGenericFilterBase: public itk::Object {
51 // constructor - destructor
52 ImageToImageGenericFilterBase(std::string filterName);
53 virtual ~ImageToImageGenericFilterBase() {}
56 typedef ImageToImageGenericFilterBase Self;
57 typedef Object Superclass;
58 typedef itk::SmartPointer<Self> Pointer;
59 typedef itk::SmartPointer<const Self> ConstPointer;
61 // Filters information
62 const std::string & GetFilterName() { return mFilterName; }
63 void SetFilterName(std::string & n) { mFilterName = n; }
66 /// Returns the dimension and pixel type of the *first* input
67 void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,unsigned int & components);
70 void SetInputFilename(const std::string & filename);
71 void AddInputFilename(const std::string & filename);
72 void SetInputFilenames(const std::vector<std::string> & filenames);
73 void SetOutputFilename(const std::string & filename);
74 void AddOutputFilename(const std::string & filename);
75 void SetOutputFilenames(const std::vector<std::string> & filenames);
76 std::string GetOutputFilename();
77 void SetIOVerbose(bool b) { mIOVerbose = b; }
80 void SetInputVVImage (vvImage::Pointer input);
81 void SetInputVVImages (std::vector<vvImage::Pointer> input);
82 void AddInputVVImage (vvImage::Pointer input);
83 vvImage::Pointer GetOutputVVImage ();
84 std::vector<vvImage::Pointer> GetOutputVVImages ();
86 // Information on available image types
87 void PrintAvailableImageTypes();
88 virtual std::string GetAvailableImageTypes() = 0;
90 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0;
91 virtual bool CheckImageType() = 0;
93 // Main function to call for using the filter.
94 virtual bool Update() = 0;
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> mInputFilenames;
106 std::list<std::string> mOutputFilenames;
110 std::string mPixelTypeName;
111 unsigned int mNbOfComponents;
112 std::string mFilterName;
114 std::vector<vvImage::Pointer> mInputVVImages;
115 std::vector<vvImage::Pointer> mOutputVVImages;
117 void ImageTypeError();
118 void SetImageTypeError();
119 bool mFailOnImageTypeError;
121 }; // end class clitk::ImageToImageGenericFilter
124 //--------------------------------------------------------------------
125 template<class FilterType>
126 class ImageToImageGenericFilter: public ImageToImageGenericFilterBase {
130 typedef ImageToImageGenericFilter<FilterType> Self;
132 // constructor - destructor
133 ImageToImageGenericFilter(std::string filterName);
135 // Main function to call for using the filter.
136 virtual bool Update();
137 virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype);
138 virtual bool CheckImageType();
139 virtual std::string GetAvailableImageTypes();
142 // Object that will manage the list of templatized function for
144 ImageTypesManager<FilterType> mImageTypesManager;
146 }; // end class clitk::ImageToImageGenericFilter
148 // #define ADD_IMAGE_DIMENSION(DIM) Initialize<DIM>();
150 #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM,COMP, PT>();
151 #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager.template AddNewDimensionAndPixelType<DIM, PT>();
154 #include "clitkImageToImageGenericFilter.txx"
158 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTER_H */