]> Creatis software - clitk.git/blob - tools/clitkDVHGenericFilter.cxx
Merge branch 'master' of git.creatis.insa-lyon.fr:clitk
[clitk.git] / tools / clitkDVHGenericFilter.cxx
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_cxx
19 #define clitkDVHGenericFilter_cxx
20
21 #include "clitkDVHGenericFilter.h"
22
23 namespace clitk
24 {
25
26   //-----------------------------------------------------------
27   // Constructor
28   //-----------------------------------------------------------
29   DVHGenericFilter::DVHGenericFilter()
30   {
31     m_Verbose=false;
32     m_InputFileName="";
33   }
34   //-----------------------------------------------------------
35   
36   //-----------------------------------------------------------
37   // Update
38   //-----------------------------------------------------------
39   void DVHGenericFilter::Update()
40   {
41     // Read the Dimension and PixelType
42     int Dimension, Components;
43     std::string PixelType;
44     ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
45     
46     if (m_ArgsInfo.channel_arg < -1 || m_ArgsInfo.channel_arg >= Components) {
47       std::cout << "Invalid image channel" << std::endl;
48       return;
49     }
50     
51     if (m_ArgsInfo.mask_given) {
52       int maskDimension, maskComponents;
53       std::string maskPixelType;
54       ReadImageDimensionAndPixelType(m_ArgsInfo.mask_arg, maskDimension, maskPixelType, maskComponents);
55       if (!(maskDimension == Dimension || maskDimension == (Dimension - 1))) {
56         std::cout << "Dimension of label mask must be equal to the (d)imension of the input image or d-1." << std::endl;
57         return;
58       }
59     }
60
61     
62     // Call UpdateWithDim
63     if (Dimension==2) {
64       switch (Components) {
65         case 1: 
66           UpdateWithDim<2,1>(PixelType);
67           break;
68         case 2: 
69           UpdateWithDim<2,2>(PixelType);
70           break;
71         case 3: 
72           UpdateWithDim<2,3>(PixelType);
73           break;
74         default:
75           std::cout << "Unsupported number of channels" << std::endl;
76           break;
77       }
78     }
79     else if (Dimension==3) {
80       switch (Components) {
81         case 1: 
82           UpdateWithDim<3,1>(PixelType);
83           break;
84         case 2: 
85           UpdateWithDim<3,2>(PixelType);
86           break;
87         case 3: 
88           UpdateWithDim<3,3>(PixelType);
89           break;
90         default:
91           std::cout << "Unsupported number of channels" << std::endl;
92           break;
93       }
94     }
95     else if (Dimension==4) {
96       switch (Components) {
97         case 1: 
98           UpdateWithDim<4,1>(PixelType);
99           break;
100         case 2: 
101           UpdateWithDim<4,2>(PixelType);
102           break;
103         case 3: 
104           UpdateWithDim<4,3>(PixelType);
105           break;
106         default:
107           std::cout << "Unsupported number of channels" << std::endl;
108           break;
109       }
110     }
111     else {
112       std::cout<<"Error, Only for 2 or 3  Dimensions!!!"<<std::endl ;
113       return;
114     }
115   }
116
117
118 } //end clitk
119
120 #endif  //#define clitkDVHGenericFilter_cxx