Salome HOME
Merge from V6_main 01/04/2013
[modules/paravis.git] / test / demo_14_med.py
1 # Copyright (C) 2010-2013  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.
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 ${TESTDIR}/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
32 def medread (path, impth):
33   print '============================================================'
34
35   if os.path.exists(path):
36     filelist = os.listdir(path)
37     num = len (filelist)
38     
39     for i in range(num):
40       fname = str(filelist[i])
41       if fname.rfind(".med") > -1:
42         v = GetRenderView()
43         v.UseLight = 1
44         v.CameraPosition = [0.0, 0.0, 6.7]
45         v.LightSwitch = 0
46         v.CameraClippingRange = [4.5, 9.5]
47         v.LODThreshold = 5.0
48         v.Background = [0., 0., 0.]
49         v.CameraParallelScale = 1.8
50         
51         file_med = MEDReader( FileName=(path + fname))
52         
53         time.sleep(10)
54         SetActiveSource(file_med)
55         Show()
56         ##Show (file_med, view=v)
57         ##Render(view=v)
58         Render()
59         time.sleep(10)
60         WriteImage(filename = (impth +  "medFile_" + str(i+1) + ".png"), view=v, Magnification=2)
61         print str(i+1), "Shown file is:  ", fname
62         
63         Delete(v)
64         v1 = CreateRenderView()
65         SetActiveView(v1)
66         
67
68 testdir = os.getenv("TESTDIR")
69 pvdata = os.getenv("PVDATA")
70
71 if __name__ == "__main__":
72   medread(path=testdir+"/MedData/", impth=testdir+"/Pic/")