Salome HOME
Merge from V6_main 01/04/2013
[modules/paravis.git] / test / VisuPrs / CutPlanes / G2.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 # This case corresponds to: /visu/CutPlanes/G2 case
21 # Create Cut planes for field of the the given MED file for 10 timestamps%
22
23 import sys
24 from paravistest import datadir, pictureext, get_picture_dir
25 from presentations import *
26 from pvsimple import *
27 import paravis
28
29 # Create presentations
30 myParavis = paravis.myParavis
31 picturedir = get_picture_dir(sys.argv[1], "CutPlanes/G2")
32
33 theFileName = datadir +  "Bug829_resu_mode.med"
34 print " --------------------------------- "
35 print "file ", theFileName
36 print " --------------------------------- "
37
38 """Build presentations of the given types for all fields of the given file."""
39 #print "Import %s..." % theFileName.split('/')[-1],
40 result = myParavis.ImportFile(theFileName)
41 aProxy = GetActiveSource()
42 if aProxy is None:
43         raise RuntimeError, "Error: can't import file."
44 else: print "OK"
45 # Get viewScalarMap
46 aView = GetRenderView()
47
48 # Create required presentations for the proxy
49 # CreatePrsForProxy(aProxy, aView, thePrsTypeList, thePictureDir, thePictureExt, theIsAutoDelete)
50 aFieldNames = aProxy.PointArrays.GetData()
51 aNbOnNodes = len(aFieldNames)
52 aFieldNames.extend(aProxy.CellArrays.GetData())
53 aTimeStamps = aProxy.TimestepValues.GetData()
54 aFieldEntity = EntityType.NODE
55 aFieldName = "MODES_DEPL"
56
57 #create Cut Planes presentations for 10 timestamps
58 for i in range(1,11):
59     hide_all(aView, True)
60     aPrs = CutPlanesOnField(aProxy, aFieldEntity,aFieldName , i)
61     if aPrs is None:
62         raise RuntimeError, "Presentation is None!!!"
63     #display only current scalar map
64     aPrs.Visibility=1
65     reset_view(aView)
66     Render(aView)    
67     
68     # Add path separator to the end of picture path if necessery
69     if not picturedir.endswith(os.sep):
70             picturedir += os.sep
71     prs_type = PrsTypeEnum.CUTPLANES
72             
73     # Get name of presentation type
74     prs_name = PrsTypeEnum.get_name(prs_type)    
75     f_prs_type = prs_name.replace(' ', '').upper()
76     # Construct image file name
77     pic_name = picturedir + aFieldName + "_" + str(i) + "_" + f_prs_type + "." + pictureext
78     
79     # Show and record the presentation
80     process_prs_for_test(aPrs, aView, pic_name)
81
82