Salome HOME
fe7b971d5085dfd58e407fca9243734d2c281eed
[modules/paravis.git] / test / VisuPrs / dump_study / B0.py
1 # Copyright (C) 2010-2014  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 # This case corresponds to: /visu/dump_study/B0 case
21
22 from paravistest import datadir
23 from presentations import *
24 import pvserver as paravis
25 from pvsimple import *
26
27 my_paravis = paravis.myParavis
28
29 # 1. TimeStamps.med import
30 file_path = datadir + "TimeStamps.med"
31 my_paravis.ImportFile(file_path)
32 med_reader = GetActiveSource()
33 if med_reader is None :
34     raise RuntimeError, "TimeStamps.med wasn't imported..."
35
36 # 2. Presentations creation
37 errors = 0
38 prs_names = ["ScalarMap", "IsoSurfaces", "CutPlanes", "CutLines", "DeformedShape", "Vectors", "StreamLines", "Plot3D", "DeformedShapeAndScalarMap", "GaussPoints"]
39 prs_list = []
40
41 med_field = "vitesse"
42
43 for name in prs_names:
44     print "Creation of ", name, " presentation..."
45     if name == "GaussPoints":
46         prs = GaussPointsOnField(med_reader, EntityType.CELL, "pression", 1)  
47         pass
48     else: 
49         prs = eval(name + "OnField(med_reader, EntityType.NODE, med_field, 1)")
50     if prs is None:
51         print "ERROR!!! ", name," presentation wasn't created..."
52         errors += 1
53     else:
54         RenameSource(name, prs.Input)
55         prs_list.append(prs)
56
57 # 3. Dump Study
58 path_to_save = os.path.join(os.getenv("HOME"), "AllPresentations.py")
59 SaveTrace( path_to_save )
60
61 # 4. Delete the created objects, recreate the view
62 source_list = GetSources().values()
63 for source in source_list:
64     Delete(source)
65
66 Delete(GetActiveView())
67 view = CreateRenderView()
68
69 # 5. Execution of the created script
70 execfile(path_to_save)
71
72 # 6. Check the restored objects
73 for name in prs_names:
74     source = FindSource(name)
75     if source is None:
76         print "There is no ", name, " in the study (must be created by executed python script)!!!"
77         errors += 1
78     else:
79         print name + " was found..."
80
81 if errors > 0:
82     raise RuntimeError, "There is(are) some error(s) was(were) found... For more info see ERRORs above..."
83
84