1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
20 #include "clitkFilterBase.h"
21 #include "clitkCommon.h"
23 //--------------------------------------------------------------------
24 clitk::FilterBase::FilterBase()
26 SetVerboseOptionFlag(false);
27 SetCurrentStepNumber(0);
28 SetCurrentStepBaseId("");
29 VerboseWarningFlagOn();
30 VerboseWarningFlagOff();
31 VerboseMemoryFlagOff();
33 VerboseWarningFlagOn();
34 m_IsCancelled = false;
36 //--------------------------------------------------------------------
39 //--------------------------------------------------------------------
40 void clitk::FilterBase::SetWarning(std::string e)
43 if (GetVerboseWarningFlag()) {
44 std::cout << GetWarning() << std::endl;
47 //--------------------------------------------------------------------
50 //--------------------------------------------------------------------
51 void clitk::FilterBase::StartNewStep(std::string s)
54 throw clitk::ExceptionObject("Filter is canceled.");
57 m_CurrentStepNumber++;
58 if (GetCurrentStepBaseId() != "") {
59 std::ostringstream oss;
60 oss << GetCurrentStepBaseId() << "." << m_CurrentStepNumber;
61 SetCurrentStepId(oss.str());
64 std::ostringstream oss;
65 oss << m_CurrentStepNumber;
66 SetCurrentStepId(oss.str());
69 m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
70 if (GetVerboseStepFlag()) {
71 std::cout << m_CurrentStepName << std::endl;
72 //"Step " << GetCurrentStepId() << " -- " << s << std::endl;
75 //--------------------------------------------------------------------
78 //--------------------------------------------------------------------
79 void clitk::FilterBase::StopCurrentStep()
83 //--------------------------------------------------------------------
86 //--------------------------------------------------------------------
87 void clitk::FilterBase::Cancel()
91 //--------------------------------------------------------------------
94 //--------------------------------------------------------------------
95 bool clitk::FilterBase::Cancelled()
99 //--------------------------------------------------------------------
102 //--------------------------------------------------------------------
103 void clitk::FilterBase::StartSubStep() {
104 m_SubstepNumbers.push_back(GetCurrentStepNumber());
105 m_SubstepID.push_back(GetCurrentStepId());
106 SetCurrentStepBaseId(GetCurrentStepId());
107 SetCurrentStepNumber(0);;
109 //--------------------------------------------------------------------
112 //--------------------------------------------------------------------
113 void clitk::FilterBase::StopSubStep() {
114 int s = m_SubstepNumbers.back();
115 m_SubstepNumbers.pop_back();
116 SetCurrentStepNumber(s);
117 m_SubstepID.pop_back();
118 if (m_SubstepID.size() != 0) {
119 SetCurrentStepBaseId(m_SubstepID.back()); }
120 else SetCurrentStepBaseId("");