Two ways to add data object for a vtkView.

1) Create a representation object, set the inputs for it by calling SetInputConnection() or SetInput(), then add representation for the view.

2) Use AddRepresentationFromInputConnection or AddRepresentationFromInput to create representation automatically.

1)
Python
from vtk import *

surfaceRepresentation = vtkRenderedSurfaceRepresentation()

sphere = vtkSphereSource()
sphere.SetPhiResolution( 100 )
sphere.SetThetaResolution( 100 )

surfaceRepresentation.SetInputConnection( sphere.GetOutputPort() )

view = vtkRenderView()
view.AddRepresentation( surfaceRepresentation )
view.SetInteractionMode( vtkRenderView.INTERACTION_MODE_3D )
view.ResetCamera()
view.GetInteractor().Start()

2) 

Python
from vtk import *

source = vtkRandomGraphSource() #vtkGraphAlgorithm
source.SetNumberOfVertices(100)
source.SetNumberOfEdges(100)
source.SetStartWithTree(True)

view = vtkGraphLayoutView()
view.AddRepresentationFromInputConnection(source.GetOutputPort())
view.ResetCamera()
view.Render()
view.GetInteractor().Start()


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

You cannot copy content of this page