[vtkusers] how to attach multi-attributes to the same dataset?
April.Q
qinjiameilf at 163.com
Fri Jul 13 03:57:06 EDT 2012
I want to build a StructuredGrid with two attribute data (both are scalars)
assign to the point data.
just something like this:
points = vtk.vtkPoints()
scalar_1 = vtk.vtkDoubleArray()
scalar_2= vtk.vtkDoubleArray()
... ...
# set points , scalar_1 and scalar_2
ind = 0
for k in range(z):
for j in range(y):
for i in range(x):
points.SetPoint(ind, datax[k,j,i], datay[k,j,i],
dataz[k,j,i])
scalar_1.InsertValue(ind, s1[k,j,i])
scalar_2.InsertValue(ind, s2[k,j,i])
ind += 1
... ...
sgrid = vtk.vtkStructuredGrid()
sgrid.SetDimensions(x,y,z)
sgrid.SetPoints(points)
# bellow is what i really want to do, they don't work
sgrid.GetPointData().SetScalars(scalar_1)
sgrid.GetPointData().GetScalars(scalar_1).SetName("scalar1")
sgrid.GetPointData().SetScalars(scalar_2)
sgrid.GetPointData().GetScalars(scalar_2).SetName("scalar2")
and when i use this StructuredGrid (sgrid) i can do something like this:
scalarOne = sgrid.GetScalar("scalar1")#get the data by it's name
scalarTwo = sgrid.GetScalar("scalar2")#get the data by it's name
any help?
thx.
--
View this message in context: http://vtk.1045678.n5.nabble.com/how-to-attach-multi-attributes-to-the-same-dataset-tp5714692.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list