VTK/VTK 6 Migration/Change to AllocateOutputData

From KitwarePublic
< VTK
Revision as of 19:35, 6 April 2012 by Berk (talk | contribs) (Created page with "= Change to AllocateOutputData() in vtkImageAlgorithm = In VTK 6, we changed the signature of vtkImageAlgorithm’s two AllocateOutputData() methods from * void AllocateOutputD...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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

  • 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>