00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkProgressReporter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2002/08/30 19:13:19 $ 00007 Version: $Revision: 1.2 $ 00008 00009 Copyright (c) 2002 Insight Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 #ifndef _itkProgressReporter_h 00018 #define _itkProgressReporter_h 00019 00020 #include "itkProcessObject.h" 00021 00022 namespace itk 00023 { 00024 00049 class ProgressReporter 00050 { 00051 public: 00053 ProgressReporter(ProcessObject* filter, int threadId, 00054 unsigned long numberOfPixels, 00055 unsigned long numberOfUpdates = 100); 00056 00058 ~ProgressReporter(); 00059 00061 void CompletedPixel() 00062 { 00063 // Inline implementation for efficiency. 00064 // We don't need to test for thread id 0 here because the 00065 // constructor sets m_PixelsBeforeUpdate to a value larger than 00066 // the number of pixels for threads other than 0. 00067 if(--m_PixelsBeforeUpdate == 0) 00068 { 00069 m_PixelsBeforeUpdate = m_PixelsPerUpdate; 00070 m_CurrentPixel += m_PixelsPerUpdate; 00071 m_Filter->UpdateProgress(m_CurrentPixel * m_InverseNumberOfPixels); 00072 } 00073 } 00074 protected: 00075 ProcessObject* m_Filter; 00076 int m_ThreadId; 00077 float m_InverseNumberOfPixels; 00078 unsigned long m_CurrentPixel; 00079 unsigned long m_PixelsPerUpdate; 00080 unsigned long m_PixelsBeforeUpdate; 00081 }; 00082 00083 } // end namespace itk 00084 00085 #endif