]> Creatis software - clitk.git/blob - common/clitkFilterBase.cxx
motion masks with and without bands
[clitk.git] / common / clitkFilterBase.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
19 // clitk
20 #include "clitkFilterBase.h"
21 #include "clitkCommon.h"
22
23 //--------------------------------------------------------------------
24 clitk::FilterBase::FilterBase() 
25 {
26   SetVerboseOptionFlag(false);
27   SetCurrentStepNumber(0);
28   SetCurrentStepBaseId("");
29   VerboseWarningFlagOn();
30   VerboseWarningFlagOff();
31   VerboseMemoryFlagOff();
32   VerboseImageSizeFlagOff();
33   SetWarning("");
34   VerboseWarningFlagOn();
35   m_IsCancelled = false;
36 }
37 //--------------------------------------------------------------------
38
39
40 //--------------------------------------------------------------------
41 void clitk::FilterBase::SetWarning(std::string e)
42 {
43   m_Warning = e;
44   if (GetVerboseWarningFlag()) {
45     std::cout << GetWarning() << std::endl;
46   }
47 }
48 //--------------------------------------------------------------------
49
50
51 //--------------------------------------------------------------------
52 void clitk::FilterBase::StartNewStep(std::string s) 
53 {
54   if (Cancelled()) {
55     throw clitk::ExceptionObject("Filter is canceled.");
56   }
57
58   m_CurrentStepNumber++;
59   if (GetCurrentStepBaseId() != "") {
60     std::ostringstream oss;
61     oss << GetCurrentStepBaseId() << "." << m_CurrentStepNumber;
62     SetCurrentStepId(oss.str());
63   }
64   else {
65     std::ostringstream oss;
66     oss << m_CurrentStepNumber;
67     SetCurrentStepId(oss.str());
68   }
69
70   m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
71   if (GetVerboseStepFlag()) {
72     std::cout << m_CurrentStepName << std::endl;
73     //"Step " << GetCurrentStepId() << " -- " << s << std::endl;
74   }
75 }
76 //--------------------------------------------------------------------
77
78
79 //--------------------------------------------------------------------
80 void clitk::FilterBase::StopCurrentStep() 
81 {
82   
83 }
84 //--------------------------------------------------------------------
85
86
87 //--------------------------------------------------------------------
88 void clitk::FilterBase::Cancel()
89 {
90   m_IsCancelled = true;
91 }
92 //--------------------------------------------------------------------
93
94
95 //--------------------------------------------------------------------
96 bool clitk::FilterBase::Cancelled()
97 {
98   return m_IsCancelled;
99 }
100 //--------------------------------------------------------------------
101
102
103 //--------------------------------------------------------------------
104 void clitk::FilterBase::StartSubStep() {
105   m_SubstepNumbers.push_back(GetCurrentStepNumber());
106   m_SubstepID.push_back(GetCurrentStepId());
107   SetCurrentStepBaseId(GetCurrentStepId());
108   SetCurrentStepNumber(0);;
109 }
110 //--------------------------------------------------------------------
111
112
113 //--------------------------------------------------------------------
114 void clitk::FilterBase::StopSubStep() {
115   int s = m_SubstepNumbers.back();
116   m_SubstepNumbers.pop_back();
117   SetCurrentStepNumber(s);
118   m_SubstepID.pop_back();
119   if (m_SubstepID.size() != 0) {
120     SetCurrentStepBaseId(m_SubstepID.back());  }
121   else SetCurrentStepBaseId("");
122 }