]> Creatis software - clitk.git/blobdiff - common/clitkImageToImageGenericFilter.h
Debug world/voxel cross cursor informations
[clitk.git] / common / clitkImageToImageGenericFilter.h
index 43a62df8aaaabc969842ba388860fe03e6daec20..07ba4928cc7121ceab7173301f0e5eacbd149004 100644 (file)
-#ifndef CLITKIMAGETOIMAGEGENERICFILTER_H
-#define CLITKIMAGETOIMAGEGENERICFILTER_H
+/*=========================================================================
+  Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
+
+  Authors belong to: 
+  - University of LYON              http://www.universite-lyon.fr/
+  - Léon Bérard cancer center       http://www.centreleonberard.fr
+  - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
 
-/**
- ===================================================================
- * @file   clitkImageToImageGenericFilter.h
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date   05 May 2008 14:40:51
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the copyright notices for more information.
 
- * @brief  
+  It is distributed under dual licence
 
- ===================================================================*/
+  - BSD        See included LICENSE.txt file
+  - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+===========================================================================**/
 
-// clitk include
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include <itkImage.h>
+#ifndef CLITKIMAGETOIMAGEGENERICFILTER_H
+#define CLITKIMAGETOIMAGEGENERICFILTER_H
 
-#include <vvImage.h>
-#include <vvFromITK.h>
-#include <vvToITK.h>
-#include <list>
+#include "clitkImageToImageGenericFilterBase.h"
 
 namespace clitk {
   
-  class ImageToImageGenericFilter: public itk::Object {
+//--------------------------------------------------------------------
+  template<class FilterType>
+  class ImageToImageGenericFilter: public ImageToImageGenericFilterBase {
     
   public: 
-    // constructor - destructor
-    ImageToImageGenericFilter();
-
-    // Types
-    typedef ImageToImageGenericFilter     Self;
-    typedef Object                        Superclass;
-    typedef itk::SmartPointer<Self>       Pointer;
-    typedef itk::SmartPointer<const Self> ConstPointer;
-
-    // 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<std::string> & filenames);
-    void SetOutputFilename(const std::string & filename);
-    void AddOutputFilename(const std::string & filename);
-    void SetOutputFilenames(const std::vector<std::string> & filenames);
-    std::string GetOutputFilename();
-    void SetIOVerbose(bool b) { mIOVerbose = b; }
-
-    // VVImage IO
-    void SetInputVVImage (vvImage::Pointer input);
-    void SetInputVVImages (std::vector<vvImage::Pointer> input);
-    void AddInputVVImage (vvImage::Pointer input);
-    vvImage::Pointer GetOutputVVImage ();
-    std::vector<vvImage::Pointer> GetOutputVVImages ();
-
-    /// Main function to implement
-    virtual void Update() = 0;
     
-  protected:
-    /// Call this function to dispatch an output towards the correct sink
-    template<class ImageType> 
-        void SetNextOutput(typename ImageType::Pointer output);
-    /// Call this function to get the nth itk input image, regardless of input source
-    template<class ImageType> 
-        typename ImageType::Pointer GetInput(unsigned int n);
-
-    std::vector<std::string> mInputFilenames;
-    std::list<std::string> mOutputFilenames;
+    typedef ImageToImageGenericFilter<FilterType> Self;
 
-    bool mIOVerbose;
-    unsigned int mDim;
-    std::string mPixelTypeName;
-    unsigned int mNbOfComponents;
+    // constructor - destructor
+    ImageToImageGenericFilter(std::string filterName);
 
-    std::vector<vvImage::Pointer> mInputVVImages;
-    std::vector<vvImage::Pointer> mOutputVVImages;
+    // 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<FilterType> mImageTypesManager;
+    
   }; // end class clitk::ImageToImageGenericFilter
 
+#include "clitkImageToImageGenericFilter.txx"  
+
 } // end namespace
 
-template<class ImageType> 
-void clitk::ImageToImageGenericFilter::SetNextOutput(typename ImageType::Pointer output)
-{
-    if (mOutputFilenames.size())
-    {
-        clitk::writeImage<ImageType>(output, mOutputFilenames.front(), mIOVerbose);
-        mOutputFilenames.pop_front();
-    }
-    if (mInputVVImages.size()) //We assume that if a vv image is set as input, we want one as the output
-        mOutputVVImages.push_back(vvImageFromITK<ImageType::ImageDimension,typename ImageType::PixelType>(output));
-}
-template<class ImageType> 
-typename ImageType::Pointer clitk::ImageToImageGenericFilter::GetInput(unsigned int n)
-{
-    if (mInputFilenames.size() > n)
-        return clitk::readImage<ImageType>(mInputFilenames[n], mIOVerbose);
-    else if (mInputVVImages.size() > n)
-        return typename ImageType::Pointer(const_cast<ImageType*>(vvImageToITK<ImageType>(mInputVVImages[n]).GetPointer()));
-    else
-        assert(false); //No input, this shouldn't happen
-}
 #endif /* end #define CLITKIMAGETOIMAGEGENERICFILTER_H */