X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkFilterBase.cxx;h=f6bebad101072e7d8ed40fe62b710f962e802f1f;hb=08f7de414957e92b25ca5b299007e941b610d3a8;hp=74424d4c3c9e14266c6fe2db4133bff97efec45f;hpb=03c0a567e50d4b3dcdee11112b0a404789468857;p=clitk.git diff --git a/common/clitkFilterBase.cxx b/common/clitkFilterBase.cxx index 74424d4..f6bebad 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,41 +14,25 @@ - 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() { - SetVerboseOption(false); + SetVerboseOptionFlag(false); SetCurrentStepNumber(0); SetCurrentStepBaseId(""); - StopOnErrorOn(); - ResetLastError(); - VerboseWarningOffOn(); // OffOn, it's cool not ? + VerboseWarningFlagOn(); + VerboseWarningFlagOff(); + VerboseMemoryFlagOff(); + VerboseImageSizeFlagOff(); 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; } //-------------------------------------------------------------------- @@ -57,7 +41,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; } } @@ -65,8 +49,12 @@ void clitk::FilterBase::SetWarning(std::string e) //-------------------------------------------------------------------- -void clitk::FilterBase::StartNewStep(std::string s) +void clitk::FilterBase::StartNewStep(std::string s, bool endl) { + if (Cancelled()) { + throw clitk::ExceptionObject("Filter is canceled."); + } + m_CurrentStepNumber++; if (GetCurrentStepBaseId() != "") { std::ostringstream oss; @@ -79,8 +67,11 @@ void clitk::FilterBase::StartNewStep(std::string s) SetCurrentStepId(oss.str()); } - if (m_VerboseStep) { - std::cout << "Step " << GetCurrentStepId() << " -- " << s << std::endl; + m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s; + if (GetVerboseStepFlag()) { + std::cout << m_CurrentStepName; + if (endl) std::cout << std::endl; + //"Step " << GetCurrentStepId() << " -- " << s << std::endl; } } //-------------------------------------------------------------------- @@ -93,3 +84,40 @@ void clitk::FilterBase::StopCurrentStep() } //-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +void clitk::FilterBase::Cancel() +{ + m_IsCancelled = true; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +bool clitk::FilterBase::Cancelled() +{ + 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(""); +}