User:Bunhead

From KitwarePublic
Revision as of 11:51, 11 December 2007 by Bunhead (talk | contribs) (vtkPoints Merge)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Dear VTK User


I am a vtk user and unfortunetly relatively new to it, I have search the archives and your post “How to write multiple vtkPolyData into on single XML file” is the closest I’ve come to what I’m trying to do. I have created two series of vtkPoints and saved them out in the polydata format with vtkPolyDataWriter, once I have saved them I try to bring them both into a new program and merge them together using vtkAppendPolyData. Whenever I try to merge two files or even a file and some already existing PolyData it won’t render them out.


I have provided my code below:


package require vtk

package require vtkinteraction


vtkRenderer ren1

vtkRenderWindow renWin

renWin AddRenderer ren1

vtkRenderWindowInteractor iren

iren SetRenderWindow renWin

ren1 SetBackground 1.8 1.8 1.8

renWin SetSize 720 720


  1. Inport two PolyData Files.


vtkPolyDataReader reader1

           reader1 SetFileName "d:/education/spencer/simulation/servers.txt"



vtkPolyDataReader reader2

           reader2 SetFileName "d:/education/spencer/simulation/points.txt"



  1. Appended into a single polydata.

vtkAppendPolyData apd

   apd AddInput [reader1 GetOutput]
   apd AddInput [reader2 GetOutput]


vtkSphereSource node

                       node SetRadius 1.25
                       node SetPhiResolution 18
                       node SetThetaResolution 18


  1. create a glyph using 'balls' as the object and 'inputData' for location with 3D space

vtkGlyph3D glyphPointsServers

           glyphPointsServers SetInputConnection [apd GetOutputPort]
           glyphPointsServers SetSource [node GetOutput]


  1. Assign simple mapper to glyph

vtkPolyDataMapper glyphMapperServers

           glyphMapperServers SetInput [glyphPointsServers GetOutput]


  1. create actor of gylph to enable rendering of points

vtkActor glyphServers

           glyphServers SetMapper glyphMapperServers
           [glyphServers GetProperty] SetColor 255 0 0
           [glyphServers GetProperty] SetSpecular .3
           [glyphServers GetProperty] SetSpecularPower 10
           ren1 AddActor glyphServers

renWin Render


Thankyou for any help you can provide,