VTK/VTK6/Migration/WikiExamples: Difference between revisions
(11 intermediate revisions by the same user not shown) | |||
Line 17: | Line 17: | ||
==Measure== | ==Measure== | ||
As part of NA-MIC Project Week, the VTK Wiki Examples were built against VTK6. | As part of NA-MIC Project Week, the VTK Wiki Examples were built against VTK6. | ||
There are | There are 564 wiki examples. | ||
* 661 compilation errors | * 661 compilation errors | ||
* 303 files had errors | * 303 files had errors | ||
==Analyze== | ==Analyze== | ||
The VTK6 API changes accounted for 349 errors. | The VTK6 API changes accounted for 349 errors in 203 examples. | ||
The errors included the following: | The errors included the following: | ||
* 380 SetInput missing | * 380 SetInput missing | ||
Line 37: | Line 37: | ||
* 2 GetWholeExtent missing | * 2 GetWholeExtent missing | ||
* 2 vtkPLOT3DReader missing | * 2 vtkPLOT3DReader missing | ||
In addition two bugs in VTK6 were found: | |||
* VTK_MAJOR_VERSION was still set at 5, VTK_MINOR_VERSION at 9. A patch to set them to 6 and 0 was submitted. | |||
* Several image related examples were failing. Some image source's did not set the origin and spacing. Downstream filters failed in a variety of ways since the spacing and origin info did not exist. | |||
For example code like this: | |||
double *spacing = inInfo->Get(vtkDataObject::SPACING()); | |||
returned a NULL pointer. | |||
and code like this: | |||
double origin[3]; | |||
inInfo->Get(vtkDataObject::ORIGIN(), origin); | |||
left origin uninitialized | |||
==Improve== | ==Improve== | ||
303 files were edited. API changes were surrounded by | '''NOTE: Recent changes to VTK6 require ''#include <vtkVersion.h>'' to use the VTK_xxx_VERSION preprocessor directives.''' | ||
303 files were manually edited. API changes were surrounded by | |||
#if VTK_MAJOR_VERSION <= 5 | #if VTK_MAJOR_VERSION <= 5 | ||
Line 46: | Line 62: | ||
VTK6 code... | VTK6 code... | ||
#endif | #endif | ||
Here are some representative changes: | |||
* '''SetInput''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
delaunay->SetInput(aPolyData); | |||
delaunay->SetSource(boundary); | |||
#else | |||
delaunay->SetInputData(aPolyData); | |||
delaunay->SetSourceData(boundary); | |||
#endif | |||
</pre> | |||
* '''AddInput''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
appendFilter->AddInput(polydata); | |||
appendFilter->AddInput(ug); | |||
#else | |||
appendFilter->AddInputData(polydata); | |||
appendFilter->AddInputData(ug); | |||
#endif | |||
</pre> | |||
* '''GetProducerPort''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
sourceMapper->SetInputConnection(source->GetProducerPort()); | |||
#else | |||
// Make sure the filter that produced source is up-to-date | |||
sourceMapper->SetInputData(source); | |||
#endif | |||
</pre> | |||
* '''AllocateScalars''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
image->SetNumberOfScalarComponents(1); | |||
image->SetScalarTypeToInt(); | |||
image->AllocateScalars(); | |||
#else | |||
image->AllocateScalars(VTK_INT,1); | |||
#endif | |||
</pre> | |||
* '''GetWholeExtent''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
imageClip->SetOutputWholeExtent(jPEGReader->GetOutput()->GetWholeExtent()); | |||
#else | |||
jPEGReader->UpdateInformation(); | |||
imageClip->SetOutputWholeExtent( | |||
jPEGReader->GetOutputInformation(0)->Get( | |||
vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())); | |||
#endif | |||
</pre> | |||
* '''PLOT3DReader''' | |||
<pre> | |||
#if VTK_MAJOR_VERSION <= 5 | |||
#include <vtkPLOT3DReader.h> | |||
#else | |||
#include <vtkMultiBlockPLOT3DReader.h> | |||
#include <vtkMultiBlockDataSet.h> | |||
#endif | |||
... | |||
#if VTK_MAJOR_VERSION <= 5 | |||
vtkSmartPointer<vtkPLOT3DReader> reader = | |||
vtkSmartPointer<vtkPLOT3DReader>::New(); | |||
#else | |||
vtkSmartPointer<vtkMultiBlockPLOT3DReader> reader = | |||
vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New(); | |||
#endif | |||
... | |||
#if VTK_MAJOR_VERSION <= 5 | |||
filter->SetInputConnection(reader->GetOutputPort()); | |||
#else | |||
filter->SetInputData(reader->GetOutput()->GetBlock(0)); | |||
#endif | |||
</pre> | |||
==Control== | ==Control== | ||
Once the changes are reflected on the Wiki, a nightly dashboard built against VTK6 will catch any new API change issues. | Once the changes are reflected on the Wiki, a nightly dashboard built against VTK6 will catch any new API change issues. |
Latest revision as of 18:24, 26 April 2012
VTK6 represents a major upgrade to VTK. VTK6 makes several API changes and also removes some deprecated API's.
This experiment measures the impact of VTK6 API changes to the VTK Wiki Examples.
This experiment uses the DMAIC methodology of the Six Sigma management process to "Define", "Measure", "Analyze", "Improve" and "Control" valgrind defects in VTK.
The basic methodology (from Wikipedia) consists of the following five steps:
- Define process goals that are consistent with customer demands and VTK's strategy.
- Measure key aspects of the current process and collect relevant data.
- Analyze the data to verify cause-and-effect relationships. Determine what the relationships are, and attempt to ensure that all factors have been considered.
- Improve or optimize the process.
- Control to ensure that any deviations from target are corrected before they result in defects. Set up pilot runs to establish software quality, move on to production, set up control mechanisms and continuously monitor the process.
Define
Convert the VTK Wiki Examples to VTK6 while still maintaining VTK5 compatibility.
Measure
As part of NA-MIC Project Week, the VTK Wiki Examples were built against VTK6. There are 564 wiki examples.
- 661 compilation errors
- 303 files had errors
Analyze
The VTK6 API changes accounted for 349 errors in 203 examples. The errors included the following:
- 380 SetInput missing
- about 100 of these were due to using SetInput/GetOutput rather than SetInputConnection/GetOutputPort
- 138 GetProducerPort missing
- 51 AllocateScalars missing
- 23 Add Input missing
- 11 SetSource missing
- 6 Update missing
- 4 SetStencil missing
- 4 SetVectorInput missing
- 2 SetMagnitudeInput missing
- 2 SetImageInput missing
- 2 GetWholeExtent missing
- 2 vtkPLOT3DReader missing
In addition two bugs in VTK6 were found:
- VTK_MAJOR_VERSION was still set at 5, VTK_MINOR_VERSION at 9. A patch to set them to 6 and 0 was submitted.
- Several image related examples were failing. Some image source's did not set the origin and spacing. Downstream filters failed in a variety of ways since the spacing and origin info did not exist.
For example code like this: double *spacing = inInfo->Get(vtkDataObject::SPACING()); returned a NULL pointer. and code like this: double origin[3]; inInfo->Get(vtkDataObject::ORIGIN(), origin); left origin uninitialized
Improve
NOTE: Recent changes to VTK6 require #include <vtkVersion.h> to use the VTK_xxx_VERSION preprocessor directives.
303 files were manually edited. API changes were surrounded by
#if VTK_MAJOR_VERSION <= 5 VTK5 code... #else VTK6 code... #endif
Here are some representative changes:
- SetInput
#if VTK_MAJOR_VERSION <= 5 delaunay->SetInput(aPolyData); delaunay->SetSource(boundary); #else delaunay->SetInputData(aPolyData); delaunay->SetSourceData(boundary); #endif
- AddInput
#if VTK_MAJOR_VERSION <= 5 appendFilter->AddInput(polydata); appendFilter->AddInput(ug); #else appendFilter->AddInputData(polydata); appendFilter->AddInputData(ug); #endif
- GetProducerPort
#if VTK_MAJOR_VERSION <= 5 sourceMapper->SetInputConnection(source->GetProducerPort()); #else // Make sure the filter that produced source is up-to-date sourceMapper->SetInputData(source); #endif
- AllocateScalars
#if VTK_MAJOR_VERSION <= 5 image->SetNumberOfScalarComponents(1); image->SetScalarTypeToInt(); image->AllocateScalars(); #else image->AllocateScalars(VTK_INT,1); #endif
- GetWholeExtent
#if VTK_MAJOR_VERSION <= 5 imageClip->SetOutputWholeExtent(jPEGReader->GetOutput()->GetWholeExtent()); #else jPEGReader->UpdateInformation(); imageClip->SetOutputWholeExtent( jPEGReader->GetOutputInformation(0)->Get( vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())); #endif
- PLOT3DReader
#if VTK_MAJOR_VERSION <= 5 #include <vtkPLOT3DReader.h> #else #include <vtkMultiBlockPLOT3DReader.h> #include <vtkMultiBlockDataSet.h> #endif ... #if VTK_MAJOR_VERSION <= 5 vtkSmartPointer<vtkPLOT3DReader> reader = vtkSmartPointer<vtkPLOT3DReader>::New(); #else vtkSmartPointer<vtkMultiBlockPLOT3DReader> reader = vtkSmartPointer<vtkMultiBlockPLOT3DReader>::New(); #endif ... #if VTK_MAJOR_VERSION <= 5 filter->SetInputConnection(reader->GetOutputPort()); #else filter->SetInputData(reader->GetOutput()->GetBlock(0)); #endif
Control
Once the changes are reflected on the Wiki, a nightly dashboard built against VTK6 will catch any new API change issues.