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