Commit 97927219 authored by Berk Geveci's avatar Berk Geveci
Browse files

Make RequestData() re-entrant.

vtkSynchronizedTemplates3D was using a data member (ExecuteExtent)
to "communicate" between RequestUpdateExtent() and RequestData().
This made it impossible to call RequestUpdateExtent() from multiple
threads simulataneously even when using different input/outputs.
Changed such that vtkSynchronizedTemplates3D is using an entry
in the output information object instead. This allows calling from
multiple threads as long as the information object is specific to
each thread.

In the process, I also removed bunch of references to
vtkKitwareContourFilter, which no longer exists.

Change-Id: I67672ebc48546e320403a80cae98c787e9c2edbe
parent 5b13c10e
......@@ -39,7 +39,7 @@
// normals of the resulting isosurface.
// .SECTION See Also
// vtkMarchingContourFilter vtkKitwareContourFilter
// vtkMarchingContourFilter
// vtkMarchingCubes vtkSliceCubes vtkDividingCubes vtkMarchingSquares
// vtkImageMarchingCubes
......
......@@ -31,7 +31,6 @@
#include "vtkPolyDataAlgorithm.h"
#include "vtkContourValues.h" // Because it passes all the calls to it
class vtkKitwareContourFilter;
class vtkStructuredGrid;
class VTKFILTERSCORE_EXPORT vtkGridSynchronizedTemplates3D : public vtkPolyDataAlgorithm
......
......@@ -33,7 +33,6 @@
#include "vtkContourValues.h" // Passes calls through
class vtkRectilinearGrid;
class vtkKitwareContourFilter;
class vtkDataArray;
class VTKFILTERSCORE_EXPORT vtkRectilinearSynchronizedTemplates : public vtkPolyDataAlgorithm
......
......@@ -21,6 +21,7 @@
#include "vtkExtentTranslator.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
#include "vtkInformationIntegerVectorKey.h"
#include "vtkInformationVector.h"
#include "vtkIntArray.h"
#include "vtkLongArray.h"
......@@ -42,6 +43,8 @@
vtkStandardNewMacro(vtkSynchronizedTemplates3D);
vtkInformationKeyRestrictedMacro(vtkSynchronizedTemplates3D, EXECUTE_EXTENT, IntegerVector, 6);
//----------------------------------------------------------------------------
// Description:
// Construct object with initial scalar range (0,1) and single contour value
......@@ -54,10 +57,6 @@ vtkSynchronizedTemplates3D::vtkSynchronizedTemplates3D()
this->ComputeScalars = 1;
this->GenerateTriangles = 1;
this->ExecuteExtent[0] = this->ExecuteExtent[1]
= this->ExecuteExtent[2] = this->ExecuteExtent[3]
= this->ExecuteExtent[4] = this->ExecuteExtent[5] = 0;
this->ArrayComponent = 0;
// by default process active point scalars
......@@ -691,7 +690,7 @@ unsigned long vtkSynchronizedTemplates3D::GetInputMemoryLimit()
void vtkSynchronizedTemplates3D::ThreadedExecute(vtkImageData *data,
vtkInformation *inInfo,
vtkInformation *outInfo,
int *exExt, vtkDataArray *inScalars)
vtkDataArray *inScalars)
{
void *ptr;
vtkPolyData *output;
......@@ -700,6 +699,7 @@ void vtkSynchronizedTemplates3D::ThreadedExecute(vtkImageData *data,
output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
int* exExt = outInfo->Get(vtkSynchronizedTemplates3D::EXECUTE_EXTENT());
if ( exExt[0] >= exExt[1] || exExt[2] >= exExt[3] || exExt[4] >= exExt[5] )
{
vtkDebugMacro(<<"3D structured contours requires 3D data");
......@@ -754,7 +754,7 @@ int vtkSynchronizedTemplates3D::RequestData(
vtkDataArray *inScalars = this->GetInputArrayToProcess(0,inputVector);
// Just call the threaded execute directly.
this->ThreadedExecute(input, inInfo, outInfo, this->ExecuteExtent, inScalars);
this->ThreadedExecute(input, inInfo, outInfo, inScalars);
output->Squeeze();
......@@ -813,13 +813,7 @@ int vtkSynchronizedTemplates3D::RequestUpdateExtent(
// This is the region that we are really updating, although
// we may require a larger input region in order to generate
// it if normals / gradients are being computed
this->ExecuteExtent[0] = ext[0];
this->ExecuteExtent[1] = ext[1];
this->ExecuteExtent[2] = ext[2];
this->ExecuteExtent[3] = ext[3];
this->ExecuteExtent[4] = ext[4];
this->ExecuteExtent[5] = ext[5];
outInfo->Set(vtkSynchronizedTemplates3D::EXECUTE_EXTENT(), ext, 6);
// expand if we need to compute gradients
if (this->ComputeGradients || this->ComputeNormals)
......
......@@ -124,12 +124,9 @@ public:
void GenerateValues(int numContours, double rangeStart, double rangeEnd)
{this->ContourValues->GenerateValues(numContours, rangeStart, rangeEnd);}
// Description:
// Needed by templated functions.
int *GetExecuteExtent() {return this->ExecuteExtent;}
void ThreadedExecute(vtkImageData *data, vtkInformation *inInfo,
vtkInformation *outInfo,
int *exExt, vtkDataArray *inScalars);
vtkDataArray *inScalars);
// Description:
// Determines the chunk size fro streaming. This filter will act like a
......@@ -156,11 +153,12 @@ protected:
virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
virtual int FillInputPortInformation(int port, vtkInformation *info);
int ExecuteExtent[6];
int ArrayComponent;
int GenerateTriangles;
static vtkInformationIntegerVectorKey* EXECUTE_EXTENT();
private:
vtkSynchronizedTemplates3D(const vtkSynchronizedTemplates3D&); // Not implemented.
void operator=(const vtkSynchronizedTemplates3D&); // Not implemented.
......
......@@ -536,8 +536,8 @@ void ContourImage(vtkSynchronizedTemplatesCutter3D *self, int *exExt,
// Contouring filter specialized for images (or slices from images)
//
void vtkSynchronizedTemplatesCutter3D::ThreadedExecute(vtkImageData *data,
vtkInformation *outInfo,
int *exExt, int)
vtkInformation *outInfo,
int)
{
vtkPolyData *output;
......@@ -545,6 +545,7 @@ void vtkSynchronizedTemplatesCutter3D::ThreadedExecute(vtkImageData *data,
output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
int* exExt = outInfo->Get(vtkSynchronizedTemplates3D::EXECUTE_EXTENT());
if ( exExt[0] >= exExt[1] || exExt[2] >= exExt[3] || exExt[4] >= exExt[5] )
{
vtkDebugMacro(<<"Cutter3D structured contours requires Cutter3D data");
......@@ -576,7 +577,7 @@ int vtkSynchronizedTemplatesCutter3D::RequestData(
this->RequestUpdateExtent(request,inputVector,outputVector);
// Just call the threaded execute directly.
this->ThreadedExecute(input, outInfo, this->ExecuteExtent, 0);
this->ThreadedExecute(input, outInfo, 0);
output->Squeeze();
......
......@@ -40,8 +40,7 @@ public:
// Description:
// Needed by templated functions.
void ThreadedExecute(vtkImageData *data, vtkInformation *outInfo,
int *exExt, int);
void ThreadedExecute(vtkImageData *data, vtkInformation *outInfo, int);
// Description
// Specify the implicit function to perform the cutting.
......
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