[vtkusers] colouring a surface according to one's own floatarray

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Tue Aug 6 10:25:46 EDT 2002


>>>>> "YF" == YaelFeldman  <YaelFeldman at aol.com> writes:

    YF> I am trying to colour a surface (a triangulated polygonal
    YF> mesh) according to a floatarray listing numbers (that are
    YF> calculated by the programme), one number corresponding to each
    YF> of the polygon vertices. I know I need to use scalars, and
    YF> vtkGlyph or somethink like it, yet all the examples seem to
    YF> reiterate the use of Plot3D files, with pre-defined scalars
    YF> e.g velocity magnitude etc. Does anyone have any advice?

Once you create your PolyData you can associate point scalars with the
points of the data.  Create a vtkFloatArray and then stick the scalars
in it and then associate this array with your point data.  Thats about
all you need.

pd = vtkPolyData() 
# this is your polydata object.  You might generate it some other way.

sc = vtkFloatArray()
for i in range(pd.GetNumberOfPoints()):
    sc.InsertNextValue(_insert_your_scalar_here)

pd.GetPointData().SetScalars(sc)

cheers,
prabhu



More information about the vtkusers mailing list