00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkIterationReporter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-02-05 19:04:58 $ 00007 Version: $Revision: 1.5 $ 00008 00009 Copyright (c) Insight Software 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 __itkIterationReporter_h 00018 #define __itkIterationReporter_h 00019 00020 #include "itkProcessObject.h" 00021 00022 namespace itk 00023 { 00024 00054 class ITKCommon_EXPORT IterationReporter 00055 { 00056 public: 00058 IterationReporter(ProcessObject* filter, int threadId, 00059 unsigned long stepsPerUpdate = 100); 00060 00062 ~IterationReporter() {}; 00063 00065 void CompletedStep() 00066 { 00067 // Inline implementation for efficiency. 00068 // We don't need to test for thread id 0 here because the 00069 // constructor sets m_StepsBeforeUpdate to a value larger than 00070 // the number of pixels for threads other than 0. 00071 if(--m_StepsBeforeUpdate == 0) 00072 { 00073 m_StepsBeforeUpdate = m_StepsPerUpdate; 00074 m_Filter->InvokeEvent( IterationEvent() ); 00075 } 00076 } 00077 protected: 00078 ProcessObject* m_Filter; 00079 int m_ThreadId; 00080 unsigned long m_StepsPerUpdate; 00081 unsigned long m_StepsBeforeUpdate; 00082 }; 00084 00085 } // end namespace itk 00086 00087 #endif 00088