VTK/VTK 6 Migration/Change to AllocateOutputData

From KitwarePublic
< VTK
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Change to AllocateOutputData() in vtkImageAlgorithm

In VTK 6, we changed the signature of vtkImageAlgorithm’s two AllocateOutputData() methods from

  • void AllocateOutputData(vtkImageData *out, int *uExtent);
  • vtkImageData *AllocateOutputData(vtkDataObject *out);

to

  • void AllocateOutputData(vtkImageData *out, vtkInformation* outInfo, int *uExtent);
  • vtkImageData *AllocateOutputData(vtkDataObject *out, vtkInformation *outInfo);

This change was made to ensure that AllocateOutputData() has direct access to the output pipeline information from which it extracts meta-data about update extent, scalar type and number of scalar components. Even though the algorithm can directly access its pipeline information through the executive, this is discouraged because the executives are free to pass other information vectors to RequestData(). Note that if you overwrote Execute() or ExecuteData(vtkDataObject *output), you don’t have access to the output information. In order to make this easier, we added a new virtual function that takes output information as an argument:

  • ExecuteData(vtkDataObject *output, vtkInformation* outInfo);

Example 1

Replace

<source lang="cpp"> void vtkImageGridSource::ExecuteData(vtkDataObject *output) {

 vtkImageData *data = this->AllocateOutputData(output);

</source>

with

<source lang="cpp"> void vtkImageGridSource::ExecuteData(vtkDataObject *output,

                                    vtkInformation* outInfo)

{

 vtkImageData *data = this->AllocateOutputData(output, outInfo);

</source>