Difference between revisions of "VTK6 Migration Guide"

From mitk.org
Jump to navigation Jump to search
m
Line 1: Line 1:
__NOTOC__
 
<!-- ## page was renamed from internal/VTK6 -->
 
 
__NOTOC__
 
__NOTOC__
  
Line 11: Line 9:
 
vtkFloatingPointType has to be replaced with double
 
vtkFloatingPointType has to be replaced with double
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
-    vtkFloatingPointType point[3];
 
-    vtkFloatingPointType point[3];
 
+    double point[3];
 
+    double point[3];
</nowiki></pre>
+
</syntaxhighlight>
  
  
Line 20: Line 18:
 
When vtk version macros (like VTK_MAJOR_VERSION) are used, the following header has to be included:
 
When vtk version macros (like VTK_MAJOR_VERSION) are used, the following header has to be included:
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
+#include <vtkVersionMacros.h>
 
+#include <vtkVersionMacros.h>
</nowiki></pre>
+
</syntaxhighlight>
  
  
Line 31: Line 29:
 
=== Example 1 ===
 
=== Example 1 ===
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
anotherFilter->SetInput(aFilter->GetOutput());
 
anotherFilter->SetInput(aFilter->GetOutput());
</nowiki></pre>
+
</syntaxhighlight>
  
 
should become
 
should become
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
anotherFilter->SetInputConnection(aFilter->GetOutputPort());
 
anotherFilter->SetInputConnection(aFilter->GetOutputPort());
</nowiki></pre>
+
</syntaxhighlight>
  
  
 
=== Example 2 ===
 
=== Example 2 ===
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
vtkDataObject* output = aFilter->GetOutput();
 
vtkDataObject* output = aFilter->GetOutput();
 
anotherFilter->SetInput(output);
 
anotherFilter->SetInput(output);
</nowiki></pre>
+
</syntaxhighlight>
  
 
should become
 
should become
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
anotherFilter->SetInputConnection(aFilter->GetOutputPort());
 
anotherFilter->SetInputConnection(aFilter->GetOutputPort());
</nowiki></pre>
+
</syntaxhighlight>
  
  
 
=== Example 3 ===
 
=== Example 3 ===
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
vtkPolyData *pd = vtkPolyData::New();
 
vtkPolyData *pd = vtkPolyData::New();
 
aFilter->SetInput(pd);
 
aFilter->SetInput(pd);
</nowiki></pre>
+
</syntaxhighlight>
  
 
should become
 
should become
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
vtkPolyData *pd = vtkPolyData::New();
 
vtkPolyData *pd = vtkPolyData::New();
 
aFilter->SetInputData(pd);
 
aFilter->SetInputData(pd);
</nowiki></pre>
+
</syntaxhighlight>
  
  
Line 78: Line 76:
 
Deprecated Macro. Just remove it.
 
Deprecated Macro. Just remove it.
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
-vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision$");
 
-vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision$");
</nowiki></pre>
+
</syntaxhighlight>
  
  
Line 86: Line 84:
 
Renamed macro
 
Renamed macro
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
-  vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
 
-  vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D);
 
+  vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
 
+  vtkTypeMacro(vtkPVAxesActor,vtkProp3D);
</nowiki></pre>
+
</syntaxhighlight>
  
  
Line 98: Line 96:
 
Replace
 
Replace
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,  
 
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,  
 
       vtkInformationVector* outInfoVec)
 
       vtkInformationVector* outInfoVec)
Line 105: Line 103:
 
   output->GetScalarType();
 
   output->GetScalarType();
 
   output->GetNumberOfScalarComponents();
 
   output->GetNumberOfScalarComponents();
</nowiki></pre>
+
</syntaxhighlight>
  
 
with
 
with
  
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,  
 
int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,  
 
       vtkInformationVector* outInfoVec)
 
       vtkInformationVector* outInfoVec)
Line 116: Line 114:
 
     vtkImageData::GetScalarType(outInfo);
 
     vtkImageData::GetScalarType(outInfo);
 
     vtkImageData::GetNumberOfScalarComponents(outInfo);
 
     vtkImageData::GetNumberOfScalarComponents(outInfo);
