[vtkusers] how to attach multi-attributes to the same dataset?

David E DeMarle dave.demarle at kitware.com
Fri Jul 13 07:36:16 EDT 2012


scalar_1.SetName("scalar1")
scalar_2.SetName("scalar2")
sgrid.GetPointData().AddArray(scalar_1)
sgrid.GetPointData().AddArray(scalar_2)

In VTK there can be only one active scalar array. But you can have as
many arrays as you want, and you can tell just about any filter to
operate on any specific array. If you don't specify, the default
behavior is to process the active scalar array, if there is one.

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Fri, Jul 13, 2012 at 3:57 AM, April.Q <qinjiameilf at 163.com> wrote:
> 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.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK 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