]> Creatis software - clitk.git/blob - vv/vvImageWriter.h
Synergy projections file format
[clitk.git] / vv / vvImageWriter.h
1 /*=========================================================================
2
3  Program:   vv
4  Language:  C++
5  Author :   Pierre Seroul (pierre.seroul@gmail.com)
6
7 Copyright (C) 2008
8 Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
9 CREATIS-LRMN http://www.creatis.insa-lyon.fr
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, version 3 of the License.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 =========================================================================*/
24 #ifndef vvImageWriter_H
25 #define vvImageWriter_H
26
27 #include <string>
28
29 // ITK includes
30 #include "itkImage.h"
31 #include "itkCommand.h"
32 #include "vvImage.h"
33
34 class vvImageWriter {
35
36 public:
37     // constructor
38     vvImageWriter();
39     ~vvImageWriter();
40
41     void SetOutputFileName(std::string filename);
42     void SetObserver(itk::Command::Pointer o) {
43         mUseAnObserver = true;
44         mObserver = o;
45     }
46     void DisableObserver() {
47         mUseAnObserver = false;
48     }
49
50     void SetInput(vvImage::Pointer image) {
51         mImage = image;
52     }
53
54     std::string GetLastError() {
55         return mLastError;
56     }
57
58     //====================================================================
59     // Main function
60     void Update() {
61         Update(mImage->GetNumberOfDimensions(),mImage->GetScalarTypeAsString());
62     }
63     void Update(int dim, std::string OutputPixelType);
64
65 protected:
66     //====================================================================
67     std::string mOutputFilename;
68     itk::Command::Pointer mObserver;
69
70     std::string mLastError;
71     bool mUseAnObserver;
72
73     //====================================================================
74     template<unsigned int VImageDimension>
75     void UpdateWithDim(std::string OutputPixelType);
76
77     //====================================================================
78     template<class OutputPixelType, unsigned int VImageDimension>
79     void UpdateWithDimAndOutputPixelType();
80
81 private:
82     vvImage::Pointer mImage;
83
84 }; // end class vvImageWriter
85
86 #endif /* end #define vvImageWriter_H */