Back to index

salome-paravis  6.5.0
demo_14_med.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 """ 
00021 MEDReader test script. 
00022 Before launching the script necessary MED files has to be placed into ${TESTDIR}/MedData directory 
00023 """
00024 
00025 if not ('servermanager' in dir()):
00026   from pvsimple import *
00027 
00028 import sys
00029 import os
00030 import time
00031 
00032 def medread (path, impth):
00033   print '============================================================'
00034 
00035   if os.path.exists(path):
00036     filelist = os.listdir(path)
00037     num = len (filelist)
00038     
00039     for i in range(num):
00040       fname = str(filelist[i])
00041       if fname.rfind(".med") > -1:
00042         v = GetRenderView()
00043         v.UseLight = 1
00044         v.CameraPosition = [0.0, 0.0, 6.7]
00045         v.LightSwitch = 0
00046         v.CameraClippingRange = [4.5, 9.5]
00047         v.LODThreshold = 5.0
00048         v.Background = [0., 0., 0.]
00049         v.CameraParallelScale = 1.8
00050         
00051         file_med = MEDReader( FileName=(path + fname))
00052         
00053         time.sleep(10)
00054         SetActiveSource(file_med)
00055         Show()
00056         ##Show (file_med, view=v)
00057         ##Render(view=v)
00058         Render()
00059         time.sleep(10)
00060         WriteImage(filename = (impth +  "medFile_" + str(i+1) + ".png"), view=v, Magnification=2)
00061         print str(i+1), "Shown file is:  ", fname
00062         
00063         Delete(v)
00064         v1 = CreateRenderView()
00065         SetActiveView(v1)
00066         
00067 
00068 testdir = os.getenv("TESTDIR")
00069 pvdata = os.getenv("PVDATA")
00070 
00071 if __name__ == "__main__":
00072   medread(path=testdir+"/MedData/", impth=testdir+"/Pic/")