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();
32 VerboseImageSizeFlagOff();
34 VerboseWarningFlagOn();
35 m_IsCancelled = false;
37 //--------------------------------------------------------------------
40 //--------------------------------------------------------------------
41 void clitk::FilterBase::SetWarning(std::string e)
44 if (GetVerboseWarningFlag()) {
45 std::cout << GetWarning() << std::endl;
48 //--------------------------------------------------------------------
51 //--------------------------------------------------------------------
52 void clitk::FilterBase::StartNewStep(std::string s)
55 throw clitk::ExceptionObject("Filter is canceled.");
58 m_CurrentStepNumber++;
59 if (GetCurrentStepBaseId() != "") {
60 std::ostringstream oss;
61 oss << GetCurrentStepBaseId() << "." << m_CurrentStepNumber;
62 SetCurrentStepId(oss.str());
65 std::ostringstream oss;
66 oss << m_CurrentStepNumber;
67 SetCurrentStepId(oss.str());
70 m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
71 if (GetVerboseStepFlag()) {
72 std::cout << m_CurrentStepName << std::endl;
73 //"Step " << GetCurrentStepId() << " -- " << s << std::endl;
76 //--------------------------------------------------------------------
79 //--------------------------------------------------------------------
80 void clitk::FilterBase::StopCurrentStep()
84 //--------------------------------------------------------------------
87 //--------------------------------------------------------------------
88 void clitk::FilterBase::Cancel()
92 //--------------------------------------------------------------------
95 //--------------------------------------------------------------------
96 bool clitk::FilterBase::Cancelled()
100 //--------------------------------------------------------------------
103 //--------------------------------------------------------------------
104 void clitk::FilterBase::StartSubStep() {
105 m_SubstepNumbers.push_back(GetCurrentStepNumber());
106 m_SubstepID.push_back(GetCurrentStepId());
107 SetCurrentStepBaseId(GetCurrentStepId());
108 SetCurrentStepNumber(0);;
110 //--------------------------------------------------------------------
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("");