VTK/VTK 6 Migration/Removal of Execute: Difference between revisions
No edit summary |
(fix apparent typo) |
||
Line 57: | Line 57: | ||
<source lang="cpp"> | <source lang="cpp"> | ||
int vtkMyReader:: | int vtkMyReader::RequestData(vtkInformation*, | ||
vtkInformationVector**, inInfoVec, | vtkInformationVector**, inInfoVec, | ||
vtkInformationVector* outInfoVec) | vtkInformationVector* outInfoVec) |
Revision as of 17:25, 6 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 neither but overwrote RequestInformation() and RequestData() instead. 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>