]> Creatis software - clitk.git/blob - common/clitkFilterBase.cxx
revived old fast_make script / clean some dependencies
[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://oncora1.lyon.fnclcc.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   SetVerboseOption(false);
27   SetCurrentStepNumber(0);
28   SetCurrentStepBaseId("");
29   VerboseWarningOffOn(); // OffOn, it's cool no ?
30   SetWarning("");
31   m_IsCancelled = false;
32 }
33 //--------------------------------------------------------------------
34
35
36 //--------------------------------------------------------------------
37 void clitk::FilterBase::SetWarning(std::string e)
38 {
39   m_Warning = e;
40   if (!GetVerboseWarningOff()) {
41     std::cout << GetWarning() << std::endl;
42   }
43 }
44 //--------------------------------------------------------------------
45
46
47 //--------------------------------------------------------------------
48 void clitk::FilterBase::StartNewStep(std::string s) 
49 {
50   if (Cancelled()) {
51     throw clitk::ExceptionObject("Filter is canceled.");
52   }
53
54   m_CurrentStepNumber++;
55   if (GetCurrentStepBaseId() != "") {
56     std::ostringstream oss;
57     oss << GetCurrentStepBaseId() << "." << m_CurrentStepNumber;
58     SetCurrentStepId(oss.str());
59   }
60   else {
61     std::ostringstream oss;
62     oss << m_CurrentStepNumber;
63     SetCurrentStepId(oss.str());
64   }
65
66   m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
67   if (m_VerboseStep) {
68     std::cout << m_CurrentStepName << std::endl;
69     //"Step " << GetCurrentStepId() << " -- " << s << std::endl;
70   }
71 }
72 //--------------------------------------------------------------------
73
74
75 //--------------------------------------------------------------------
76 void clitk::FilterBase::StopCurrentStep() 
77 {
78   
79 }
80 //--------------------------------------------------------------------
81
82
83 //--------------------------------------------------------------------
84 void clitk::FilterBase::Cancel()
85 {
86   m_IsCancelled = true;
87 }
88 //--------------------------------------------------------------------
89
90
91 //--------------------------------------------------------------------
92  bool clitk::FilterBase::Cancelled()
93  {
94    return m_IsCancelled;
95  }
96 //--------------------------------------------------------------------
97