In recent VTK, SetInput has been superceeded by SetInputData. Try using that method name and it should work for you.<div><br></div><div>Jeff<span></span><br><br>On Thursday, November 7, 2013, Meehan, Bernard wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I was trying to convert some of the C++ examples into python, mostly so<br>
that I could learn about how all of the classes work together, and can't<br>
seem to get a vtkMutableDirectedGraph hooked up with a vtkGraphLayout in a<br>
pipeline Š the original code was here<br>
(<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Graphs/VisualizeDirectedGraph" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Graphs/VisualizeDirectedGraph</a>).<br>
<br>
Here is what I had done in Python:<br>
import vtk<br>
<br>
g = vtk.vtkMutableDirectedGraph()<br>
<br>
verts = [g.AddVertex() for i in range(4)]<br>
<br>
g.AddGraphEdge(verts[0], verts[1])<br>
g.AddGraphEdge(verts[1], verts[2])<br>
g.AddGraphEdge(verts[2], verts[0])<br>
<br>
g_layout = vtk.vtkGraphLayout()<br>
# If I uncomment this line and run, I get the following error:<br>
# TypeError: SetInputConnection argument 1: method requires a<br>
vtkAlgorithmOutput, a vtkMutableDirectedGraph was provided.<br>
# g_layout.SetInputConnection(g)<br>
<br>
# If I uncomment this line and run, I get the following error:<br>
# AttributeError: SetInput<br>
# g_layout.SetInput(g)<br>
<br>
# ?? any ideas on how to hook these up ??<br>
<br>
g_layout.SetLayoutStrategy(vtk.vtkSimple2DLayoutStrategy())<br>
<br>
# Do layout manually before handing graph to the view. This allows us to<br>
know<br>
# the positions of the edge arrows.<br>
g_layout_v = vtk.vtkGraphLayoutView()<br>
<br>
# Tell the view to use the vertex layout we provide.<br>
g_layout_v.SetStrategyToPassThrough()<br>
<br>
# The arrows will be positioned on a straight line between the two<br>
vertices so<br>
# tell the view not to draw arcs for the parallel edges.<br>
g_layout_v.SetEdgeLayoutStrategyToPassThrough()<br>
<br>
# Add the graph to the view. This will render vertices and edges, but not<br>
the<br>
# edge arrows.<br>
g_layout_v.AddRepresentationFromInputConnection(g_layout.GetOutputPort())<br>
<br>
# Manually create an actor containing the glyphed arrows.<br>
g2pd = vtk.vtkGraphToPolyData()<br>
g2pd.SetInputConnection(g_layout.GetOutputPort())<br>
g2pd.EdgeGlyphOutputOn()<br>
<br>
# Set the position (0: edge start, 1: edge end) where the edge arrows<br>
should<br>
# go.<br>
g2pd.SetEdgeGlyphPosition(0.98)<br>
<br>
# Make a simple edge arrow for glyphing.<br>
arrow = vtk.vtkArrowSource()<br>
arrow.SetGlyphTypeToEdgeArrow()<br>
arrow.SetScale(0.1)<br>
arrow.Update() # necessary?<br>
<br>
# Use a vtkGlyph3D to repeat the glyph on all edges.<br>
glyph = vtk.vtkGlyph3D()<br>
glyph.SetInputConnection(0, g2pd.GetOutputPort(1)) # what?<br>
glyph.SetInputConnection(1, arrow.GetOutputPort())<br>
<br>
mapper = vtk.vtkPolyDataMapper()<br>
mapper.SetInputConnection(glyph.GetOutputPort())<br>
<br>
actor = vtk.vtkActor()<br>
actor.SetMapper(mapper)<br>
<br>
g_layout_v.ResetCamera()<br>
g_layout_v.Render()<br>
g_layout_v.GetInteractor().Start()<br>
<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div>