[vtkusers] Re: Need some help with vtkGraph representation and visualisation pipeline of graphs.

Geoframer geoframer at gmail.com
Tue May 1 09:49:32 EDT 2007


Hmm i forgot to mention in the previous note.... The graph is actually 3d
but it is proportioned into space very strange.

If you take random values between 0 and 1 for all x, y, z. The output should
be in a unit-cube of 1 by 1 by 1. However my visualisation output is very
very flat, Whereas the bounds for all 3 axis (x,y,z) is :

(0.00047628092579543591,
 0.99925798177719116,
 0.00036964597529731691,
 0.99911946058273315,
 0.0020560580305755138,
 0.99996763467788696)

As outputed by points.GetBounds()

So what am i doing wrong, and is there other stuff that's faulty in my
pipeline. Please let me know and sorry about the multiple post.

Regards - Geofram

On 5/1/07, Geoframer <geoframer at gmail.com> wrote:
>
> I managed to actually turn it into a graph instead of the previous weird
> visualisation output... however it is still not a 3d graph. Apparently the
> layout of the graph is altered dependent on the edges you add, in the
> previous code i had no edges.
>
> All comments and remarks are still very welcome, especially on how to
> create a 3d graph.
>
> Regards - Geofram
> --- insert new 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)
>
> for i in range(499):
>     graph.AddEdge(i,i+1)
>
>
> graphtopoly = vtk.vtkGraphToPolyData()
> graphtopoly.SetInput(graph)
>
> mapper = vtk.vtkPolyDataMapper()
> mapper.SetInputConnection(graphtopoly.GetOutputPort())
> mapper.SetInputConnection(graphlayout.GetOutputPort())
>
> graphactor = vtk.vtkActor()
> 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()
> ---------
> On 5/1/07, Geoframer <geoframer at gmail.com> wrote:
> >
> > 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/dbefda00/attachment.htm>


More information about the vtkusers mailing list