[vtkusers] Python vtkPointData Help!
Charles O'Connor
oconnor1 at llnl.gov
Thu Sep 29 13:03:41 EDT 2005
Dear VTK users,
I am new to VTK and trying to get my data read into its format. I have
prepared my data as a VTK data array by doing the following:
-------------------------------------------------------------
aa = vtk.vtkFloatArray()
aa.SetNumberOfValues( nxx * nyy )
aa.SetName( 'pcmdiqnt' )
k = 0
for j in range( 0, nyy ):
for i in range( 0, nxx ):
aa.SetValue( k, vv[j,i] )
k = k + 1
bb = vtk.vtkPointData()
bb.AddArray( aa )
print 'debug PointData IsArrayAnAttribute', bb.IsArrayAnAttribute( 0 )
print 'debug bb PointData array 0 name = ', bb.GetArrayName( 0 )
print 'debug bb PointData array count = ', bb.GetNumberOfArrays( )
----------------------------------------------------------
This produces the output:
debug PointData IsArrayAnAttribute -1
debug bb PointData array 0 name = pcmdiqnt
debug bb PointData array count = 1
This knows the array name (i.e., "pcmdiqnt") and the number of array is
1. This is correct, but the "IsArrayAnAttibute" returns a -1. This is
wrong. Why?
What I am ultimately after is:
pp = vtk.vtkPoints()
pp.SetNumberOfPoints( nxx * nyy )
k = 0
for j in range( 0, nyy ):
for i in range( 0, nxx ):
pp.SetPoint( k, xx[i], yy[j], 0.0 )
k = k + 1
ss = vtk.vtkStructuredGrid()
ss.SetDimensions( nxx, nyy, 1 )
ss.SetPoints( pp )
ss.SetFieldData( bb )
ss.Update()
ss.UpdateData()
Can someone help me to get a vtk.vtkStructuredGrid() so I can plot my data?
Thanks in advance and best regards,
Charles O'Connor
More information about the vtkusers
mailing list