[vtkusers] color map surprise

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Jan 22 10:04:21 EST 2004


I am using a vtkDataSetSurfaceFilter to plot an interpolated surface
across a vtkStructuredGrid using the default color map.  I am
surprised to find that the large scalars are blue and the small
scalars are red, which is the opposite of the behavior I am used to,
eg with surf and colormap jet in matlab.

Am I doing something wrong, or is there a simple call to reverse the
scale so large scalars are on the red end?

Here's an example python script -- I label the '0' scalar point with a
text label.

import vtk

renderer = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(renWin)

grid = vtk.vtkStructuredGrid()
grid.SetDimensions(8,8,1)


points = vtk.vtkPoints()
scalars = vtk.vtkFloatArray()
i = 0
for line in file('xyz.dat'):
    x, y, z =  [float(val) for val in line.split()]
    scalars.InsertNextValue(float(i))
    points.InsertNextPoint(x,y,z)

    if i==0:
        # add a label for point 0
        text = vtk.vtkVectorText()
        text.SetText('0')
        textMapper = vtk.vtkPolyDataMapper()
        textMapper.SetInput(text.GetOutput())

        textActor = vtk.vtkFollower()
        textActor.SetMapper(textMapper)
        textActor.SetPosition(x, y, z)
        renderer.AddActor(textActor)


    i+=1
    
grid.SetPoints(points)
grid.GetPointData().SetScalars(scalars)

filter = vtk.vtkDataSetSurfaceFilter()
filter.SetInput(grid)

mapper = vtk.vtkPolyDataMapper()
mapper.SetInput(filter.GetOutput())

surfActor = vtk.vtkActor()
surfActor.SetMapper(mapper)


property = surfActor.GetProperty()
property.SetRepresentationToSurface()
property.SetInterpolationToGouraud()

renderer.AddActor(surfActor)
mapper.SetScalarRange(0, 64)

interactor.Initialize()
interactor.Start()


And the xyz data file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xyz.dat
Type: application/octet-stream
Size: 1072 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040122/4924b075/attachment.obj>
-------------- next part --------------



Thanks,
John Hunter


More information about the vtkusers mailing list