[vtkusers] how to render a MultiBlockDataSet ?
April.Q
qinjiameilf at 163.com
Fri Jul 20 00:05:16 EDT 2012
how to render a MultiBlockDataSet in only one
renderWindow, not producing renderWindows for every leaf node .
Renderer = vtk.vtkRenderer()
Renderer.ResetCamera()
Renderer.ResetCameraClippingRange ()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(Renderer)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
##try to use iterator
iterator = MyMultiBlockDataSet.NewIterator()
iterator.InitTraversal()
iterator.VisitOnlyLeavesOn()
iterator.SkipEmptyNodesOn()
iterator.GoToFirstItem()
while not iterator.IsDoneWithTraversal():
print " now idx:", iterator.GetCurrentFlatIndex()
currentInput =
vtk.vtkStructuredGrid.SafeDownCast(iterator.GetCurrentDataObject())
currentInput.GetPointData().SetActiveScalars("scalarvr")
imageReslice = vtk.vtkImageReslice()
imageReslice.SetInput(currentInput)
iteratorMapper = vtk.vtkImageMapper()
iteratorMapper.SetInputConnection(imageReslice.GetOutputPort())
iterator.GoToNextItem()
iteratorActor = vtk.vtkActor()
iteratorActor.SetMapper( iteratorMapper )
Renderer.AddViewProp( iteratorActor )
Renderer.AddActor(iteratorActor)
iren.Initialize()
iren.Render()
print "over!"
What i got is only ErrorMessage:
# iteratorActor.SetMapper( iteratorMapper ) #the error take place here
TypeError: argument 1: method requires a vtkMapper, a vtkOpenGLImageMapper
was provided.
how to fix the problem? and how to render MultiBlockDataSet use
compositedata filers and mappers and renders ?
something like this:
pipeline = vtk.vtkCompositeDataPipeline()
algorithm = vtk.vtkAlgorithm()
algorithm.SetExecutive(pipeline)
algorithm.SetDefaultExecutivePrototype(pipeline)
compositeFilter = vtk.vtkCompositeDataGeometryFilter()
compositeFilter.SetInput(MyMultiBlockDataSet)
compositeFilter.Update()
imageReslice = vtk.vtkImageReslice()
imageReslice.SetInput(compositeFilter.GetOutput() )
sliceMapper = vtk.vtkImageMapper()
sliceMapper.SetInputConnection(imageReslice.GetOutputPort())
sliceMapper.SetInput(imageReslice.GetOutput())
sliceActor = vtk.vtkActor()
sliceActor.SetMapper( sliceMapper )
# ErrorMessage:method requires a vtkMapper, a vtkOpenGLImageMapper
was provided.
Renderer.AddActor(sliceActor)
Renderer.SetActiveCamera(Camera)
renWin.Render()
iren.Initialize()
iren.Start()
--
View this message in context: http://vtk.1045678.n5.nabble.com/how-to-render-a-MultiBlockDataSet-tp5714811.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list