00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _itkProgressReporter_h
00018 #define _itkProgressReporter_h
00019
00020 #include "itkProcessObject.h"
00021
00022 namespace itk
00023 {
00024
00058 class ITKCommon_EXPORT ProgressReporter
00059 {
00060 public:
00062 ProgressReporter(ProcessObject* filter, int threadId,
00063 unsigned long numberOfPixels,
00064 unsigned long numberOfUpdates = 100,
00065 float initialProgress = 0.0f,
00066 float progressWeight = 1.0f );
00067
00069 ~ProgressReporter();
00070
00072 void CompletedPixel()
00073 {
00074
00075 if(--m_PixelsBeforeUpdate == 0)
00076 {
00077 m_PixelsBeforeUpdate = m_PixelsPerUpdate;
00078 m_CurrentPixel += m_PixelsPerUpdate;
00079
00080 if (m_ThreadId == 0)
00081 {
00082 m_Filter->UpdateProgress(
00083 m_CurrentPixel * m_InverseNumberOfPixels * m_ProgressWeight + m_InitialProgress);
00084 }
00085
00086 if( m_Filter->GetAbortGenerateData() )
00087 {
00088 throw ProcessAborted();
00089 }
00090 }
00091 }
00092
00093 protected:
00094 ProcessObject* m_Filter;
00095 int m_ThreadId;
00096 float m_InverseNumberOfPixels;
00097 unsigned long m_CurrentPixel;
00098 unsigned long m_PixelsPerUpdate;
00099 unsigned long m_PixelsBeforeUpdate;
00100 float m_InitialProgress;
00101 float m_ProgressWeight;
00102
00103 private:
00104 ProgressReporter();
00105
00106 };
00107
00108 }
00109
00110 #endif