Orfeo Toolbox  4.0
itkProgressReporter.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #include "itkProgressReporter.h"
19 
20 namespace itk
21 {
22 //----------------------------------------------------------------------------
24  SizeValueType numberOfPixels,
25  SizeValueType numberOfUpdates,
26  float initialProgress,
27  float progressWeight):
28  m_Filter(filter),
29  m_ThreadId(threadId),
30  m_CurrentPixel(0),
31  m_InitialProgress(initialProgress),
32  m_ProgressWeight(progressWeight)
33 {
34  // Make sure we have at least one pixel.
35  const float numPixels = (numberOfPixels > 0) ? static_cast<float>(numberOfPixels) : 1.0F;
36  // We cannot update more times than there are pixels.
37  const float numUpdates = (numberOfUpdates>numberOfPixels) ? numPixels : static_cast<float>(numberOfUpdates);
38 
39  // Calculate the interval for updates.
40  m_PixelsPerUpdate = static_cast< SizeValueType >( numPixels / numUpdates );
41  m_InverseNumberOfPixels = 1.0f / numPixels;
42 
43  // Only thread 0 should update progress. (But all threads need to
44  // count pixels so they can check the abort flag.)
45  if ( m_ThreadId == 0 )
46  {
47  // Set the progress to initial progress. The filter is just starting.
49  }
50 
52 }
53 
54 //----------------------------------------------------------------------------
56 {
57  // Only thread 0 should update progress.
58  if ( m_ThreadId == 0 )
59  {
60  // Set the progress to the end of its current range. The filter has
61  // finished.
63  }
64 }
65 } // end namespace itk

Generated at Sat Mar 8 2014 15:23:52 for Orfeo Toolbox with doxygen 1.8.3.1