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