[vtkusers] Need some help with vtkGraph representation and visualisation pipeline of graphs.
Geoframer
geoframer at gmail.com
Tue May 1 08:33:38 EDT 2007
Hey everybody,
I'm relatively new to VTK but have been experimenting a bit. I'm
particularly interested in the graph representation which is present in the
Infovis module.
I have been able to visualise a basic vtkRandomGraphSource (perhaps trivial
to most of you) but now that i'm trying to create my own (3d) graph to
visualise i get some unexpected behaviour. Basically what i (am trying to)
do is create 500 random points (x,y,z) with random values between 0 and 1.
With these points i want to create a (3d) graph. But as there is no
documentation or example code on the Infovis module yet i can't seem to get
it right. The code that i have this far (heavily flawed probably but at
least it produces some sort of visual result) can be found below.
If anyone can help me or point out some of my errors in how to create and
visualise graphs it would be great.
Kind regards - Geofram
------ insert python-code -----
import vtk
import random
points = vtk.vtkPoints()
for i in range(500):
points.InsertPoint(i, random.random(),random.random(),random.random())
layout = vtk.vtkRandomLayoutStrategy()
layout.ThreeDimensionalLayoutOn()
layout.AutomaticBoundsComputationOn()
graphlayout = vtk.vtkGraphLayout()
graphlayout.SetLayoutStrategy(layout)
graph = vtk.vtkGraph()
graph.SetPoints(points)
graph.SetNumberOfVertices(500)
graphtopoly = vtk.vtkGraphToPolyData()
graphtopoly.SetInput(graph)
mapper = vtk.vtkLabeledDataMapper()
mapper.SetInputConnection(graphtopoly.GetOutputPort())
graphactor = vtk.vtkActor2D()
graphactor.SetMapper(mapper)
viewer = vtk.infovis.vtkGraphLayoutViewer()
viewer.SetInput(graph)
ren = vtk.vtkRenderer()
win = vtk.vtkRenderWindow()
win.AddRenderer(ren)
interact = vtk.vtkRenderWindowInteractor()
interact.SetRenderWindow(win)
viewer.SetRenderWindow(win)
win.GetInteractor().Initialize()
win.GetInteractor().Start()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070501/27d9a5fe/attachment.htm>
More information about the vtkusers
mailing list