[vtkusers] Implementing vtkImageAlgorithm::RequestData vs ExecuteDataWithInformation

Elvis Stansvik elvis.stansvik at orexplore.com
Tue Jul 5 03:48:21 EDT 2016


The ExecuteDataWithInformation function is described as a convenience
function that image readers can implement instead of RequestData. The
former is called by the latter as follows:

//----------------------------------------------------------------------------
// This is the superclasses style of Execute method.  Convert it into
// an imaging style Execute method.
int vtkImageAlgorithm::RequestData(
  vtkInformation* request,
  vtkInformationVector** vtkNotUsed( inputVector ),
  vtkInformationVector* outputVector)
{
  // the default implimentation is to do what the old pipeline did find what
  // output is requesting the data, and pass that into ExecuteData

  // which output port did the request come from
  int outputPort =
    request->Get(vtkDemandDrivenPipeline::FROM_OUTPUT_PORT());

  // if output port is negative then that means this filter is calling the
  // update directly, in that case just assume port 0
  if (outputPort == -1)
      {
      outputPort = 0;
      }

  // get the data object
  vtkInformation *outInfo =
    outputVector->GetInformationObject(outputPort);
  // call ExecuteData
  this->SetErrorCode( vtkErrorCode::NoError );
  if (outInfo)
    {
    this->ExecuteDataWithInformation(
outInfo->Get(vtkDataObject::DATA_OBJECT()),
                                      outInfo );
    }
  else
    {
    this->ExecuteData(NULL);
    }
  // Check for any error set by downstream filter (IO in most case)
  if ( this->GetErrorCode() )
    {
    return 0;
    }

  return 1;
}

So all it does is get the output port from which the request came from,
request the output information and output data object and pass it along to
ExecuteDataWithInformation. In my case I only have one output port (port
0), so that's what I used when I implemented RequestData.

I'm wondering if I should switch to implementing
ExecuteDataWithInformation. The last thing it does is check for errors set
by downstream filters with GetErrorCode(). Is this something I should be
doing? I can't see that any of the other image readers that have chosen to
implement RequestData are doing this (vtkDEMReader, vtkVolume16Reader, ...).

Thanks for any advice,
Elvis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160705/ad895fd3/attachment.html>


More information about the vtkusers mailing list