//--------------------------------------------------------------------
clitk::FilterBase::FilterBase()
{
- SetVerboseOption(false);
+ SetVerboseOptionFlag(false);
SetCurrentStepNumber(0);
SetCurrentStepBaseId("");
- VerboseWarningOffOn(); // OffOn, it's cool no ?
+ VerboseWarningFlagOn();
+ VerboseWarningFlagOff();
+ VerboseMemoryFlagOff();
SetWarning("");
+ VerboseWarningFlagOn();
m_IsCancelled = false;
}
//--------------------------------------------------------------------
void clitk::FilterBase::SetWarning(std::string e)
{
m_Warning = e;
- if (!GetVerboseWarningOff()) {
+ if (GetVerboseWarningFlag()) {
std::cout << GetWarning() << std::endl;
}
}
}
m_CurrentStepName = "Step "+GetCurrentStepId()+" -- "+s;
- if (m_VerboseStep) {
+ if (GetVerboseStepFlag()) {
std::cout << m_CurrentStepName << std::endl;
//"Step " << GetCurrentStepId() << " -- " << s << std::endl;
}
//--------------------------------------------------------------------
- bool clitk::FilterBase::Cancelled()
- {
- return m_IsCancelled;
- }
+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);
+ SetCurrentStepBaseId(m_SubstepID.back());
+ m_SubstepID.pop_back();
+}
virtual bool GetDebug() const { return Superclass::GetDebug(); }
// Verbose options management
- itkSetMacro(VerboseOption, bool);
- itkGetConstMacro(VerboseOption, bool);
- itkBooleanMacro(VerboseOption);
- GGO_DefineOption_Flag(verboseOption, SetVerboseOption);
+ itkSetMacro(VerboseFlag, bool);
+ itkGetConstMacro(VerboseFlag, bool);
+ itkBooleanMacro(VerboseFlag);
+
+ // Verbose Options
+ itkSetMacro(VerboseOptionFlag, bool);
+ itkGetConstMacro(VerboseOptionFlag, bool);
+ itkBooleanMacro(VerboseOptionFlag);
+
+ // Verbose Memory
+ itkSetMacro(VerboseMemoryFlag, bool);
+ itkGetConstMacro(VerboseMemoryFlag, bool);
+ itkBooleanMacro(VerboseMemoryFlag);
// Steps management
itkSetMacro(NumberOfSteps, int);
itkGetConstMacro(NumberOfSteps, int);
- itkSetMacro(VerboseStep, bool);
- itkGetConstMacro(VerboseStep, bool);
- itkBooleanMacro(VerboseStep);
- GGO_DefineOption_Flag(verboseStep, SetVerboseStep);
+ itkSetMacro(VerboseStepFlag, bool);
+ itkGetConstMacro(VerboseStepFlag, bool);
+ itkBooleanMacro(VerboseStepFlag);
- itkSetMacro(WriteStep, bool);
- itkGetConstMacro(WriteStep, bool);
- itkBooleanMacro(WriteStep);
- GGO_DefineOption_Flag(writeStep, SetWriteStep);
+ itkSetMacro(WriteStepFlag, bool);
+ itkGetConstMacro(WriteStepFlag, bool);
+ itkBooleanMacro(WriteStepFlag);
itkSetMacro(CurrentStepNumber, int);
itkGetConstMacro(CurrentStepNumber, int);
itkGetConstMacro(CurrentStepBaseId, std::string);
itkSetMacro(CurrentStepName, std::string);
itkGetConstMacro(CurrentStepName, std::string);
-
+
+ void StartSubStep();
+ void StopSubStep();
+
// Convenient function for verbose option
template<class OptionType>
void VerboseOption(std::string name, OptionType value);
void SetWarning(std::string e);
itkGetConstMacro(Warning, std::string);
- itkSetMacro(VerboseWarningOff, bool);
- itkGetConstMacro(VerboseWarningOff, bool);
- itkBooleanMacro(VerboseWarningOff);
- GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff);
+ itkSetMacro(VerboseWarningFlag, bool);
+ itkGetConstMacro(VerboseWarningFlag, bool);
+ itkBooleanMacro(VerboseWarningFlag);
// Use this function to cancel the filter between step
void Cancel();
void StopCurrentStep(typename TInternalImageType::Pointer p);
void StopCurrentStep();
- bool m_VerboseOption;
- bool m_VerboseStep;
- bool m_WriteStep;
+ bool m_VerboseFlag;
+ bool m_VerboseOptionFlag;
+ bool m_VerboseStepFlag;
+ bool m_VerboseMemoryFlag;
+ bool m_WriteStepFlag;
int m_CurrentStepNumber;
int m_NumberOfSteps;
std::string m_CurrentStepId;
std::string m_CurrentStepBaseId;
std::string m_CurrentStepName;
std::string m_Warning;
- bool m_VerboseWarningOff;
+ bool m_VerboseWarningFlag;
bool m_IsCancelled;
Timer m_CurrentStepTimer;
-
+
+ std::vector<int> m_SubstepNumbers;
+ std::vector<std::string> m_SubstepID;
+
private:
FilterBase(const Self&); //purposely not implemented
void operator=(const Self&); //purposely not implemented
======================================================================-====*/
#include "clitkImageCommon.h"
+#include "clitkMemoryUsage.h"
//--------------------------------------------------------------------
template<class OptionType>
void clitk::FilterBase::VerboseOption(std::string name, OptionType value)
{
- if (!this->GetVerboseOption()) return;
+ if (!this->GetVerboseOptionFlag()) return;
std::cout << "Set option '" << name << "' = " << value << std::endl;
}
//--------------------------------------------------------------------
template<class OptionType>
void clitk::FilterBase::VerboseOption(std::string name, int nb, OptionType value)
{
- if (!this->GetVerboseOption()) return;
+ if (!this->GetVerboseOptionFlag()) return;
if (nb==0) std::cout << "Set option '" << name << "' not given" << std::endl;
else {
std::cout << "Set option '" << name << "' = " << value << std::endl;
template<class OptionType>
void clitk::FilterBase::VerboseOptionV(std::string name, int nb, OptionType * value)
{
- if (!this->GetVerboseOption()) return;
+ if (!this->GetVerboseOptionFlag()) return;
if (nb==0) std::cout << "Set option '" << name << "' not given" << std::endl;
else {
std::cout << "Set option '" << name << "'[" << nb << "] ";
void clitk::FilterBase::StopCurrentStep(typename TInternalImageType::Pointer p)
{
StopCurrentStep();
- if (m_WriteStep) {
+ if (m_WriteStepFlag) {
std::ostringstream name;
name << "step-" << GetCurrentStepId() << ".mhd";
clitk::writeImage<TInternalImageType>(p, name.str());
}
+ clitk::PrintMemory(GetVerboseMemoryFlag(), "End of step");
}
//--------------------------------------------------------------------