I would like to display a 3D lattice DAG, where every vertex has associated integer (x,y,z) coordinates, and the edges are the edges of the corresponding cubic lattice. I can build the graph with vtkMutableDirectedGraph
and vtkTree
, but I can’t figure out how to assign the coordinates and which mapper to use (I want vertices as spheres and edges as tubes or arrows).
There’s vtkGraph.SetPoints
, but are those associated with the vertices? There’s vertex data which I could use to store the coordinates, but how can I set the data as I add each vertex (and not as a whole array for all vertices at one shot), and how I can use this in a mapper?
For instance, using Python, I can create this simple vtkTree
:
graph = vtk.vtkMutableDirectedGraph()
v0 = graph.AddVertex()
v1a = graph.AddVertex()
v1b = graph.AddVertex()
v1c = graph.AddVertex()
graph.AddEdge(v0, v1a)
graph.AddEdge(v0, v1b)
graph.AddEdge(v0, v1c)
coord = vtk.vtkIntArray()
coord.SetName('coord')
coord.SetNumberOfComponents(3)
coord.InsertNextTuple([0,0,0])
coord.InsertNextTuple([1,0,0])
coord.InsertNextTuple([0,1,0])
coord.InsertNextTuple([0,0,1])
graph.GetVertexData().AddArray(coord)
tree = vtk.vtkTree()
tree.CheckedShallowCopy(graph)
How can I now display it, as I said, with spheres and tubes? (And ideally adding the coordinates in the AddVertex
calls)