]> Creatis software - clitk.git/blob - common/clitkFilterBase.txx
Remove warnings
[clitk.git] / common / clitkFilterBase.txx
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
19 #include "clitkImageCommon.h"
20 #include "clitkMemoryUsage.h"
21
22 //--------------------------------------------------------------------
23 template<class OptionType>
24 void clitk::FilterBase::VerboseOption(std::string name, OptionType value) 
25 {
26   if (!this->GetVerboseOptionFlag()) return;
27   std::cout << "Set option '" << name << "' = " << value << std::endl;
28 }
29 //--------------------------------------------------------------------
30
31
32 //--------------------------------------------------------------------
33 template<class OptionType>
34 void clitk::FilterBase::VerboseOption(std::string name, int nb, OptionType value) 
35 {
36   if (!this->GetVerboseOptionFlag()) return;
37   if (nb==0) std::cout << "Set option '" << name << "' not given" << std::endl;
38   else {
39     std::cout << "Set option '" << name << "' = " << value << std::endl;
40   }
41 }
42 //--------------------------------------------------------------------
43
44
45 //--------------------------------------------------------------------
46 template<class OptionType>
47 void clitk::FilterBase::VerboseOptionV(std::string name, int nb, OptionType * value) 
48 {
49   if (!this->GetVerboseOptionFlag()) return;
50   if (nb==0) std::cout << "Set option '" << name << "' not given" << std::endl;
51   else {
52     std::cout << "Set option '" << name << "'[" << nb << "] ";
53     for(int i=0; i<nb; i++) std::cout << value[i] << " ";
54     std::cout << std::endl;
55   }
56 }
57 //--------------------------------------------------------------------
58
59
60 //--------------------------------------------------------------------
61 template<class TInternalImageType>
62 void clitk::FilterBase::StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt) 
63 {
64   StopCurrentStep();
65   if (m_WriteStepFlag) {
66     std::ostringstream name;
67     name << "step-" << GetCurrentStepId() << ".mhd";
68     clitk::writeImage<TInternalImageType>(p, name.str());
69   }
70   clitk::PrintMemory(GetVerboseMemoryFlag(), "End of step"); 
71   if (GetVerboseImageSizeFlag()) {
72     std::ostream & os = std::cout;
73     unsigned int dim = p->GetImageDimension();
74     int nb = 1;
75     os << txt << " size = ";
76     for(unsigned int i=0; i<dim-1; i++) {
77       os << p->GetLargestPossibleRegion().GetSize()[i] << "x";
78       nb *= p->GetLargestPossibleRegion().GetSize()[i];
79     }
80     os << p->GetLargestPossibleRegion().GetSize()[dim-1] << "  ";
81     nb *= p->GetLargestPossibleRegion().GetSize()[dim-1];
82     os << " pixels = " << nb << std::endl;    
83   }
84 }
85 //--------------------------------------------------------------------
86
87