VTK/VTK 6 Migration/Removal of Execute

From KitwarePublic
< VTK
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Removal of ExecuteInformation() and ExecuteData() from Algorithm Superclasses

Some of the algorithm superclasses such as vtkPointSetAlgorithm defined the ExecuteInformation() and ExecuteData() virtual functions. These were implemented in order to make transition from VTK 4 to 5 easy. However, none of the subclasses of these algorithms actually overwrote them but instead overwrote RequestInformation() and RequestData(). To complete this transition, we removed ExecuteInformation() and ExecuteData() from the following superclasses:

  • vtkDataObjectAlgorithm
  • vtkGenericDataSetAlgorithm
  • vtkHyperOctreeAlgorithm
  • vtkPiecewiseFunctionAlgorithm
  • vtkPolyDataAlgorithm
  • vtkRectilinearGridAlgorithm
  • vtkSelectionAlgorithm
  • vtkStructuredGridAlgorithm
  • vtkUnstructuredGridAlgorithm

Any subclasses of the above classes that overrode ExecuteInformation() or ExecuteData() will have to changed to use RequestInformation() and RequestData(). You should also use this opportunity to use the input and output information objects to access input and output data objects, rather than using GetInput() and GetOutput(). Note that vtkImageAlgorithm still supports ExecuteData() and Execute().

Example 1

Replace

<source lang="cpp"> void vtkMyReader::ExecuteInformation() {

  vtkImageData* output = this->GetOutput();
  output->SetWholeExtent(…);
  output->SetScalarType(VTK_UNSIGNED_CHAR);

} </source>

with

<source lang="cpp"> int vtkMyReader::RequestInformation(vtkInformation*, vtkInformationVector**,

      vtkInformationVector* outInfoVec)

{

  vtkInformation* outInfo = outInfoVec->GetInformationObject(0);
  outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), …);
   vtkDataObject::SetPointDataActiveScalarInfo(
      outInfo, VTK_UNSIGNED_CHAR, 1);
  return 1;

} </source>

Example 2

Replace

<source lang="cpp"> void vtkMyAlgorithm::Execute() {

  vtkImageData* input= this->GetInput();
  vtkPolyData* output = this->GetOutput();

</source>

with

<source lang="cpp"> int vtkMyReader::RequestData(vtkInformation*,

     vtkInformationVector**, inInfoVec, 
      vtkInformationVector* outInfoVec)

{

   vtkImageData* input = vtkImageData::GetData(inInfoVec[0]);
   vtkPolyData* output = vtkPolyData::GetData(outInfoVec);

</source>