Orfeo Toolbox
3.16
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
OTB
Utilities
ITK
Code
Common
itkProgressReporter.cxx
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Insight Segmentation & Registration Toolkit
4
Module: $RCSfile: itkProgressReporter.cxx,v $
5
Language: C++
6
Date: $Date: 2009-11-24 02:27:27 $
7
Version: $Revision: 1.9 $
8
9
Copyright (c) Insight Software Consortium. All rights reserved.
10
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12
This software is distributed WITHOUT ANY WARRANTY; without even
13
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
PURPOSE. See the above copyright notices for more information.
15
16
=========================================================================*/
17
#include "
itkProgressReporter.h
"
18
#include "itkNumericTraits.h"
19
20
namespace
itk
21
{
22
23
//----------------------------------------------------------------------------
24
ProgressReporter::ProgressReporter
(
ProcessObject
* filter,
int
threadId,
25
unsigned
long
numberOfPixels,
26
unsigned
long
numberOfUpdates,
27
float
initialProgress,
28
float
progressWeight):
29
m_Filter(filter),
30
m_ThreadId(threadId),
31
m_CurrentPixel(0),
32
m_InitialProgress( initialProgress ),
33
m_ProgressWeight( progressWeight )
34
{
35
36
float
numPixels = numberOfPixels;
37
float
numUpdates = numberOfUpdates;
38
39
// Make sure we have at least one pixel.
40
if
(numPixels < 1)
41
{
42
numPixels = 1;
43
}
44
45
// We cannot update more times than there are pixels.
46
if
(numUpdates > numPixels)
47
{
48
numUpdates = numPixels;
49
}
50
51
// Calculate the interval for updates.
52
m_PixelsPerUpdate
=
static_cast<
unsigned
long
>
(numPixels/numUpdates);
53
m_InverseNumberOfPixels
= 1.0f / numPixels;
54
55
// Only thread 0 should update progress. (But all threads need to
56
// count pixels so they can check the abort flag.)
57
if
(
m_ThreadId
== 0)
58
{
59
// Set the progress to initial progress. The filter is just starting.
60
m_Filter
->
UpdateProgress
(
m_InitialProgress
);
61
}
62
63
m_PixelsBeforeUpdate
=
m_PixelsPerUpdate
;
64
}
65
66
//----------------------------------------------------------------------------
67
ProgressReporter::~ProgressReporter
()
68
{
69
// Only thread 0 should update progress.
70
if
(
m_ThreadId
== 0)
71
{
72
// Set the progress to the end of its current range. The filter has finished.
73
m_Filter
->
UpdateProgress
(
m_InitialProgress
+
m_ProgressWeight
);
74
}
75
}
76
77
}
// end namespace itk
Generated at Sun Feb 3 2013 00:00:03 for
Orfeo Toolbox
with
doxygen 1.8.1.1