/*========================================================================= Program: clitk Module: $RCSfile: clitkImageToImageGenericFilter.h,v $ Language: C++ Date: $Date: 2010/02/09 14:19:28 $ Version: $Revision: 1.6 $ Author : Joel Schaerer David Sarrut Copyright (C) 2008 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr CREATIS-LRMN http://www.creatis.insa-lyon.fr This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =========================================================================*/ #ifndef CLITKIMAGETOIMAGEGENERICFILTER_H #define CLITKIMAGETOIMAGEGENERICFILTER_H // clitk include #include "clitkCommon.h" #include "clitkImageCommon.h" #include "clitkCommonGenericFilter.h" #include // vv include #include #include #include #include #include namespace clitk { //-------------------------------------------------------------------- class ImageToImageGenericFilterBase: public itk::Object { public: // constructor - destructor ImageToImageGenericFilterBase(std::string filterName); virtual ~ImageToImageGenericFilterBase() {} // Types typedef ImageToImageGenericFilterBase Self; typedef Object Superclass; typedef itk::SmartPointer Pointer; typedef itk::SmartPointer ConstPointer; // Filters information const std::string & GetFilterName() { return mFilterName; } void SetFilterName(std::string & n) { mFilterName = n; } // Generic IO /// Returns the dimension and pixel type of the *first* input void GetInputImageDimensionAndPixelType(unsigned int& dim, std::string& pixeltype,unsigned int & components); // File IO void SetInputFilename(const std::string & filename); void AddInputFilename(const std::string & filename); void SetInputFilenames(const std::vector & filenames); void SetOutputFilename(const std::string & filename); void AddOutputFilename(const std::string & filename); void SetOutputFilenames(const std::vector & filenames); std::string GetOutputFilename(); void SetIOVerbose(bool b) { mIOVerbose = b; } // VVImage IO void SetInputVVImage (vvImage::Pointer input); void SetInputVVImages (std::vector input); void AddInputVVImage (vvImage::Pointer input); vvImage::Pointer GetOutputVVImage (); std::vector GetOutputVVImages (); // Information on available image types void PrintAvailableImageTypes(); virtual std::string GetAvailableImageTypes() = 0; virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype) = 0; virtual bool CheckImageType() = 0; // Main function to call for using the filter. virtual bool Update() = 0; protected: /// Call this function to dispatch an output towards the correct sink template void SetNextOutput(typename ImageType::Pointer output); /// Call this function to get the nth itk input image, regardless of input source template typename ImageType::Pointer GetInput(unsigned int n); std::vector mInputFilenames; std::list mOutputFilenames; bool mIOVerbose; unsigned int mDim; std::string mPixelTypeName; unsigned int mNbOfComponents; std::string mFilterName; std::vector mInputVVImages; std::vector mOutputVVImages; void ImageTypeError(); void SetImageTypeError(); bool mFailOnImageTypeError; }; // end class clitk::ImageToImageGenericFilter //-------------------------------------------------------------------- template class ImageToImageGenericFilter: public ImageToImageGenericFilterBase { public: typedef ImageToImageGenericFilter Self; // constructor - destructor ImageToImageGenericFilter(std::string filterName); virtual ~ImageToImageGenericFilter() { delete mImageTypesManager; } // Main function to call for using the filter. virtual bool Update(); virtual bool CheckImageType(unsigned int dim,unsigned int ncomp, std::string pixeltype); virtual bool CheckImageType(); virtual std::string GetAvailableImageTypes(); protected: // Object that will manage the list of templatized function for // each image type. ImageTypesManager * mImageTypesManager; }; // end class clitk::ImageToImageGenericFilter // #define ADD_IMAGE_DIMENSION(DIM) Initialize(); #define ADD_VEC_IMAGE_TYPE(DIM, COMP, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType(); #define ADD_IMAGE_TYPE(DIM, PT) this->mImageTypesManager->template AddNewDimensionAndPixelType(); #include "clitkImageToImageGenericFilter.txx" } // end namespace #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTER_H */