[vtkusers] Color by vector of glyph

ravikg ravikg.iitk at gmail.com
Thu Oct 21 09:01:10 EDT 2010


Hi,

I am new to VTK. I am trying a lot and searched a lot but could not get any
help to the color working. I want to colour the vector arrow using thier
direction. Please help.
Below is the code of my program:

import vtk
import math

input_data = 'uvadata/tornado.vtk'

reader = vtk.vtkStructuredPointsReader()
mapper = vtk.vtkPolyDataMapper()
ren = vtk.vtkRenderer()

reader.SetFileName(input_data)

mapper.SetScalarRange(0.0,51.7)

#filter
maskP = vtk.vtkMaskPoints()
maskP.SetOnRatio(50)
maskP.RandomModeOn()
maskP.SetInputConnection(reader.GetOutputPort())

#arrow
arw= vtk.vtkArrowSource()
arrow = vtk.vtkArrowSource()
arrow.SetTipResolution(16)
arrow.SetTipLength(0.3)
arrow.SetTipRadius(0.1)

glyp = vtk.vtkGlyph3D()
glyp.SetSource(arrow.GetOutput())
glyp.SetInput(maskP.GetOutput())
glyp.SetVectorModeToUseVector()
glyp.SetScaleFactor(0.15)
glyp.SetColorModeToColorByVector()
glyp.SetScaleModeToScaleByVector()
glyp.OrientOn()
glyp.Update()

mapper.SetInput(glyp.GetOutput())
mapper.SetScalarRange(reader.GetOutput().GetScalarRange())
mapper.ScalarVisibilityOn()
mapper.SetScalarModeToUsePointFieldData()

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

# outline
outline = vtk.vtkOutlineFilter()
outline.SetInput(glyp.GetOutput())
mapper2 = vtk.vtkPolyDataMapper()
mapper2.SetInput(outline.GetOutput())
actor2 = vtk.vtkActor()
actor2.SetMapper(mapper2)

ren.AddActor(actor)
ren.AddActor(actor2)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
istyle = vtk.vtkInteractorStyleTrackballCamera()
iren.SetInteractorStyle(istyle)
iren.SetRenderWindow(renWin)
ren.ResetCamera()
renWin.Render()

iren.Start()

-- 
View this message in context: http://vtk.1045678.n5.nabble.com/Color-by-vector-of-glyph-tp3230451p3230451.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list