1 # Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # Macro to show SALOME object in ParaView viewer.
22 # The macro inspects current selection obtained from SALOME GUI
23 # and displays supported objects in the viewer:
35 session = salome.naming_service.Resolve('/Kernel/Session')
37 from pvsimple import *
39 selection = session.getSelection()
41 for entry in selection:
42 sobj = salome.myStudy.FindObjectID(entry)
45 from salome.geom import geomBuilder
46 geompy = geomBuilder.New(salome.myStudy)
47 go = sobj.GetObject()._narrow(GEOM.GEOM_Object)
49 tmpf = tempfile.NamedTemporaryFile(suffix='.vtk')
52 geompy.ExportVTK(go, fname)
54 p = LegacyVTKReader(FileNames=[fname])
55 renderView = GetActiveViewOrCreate('RenderView')
56 pd = Show(p, renderView)
57 renderView.ResetCamera()
65 from salome.smesh import smeshBuilder
66 mesh = smeshBuilder.New(salome.myStudy)
67 mo = sobj.GetObject()._narrow(SMESH.SMESH_Mesh)
69 tmpf = tempfile.NamedTemporaryFile(suffix='.med')
72 mo.ExportToMEDX(fname, True, SMESH.MED_V2_2, True, True)
74 p = MEDReader(FileName=fname)
75 renderView = GetActiveViewOrCreate('RenderView')
76 pd = Show(p, renderView)
77 renderView.ResetCamera()