Difference between revisions of "VTK/Examples/Python/Arrays/GetValues"

From KitwarePublic
< VTK‎ | Examples‎ | Python
Jump to navigationJump to search
m (Missing file name)
Line 3: Line 3:
 
==GetValues.py==
 
==GetValues.py==
 
<source lang="python">
 
<source lang="python">
 +
from __future__ import print_function
 
import vtk
 
import vtk
 
from vtk import *
 
from vtk import *
Line 16: Line 17:
 
normal0 = normals.GetTuple3(0);
 
normal0 = normals.GetTuple3(0);
  
print "Normal0: " + str(normal0[0]) + " " + str(normal0[1]) + " " + str(normal0[2])
+
print("Normal0: " + str(normal0[0]) + " " + str(normal0[1]) + " " + str(normal0[2]))
 +
 
 
</source>
 
</source>

Revision as of 00:43, 23 August 2015

Seems to work, but segfaults at the end?

GetValues.py

from __future__ import print_function
import vtk
from vtk import *

#setup sphere
sphereSource = vtk.vtkSphereSource()
sphereSource.Update()

polydata = vtk.vtkPolyData()
polydata.ShallowCopy(sphereSource.GetOutput())

normals = polydata.GetPointData().GetNormals();
normal0 = normals.GetTuple3(0);

print("Normal0: " + str(normal0[0]) + " " + str(normal0[1]) + " " + str(normal0[2]))