[Paraview] Python: two actors AND connection to local runningParaview

Jordi Campos i Miralles jcampos at maia.ub.es
Wed Jun 20 15:46:23 EDT 2007


I think I start understanding the differences between the VTK pipeline
and the way to proceed in Paraview... So, I could draw two "objects"
with different visual properties.

I brief, I have in mind the following:

VTK                       = PARAVIEW
readers, writers, filters = use "sources"
mappers, actors           = use "displays"
camera, lights            = use "render module"

So the working script is listed below. I still have doubts about
connecting to a running Paraview from a script... but tomorrow I'll
continue working...

BTW, really interesting the python console on PV, it let me experiment
all this stuff "on-line". Congrats to developers! It's really a flexible
and extensible scheme.

jor;)i

SCRIPT-----------------------------------------------------
#                                                    PV-04-Displays.py
import paraview

paraview.ActiveConnection = paraview.Connect()    # Create a built-in server

renderW = paraview.CreateRenderWindow()           # RenderWindow

source1 = paraview.CreateProxy("sources",         # Sphere: source
                               "SphereSource", "sources")

disp1 = paraview.CreateDisplay(source1, renderW)  # Sphere: display
disp1.SetRepresentation( 1 )   ; disp1.SetOpacity( 0.5 )
disp1.SetScale( 0.8, 1.2, 1. ) ; disp1.UpdateVTKObjects()

source2 = paraview.CreateProxy("sources",         # Cone:   source
                               "ConeSource", "sources")

disp2 = paraview.CreateDisplay(source2, renderW)  # Cone:   display
disp2.SetRepresentation( 2 )     ; disp2.SetColor( 1, 1, 0 )
disp2.SetPosition( -0.25, 0, 0 ) ; disp2.SetOrientation( 0, 0, 20 )
disp2.UpdateVTKObjects()

renderW.ResetCamera()
renderW.StillRender()
raw_input("Enter to finish")
-----------------------------------------------------

(I have updated
http://namaste.maia.ub.es/public/vtk-volume-rendering-tutorial.pdf )




El dc 20 de 06 del 2007 a les 13:43 +0200, en/na Jordi Campos i Miralles
va escriure:
> After basic example of http://www.paraview.org/Wiki/ParaView:pvpython ,
> I tried to create two actors with different colors, to pass them to
> different Renderers of a running Paraview, but I found some problems.
> 
> I inserted the questions in the script code that is placed below.
> 
> Can anybody help me to understand how to perform it in Paraview
> scripting?
> 
> Thanks in advance,
> 
> jor;)i
> 
> 
> SCRIPT-----------------------------------------------------
> #                                                    PV-03-RenderM.py
> import paraview
> 
> # QUESTIONS ARE IN CAPITAL LETTERS
> 
> paraview.ActiveConnection = paraview.Connect()    # Create a built-in server
> 
> source1 = paraview.CreateProxy("sources",         # Sources
>                                "SphereSource", "sources")
> 
> source2 = paraview.CreateProxy("sources", "ConeSource", "sources")
> 
> mapper1 = paraview.CreateProxy("mappers",         # Mappers
>                                "PolyDataMapper", "mappers")
> mapper1.SetInput( source1 )
> mapper1.UpdateVTKObjects()
> 
> mapper2 = paraview.CreateProxy("mappers", "PolyDataMapper", "mappers")
> mapper2.SetInput( source2 )
> 
> actor1  = paraview.CreateProxy("props",           # Actors
>                                "Actor", "props")  # (todo: check LODActor)
> actor1.SetMapper( mapper1 )
> actor1.SetPosition( 2, 0, 0 )
> actor1.UpdateVTKObjects()
> 
> actor2  = paraview.CreateProxy("props", "Actor", "props")
> actor2.SetMapper( mapper2 )
> 
> prop    = paraview.CreateProxy("properties",      # Properties
>                                "Property", "properties")
> prop.SetColor(1, 1, 0)
> prop.UpdateVTKObjects() # IS IT NECESSARY???
> prop    = actor2.SetProperty()
> actor2.UpdateVTKObjects()
> # IS THERE A SHORTER WAY TO CHANGE THE COLOR???
> 
> renderer = paraview.CreateProxy("renderers",      # Renderers
>                                 "Renderer", "renderers")
> # renderer.AddActor( actor1 ) FAILS, WHY???
> # renderer.AddActor( actor2 )
> # ALSO renderer.AddToActors( actor1 )... ????
> 
> print paraview.GetRenderModules()
> # RETURNS EMPTY LIST, SHOULDN'T NEW CREATED 'render' APPEAR???
> 
> renderW  = paraview.CreateRenderWindow()          # RenderWindows
> # I WOULD LIKE TO USE LODRenderModule W CONE
> # AND SimpleRenderModule W SPHERE, IS IT POSSIBLE?
> 
> disp1 = paraview.CreateDisplay(source1, renderW)  # Displays
> disp2 = paraview.CreateDisplay(source2, renderW)
> # WHICH IS THE CORRESPONDANCE IN VTK?
> 
> renderW.ResetCamera()
> renderW.StillRender()
> # WHO CAN I TAKE AN SCREENSHOT???
> 
> raw_input("Enter to finish")
> # I'M INTERESTED INI CONNECTING TO A RUNNING PARAVIEW (LOCAL IN MY MACHINE),
> # CREATE THE SCENE AND AFTERWARDS LET THE USER INTERACT, IS IT POSSIBLE???
> -----------------------------------------------------
> pg 90 of
> http://namaste.maia.ub.es/public/vtk-volume-rendering-tutorial.pdf
> 
> 
> 
> 
-- 
Jordi Campos i Miralles
Departament de Matemàtica Aplicada i Anàlisi, MAiA
Facultat de Matemàtiques, Universitat de Barcelona
Gran Via de les Corts Catalanes, 585
08007 Barcelona
Telf : +34 93 403 93 72 



More information about the ParaView mailing list