[vtkusers] scalar values

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Tue Oct 8 13:01:53 EDT 2002


>>>>> "VS" == vidya sivakumar <vidya.sivakumar at quest-global.com> writes:

    VS> Hi All, I am not very clear about associating scalar values to
    VS> point data.  I have an expression to compute the scalar value
    VS> at each point(x,y,z).  HOw do I read the values into a
    VS> vtkFLoatarray or a double array.  I tried using vtkFloatArray
    VS> but it did not work.  Can anybody help?  Thanks in advance,

Add a scalar for each point in the FloatArray.  Here is some python
pseudo code:

 fa = vtkFloatArray()
 pnts = vtkPoints()
 # create your points.
 for i in range(pnts.GetNumberOfPoints()):
     pnt = pnts.GetPoint(0)
     scalar = function(pnt) # your function
     fa.InsertNextValue(scalar)

Now you can use the vtkFloatArray to do what you want.   For instance
if the points are part of a vtkPolyData object you can do this:

 pd = vtkPolyData()
 pd.GetPointData().SetScalars(fa)


cheers,
prabhu



More information about the vtkusers mailing list