Difference between revisions of "VTK/VTK 6 Migration/Removal of Execute"

From KitwarePublic
< VTK
Jump to navigationJump to search
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
= Removal of ExecuteInformation() and ExecuteData() from Algorithm Superclasses =
 
= 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 neither but overwrote RequestInformation() and RequestData() instead. To complete this transition, we removed ExecuteInformation() and ExecuteData() from the following 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
 
* vtkDataObjectAlgorithm
Line 57: Line 57:
  
 
<source lang="cpp">
 
<source lang="cpp">
int vtkMyReader::RequestInformation(vtkInformation*,  
+
int vtkMyReader::RequestData(vtkInformation*,  
 
       vtkInformationVector**, inInfoVec,  
 
       vtkInformationVector**, inInfoVec,  
 
       vtkInformationVector* outInfoVec)
 
       vtkInformationVector* outInfoVec)

Latest revision as of 10:59, 11 June 2012

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

void vtkMyReader::ExecuteInformation()
{
   vtkImageData* output = this->GetOutput();
   output->SetWholeExtent();
   output->SetScalarType(VTK_UNSIGNED_CHAR);
}

with

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;
}

Example 2

Replace

void vtkMyAlgorithm::Execute()
{

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

with

int vtkMyReader::RequestData(vtkInformation*, 
      vtkInformationVector**, inInfoVec, 
       vtkInformationVector* outInfoVec)
{
    vtkImageData* input = vtkImageData::GetData(inInfoVec[0]);
    vtkPolyData* output = vtkPolyData::GetData(outInfoVec);