]> Creatis software - clitk.git/blob - tools/clitkDVHGenericFilter.h
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / tools / clitkDVHGenericFilter.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 CLITKDVHGENERICFILTER_H
19 #define CLITKDVHGENERICFILTER_H
20
21 // clitk include
22 #include "clitkIO.h"
23 #include "clitkCommon.h"
24 #include "clitkImageCommon.h" 
25 #include "clitkImageToImageGenericFilter.h"
26 #include "clitkDVH_ggo.h"
27
28 // itk include
29 #include "itkImage.h"
30 #include "itkImageIOBase.h"
31 #include "itkImageRegionIterator.h"
32 #include "itkImageRegionConstIterator.h"
33 #include "itkLightObject.h"
34 #include "itkLabelStatisticsImageFilter.h"
35 #include "itkLabelGeometryImageFilter.h"
36
37 //--------------------------------------------------------------------
38 namespace clitk
39 {
40
41 //template<class args_info_type>
42 class ITK_EXPORT DVHGenericFilter: public itk::LightObject
43 {
44
45 public:
46
47
48     //--------------------------------------------------------------------
49     typedef DVHGenericFilter         Self;
50     typedef itk::LightObject               Superclass;
51     typedef itk::SmartPointer<Self>            Pointer;
52     typedef itk::SmartPointer<const Self>      ConstPointer;
53
54     //--------------------------------------------------------------------
55     // Method for creation through the object factory
56     // and Run-time type information (and related methods)
57     itkNewMacro(Self);
58     itkTypeMacro(DVHGenericFilter, LightObject);
59
60     //--------------------------------------------------------------------
61     void SetArgsInfo(const args_info_clitkDVH & a)
62     {
63      m_ArgsInfo=a;
64      m_Verbose=m_ArgsInfo.verbose_flag;
65
66      if(m_ArgsInfo.input_given)
67       m_InputFileName=m_ArgsInfo.input_arg[0];
68      else if(m_ArgsInfo.inputs_num>0)
69      m_InputFileName=m_ArgsInfo.inputs[0];
70      else {
71      std::cerr << "You must give an input file name" << std::endl;
72      exit(1);
73       }
74     }
75     //--------------------------------------------------------------------
76     // Main function called each time the filter is updated
77     //template<class InputImageType>
78     //void UpdateWithInputImageType();
79     void Update();
80
81     // Set methods
82     void SetDefaultPixelValue (double value) {  mDefaultPixelValue = value ;}
83     void SetTypeOfOperation (int value) {  mTypeOfOperation = value ;}
84     void SetScalar (double value) {  mScalar = value ;}
85     void EnableOverwriteInputImage(bool b);
86
87     // Get methods
88     double GetDefaultPixelValue () { return  mDefaultPixelValue ;}
89     int GetTypeOfOperation () { return  mTypeOfOperation ;}
90     double GetScalar () { return  mScalar ;}
91
92 protected:
93
94    //--------------------------------------------------------------------
95    // Constructor & Destructor
96    DVHGenericFilter();
97    ~DVHGenericFilter() {};
98    // template<unsigned int Dim> void InitializeImageType();
99    // args_info_type mArgsInfo;
100
101    //--------------------------------------------------------------------
102    // Tempated members
103    //--------------------------------------------------------------------
104    template<unsigned int Dimension, unsigned int Components> void UpdateWithDim(std::string PixelType);
105    template <unsigned int Dimension, class PixelType, unsigned int Components> void UpdateWithDimAndPixelType();
106
107    //--------------------------------------------------------------------
108    // Data members
109    //--------------------------------------------------------------------
110    args_info_clitkDVH m_ArgsInfo;
111    bool m_Verbose;
112    std::string m_InputFileName;
113
114    template<unsigned int Dim> void InitializeImageType();
115    bool mIsOperationUseASecondImage;
116    double mScalar;
117    double mDefaultPixelValue;
118    int mTypeOfOperation;
119    bool mOverwriteInputImage;
120    bool mOutputIsFloat;
121
122    template<class Iter1, class Iter2> void ComputeImage(Iter1 it, Iter2 ito);
123
124    template<class Iter1, class Iter2, class Iter3> void ComputeImage(Iter1 it1, Iter2 it2, Iter3 ito);
125
126
127 }; // end class
128 //--------------------------------------------------------------------
129
130 } // end namespace clitk
131
132 #ifndef ITK_MANUAL_INSTANTIATION
133 #include "clitkDVHGenericFilter.txx"
134 #endif
135
136 #endif // #define clitkDVHGenericFilter_h