1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKFILTERBASE_H
20 #define CLITKFILTERBASE_H
23 #include "clitkTimer.h"
24 #include "clitkFilterMacros.txx"
25 #include "clitkLabelizeParameters.h"
28 #include "itkObject.h"
32 //--------------------------------------------------------------------
34 Convenient class to manage frequent options
36 //--------------------------------------------------------------------
41 // Standard class typedefs
42 typedef FilterBase Self;
44 // Run-time type information (and related methods)
45 virtual const char *GetNameOfClass() const
50 // Needed by itkSetMacro (cannot inherit from itkObject because of
51 // multiple inheritance)
52 virtual void Modified() {}
53 virtual bool GetDebug() const { return false; }
55 // To put in class that inherit from FilterBase
56 #define FILTERBASE_INIT \
57 virtual void Modified() { Superclass::Modified(); } \
58 virtual bool GetDebug() const { return Superclass::GetDebug(); }
60 // Verbose options management
61 itkSetMacro(VerboseFlag, bool);
62 itkGetConstMacro(VerboseFlag, bool);
63 itkBooleanMacro(VerboseFlag);
66 itkSetMacro(VerboseOptionFlag, bool);
67 itkGetConstMacro(VerboseOptionFlag, bool);
68 itkBooleanMacro(VerboseOptionFlag);
71 itkSetMacro(VerboseMemoryFlag, bool);
72 itkGetConstMacro(VerboseMemoryFlag, bool);
73 itkBooleanMacro(VerboseMemoryFlag);
76 itkSetMacro(VerboseImageSizeFlag, bool);
77 itkGetConstMacro(VerboseImageSizeFlag, bool);
78 itkBooleanMacro(VerboseImageSizeFlag);
81 itkSetMacro(NumberOfSteps, int);
82 itkGetConstMacro(NumberOfSteps, int);
83 itkSetMacro(VerboseStepFlag, bool);
84 itkGetConstMacro(VerboseStepFlag, bool);
85 itkBooleanMacro(VerboseStepFlag);
87 itkSetMacro(WriteStepFlag, bool);
88 itkGetConstMacro(WriteStepFlag, bool);
89 itkBooleanMacro(WriteStepFlag);
91 itkSetMacro(CurrentStepNumber, int);
92 itkGetConstMacro(CurrentStepNumber, int);
93 itkSetMacro(CurrentStepId, std::string);
94 itkGetConstMacro(CurrentStepId, std::string);
95 itkSetMacro(CurrentStepBaseId, std::string);
96 itkGetConstMacro(CurrentStepBaseId, std::string);
97 itkSetMacro(CurrentStepName, std::string);
98 itkGetConstMacro(CurrentStepName, std::string);
103 // Convenient function for verbose option
104 template<class OptionType>
105 void VerboseOption(std::string name, OptionType value);
106 template<class OptionType>
107 void VerboseOption(std::string name, int nb, OptionType value);
108 template<class OptionType>
109 void VerboseOptionV(std::string name, int nb, OptionType * value);
111 void SetWarning(std::string e);
112 itkGetConstMacro(Warning, std::string);
113 itkSetMacro(VerboseWarningFlag, bool);
114 itkGetConstMacro(VerboseWarningFlag, bool);
115 itkBooleanMacro(VerboseWarningFlag);
117 // Use this function to cancel the filter between step
123 virtual ~FilterBase() {}
124 void StartNewStep(std::string s, bool endl=true);
125 template<class TInternalImageType>
126 void StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt="");
127 void StopCurrentStep();
130 bool m_VerboseOptionFlag;
131 bool m_VerboseStepFlag;
132 bool m_VerboseMemoryFlag;
133 bool m_VerboseImageSizeFlag;
134 bool m_WriteStepFlag;
135 int m_CurrentStepNumber;
137 std::string m_CurrentStepId;
138 std::string m_CurrentStepBaseId;
139 std::string m_CurrentStepName;
140 std::string m_Warning;
141 bool m_VerboseWarningFlag;
143 Timer m_CurrentStepTimer;
145 std::vector<int> m_SubstepNumbers;
146 std::vector<std::string> m_SubstepID;
149 FilterBase(const Self&); //purposely not implemented
150 void operator=(const Self&); //purposely not implemented
153 //--------------------------------------------------------------------
155 } // end namespace clitk
156 //--------------------------------------------------------------------
158 #ifndef ITK_MANUAL_INSTANTIATION
159 #include "clitkFilterBase.txx"
162 #endif // CLITKFILTERBASE_H