Salome HOME
Porting to PV500
[modules/paravis.git] / test / demo_14_med.py
1 # Copyright (C) 2010-2015  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 """ 
21 MEDReader test script. 
22 Before launching the script necessary MED files has to be placed into ./MedData directory 
23 """
24
25 if not ('servermanager' in dir()):
26   from pvsimple import *
27
28 import sys
29 import os
30 import time
31 import inspect
32
33 def medread (path, impth):
34   print '============================================================'
35
36   if os.path.exists(path):
37     filelist = os.listdir(path)
38     num = len (filelist)
39     
40     for i in range(num):
41       fname = str(filelist[i])
42       if fname.rfind(".med") > -1:
43         v = GetRenderView()
44         v.UseLight = 1
45         v.CameraPosition = [0.0, 0.0, 6.7]
46         v.LightSwitch = 0
47         v.CameraClippingRange = [4.5, 9.5]
48         v.LODThreshold = 5.0
49         v.Background = [0., 0., 0.]
50         v.CameraParallelScale = 1.8
51         
52         file_med = MEDReader( FileName=(path + fname))
53         
54         time.sleep(10)
55         SetActiveSource(file_med)
56         Show()
57         ##Show (file_med, view=v)
58         ##Render(view=v)
59         Render()
60         time.sleep(10)
61         WriteImage(filename = (impth +  "medFile_" + str(i+1) + ".png"), view=v, Magnification=2)
62         print str(i+1), "Shown file is:  ", fname
63         
64         Delete(v)
65         v1 = CreateRenderView()
66         SetActiveView(v1)
67         
68
69 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
70 testdir = os.path.dirname( os.path.abspath(scriptdir) )
71
72
73 if __name__ == "__main__":
74   medread(path=testdir+"/MedData/", impth=testdir+"/Pic/")