//--------------------------------------------------------------------
clitk::FilterBase::FilterBase()
{
- m_MustStop = false;
+ SetMustStop(false);
SetVerboseOption(false);
SetCurrentStepNumber(0);
SetCurrentStepBaseId("");
StopOnErrorOn();
ResetLastError();
- VerboseWarningOffOn(); // OffOn, it's cool not ?
+ VerboseWarningOffOn(); // OffOn, it's cool no ?
SetWarning("");
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
void clitk::FilterBase::StartNewStep(std::string s)
{
+ //m_CurrentStepTimer.Reset();
+ // m_CurrentStepTimer.Start();
m_CurrentStepNumber++;
if (GetCurrentStepBaseId() != "") {
std::ostringstream oss;
//--------------------------------------------------------------------
void clitk::FilterBase::StopCurrentStep()
{
-
+ // m_CurrentStepTimer.Stop();
+ // m_CurrentStepTimer.Print(std::cout);
+ // std::ostringstream oss;
+ //oss << " (" <<
+ // m_CurrentStepName = m_CurrentStepName +"
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
-void clitk::FilterBase::MustStop()
+void clitk::FilterBase::SetMustStop(bool b)
{
- m_MustStop = true;
+ m_MustStop = b;
+ if (GetMustStop()) {
+ SetLastError("Filter is interrupted.");
+ }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+bool clitk::FilterBase::GetMustStop()
+{
+ if (m_MustStop) return true;
+ if (HasError()) return true;
+ return false;
}
//--------------------------------------------------------------------
// clitk
#include "clitkCommon.h"
+#include "clitkTimer.h"
#include "clitkFilterMacros.txx"
#include "clitkLabelizeParameters.h"
GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
// Use this function to stop (when threaded)
- void MustStop();
+ void SetMustStop(bool b);
+ bool GetMustStop();
protected:
FilterBase();
std::string m_Warning;
bool m_VerboseWarningOff;
bool m_MustStop;
+ Timer m_CurrentStepTimer;
private:
FilterBase(const Self&); //purposely not implemented
} // end namespace clitk
//--------------------------------------------------------------------
+#define StartNewStepOrStop(s) StartNewStep(s); if (GetMustStop()) return;
+
#ifndef ITK_MANUAL_INSTANTIATION
#include "clitkFilterBase.txx"
#endif
template<class TInternalImageType>
void clitk::FilterBase::StopCurrentStep(typename TInternalImageType::Pointer p)
{
+ StopCurrentStep();
if (m_WriteStep) {
std::ostringstream name;
name << "step-" << GetCurrentStepId() << ".mhd";
m_FailOnImageTypeError = true;
m_ReadOnDisk = true;
m_LastError = "";
+ StopOnErrorOn();
}
//--------------------------------------------------------------------
//--------------------------------------------------------------------
+//--------------------------------------------------------------------
+void clitk::ImageToImageGenericFilterBase::MustStop()
+{
+ if (m_FilterBase != NULL) {
+ m_FilterBase->SetMustStop(true);
+ }
+}
+//--------------------------------------------------------------------
+
+
// Get the associated filter
FilterBase * GetFilterBase() { return m_FilterBase; }
+
+ // Indicate that the filter must stop as soon as possible (if threaded)
+ void MustStop();
+ itkSetMacro(StopOnError, bool);
+ itkGetConstMacro(StopOnError, bool);
+ itkBooleanMacro(StopOnError);
protected:
bool m_ReadOnDisk;
std::string m_LastError;
void SetFilterBase(FilterBase * f) { m_FilterBase = f; }
FilterBase * m_FilterBase;
+ bool m_StopOnError;
}; // end class clitk::ImageToImageGenericFilter