[vtkusers] getScalars (and vtk_to_numpy) question
Mathias Franzius
Mathias.Franzius at web.de
Mon Mar 30 03:02:02 EDT 2009
Hi all,
I bring this topic up once more, because I still couldn't figure out how to get an array
of scalars out of a vtkPolyData [and then convert it to a numpy array].
This is a simple example of how I tried it:
###
import vtk, scipy
ren = vtk.vtkRenderer()
rw = vtk.vtkRenderWindow()
rw.AddRenderer(ren)
cs = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputConnection( cs.GetOutputPort() )
actor = vtk.vtkActor()
actor.SetMapper( mapper )
ren.AddActor(actor)
rw.Render()
polyd = mapper.GetInput()
polyd.Update()
pointd = polyd.GetPointData()
pointd.Update()
scalars = pointd.GetScalars() ### (A) returns None
scalars.Update() ### (B) breaks on None
ar = vtk.vtk_to_numpy(scalars)
img = scipy.misc.toimage(ar)
img.show()
###
In line (A) pointd.GetScalars() returns a None value, which of course breaks line (B).
I assume I misunderstood how to get the scalar values?
Could someone point this out please?
Thanks!
Mathias
__________________________________________________________________________
Verschicken Sie SMS direkt vom Postfach aus - in alle deutschen und viele
ausländische Netze zum gleichen Preis!
https://produkte.web.de/webde_sms/sms
More information about the vtkusers
mailing list