2 Visualize a MEDCoupling instance in ParaViS through CORBA
3 ---------------------------------------------------------
5 ParaViS can be used to directly visualize a mesh or a field stored in memory in a Python
6 process. For information, this technique will become the preferred choice for the MED
7 Calculator in a future Salome release.
8 The following use cases can also be mentioned:
10 * YACS, to create visualization nodes
11 * create a Python mock-up script and use the standard Python interpreter whilst benefiting
12 from the ParaViS graphical interface
17 Import the whole Python module MEDCouplingCorba. ::
19 from MEDCouplingCorba import *
22 Create a 2D MEDCouplingUMesh instance
23 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 Create a trivial unstructured mesh "m" which will be sent through CORBA to ParaViS.
28 arr=DataArrayDouble(11)
32 m=m.buildUnstructured()
34 .. note:: "m" is unstructured but a Cartesian mesh would also work perfectly fine.
36 Create a CORBA servant from "m", and turn the Python process into a CORBA server
37 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39 Invoke MEDCouplingUMeshServant._this() on "m" to turn it into a CORBA reference ("ref_m").
42 ref_m=MEDCouplingUMeshServant._this(m)
44 .. note:: This command doesn't only create a CORBA servant but also makes the current
45 Python process a full CORBA server.
47 Read the identifiers that are passed to ParaViS
48 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
50 What follows holds for any omniORBpy code. Display the IOR "ior" of "ref_m".
51 This character string is given to the ParaViS plugin (ParaMEDCorbaPlugin) to create
57 ior=orb.object_to_string(ref_m)
60 A simple copy/paste in the ParaViS GUI allows to create the source and to have our
61 mesh rendered on screen.
63 Use ParaViS interactively
64 ~~~~~~~~~~~~~~~~~~~~~~~~~
66 This section simply highlights what can be done in principle. It should be regarded
67 as a starting point towards the creation of more advanced scripts.
68 With ParaViS still up, retrieve a remote handle on ParaViS:
71 import PARAVIS_Gen_idl
74 paravis=salome.lcc.FindOrLoadComponent("FactoryServer","PARAVIS")
76 Then send a script to ParaViS so that it displays "m":
80 src1 = ParaMEDCorbaPluginSource()
82 asc=GetAnimationScene()
84 dr=Show()\ndr.Visibility = 1
88 paravis.ExecuteScript(content)
94 :ref:`python_testMEDCouplingcorba1_solution`