VTK/VTK6/Migration/WikiExamples

From KitwarePublic
Jump to navigationJump to search

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

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
  source->Update();
  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

Control

Once the changes are reflected on the Wiki, a nightly dashboard built against VTK6 will catch any new API change issues.