#!/usr/bin/env python

# Create the RenderWindow, Renderer and interactive renderer
#
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
# make sure to have the same regression image on all platforms.
renWin.SetMultiSamples(0)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
# Force a starting random value
raMath = vtk.vtkMath()
raMath.RandomSeed(6)
# Generate random attributes on a plane
#
ps = vtk.vtkPlaneSource()
ps.SetXResolution(10)
ps.SetYResolution(10)
ag = vtk.vtkRandomAttributeGenerator()
ag.SetInputConnection(ps.GetOutputPort())
ag.GenerateAllDataOn()
ss = vtk.vtkSphereSource()
ss.SetPhiResolution(16)
ss.SetThetaResolution(32)
tg = vtk.vtkTensorGlyph()
tg.SetInputConnection(ag.GetOutputPort())
tg.SetSourceConnection(ss.GetOutputPort())
tg.SetScaleFactor(0.1)
tg.SetMaxScaleFactor(10)
tg.ClampScalingOn()
n = vtk.vtkPolyDataNormals()
n.SetInputConnection(tg.GetOutputPort())
cs = vtk.vtkConeSource()
cs.SetResolution(6)
glyph = vtk.vtkGlyph3D()
glyph.SetInputConnection(ag.GetOutputPort())
glyph.SetSourceConnection(cs.GetOutputPort())
glyph.SetScaleModeToDataScalingOff()
glyph.SetScaleFactor(0.05)
pdm = vtk.vtkPolyDataMapper()
pdm.SetInputConnection(n.GetOutputPort())
#pdm SetInputConnection [glyph GetOutputPort]
a = vtk.vtkActor()
a.SetMapper(pdm)
pm = vtk.vtkPolyDataMapper()
pm.SetInputConnection(ps.GetOutputPort())
pa = vtk.vtkActor()
pa.SetMapper(pm)
ren1.AddActor(a)
ren1.AddActor(pa)
ren1.SetBackground(0,0,0)
renWin.SetSize(300,300)
renWin.Render()
# prevent the tk window from showing up then start the event loop
# --- end of script --
