There are three examples using views displaying relations of vtk classes. The article learned from VTKUsersGuide

vtkTreeRingView

Python
#!/usr/bin/env python

from vtk import *

def main():
    datapath = "/Users/weiyang/Downloads/VTKData" #vtk.util.misc.vtkGetDataRoot()

    reader1 = vtkXMLTreeReader()
    reader1.SetFileName(datapath + "/Data/Infovis/XML/vtkclasses.xml")
    reader1.SetEdgePedigreeIdArrayName("tree edge")
    reader1.GenerateVertexPedigreeIdsOff();
    reader1.SetVertexPedigreeIdArrayName("id");

    reader2 = vtkXMLTreeReader()
    reader2.SetFileName(datapath + "/Data/Infovis/XML/vtklibrary.xml")
    reader2.SetEdgePedigreeIdArrayName("graph edge")
    reader2.GenerateVertexPedigreeIdsOff();
    reader2.SetVertexPedigreeIdArrayName("id");

    # Setup the view parameters for displaying the graph
    view = vtkTreeRingView()
    view.SetTreeFromInputConnection(reader2.GetOutputPort())
    view.SetGraphFromInputConnection(reader1.GetOutputPort())
    view.SetAreaColorArrayName("VertexDegree")
    view.SetEdgeColorToSplineFraction()
    view.SetAreaHoverArrayName("id")
    view.SetColorEdges(True)
    view.SetAreaLabelArrayName("id")
    view.SetAreaLabelVisibility(True)
    view.SetShrinkPercentage(0.02)
    view.SetBundlingStrength(.8)

    # Apply a theme to the views
    theme = vtkViewTheme.CreateMellowTheme()

    view.ApplyViewTheme(theme)
    view.ResetCamera()
    view.Render()
    view.GetInteractor().Start()

# If we open this file to execute, __name__ is '__main__', or the name is file name of .py
if __name__ == "__main__":
    main()

vtkIcicleView

We use vtkIcicleView instead of vtkTreeRingView in the above example, then it gives us icicle graph.

vtkTreeMapView

We use vtkTreeMapView instead of vtkTreeRingView in the first example, then it gives us the following graph.


0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Tex To PDF
: convert the Latex file which suffix is tex to a PDF file

X
0
Would love your thoughts, please comment.x
()
x