</nowiki></pre>
+
</syntaxhighlight>
  
  
 
=== Example 2 ===
 
=== Example 2 ===
<pre><nowiki>
+
<syntaxhighlight lang="cpp">
 
int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**,  
 
int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**,  
 
       vtkInformationVector* outInfoVec)
 
       vtkInformationVector* outInfoVec)
Line 128: Line 126:
 
output->GetScalarType();
 
output->GetScalarType();
 
output->GetNumberOfScalarComponents();
 
output->GetNumberOfScalarComponents();
</nowiki></pre>
+
</syntaxhighlight>
  
 
This code does not need to be changed.
 
This code does not need to be changed.

Revision as of 17:10, 4 December 2014


VTK Documentation


FloatingPointType

vtkFloatingPointType has to be replaced with double

<syntaxhighlight lang="cpp"> - vtkFloatingPointType point[3]; + double point[3]; </syntaxhighlight>


versionMacros

When vtk version macros (like VTK_MAJOR_VERSION) are used, the following header has to be included:

<syntaxhighlight lang="cpp"> +#include <vtkVersionMacros.h> </syntaxhighlight>


Pipeline changes

VTk Docu


Example 1

<syntaxhighlight lang="cpp"> anotherFilter->SetInput(aFilter->GetOutput()); </syntaxhighlight>

should become

<syntaxhighlight lang="cpp"> anotherFilter->SetInputConnection(aFilter->GetOutputPort()); </syntaxhighlight>


Example 2

<syntaxhighlight lang="cpp"> vtkDataObject* output = aFilter->GetOutput(); anotherFilter->SetInput(output); </syntaxhighlight>

should become

<syntaxhighlight lang="cpp"> anotherFilter->SetInputConnection(aFilter->GetOutputPort()); </syntaxhighlight>


Example 3

<syntaxhighlight lang="cpp"> vtkPolyData *pd = vtkPolyData::New(); aFilter->SetInput(pd); </syntaxhighlight>

should become

<syntaxhighlight lang="cpp"> vtkPolyData *pd = vtkPolyData::New(); aFilter->SetInputData(pd); </syntaxhighlight>


Update on vtkData

Since vtkData Objects no longer have a source, the update method is not existing anymore. Instead, call the update method of the source directly.


CxxRevisionMacro

Deprecated Macro. Just remove it.

<syntaxhighlight lang="cpp"> -vtkCxxRevisionMacro(vtkPVAxesActor, "$Revision$"); </syntaxhighlight>


vtkTypeRevisionMacro

Renamed macro

<syntaxhighlight lang="cpp"> - vtkTypeRevisionMacro(vtkPVAxesActor,vtkProp3D); + vtkTypeMacro(vtkPVAxesActor,vtkProp3D); </syntaxhighlight>


allocateScalars

Example 1

Replace

<syntaxhighlight lang="cpp"> int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,

      vtkInformationVector* outInfoVec)

{

  vtkImageData* output = this->GetOutput();
  output->GetScalarType();
  output->GetNumberOfScalarComponents();

</syntaxhighlight>

with

<syntaxhighlight lang="cpp"> int vtkMyAlg::RequestInformation(vtkInformation*, vtkInformationVector**,

      vtkInformationVector* outInfoVec)

{

   vtkInformation* outInfo = outInfoVec->GetInformationObject(0);
   vtkImageData::GetScalarType(outInfo);
   vtkImageData::GetNumberOfScalarComponents(outInfo);

</syntaxhighlight>


Example 2

<syntaxhighlight lang="cpp"> int vtkMyAlg::RequestData(vtkInformation*, vtkInformationVector**,

      vtkInformationVector* outInfoVec)

{ vtkImageData* output = vtkImageData::GetData(outInfoVec); // Allocate output scalars here output->GetScalarType(); output->GetNumberOfScalarComponents(); </syntaxhighlight>

This code does not need to be changed.