[vtkusers] Implementing vtkImageAlgorithm::RequestData vs ExecuteDataWithInformation
Elvis Stansvik
elvis.stansvik at orexplore.com
Tue Jul 5 04:04:25 EDT 2016
2016-07-05 9:48 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:
> 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
>
Sorry I meant "the last thing vtkImageAlgorithm::RequestData does", not
"the last thing it does".
Elvis
> 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/0e5e6687/attachment.html>
More information about the vtkusers
mailing list