[vtkusers] help: balls and arrows

Robert Ellis Parrott parrott at fas.harvard.edu
Wed Jan 16 17:36:57 EST 2002


Here's probably a dumb question from a new user:

I'm trying to visualize particles moving in space by attaching a sphere to
their positions, and then attaching a correctly oriented arrow to the
sphere.

The sphere part is working fine, but I'm having trouble with
vtkArrowSource. I have a vtkPointData set with Vector attributes attached
which is the velocity of the particle.

    particleData = vtkpython.vtkPolyData()
    particleData.SetPoints(pts1)
    particleData.GetPointData().SetScalars(scls);
    particleData.GetPointData().SetVectors(vels);

I then create a vtkSphereSource and a vtkArrowSource, set them up, and
then create vtkGlyph3D objects for them:

    particles = vtkpython.vtkGlyph3D()
    particles.SetInput(particleData)
    particles.SetSource(sphere.GetOutput())
    particles.SetScaleModeToDataScalingOff()
    particles.SetColorModeToColorByScalar()
    particles.SetRange(0.0,5.0)

    vectors = vtkpython.vtkGlyph3D()
    vectors.SetInput(particleData)
    vectors.SetSource(arrow.GetOutput())
    vectors.SetScaleFactor(0.0025)
    vectors.SetVectorModeToUseVector()
    vectors.SetScaleModeToScaleByVector()
    vectors.SetColorModeToColorByScalar()

>From this I create two mapper objects for them

    particleMapper = vtkpython.vtkPolyDataMapper()
    particleMapper.SetInput(particles.GetOutput())
    vectorMapper = vtkpython.vtkPolyDataMapper()
    vectorMapper.SetInput(vectors.GetOutput())

And actors and render.

What I find is that the Spheres are placed at the points, and the the
Arrows always start at the origin. I think that they have the correct
orientation, but I'd really like to attach them to the spheres, and not
emanating from the origin.


How might I do this?

thanx,

rob



----------------------------
Robert E. Parrott
Department of Physics
429 Lyman Laboratory
Harvard University
Cambridge, Massachusetts 02138
(617)-496-4013
parrott at fas.harvard.edu
Robert.E.Parrott.96 at alum.dartmouth.org (permanent)






More information about the vtkusers mailing list