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