[vtkusers] Glyph3D

Roger Blum roger_blum at swissonline.ch
Mon Nov 14 20:25:03 EST 2005


Hi vtk users,

I am using a nightly build of vtk with tcl wrapping.
I would like to display different glyphs with different colors and
orientation.
I have written a small test script to demonstrate what I intend to do
(thanks to John Biddiscombe for his input a couple of weeks ago).
Executing the script shows 5 glyphs (this is correct), but all glyphs are
the same, have the same color and the same orientation. So the
provided input is not applied when generating the glyphs.

This is the relevant code snippet of my test script:

<Begin snippet>

# Define lookup table for colors with 4 colors
vtkLookupTable LUT
LUT SetNumberOfColors 4
LUT SetTableValue 0 0.0 0.0 1.0 1.0
LUT SetTableValue 1 1.0 0.0 0.0 1.0
LUT SetTableValue 2 0.0 1.0 0.0 1.0
LUT SetTableValue 3 1.0 1.0 0.0 1.0

# Create the glyph sources
vtkCubeSource CS
CS SetCenter 0 0 0
CS SetXLength 50
CS SetYLength 20
CS SetZLength 10

vtkSphereSource SS
SS SetCenter 0 0 0
SS SetPhiResolution 8
SS SetRadius 20
SS SetThetaResolution 8

# Points for glyphs
vtkPoints P
P InsertNextPoint 100 100 10
P InsertNextPoint 100 200 50
P InsertNextPoint 200 200 20
P InsertNextPoint 200 100 100
P InsertNextPoint 1000 1000 100

# Define index table for selecting sources
vtkIntArray IA
IA SetName "objtypes"
IA InsertNextValue 0
IA InsertNextValue 0
IA InsertNextValue 1
IA InsertNextValue 1
IA InsertNextValue 1

# Define index table for selecting color
vtkIntArray IA2
IA2 SetName "colors"
IA2 InsertNextValue 0
IA2 InsertNextValue 1
IA2 InsertNextValue 2
IA2 InsertNextValue 3
IA2 InsertNextValue 3

# Define vector table for glyph orientation
vtkFloatArray FA2
FA2 SetName "directions"
FA2 SetNumberOfComponents 3
FA2 InsertNextTuple3 1.0 2.0 2.0
FA2 InsertNextTuple3 1.0 0.0 0.0
FA2 InsertNextTuple3 1.0 2.0 2.0
FA2 InsertNextTuple3 0.0 1.0 0.0
FA2 InsertNextTuple3 0.0 0.0 1.0

# Collect arrays in a point data object
vtkPointData PD
PD SetScalars IA
PD SetScalars IA2
PD SetVectors FA2

# Define polydata with points and point data
vtkPolyData PD2
PD2 SetFieldData PD
PD2 SetPoints P

# Create the glyph filter
vtkGlyph3D G3D
G3D SetInput PD2
G3D SetOutput [G3D GetOutput]
G3D SetSource 0 [CS GetOutput]
G3D SetSource 1 [SS GetOutput]
G3D SetIndexModeToScalar
G3D SetRange 0 1
G3D SetScaleModeToDataScalingOff
G3D SetColorModeToColorByScalar
G3D OrientOff
G3D SetVectorModeToUseVector
G3D GeneratePointIdsOn
G3D SetInputArrayToProcess 0 0 0 0 "objtypes"
G3D SetInputArrayToProcess 1 0 0 0 "directions"
G3D SetInputArrayToProcess 3 0 0 0 "colors"

# Create the mapper
vtkPolyDataMapper PDM
PDM SetInput [G3D GetOutput]
PDM SetLookupTable LUT
# Create the actor
vtkActor A
A SetMapper PDM
A SetOrigin 0 0 0
A SetPosition 0 0 0
A SetScale 1 1 1
A SetPickable 1
A SetVisibility 1

<end snippet>

Executing this script produces the warning:
"Turning indexing off: no data to index with"

How do I have to provide the arrays to make them be used by the vtkglyph3d
object?

Thanks in advance for any help.

Roger 






More information about the vtkusers mailing list