X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkFilterBase.cxx;h=482a82c52f249d365bea5e847e58c05da2ecd9ca;hb=417fa02691e61ff52abb5ce74c81d767755aca7e;hp=2b427202040f21f827a9ff113b1cb60407044687;hpb=38786c4da19b87319bbe3cecc145e3d1771d10da;p=clitk.git diff --git a/common/clitkFilterBase.cxx b/common/clitkFilterBase.cxx index 2b42720..482a82c 100644 --- a/common/clitkFilterBase.cxx +++ b/common/clitkFilterBase.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,42 +14,24 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ // clitk #include "clitkFilterBase.h" +#include "clitkCommon.h" //-------------------------------------------------------------------- clitk::FilterBase::FilterBase() { - m_MustStop = false; - SetVerboseOption(false); + SetVerboseOptionFlag(false); SetCurrentStepNumber(0); SetCurrentStepBaseId(""); - StopOnErrorOn(); - ResetLastError(); - VerboseWarningOffOn(); // OffOn, it's cool not ? + VerboseWarningFlagOn(); + VerboseWarningFlagOff(); + VerboseMemoryFlagOff(); SetWarning(""); -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::FilterBase::ResetLastError() -{ - m_LastError = ""; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::FilterBase::SetLastError(std::string e) -{ - m_LastError = e; - if (GetStopOnError()) { - std::cerr << GetLastError() << std::endl; - exit(0); - } + VerboseWarningFlagOn(); + m_IsCancelled = false; } //-------------------------------------------------------------------- @@ -58,7 +40,7 @@ void clitk::FilterBase::SetLastError(std::string e) void clitk::FilterBase::SetWarning(std::string e) { m_Warning = e; - if (!GetVerboseWarningOff()) { + if (GetVerboseWarningFlag()) { std::cout << GetWarning() << std::endl; } } @@ -68,6 +50,10 @@ void clitk::FilterBase::SetWarning(std::string e) //-------------------------------------------------------------------- void clitk::FilterBase::StartNewStep(std::string s) { + if (Cancelled()) { + throw clitk::ExceptionObject("Filter is canceled."); + } + m_CurrentStepNumber++; if (GetCurrentStepBaseId() != "") { std::ostringstream oss; @@ -81,7 +67,7 @@ void clitk::FilterBase::StartNewStep(std::string s) } m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s; - if (m_VerboseStep) { + if (GetVerboseStepFlag()) { std::cout << m_CurrentStepName << std::endl; //"Step " << GetCurrentStepId() << " -- " << s << std::endl; } @@ -98,10 +84,38 @@ void clitk::FilterBase::StopCurrentStep() //-------------------------------------------------------------------- -void clitk::FilterBase::MustStop() +void clitk::FilterBase::Cancel() +{ + m_IsCancelled = true; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +bool clitk::FilterBase::Cancelled() { - m_MustStop = true; + return m_IsCancelled; } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void clitk::FilterBase::StartSubStep() { + m_SubstepNumbers.push_back(GetCurrentStepNumber()); + m_SubstepID.push_back(GetCurrentStepId()); + SetCurrentStepBaseId(GetCurrentStepId()); + SetCurrentStepNumber(0);; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void clitk::FilterBase::StopSubStep() { + int s = m_SubstepNumbers.back(); + m_SubstepNumbers.pop_back(); + SetCurrentStepNumber(s); + m_SubstepID.pop_back(); + if (m_SubstepID.size() != 0) { + SetCurrentStepBaseId(m_SubstepID.back()); } + else SetCurrentStepBaseId(""); +}