Commit 0e867e58 authored by Karthik Krishnan's avatar Karthik Krishnan

Attempt to address thread issues in the space leaping filter

Bug report http://www.vtk.org/Bug/view.php?id=12115 related
to failures when using a large number of threads. The fix
enforces non-overlapping output extents, so that two threads
don't write to the same data at the seams.
Also address a valgrind detection of an uninitialized var. The
TableSize passed down must be initialized.
parent f4c16ec4
......@@ -684,6 +684,7 @@ vtkFixedPointVolumeRayCastMapper::vtkFixedPointVolumeRayCastMapper()
this->SavedGradientOpacityFunction[i] = NULL;
this->SavedColorChannels[i] = 0;
this->SavedScalarOpacityDistance[i] = 0;
this->TableSize[i] = 0;
}
this->SavedSampleDistance = 0;
......
......@@ -21,6 +21,9 @@
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkDataArray.h"
#include "vtkPointData.h"
#include <sstream>
#include <fstream>
#include <iostream>
#ifdef vtkVolumeRayCastSpaceLeapingImageFilter_DEBUG
#include "vtkMetaImageWriter.h"
......@@ -212,6 +215,7 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxExecute(
vtkImageData *outData, int outExt[6],
T )
{
// the number of independent components for which we need to keep track of
// min/max
vtkDataArray * scalars = self->GetCurrentScalars();
......@@ -274,6 +278,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxExecute(
sz1 += outExt[4];
sz2 += outExt[4];
// Bounds check
if ((int)sz2 > outExt[5])
{
sz2 = outExt[5];
}
tmpPtrK = outBasePtr + sz1 * outInc2;
for ( j = 0; j < inDim[1]; j++, dptr+= inInc1 )
......@@ -285,6 +295,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxExecute(
sy1 += outExt[2];
sy2 += outExt[2];
// Bounds check
if ((int)sy2 > outExt[3])
{
sy2 = outExt[3];
}
tmpPtrJ = tmpPtrK + sy1 * outInc1;
for ( i = 0; i < inDim[0]; i++ )
......@@ -296,6 +312,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxExecute(
sx1 += outExt[0];
sx2 += outExt[0];
// Bounds check
if ((int)sx2 > outExt[1])
{
sx2 = outExt[1];
}
tmpPtrI = tmpPtrJ + sx1 * outInc0;
for ( c = 0; c < nComponents; c++, tmpPtrI += 3 )
......@@ -409,6 +431,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMaxGradientMagnitudeExecute(
sz1 += outExt[4];
sz2 += outExt[4];
// Bounds check
if ((int)sz2 > outExt[5])
{
sz2 = outExt[5];
}
tmpPtrK = outBasePtr + sz1 * outInc2;
unsigned char *gptr = *gsptr;
......@@ -422,6 +450,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMaxGradientMagnitudeExecute(
sy1 += outExt[2];
sy2 += outExt[2];
// Bounds check
if ((int)sy2 > outExt[3])
{
sy2 = outExt[3];
}
tmpPtrJ = tmpPtrK + sy1 * outInc1;
for ( i = 0; i < inDim[0]; i++ )
......@@ -433,6 +467,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMaxGradientMagnitudeExecute(
sx1 += outExt[0];
sx2 += outExt[0];
// Bounds check
if ((int)sx2 > outExt[1])
{
sx2 = outExt[1];
}
tmpPtrI = tmpPtrJ + sx1 * outInc0;
for ( c = 0; c < nComponents; c++, tmpPtrI += 3 )
......@@ -544,6 +584,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxAndMaxGradientMagnitudeExecute(
sz1 += outExt[4];
sz2 += outExt[4];
// Bounds check
if ((int)sz2 > outExt[5])
{
sz2 = outExt[5];
}
tmpPtrK = outBasePtr + sz1 * outInc2;
unsigned char *gptr = *gsptr;
......@@ -557,6 +603,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxAndMaxGradientMagnitudeExecute(
sy1 += outExt[2];
sy2 += outExt[2];
// Bounds check
if ((int)sy2 > outExt[3])
{
sy2 = outExt[3];
}
tmpPtrJ = tmpPtrK + sy1 * outInc1;
for ( i = 0; i < inDim[0]; i++ )
......@@ -568,6 +620,12 @@ vtkVolumeRayCastSpaceLeapingImageFilterMinMaxAndMaxGradientMagnitudeExecute(
sx1 += outExt[0];
sx2 += outExt[0];
// Bounds check
if ((int)sx2 > outExt[1])
{
sx2 = outExt[1];
}
tmpPtrI = tmpPtrJ + sx1 * outInc0;
for ( c = 0; c < nComponents; c++, tmpPtrI += 3 )
......@@ -791,6 +849,9 @@ void vtkVolumeRayCastSpaceLeapingImageFilter::ThreadedRequestData(
vtkImageData **outData,
int outExt[6], int vtkNotUsed(id))
{
#ifdef vtkVolumeRayCastSpaceLeapingImageFilter_DEBUG
std::cout << "Thread id = " << id << std::endl;
#endif
// A. Initialize the data with a blank flag.
......
Markdown is supported
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