[vtkusers] 3D surface using in memory binary data in python

James Carroll mrmaple at gmail.com
Fri Sep 2 09:14:40 EDT 2005


Hi Brian,

> Any suggestions would be appreciated. I'm having a little trouble
> "getting" VTK.  Thanks!

I'm not too far ahead of you, but there are some examples I've come across.

The best ones that I've found that start to answer your questions are
examples that use numarray and vtk:

from numarray import *
import vtk

a = array( (arange(1,10000)),type=Float64)  #or any numarray

datastring = a.tostring()

data = vtk.vtkDoubleArray()
data.SetVoidArray( datastring, len(datastring)/data.GetDataTypeSize(), 1)

id = vtk.vtkImageData()
id.GetPointData().SetScalars(data)
id.SetDimensions(100,100,1)
id.SetSpacing(1.0,1.0,0.0)
id.SetOrigin(0.0,0.0,0.0)

This snippet was the first mailing list posting that came up when I
googled for: numarray vtk

Once you have imageData, then all the rest of the examples apply.

-Jim


On 9/1/05, Brian Ramos <vtkusers at brianramos.com> wrote:
> Hi everyone,
> 
> I'm very new to VTK and I'm having trouble using binary data in memory.
>   Basically what I have is a python string with binary data (floating
> point, atm) that represents height and I'd like to display it as a
> surface.  The X and Y coordinates I need to generate programatically but
> they're simple a regular array (about 200x200).
> 
> The BandContourTerrain.py example is pretty close to what I'd like to
> generate but I can't seem to get anything that works.
> 
> 
> - Brian Ramos
> 
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



More information about the vtkusers mailing list