Commit ce38ab1d authored by David Gobbi's avatar David Gobbi Committed by Code Review
Browse files

Merge topic 'threshold-connectivity-progress' into master

00ecfdbb ENH: Add a progress estimate to vtkImageThresholdConnectivity.
parents 1271c383 00ecfdbb
......@@ -18,8 +18,8 @@
#include "vtkMath.h"
#include "vtkImageData.h"
#include "vtkImageStencilData.h"
#include "vtkImageProgressIterator.h"
#include "vtkImageStencilIterator.h"
#include "vtkImageIterator.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
#include "vtkImageStencilData.h"
......@@ -334,7 +334,7 @@ void vtkImageThresholdConnectivityExecute(
// Set the "outside" with either the input or the OutValue
vtkImageIterator<IT> inIt(inData, outExt);
vtkImageProgressIterator<OT> outIt(outData, outExt, self, id);
vtkImageIterator<OT> outIt(outData, outExt);
while (!outIt.IsAtEnd())
{
IT* inSI = inIt.BeginSpan();
......@@ -430,6 +430,10 @@ void vtkImageThresholdConnectivityExecute(
static_cast<vtkIdType>(extent[3] - extent[2] + 1)*
static_cast<vtkIdType>(extent[5] - extent[4] + 1));
// for the progress meter
double progress = 0.0;
vtkIdType target = static_cast<vtkIdType>(fullsize/50.0);
target++;
// Setup the mask
maskData->SetWholeExtent(inData->GetWholeExtent());
......@@ -502,8 +506,8 @@ void vtkImageThresholdConnectivityExecute(
}
double point[3];
int nPoints = points->GetNumberOfPoints();
for (int p = 0; p < nPoints; p++)
vtkIdType nPoints = points->GetNumberOfPoints();
for (vtkIdType p = 0; p < nPoints; p++)
{
points->GetPoint(p,point);
vtkFloodFillSeed seed = vtkFloodFillSeed(
......@@ -519,7 +523,8 @@ void vtkImageThresholdConnectivityExecute(
}
}
int counter = 0;
vtkIdType counter = 0;
vtkIdType fullcount = 0;
while (!seedStack.empty())
{
......@@ -536,6 +541,18 @@ void vtkImageThresholdConnectivityExecute(
}
*maskPtr1 = 255;
fullcount++;
if (id == 0 && (fullcount % target) == 0)
{
double v = counter/(10.0*fullcount);
double p = fullcount/(v*fullsize + (1.0 - v)*fullcount);
if (p > progress)
{
progress = p;
self->UpdateProgress(progress);
}
}
IT *inPtr1 = inPtr + (seed[0]*inInc[0] +
seed[1]*inInc[1] +
seed[2]*inInc[2]);
......@@ -652,6 +669,11 @@ void vtkImageThresholdConnectivityExecute(
}
}
if (id == 0)
{
self->UpdateProgress(1.0);
}
voxelCount = counter;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment