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 itkTypeMacro(FilterBase, Object);
47 // Needed by itkSetMacro (cannot inherit from itkObject because of
48 // multiple inheritance)
49 virtual void Modified() {}
50 virtual bool GetDebug() const { return false; }
52 // To put in class that inherit from FilterBase
53 #define FILTERBASE_INIT \
54 virtual void Modified() { Superclass::Modified(); } \
55 virtual bool GetDebug() const { return Superclass::GetDebug(); }
57 // Verbose options management
58 itkSetMacro(VerboseFlag, bool);
59 itkGetConstMacro(VerboseFlag, bool);
60 itkBooleanMacro(VerboseFlag);
63 itkSetMacro(VerboseOptionFlag, bool);
64 itkGetConstMacro(VerboseOptionFlag, bool);
65 itkBooleanMacro(VerboseOptionFlag);
68 itkSetMacro(VerboseMemoryFlag, bool);
69 itkGetConstMacro(VerboseMemoryFlag, bool);
70 itkBooleanMacro(VerboseMemoryFlag);
73 itkSetMacro(VerboseImageSizeFlag, bool);
74 itkGetConstMacro(VerboseImageSizeFlag, bool);
75 itkBooleanMacro(VerboseImageSizeFlag);
78 itkSetMacro(NumberOfSteps, int);
79 itkGetConstMacro(NumberOfSteps, int);
80 itkSetMacro(VerboseStepFlag, bool);
81 itkGetConstMacro(VerboseStepFlag, bool);
82 itkBooleanMacro(VerboseStepFlag);
84 itkSetMacro(WriteStepFlag, bool);
85 itkGetConstMacro(WriteStepFlag, bool);
86 itkBooleanMacro(WriteStepFlag);
88 itkSetMacro(CurrentStepNumber, int);
89 itkGetConstMacro(CurrentStepNumber, int);
90 itkSetMacro(CurrentStepId, std::string);
91 itkGetConstMacro(CurrentStepId, std::string);
92 itkSetMacro(CurrentStepBaseId, std::string);
93 itkGetConstMacro(CurrentStepBaseId, std::string);
94 itkSetMacro(CurrentStepName, std::string);
95 itkGetConstMacro(CurrentStepName, std::string);
100 // Convenient function for verbose option
101 template<class OptionType>
102 void VerboseOption(std::string name, OptionType value);
103 template<class OptionType>
104 void VerboseOption(std::string name, int nb, OptionType value);
105 template<class OptionType>
106 void VerboseOptionV(std::string name, int nb, OptionType * value);
108 void SetWarning(std::string e);
109 itkGetConstMacro(Warning, std::string);
110 itkSetMacro(VerboseWarningFlag, bool);
111 itkGetConstMacro(VerboseWarningFlag, bool);
112 itkBooleanMacro(VerboseWarningFlag);
114 // Use this function to cancel the filter between step
120 virtual ~FilterBase() {}
121 void StartNewStep(std::string s);
122 template<class TInternalImageType>
123 void StopCurrentStep(typename TInternalImageType::Pointer p, std::string txt="");
124 void StopCurrentStep();
127 bool m_VerboseOptionFlag;
128 bool m_VerboseStepFlag;
129 bool m_VerboseMemoryFlag;
130 bool m_VerboseImageSizeFlag;
131 bool m_WriteStepFlag;
132 int m_CurrentStepNumber;
134 std::string m_CurrentStepId;
135 std::string m_CurrentStepBaseId;
136 std::string m_CurrentStepName;
137 std::string m_Warning;
138 bool m_VerboseWarningFlag;
140 Timer m_CurrentStepTimer;
142 std::vector<int> m_SubstepNumbers;
143 std::vector<std::string> m_SubstepID;
146 FilterBase(const Self&); //purposely not implemented
147 void operator=(const Self&); //purposely not implemented
150 //--------------------------------------------------------------------
152 } // end namespace clitk
153 //--------------------------------------------------------------------
155 #ifndef ITK_MANUAL_INSTANTIATION
156 #include "clitkFilterBase.txx"
159 #endif // CLITKFILTERBASE_H