<div><div class="gmail_quote">On Tue, Feb 23, 2010 at 9:30 AM, Jeff Baumes <span dir="ltr"><<a href="mailto:jeff.baumes@kitware.com">jeff.baumes@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Arrowheads are possible. Currently the functionality is not exposed in vtkGraphLayoutView, but it is possible to create your own actor. Here is the python code for doing it:<br><br>from vtk import *<br><br># Make a small random graph and graph view.<br>
source = vtkRandomGraphSource()<br>view = vtkGraphLayoutView()<br><br># Do layout manually before handing graph to the view.<br># This allows us to know the positions of edge arrows.<br>layout = vtkGraphLayout()<br>strategy = vtkSimple2DLayoutStrategy()<br>
layout.SetInputConnection(source.GetOutputPort())<br>layout.SetLayoutStrategy(strategy);<br>view.SetLayoutStrategyToPassThrough()<br><br># Add the graph to the view. This will render vertices and edges,<br># but not edge arrows.<br>
view.AddRepresentationFromInputConnection(layout.GetOutputPort())<br><br># Manually create an actor containing the glyphed arrows.<br>graphToPoly = vtkGraphToPolyData()<br>graphToPoly.SetInputConnection(layout.GetOutputPort())<br>
graphToPoly.EdgeGlyphOutputOn()<br><br># Set the position (0: edge start, 1: edge end) where<br># the edge arrows should go.<br>graphToPoly.SetEdgeGlyphPosition(0.8)<br><br># Make a simple edge arrow for glyphing.<br>arrowSource = vtkGlyphSource2D()<br>
arrowSource.SetGlyphTypeToEdgeArrow()<br>arrowSource.SetScale(0.3)<br><br># Use Glyph3D to repeat the glyph on all edges.<br>arrowGlyph = vtkGlyph3D()<br>arrowGlyph.SetInputConnection(0, graphToPoly.GetOutputPort(1))<br>
arrowGlyph.SetInputConnection(1, arrowSource.GetOutputPort())<br>
<br># Add the edge arrow actor to the view.<br>arrowMapper = vtkPolyDataMapper()<br>arrowMapper.SetInputConnection(arrowGlyph.GetOutputPort())<br>arrowActor = vtkActor()<br>arrowActor.SetMapper(arrowMapper)<br>view.GetRenderer().AddActor(arrowActor)<br>
<br># Start interaction.<br>view.ResetCamera()<br>view.GetInteractor().Start()<br><br>Jeff<br><br></blockquote><div><br></div><div>I tried to port this to c++: </div><a href="http://www.vtk.org/Wiki/VTK/Examples/Graphs/VisualizeDirectedGraph">http://www.vtk.org/Wiki/VTK/Examples/Graphs/VisualizeDirectedGraph</a><div>
<br></div><div>but something didn't translate. </div><div><br clear="all">Thoughts?<br><br></div><div>David</div></div></div>