[vtkusers] vtkDoubleArray and python problem

Chiang, Wen-Hsing wchiang at sspa.com
Wed Jan 16 15:27:45 EST 2002


Rob,
The new vtkDataArray is a little bit confusing. Here is a part of the
c++ code that I used to display velocity vectors. I think you need to
set the number of (velocity-) components, instead of number of tuples,
which is equivalent to the number of velocity vectors in this case.

m_pcVector= vtkFloatArray::New();
m_pcVector->SetNumberOfComponents(3);

...calculate velocity components (vx, vy, vz)
...and then insert them as a new tuple
m_pcVector->InsertNextTuple3(vx, vy, vz);		


Wen-Hsing Chiang


>Message: 8
>Hi folks,
>
>I'm trying to use VTK 4.0 to visualize some phase space info in python
>2.2; this is on linux.
>
>I'm trying to load coordinates and velocities into VTK data type,
>vtkDoubleArray.I can load position coordinates into a vtkPoints object,
>and scalar values into a vtkDoubleArray via SetValue(i,float) type of
>method.
>
>However, I can't (or don't know how to, perhaps) load 3 element arrays
>like position or velocity into a vtkDoubleArray.
>
>Looking though the man pages, there are methods like SetTuple(..) etc.,
>but for most of these I get:
>
>>> pts = vtkDoubleArray()
>>> pts.SetNumberOfTuples(5)
>>> dum = pts.InsertNextTuple([1.0,1.0,1.0])
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: InsertNextTuple
>>> dum = pts.SetTuple(1, [1.0, 1.0, 1.0])
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>AttributeError: SetTuple
>
>After doing a "nm libvtkCommonPython.so | grep DoubleArray" it seems as
>if these aren't even methods.
>
>How does one enter componenet data into a vtkDoubleArray in python? I
need
>to associate a velocity with a position (visualize a vector field), and
>this seems the only way.
>
>thanx in advance,
>rob

> ----------------------------
>Robert E. Parrott
>Department of Physics
>429 Lyman Laboratory
>Harvard University
>Cambridge, Massachusetts 02138
>(617)-496-4013
>parrott at fas.harvard.edu
>Robert.E.Parrott.96 at alum.dartmouth.org (permanent)



More information about the vtkusers mailing list