Salome HOME
Merge branch 'akl/tests_update'
[modules/paravis.git] / test / VisuPrs / bugs / A9.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/bugs/A9 case
21
22 import os
23 import sys
24
25 from paravistest import datadir, get_picture_dir, pictureext
26 from presentations import *
27 import paravis
28 import pvsimple
29
30 my_paravis = paravis.myParavis
31
32 os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
33 picturedir = get_picture_dir("bugs/A9")
34
35 # 1. Step1: Import MED file
36 print "**** Step1: Importing MED file"
37
38 print 'Import "sortie_med_volumique.med"...............',
39 file_path = datadir + "sortie_med_volumique_v3.0.6.med"
40 my_paravis.ImportFile(file_path)
41 med_reader = pvsimple.GetActiveSource()
42
43 if med_reader is None:
44     print "FAILED"
45 else:
46     print "OK"
47
48 print 'Get view........................................',
49 view = pvsimple.GetRenderView()
50 if view is None:
51     print "FAILED"
52 else:
53     reset_view(view)
54     print "OK"
55     
56 mesh_name = 'Volume_fluide'
57 cell_entity = EntityType.CELL
58 node_entity = EntityType.NODE
59
60 # 2. Step2: Displaying mesh
61 errors = 0
62
63 print "**** Step2: Display mesh"
64 print "BREAKPOINT_1"
65
66 # Creation of Mesh presentation on nodes
67 print "Creating Mesh presentation on nodes......."
68 mesh = MeshOnEntity(med_reader, mesh_name, node_entity)
69 if mesh is None:
70     print "ERROR!!! Mesh presentation on nodes creation FAILED!!!"
71     errors += 1
72 else:
73     picture_path = os.path.join(picturedir, "MeshPresentation_OnNodes." + pictureext)
74     process_prs_for_test(mesh, view, picture_path)
75     print "OK"
76
77 # Creation of Mesh presentation on cells
78 print "Creating Mesh presentation on cells......."
79 mesh = MeshOnEntity(med_reader, mesh_name, cell_entity)
80 if mesh is None:
81     print "ERROR!!! Mesh presentation on cells creation FAILED!!!"
82     errors += 1
83 else:
84     picture_path = os.path.join(picturedir, "MeshPresentation_OnCells." + pictureext)
85     process_prs_for_test(mesh, view, picture_path)
86     print "OK"
87
88 # 3. Step3: Displaying scalar field 'Dissip'
89 print "**** Step3: Display scalar field 'Dissip'"
90
91 entity = cell_entity
92
93 # Scalar Map creation
94 print "Creating Scalar Map.......",
95 scalarmap = ScalarMapOnField(med_reader, entity, 'Dissip', 1)
96
97 if scalarmap is None:
98     print "ERROR!!! Scalar Map creation FAILED!!!"
99     errors += 1
100 else:
101     picture_path = os.path.join(picturedir, "ScalarMap_Dissip." + pictureext)
102     process_prs_for_test(scalarmap, view, picture_path)
103     print "OK"
104
105 # Iso Surfaces creation
106 print "Creating Iso Surfaces.......",
107 isosurfaces = IsoSurfacesOnField(med_reader, entity, 'Dissip', 1)
108
109 if isosurfaces is None:
110     print "ERROR!!! Iso Surfaces creation FAILED!!!"
111     errors += 1
112 else:
113     picture_path = os.path.join(picturedir, "IsoSurfaces_Dissip." + pictureext)
114     process_prs_for_test(isosurfaces, view, picture_path)
115     print "OK"
116
117 # Gauss Points creation
118 print "Creating Gauss Points.......",
119 gausspoints = GaussPointsOnField(med_reader, entity, 'Dissip', 1)
120
121 if gausspoints is None:
122     print "ERROR!!! Gauss Points creation FAILED!!!"
123     errors += 1
124 else:
125     picture_path = os.path.join(picturedir, "GaussPoints_Dissip." + pictureext)
126     process_prs_for_test(isosurfaces, view, picture_path)
127     print "OK"
128
129 # 4. Step4: Displaying vectoriel field 'VitesseX'
130 entity = cell_entity
131
132 print "**** Step5: Display vectoriel field 'VitesseX'"
133 # Deformed Shape creation
134 print "Creating Deformed Shape.......",
135
136 defshape = DeformedShapeOnField(med_reader, entity, 'VitesseX', 1)
137 if defshape is None:
138     print "ERROR!!! Deformed Shape creation FAILED!!!"
139     errors += 1
140 else:
141     picture_path = os.path.join(picturedir, "DeformedShape_VitesseX." + pictureext)
142     process_prs_for_test(defshape, view, picture_path)
143     print "OK"
144
145 # Vectors creation
146 print "Creating Vectors.......",
147 vectors = VectorsOnField(med_reader, entity, 'VitesseX', 1)
148
149 if vectors is None:
150     print "ERROR!!! Vectors creation FAILED!!!"
151     errors += 1
152 else:
153     picture_path = os.path.join(picturedir, "Vectors_VitesseX." + pictureext)
154     process_prs_for_test(vectors, view, picture_path)
155     print "OK"
156
157 # Scalar Map On Deformed Shape creation
158 print "Creating Scalar Map On Deformed Shape.......",
159 smapondefshape = DeformedShapeAndScalarMapOnField(med_reader, entity, 'VitesseX', 1)
160
161 if smapondefshape is None:
162     print "ERROR!!! ScalarMapOnDeformedShape creation failed!!!"
163     errors += 1
164 else:
165     picture_path = os.path.join(picturedir, "ScalMapOnDefShape_VitesseX." + pictureext)
166     process_prs_for_test(smapondefshape, view, picture_path)
167     print "OK"
168
169 if errors == 1:
170     raise RuntimeError, "There is an error was occured... For more info see ERROR message above.."
171 elif errors > 1:
172     raise RuntimeError, "There are some errors were occured... For more info see ERRORs messages above.."
173 print "BREAKPOINT_2"