return to first page linux journal archive
keywordscontents

Listing 1. Code to Place Spherical Glyphs at Each Data Point

#Create polygonal object to be used as a glyph
	vtkSphereSource sphere
#Create the glyph object
        vtkGlyph3D glyphs
#Create the mapper for the glyphs
        vtkPolyDataMapper glMapper
#Create the glyph actor
        vtkActor glActor
#Create objects for position and scalar data
        vtkFloatPoints points
        vtkFloatScalars values
for {set i 0} {$i <$npoints} {incr i} {
#Populate the storage objects
  points InsertPoint $i $xpos($i) $ypos($i)\
	 $zpos($i)
  values InsertScalar $i $rad($i)
#Create polygonal object for points & scalars
	vtkPolyData pointset
#Associate the points and scalars with the 
#PolyData set (the polydata now holds
#the point and scalar data internally and 
#does not look it up from the points or 
#values objects
  pointset SetPoints points
  [pointset GetPointData] SetScalars values
#Delete these objects to clear memory
	points Delete
	values Delete
#set the attributes of the spherical glyphs
 	sphere SetPhiResolution 2
        sphere SetThetaResolution 2
        sphere SetReleaseDataFlag 1
#Set the attributes of the glyph objects
        glyphs ScalingOn
        glyphs SetScaleModeToScaleByScalar
#Set the mapper attributes
	glMapper ScalarVisibilityOff
#Build the pipeline:
        glyphs SetSource [sphere GetOutput]
        glyphs SetInput pointset
#The glyphs need position and geometry 
information (two inputs)
        glMapper SetInput [glyphs GetOutput]
	glActor SetMapper glMapper
#Create a renderer
	vtkRenderer ren
#Create a window to render in
        vtkRenderWindow renWin
#Create object to allow dynamic interaction 
#with the render window
        vtkRenderWindowInteractor iren
#Add the renderer to the render window 
        renWin AddRenderer ren
#Associate the interactor with render window
        iren SetRenderWindow renWin
#Add the glyph actor to the scene
        ren AddActor glActor
#start the visualziation
        iren Initialize