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

Fixed and added to the vtkAlgorithm's update extent API.

Fixed: SetUpdateExtent() and its ilk were setting the update
extent on the input. Fixed it to be on the output. This is
more consistent with the executive API. Also updated other
code accordingly.

Change-Id: Iac92df21b8fa8dbeb58e4e27c5ffc796fadc4eaa
Added: API to get update extent from the output.
parent 5f6ae052
......@@ -1333,12 +1333,22 @@ vtkInformation* vtkAlgorithm::GetInputInformation(int port, int index)
//----------------------------------------------------------------------------
vtkAlgorithm* vtkAlgorithm::GetInputAlgorithm(int port, int index)
{
int dummy;
return this->GetInputAlgorithm(port, index, dummy);
}
//----------------------------------------------------------------------------
vtkAlgorithm* vtkAlgorithm::GetInputAlgorithm(int port,
int index,
int& algPort)
{
vtkAlgorithmOutput* aoutput = this->GetInputConnection(port, index);
if (!aoutput)
{
return 0;
}
algPort = aoutput->GetIndex();
return aoutput->GetProducer();
}
......@@ -1615,14 +1625,13 @@ double vtkAlgorithm::ComputePriority()
}
//-------------------------------------------------------------
int vtkAlgorithm::SetUpdateExtentToWholeExtent(
int port, int connection)
int vtkAlgorithm::SetUpdateExtentToWholeExtent(int port)
{
if (this->GetInputInformation(port, connection))
if (this->GetOutputInformation(port))
{
return
vtkStreamingDemandDrivenPipeline::SetUpdateExtentToWholeExtent(
this->GetInputInformation(port, connection));
this->GetOutputInformation(port));
}
else
{
......@@ -1633,19 +1642,19 @@ int vtkAlgorithm::SetUpdateExtentToWholeExtent(
//-------------------------------------------------------------
int vtkAlgorithm::SetUpdateExtentToWholeExtent()
{
return this->SetUpdateExtentToWholeExtent(0, 0);
return this->SetUpdateExtentToWholeExtent(0);
}
//-------------------------------------------------------------
void vtkAlgorithm::SetUpdateExtent(int port, int connection,
void vtkAlgorithm::SetUpdateExtent(int port,
int piece,
int numPieces,
int ghostLevel)
{
if (this->GetInputInformation(port, connection))
if (this->GetOutputInformation(port))
{
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
this->GetInputInformation(port, connection),
this->GetOutputInformation(port),
piece,
numPieces,
ghostLevel);
......@@ -1654,17 +1663,89 @@ void vtkAlgorithm::SetUpdateExtent(int port, int connection,
//-------------------------------------------------------------
void vtkAlgorithm::SetUpdateExtent(int port,
int connection,
int extent[6])
{
if (this->GetInputInformation(port, connection))
if (this->GetOutputInformation(port))
{
vtkStreamingDemandDrivenPipeline::SetUpdateExtent(
this->GetInputInformation(port, connection),
this->GetOutputInformation(port),
extent);
}
}
//----------------------------------------------------------------------------
int* vtkAlgorithm::GetUpdateExtent(int port)
{
if (this->GetOutputInformation(port))
{
return vtkStreamingDemandDrivenPipeline::GetUpdateExtent(
this->GetOutputInformation(port));
}
return 0;
}
//----------------------------------------------------------------------------
void vtkAlgorithm::GetUpdateExtent(int port,
int& x0, int& x1, int& y0, int& y1,
int& z0, int& z1)
{
if (this->GetOutputInformation(port))
{
int extent[6];
vtkStreamingDemandDrivenPipeline::GetUpdateExtent(
this->GetOutputInformation(port), extent);
x0 = extent[0];
x1 = extent[1];
y0 = extent[2];
y1 = extent[3];
z0 = extent[4];
z1 = extent[5];
}
}
//----------------------------------------------------------------------------
void vtkAlgorithm::GetUpdateExtent(int port, int extent[6])
{
if (this->GetOutputInformation(port))
{
vtkStreamingDemandDrivenPipeline::GetUpdateExtent(
this->GetOutputInformation(port), extent);
}
}
//----------------------------------------------------------------------------
int vtkAlgorithm::GetUpdatePiece(int port)
{
if (this->GetOutputInformation(port))
{
return vtkStreamingDemandDrivenPipeline::GetUpdatePiece(
this->GetOutputInformation(port));
}
return 0;
}
//----------------------------------------------------------------------------
int vtkAlgorithm::GetUpdateNumberOfPieces(int port)
{
if (this->GetOutputInformation(port))
{
return vtkStreamingDemandDrivenPipeline::GetUpdateNumberOfPieces(
this->GetOutputInformation(port));
}
return 1;
}
//----------------------------------------------------------------------------
int vtkAlgorithm::GetUpdateGhostLevel(int port)
{
if (this->GetOutputInformation(port))
{
return vtkStreamingDemandDrivenPipeline::GetUpdateGhostLevel(
this->GetOutputInformation(port));
}
return 0;
}
//----------------------------------------------------------------------------
void vtkAlgorithm::SetInputDataInternal(int port, vtkDataObject *input)
{
......
......@@ -328,6 +328,11 @@ public:
// Get the algorithm output port connected to an input port.
vtkAlgorithmOutput* GetInputConnection(int port, int index);
// Description:
// Returns the algorithm and the output port index of
// that algorithm connected to a port-index pair.
vtkAlgorithm* GetInputAlgorithm(int port, int index, int& algPort);
// Description:
// Returns the algorithm connected to a port-index pair.
vtkAlgorithm* GetInputAlgorithm(int port, int index);
......@@ -444,45 +449,83 @@ public:
static vtkInformationIntegerKey* MANAGES_METAINFORMATION();
// Description:
// If the whole input extent is required to generate the requested output
// extent, this method can be called to set the input update extent to the
// whole input extent. This method assumes that the whole extent is known
// (that UpdateInformation has been called).
// This function has no effect is input connection is not established.
int SetUpdateExtentToWholeExtent(int port, int connection);
// If the whole output extent is required, this method can be called to set
// the output update extent to the whole extent. This method assumes that
// the whole extent is known (that UpdateInformation has been called).
int SetUpdateExtentToWholeExtent(int port);
// Description:
// Convenience function equivalent to SetUpdateExtentToWholeExtent(0, 0)
// This function has no effect is input connection is not established.
// Convenience function equivalent to SetUpdateExtentToWholeExtent(0)
// This method assumes that the whole extent is known (that UpdateInformation
// has been called).
int SetUpdateExtentToWholeExtent();
// Description:
// Set the update extent in terms of piece and ghost levels.
// This function has no effect is input connection is not established.
void SetUpdateExtent(int port, int connection,
// Set the output update extent in terms of piece and ghost levels.
void SetUpdateExtent(int port,
int piece,int numPieces, int ghostLevel);
// Description:
// Convenience function equivalent to SetUpdateExtent(0, 0, piece,
// Convenience function equivalent to SetUpdateExtent(0, piece,
// numPieces, ghostLevel)
// This function has no effect is input connection is not established.
void SetUpdateExtent(int piece,int numPieces, int ghostLevel)
{
this->SetUpdateExtent(0, 0, piece, numPieces, ghostLevel);
this->SetUpdateExtent(0, piece, numPieces, ghostLevel);
}
// Description:
// Set the update extent for data objects that use 3D extents
// This function has no effect is input connection is not established.
void SetUpdateExtent(int port, int connection, int extent[6]);
// Set the output update extent for data objects that use 3D extents
void SetUpdateExtent(int port, int extent[6]);
// Description:
// Convenience function equivalent to SetUpdateExtent(0, 0, extent)
// This function has no effect is input connection is not established.
// Convenience function equivalent to SetUpdateExtent(0, extent)
void SetUpdateExtent(int extent[6])
{
this->SetUpdateExtent(0, 0, extent);
this->SetUpdateExtent(0, extent);
}
// Description:
// These functions return the update extent for output ports that
// use 3D extents. Where port is not specified, it is assumed to
// be 0.
int* GetUpdateExtent()
{
return this->GetUpdateExtent(0);
}
int* GetUpdateExtent(int port);
void GetUpdateExtent(int& x0, int& x1, int& y0, int& y1,
int& z0, int& z1)
{
this->GetUpdateExtent(0, x0, x1, y0, y1, z0, z1);
}
void GetUpdateExtent(int port,
int& x0, int& x1, int& y0, int& y1,
int& z0, int& z1);
void GetUpdateExtent(int extent[6])
{
this->GetUpdateExtent(0, extent);
}
void GetUpdateExtent(int port, int extent[6]);
// Description:
// These functions return the update extent for output ports that
// use piece extents. Where port is not specified, it is assumed to
// be 0.
int GetUpdatePiece()
{
return this->GetUpdatePiece(0);
}
int GetUpdatePiece(int port);
int GetUpdateNumberOfPieces()
{
return this->GetUpdateNumberOfPieces(0);
}
int GetUpdateNumberOfPieces(int port);
int GetUpdateGhostLevel()
{
return this->GetUpdateGhostLevel(0);
}
int GetUpdateGhostLevel(int port);
protected:
vtkAlgorithm();
......
......@@ -382,12 +382,11 @@ int vtkContourFilter::RequestData(
{
cgrid->SetValue(i, values[i]);
}
vtkStreamingDemandDrivenPipeline::SafeDownCast(
cgrid->GetExecutive())->SetUpdateExtent(
0,
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()),
info->Get(vtkStreamingDemandDrivenPipeline:: UPDATE_NUMBER_OF_PIECES()),
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()));
cgrid->SetUpdateExtent(
0,
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()),
info->Get(vtkStreamingDemandDrivenPipeline:: UPDATE_NUMBER_OF_PIECES()),
info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()));
cgrid->SetInputArrayToProcess(0,this->GetInputArrayInformation(0));
cgrid->Update();
output->ShallowCopy(cgrid->GetOutput());
......
......@@ -878,10 +878,6 @@ void vtkExtractArraysOverTime::ExecuteAtTimeStep(
filter->SetInputData(0, inputClone);
filter->SetInputData(1, selInputClone);
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(
filter->GetExecutive());
vtkDebugMacro(<< "Preparing subfilter to extract from dataset");
//pass all required information to the helper filter
int piece = -1;
......@@ -894,10 +890,7 @@ void vtkExtractArraysOverTime::ExecuteAtTimeStep(
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
npieces = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES());
if (sddp)
{
sddp->SetUpdateExtent(0, piece, npieces, 0);
}
filter->SetUpdateExtent(0, piece, npieces, 0);
}
if (outInfo->Has(
......@@ -905,10 +898,7 @@ void vtkExtractArraysOverTime::ExecuteAtTimeStep(
{
uExtent = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT());
if (sddp)
{
sddp->SetUpdateExtent(0, uExtent);
}
filter->SetUpdateExtent(0, uExtent);
}
filter->Update();
......
......@@ -382,10 +382,6 @@ vtkDataObject* vtkExtractSelection::RequestDataFromBlock(
tp->Delete();
tp = 0;
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(
subFilter->GetExecutive());
vtkDebugMacro(<< "Preparing subfilter to extract from dataset");
//pass all required information to the helper filter
int piece = -1;
......@@ -398,20 +394,14 @@ vtkDataObject* vtkExtractSelection::RequestDataFromBlock(
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
npieces = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES());
if (sddp)
{
sddp->SetUpdateExtent(0, piece, npieces, 0);
}
subFilter->SetUpdateExtent(0, piece, npieces, 0);
}
if (outInfo->Has(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT()))
{
uExtent = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT());
if (sddp)
{
sddp->SetUpdateExtent(0, uExtent);
}
subFilter->SetUpdateExtent(0, uExtent);
}
vtkDataObject* inputCopy = input->NewInstance();
......
......@@ -138,10 +138,6 @@ int vtkProbeSelectedLocations::RequestData(vtkInformation *vtkNotUsed(request),
tp->Delete();
tp = 0;
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(
subFilter->GetExecutive());
vtkDebugMacro(<< "Preparing subfilter to extract from dataset");
//pass all required information to the helper filter
int piece = -1;
......@@ -154,20 +150,14 @@ int vtkProbeSelectedLocations::RequestData(vtkInformation *vtkNotUsed(request),
vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER());
npieces = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES());
if (sddp)
{
sddp->SetUpdateExtent(0, piece, npieces, 0);
}
subFilter->SetUpdateExtent(0, piece, npieces, 0);
}
if (outInfo->Has(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT()))
{
uExtent = outInfo->Get(
vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT());
if (sddp)
{
sddp->SetUpdateExtent(0, uExtent);
}
subFilter->SetUpdateExtent(0, uExtent);
}
subFilter->Update();
......
......@@ -158,12 +158,7 @@ int vtkPProbeFilter::RequestUpdateExtent(vtkInformation *,
vtkInformation *sourceInfo = inputVector[1]->GetInformationObject(0);
vtkInformation *outInfo = outputVector->GetInformationObject(0);
vtkStreamingDemandDrivenPipeline* sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(this->GetExecutive());
if (sddp)
{
sddp->SetUpdateExtentToWholeExtent(inInfo);
}
vtkStreamingDemandDrivenPipeline::SetUpdateExtentToWholeExtent(inInfo);
//inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER(), 0);
//inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(), 1);
......
......@@ -95,7 +95,9 @@ void vtkAVIWriter::Start()
int wExtent[6];
this->GetInputInformation(0,0)->Get(
vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wExtent);
this->GetInputAlgorithm(0, 0)->SetUpdateExtentToWholeExtent();
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
inputAlg->SetUpdateExtentToWholeExtent(inputAlgPort);
LONG hr;
AVISTREAMINFO strhdr;
......
......@@ -465,10 +465,9 @@ void vtkImageExport::PropagateUpdateExtentCallback(int* extent)
{
if (this->GetInputAlgorithm())
{
vtkStreamingDemandDrivenPipeline::SafeDownCast(
this->GetInputAlgorithm()->GetExecutive())->SetUpdateExtent(
this->GetInputConnection(0, 0)->GetIndex(),
extent);
this->GetInputAlgorithm()->SetUpdateExtent(
this->GetInputConnection(0, 0)->GetIndex(),
extent);
}
}
......
......@@ -71,7 +71,8 @@ int vtkPDataSetWriter::Write()
ostream *fptr;
vtkDataSet *input = this->GetInput();
vtkAlgorithm *inputAlg = this->GetInputAlgorithm();
int inputAlgPort;
vtkAlgorithm *inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
if (this->FileName == NULL)
{
......@@ -246,7 +247,8 @@ int vtkPDataSetWriter::Write()
{
sprintf(fileName, this->FilePattern, fileRoot, i);
writer->SetFileName(fileName);
this->SetUpdateExtent(i, this->NumberOfPieces, this->GhostLevel);
inputAlg->SetUpdateExtent(inputAlgPort,
i, this->NumberOfPieces, this->GhostLevel);
inputAlg->Update();
copy = input->NewInstance();
copy->ShallowCopy(input);
......@@ -308,6 +310,8 @@ int vtkPDataSetWriter::WriteImageMetaData(vtkImageData * input,
int *pi;
double *pf;
vtkInformation* inInfo = this->GetInputInformation();
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
// We should indicate the type of data that is being saved.
*fptr << " dataType=\"" << input->GetClassName() << "\"" << endl;
......@@ -330,8 +334,8 @@ int vtkPDataSetWriter::WriteImageMetaData(vtkImageData * input,
for (i = 0; i < this->NumberOfPieces; ++i)
{
this->SetUpdateExtent(
i, this->NumberOfPieces, this->GhostLevel);
inputAlg->SetUpdateExtent(inputAlgPort,
i, this->NumberOfPieces, this->GhostLevel);
pi = vtkStreamingDemandDrivenPipeline::GetUpdateExtent(inInfo);
sprintf(str, this->FilePattern, root, i);
*fptr << " <Piece fileName=\"" << str << "\"" << endl
......@@ -353,6 +357,8 @@ int vtkPDataSetWriter::WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
{
int i;
int *pi;
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
// We should indicate the type of data that is being saved.
*fptr << " dataType=\"" << input->GetClassName() << "\"" << endl;
......@@ -368,8 +374,8 @@ int vtkPDataSetWriter::WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
*fptr << " numberOfPieces=\"" << this->NumberOfPieces << "\" >" << endl;
for (i = 0; i < this->NumberOfPieces; ++i)
{
this->SetUpdateExtent(
i, this->NumberOfPieces, this->GhostLevel);
inputAlg->SetUpdateExtent(inputAlgPort,
i, this->NumberOfPieces, this->GhostLevel);
pi = vtkStreamingDemandDrivenPipeline::GetUpdateExtent(
this->GetInputInformation());
sprintf(str, this->FilePattern, root, i);
......@@ -393,6 +399,8 @@ int vtkPDataSetWriter::WriteStructuredGridMetaData(vtkStructuredGrid *input,
{
int i;
int *pi;
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
// We should indicate the type of data that is being saved.
*fptr << " dataType=\"" << input->GetClassName() << "\"" << endl;
......@@ -408,7 +416,8 @@ int vtkPDataSetWriter::WriteStructuredGridMetaData(vtkStructuredGrid *input,
*fptr << " numberOfPieces=\"" << this->NumberOfPieces << "\" >" << endl;
for (i = 0; i < this->NumberOfPieces; ++i)
{
this->SetUpdateExtent(i, this->NumberOfPieces, this->GhostLevel);
inputAlg->SetUpdateExtent(inputAlgPort,
i, this->NumberOfPieces, this->GhostLevel);
pi = vtkStreamingDemandDrivenPipeline::GetUpdateExtent(
this->GetInputInformation());
sprintf(str, this->FilePattern, root, i);
......
......@@ -226,9 +226,7 @@ int ImageDataLIC2D(int argc, char* argv[])
for (int kk=0; kk < num_partitions; kk++)
{
vtkStreamingDemandDrivenPipeline* sddp = vtkStreamingDemandDrivenPipeline::SafeDownCast(
filter->GetExecutive());
sddp->SetUpdateExtent(0, kk, num_partitions, 0);
filter->SetUpdateExtent(0, kk, num_partitions, 0);
vtkTimerLog* timer = vtkTimerLog::New();
timer->StartTimer();
......@@ -237,7 +235,6 @@ int ImageDataLIC2D(int argc, char* argv[])
filter->GetLICSuccess() == 0 )
{
timer->Delete();
sddp = NULL;
timer = NULL;
return 0;
}
......
......@@ -211,16 +211,13 @@ static int StructuredGridLIC2DSlice(int argc, char* argv[])
for (int kk=0; kk < num_partitions; kk++)
{
vtkStreamingDemandDrivenPipeline * sddp =
vtkStreamingDemandDrivenPipeline::SafeDownCast(filter->GetExecutive());
sddp->SetUpdateExtent(0, kk, num_partitions, 0);
filter->SetUpdateExtent(0, kk, num_partitions, 0);
cout << "*****************" << endl;
filter->Update();
if ( filter->GetFBOSuccess() == 0 ||
filter->GetLICSuccess() == 0 )
{
sddp = NULL;
return 0;
}
......
......@@ -212,9 +212,11 @@ void vtkUnstructuredGridVolumeRayCastMapper::Render( vtkRenderer *ren, vtkVolume
return;
}
this->GetInputAlgorithm()->UpdateInformation();
this->SetUpdateExtentToWholeExtent();
this->GetInputAlgorithm()->Update();
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
inputAlg->UpdateInformation();
inputAlg->SetUpdateExtentToWholeExtent(inputAlgPort);
inputAlg->Update();
// Check to make sure we have an appropriate integrator.
if (this->RayIntegrator)
......
......@@ -2672,9 +2672,11 @@ void vtkUnstructuredGridVolumeZSweepMapper::Render(vtkRenderer *ren,
return;
}
this->GetInputAlgorithm()->UpdateInformation();
this->GetInputAlgorithm()->SetUpdateExtentToWholeExtent();
this->GetInputAlgorithm()->Update();
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
inputAlg->UpdateInformation();
inputAlg->SetUpdateExtentToWholeExtent(inputAlgPort);
inputAlg->Update();
// Check to make sure we have an appropriate integrator.
if (this->RayIntegrator)
......
......@@ -93,9 +93,11 @@ void vtkVolumeTextureMapper::Update(int port)
{
if ( this->GetInput() )
{
this->GetInputAlgorithm()->UpdateInformation();
this->SetUpdateExtentToWholeExtent();
this->GetInputAlgorithm()->Update(port);
int inputAlgPort;
vtkAlgorithm* inputAlg = this->GetInputAlgorithm(0, 0, inputAlgPort);
inputAlg->UpdateInformation();
inputAlg->SetUpdateExtentToWholeExtent(inputAlgPort);
inputAlg->Update(port);
}
}