X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkFilterBase.h;h=1019b7b76aa49f9b28e8796151a2e60c7c89672b;hb=d55f025b18f68066a52b8f33c2dc6481e82c2580;hp=a53a181490b07ab0180e34b7d2e7c1b2e09ac879;hpb=868922dc773690f1be8f21159f10fc4702e5c09f;p=clitk.git diff --git a/common/clitkFilterBase.h b/common/clitkFilterBase.h index a53a181..1019b7b 100644 --- a/common/clitkFilterBase.h +++ b/common/clitkFilterBase.h @@ -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,13 +14,12 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ #ifndef CLITKFILTERBASE_H #define CLITKFILTERBASE_H // clitk -#include "clitkCommon.h" #include "clitkTimer.h" #include "clitkFilterMacros.txx" #include "clitkLabelizeParameters.h" @@ -32,17 +31,21 @@ namespace clitk { //-------------------------------------------------------------------- /* - Convenient class to manage options from GGO gengetopt) to filter + Convenient class to manage frequent options */ //-------------------------------------------------------------------- - class FilterBase { + class FilterBase + { public: // Standard class typedefs typedef FilterBase Self; // Run-time type information (and related methods) - itkTypeMacro(FilterBase, Object); + virtual const char *GetNameOfClass() const + { + return "FilterBase"; + } // Needed by itkSetMacro (cannot inherit from itkObject because of // multiple inheritance) @@ -55,23 +58,35 @@ namespace clitk { 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); + + // Verbose ImageSize + itkSetMacro(VerboseImageSizeFlag, bool); + itkGetConstMacro(VerboseImageSizeFlag, bool); + itkBooleanMacro(VerboseImageSizeFlag); // 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); @@ -81,7 +96,10 @@ namespace clitk { itkGetConstMacro(CurrentStepBaseId, std::string); itkSetMacro(CurrentStepName, std::string); itkGetConstMacro(CurrentStepName, std::string); - + + void StartSubStep(); + void StopSubStep(); + // Convenient function for verbose option template void VerboseOption(std::string name, OptionType value); @@ -90,49 +108,43 @@ namespace clitk { template void VerboseOptionV(std::string name, int nb, OptionType * value); - // Error - void SetLastError(std::string e); - void ResetLastError(); - itkGetConstMacro(LastError, std::string); - bool HasError() { return (GetLastError() != ""); } - itkSetMacro(StopOnError, bool); - itkGetConstMacro(StopOnError, bool); - itkBooleanMacro(StopOnError); - void SetWarning(std::string e); itkGetConstMacro(Warning, std::string); - itkSetMacro(VerboseWarningOff, bool); - itkGetConstMacro(VerboseWarningOff, bool); - itkBooleanMacro(VerboseWarningOff); - GGO_DefineOption_Flag(verboseWarningOff, SetVerboseWarningOff); - - // Use this function to stop (when threaded) - void SetMustStop(bool b); - bool GetMustStop(); + itkSetMacro(VerboseWarningFlag, bool); + itkGetConstMacro(VerboseWarningFlag, bool); + itkBooleanMacro(VerboseWarningFlag); + // Use this function to cancel the filter between step + void Cancel(); + bool Cancelled(); + protected: FilterBase(); virtual ~FilterBase() {} - void StartNewStep(std::string s); + void StartNewStep(std::string s, bool endl=true); template - void StopCurrentStep(typename TInternalImageType::Pointer p); + void StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt=""); 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_VerboseImageSizeFlag; + bool m_WriteStepFlag; int m_CurrentStepNumber; int m_NumberOfSteps; std::string m_CurrentStepId; std::string m_CurrentStepBaseId; - std::string m_LastError; std::string m_CurrentStepName; - bool m_StopOnError; std::string m_Warning; - bool m_VerboseWarningOff; - bool m_MustStop; + bool m_VerboseWarningFlag; + bool m_IsCancelled; Timer m_CurrentStepTimer; + std::vector m_SubstepNumbers; + std::vector m_SubstepID; + private: FilterBase(const Self&); //purposely not implemented void operator=(const Self&); //purposely not implemented @@ -143,8 +155,6 @@ namespace clitk { } // end namespace clitk //-------------------------------------------------------------------- -#define StartNewStepOrStop(s) StartNewStep(s); if (GetMustStop()) return; - #ifndef ITK_MANUAL_INSTANTIATION #include "clitkFilterBase.txx" #endif