]> Creatis software - clitk.git/blob - common/vvImageWriter.h
Remove sonarQube
[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   bool GetSaveTransform() { return mSaveTransform; }
52   void SetSaveTransform(bool b) { mSaveTransform = b; }
53
54   //====================================================================
55   // Main function
56   void Update() {
57     Update(mImage->GetNumberOfDimensions(),mImage->GetScalarTypeAsITKString());
58   }
59   void Update(int dim, std::string OutputPixelType);
60
61 protected:
62   // constructor
63   vvImageWriter();
64   ~vvImageWriter();
65
66   //====================================================================
67   std::string mOutputFilename;
68   itk::Command::Pointer mObserver;
69
70   std::string mLastError;
71   bool mUseAnObserver;
72   bool mSaveTransform;
73
74   //====================================================================
75   template<unsigned int VImageDimension>
76   void UpdateWithDim(std::string OutputPixelType);
77
78   //====================================================================
79   template<class OutputPixelType, unsigned int VImageDimension>
80   void UpdateWithDimAndOutputPixelType();
81
82 private:
83   vvImage::Pointer mImage;
84
85 }; // end class vvImageWriter
86
87 #endif /* end #define vvImageWriter_H */