]> Creatis software - clitk.git/blob - common/vvImageWriter.h
changes in license header
[clitk.git] / common / vvImageWriter.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://www.centreleonberard.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 vvImageWriter_H
19 #define vvImageWriter_H
20 #include <string>
21
22 // ITK includes
23 #include "itkImage.h"
24 #include "itkCommand.h"
25 #include "vvImage.h"
26
27 class vvImageWriter : public itk::LightObject {
28
29 public:
30   typedef vvImageWriter Self;
31   typedef itk::SmartPointer<Self> Pointer;
32   itkNewMacro(Self);
33
34   void SetOutputFileName(std::string filename);
35   void SetObserver(itk::Command::Pointer o) {
36     mUseAnObserver = true;
37     mObserver = o;
38   }
39   void DisableObserver() {
40     mUseAnObserver = false;
41   }
42
43   void SetInput(vvImage::Pointer image) {
44     mImage = image;
45   }
46
47   std::string GetLastError() {
48     return mLastError;
49   }
50
51   //====================================================================
52   // Main function
53   void Update() {
54     Update(mImage->GetNumberOfDimensions(),mImage->GetScalarTypeAsITKString());
55   }
56   void Update(int dim, std::string OutputPixelType);
57
58 protected:
59   // constructor
60   vvImageWriter();
61   ~vvImageWriter();
62
63   //====================================================================
64   std::string mOutputFilename;
65   itk::Command::Pointer mObserver;
66
67   std::string mLastError;
68   bool mUseAnObserver;
69
70   //====================================================================
71   template<unsigned int VImageDimension>
72   void UpdateWithDim(std::string OutputPixelType);
73
74   //====================================================================
75   template<class OutputPixelType, unsigned int VImageDimension>
76   void UpdateWithDimAndOutputPixelType();
77
78 private:
79   vvImage::Pointer mImage;
80
81 }; // end class vvImageWriter
82
83 #endif /* end #define vvImageWriter_H */