]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/united/A4.py
Salome HOME
Porting to python3
[modules/paravis.git] / test / VisuPrs / united / A4.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/united/A4 case
21
22 from paravistest import datadir
23 from presentations import *
24 import pvsimple
25
26 cell_entity = EntityType.CELL
27 node_entity = EntityType.NODE
28
29 # 1. Import MED file
30 print("**** Step1: Import MED file")
31
32 print('Import "Hexa8.med"....................', end=' ')
33 file_path = datadir + "Hexa8.med"
34 pvsimple.OpenDataFile(file_path)
35 med_reader1 = pvsimple.GetActiveSource()
36
37 if med_reader1 is None:
38     print("FAILED")
39 else:
40     print("OK")
41
42 mesh_name1 = 'Maillage MED_HEXA8'
43 scalar_field = 'scalar field'
44 vectoriel_field = 'vectoriel field'
45 view = pvsimple.GetRenderView()
46
47 print("Creating Scalar Map...................", end=' ')
48 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, scalar_field, 1)
49 if scalarmap1 is None:
50     print("FAILED")
51 else:
52     display_only(scalarmap1, view)
53     reset_view(view)
54     print("OK")
55
56 print("Creating Vectors......................", end=' ')
57 vectors1 = VectorsOnField(med_reader1, cell_entity, vectoriel_field, 1)
58 if vectors1 is None:
59     print("FAILED")
60 else:
61     print("OK")
62
63 print("Creating Deformed Shape...............", end=' ')
64 defshape1 = DeformedShapeOnField(med_reader1, cell_entity, vectoriel_field, 1)
65 if defshape1 is None:
66     print("FAILED")
67 else:
68     print("OK")
69
70 print("Creating mesh.........................", end=' ')
71 mesh1 = MeshOnEntity(med_reader1, mesh_name1, cell_entity)
72 if mesh1 is None:
73     print("FAILED")
74 else:
75     mesh1.Representation = 'Wireframe'
76     display_only(mesh1, view)
77     reset_view(view)
78     print("OK")
79
80 print("Displaying vectors....................", end=' ')
81 display_only(vectors1, view)
82 print("OK")
83
84 print("Displaying Deformed Shape.............", end=' ')
85 display_only(defshape1, view)
86 print("OK")
87
88 print("Set scale factor of  Deformed Shape...", end=' ')
89 warp_vector = defshape1.Input
90 warp_vector.ScaleFactor = 10
91 print("OK")
92
93 print("Displaying changed Deformed Shape.....", end=' ')
94 display_only(defshape1, view)
95 print("OK")
96
97 print("Editing Vectors.......................", end=' ')
98 glyph = vectors1.Input
99 glyph.ScaleFactor = 2
100 vectors1.LineWidth = 2
101 glyph.GlyphType.Center = [0.5, 0.0, 0.0] # TAIL position
102 print("OK")
103
104 print("Displaying changed Vectors............", end=' ')
105 vectors1.Visibility = 1
106 pvsimple.Render()
107 print("OK")
108
109 hide_all(view)
110
111 # 2. Second MED file import
112
113 print('Importing file "cube_hexa8_quad4.med".', end=' ')
114 file_path = datadir + "cube_hexa8_quad4.med"
115 mesh_name2 = 'CUBE_EN_HEXA8_QUAD4'
116 pvsimple.OpenDataFile(file_path)
117 med_reader2 = pvsimple.GetActiveSource()
118
119 if med_reader2 is None:
120     print("FAILED")
121 else:
122     print("OK")
123
124 print("Creating mesh.........................", end=' ')
125 mesh2 = MeshOnEntity(med_reader2, mesh_name2, cell_entity)
126 if mesh2 is None:
127     print("FAILED")
128 else:
129     display_only(mesh2, view)
130     print("OK")
131
132 print("Setting wireframe repr. of mesh.......", end=' ')
133 mesh2.Representation = 'Wireframe'
134 print("OK")
135
136 print("Creating Vectors......................", end=' ')
137 vectors2 = VectorsOnField(med_reader2, cell_entity, "fieldcelldouble", 1)
138 if vectors1 is None:
139     print("FAILED")
140 else:
141     glyph2 = vectors2.Input
142     glyph2.ScaleFactor = 0.2
143     vectors2.LineWidth = 2
144     glyph2.GlyphType.Center = [0.5, 0.0, 0.0] # TAIL position
145     print("OK")
146
147
148
149 print("Displaying Vectors (with mesh)........", end=' ')
150 vectors2.Visibility = 1
151 pvsimple.Render()
152 print("OK")
153
154 hide_all(view)
155
156 # 3. Third MED file import
157
158 print('Importing file "Penta6.med"...........', end=' ')
159 file_path = datadir + "Penta6.med"
160 pvsimple.OpenDataFile(file_path)
161 med_reader3 = pvsimple.GetActiveSource()
162
163 if med_reader3 is None:
164     print("FAILED")
165 else:
166     print("OK")
167
168 print("Creating Cut Planes...................", end=' ')
169 cutplanes1 = CutPlanesOnField(med_reader3, cell_entity, scalar_field, 1)
170 if cutplanes1 is None:
171     print("FAILED")
172 else:
173     display_only(cutplanes1, view)
174     reset_view(view)
175     print("OK")
176
177 print("Creating Deformed Shape...............", end=' ')
178 defshape2 = DeformedShapeOnField(med_reader3, cell_entity, vectoriel_field, 1)
179 if defshape2 is None:
180     print("FAILED")
181 else:
182     print("OK")
183
184 print("Creating Vectors......................", end=' ')
185 vectors3 = VectorsOnField(med_reader3, cell_entity, vectoriel_field, 1)
186 if vectors3 is None:
187     print("FAILED")
188 else:
189     print("OK")
190
191 print("Creating Iso Surfaces.....", end=' ')
192 isosurfaces1 = IsoSurfacesOnField(med_reader3, cell_entity, vectoriel_field, 1)
193 if isosurfaces1 is None:
194     print("FAILED")
195 else:
196     print("OK")
197
198 print("Displaying Vectors (l.w.=2, s.f.=1.5).", end=' ')
199 glyph3 = vectors3.Input
200 glyph3.ScaleFactor = 1.5
201 vectors3.LineWidth = 2
202 display_only(vectors3, view)
203 print("OK")
204
205 print("Displaying Deformed Shape.............", end=' ')
206 defshape2.Visibility = 1
207 pvsimple.Render()
208 print("OK")
209
210 print("Displaying Iso Surfaces...............", end=' ')
211 isosurfaces1.Visibility = 1
212 pvsimple.Render()
213 print("OK")
214
215 hide_all(view)
216
217 # 4. Import Quad4,Tetra4 and Tria3 MED files
218
219 print('Importing "Quad4.med".................', end=' ')
220 file_path = datadir + "Quad4.med"
221 pvsimple.OpenDataFile(file_path)
222 med_reader4 = pvsimple.GetActiveSource()
223
224 if med_reader4 is None:
225     print("FAILED")
226 else:
227     print("OK")
228
229 mesh_name4 = 'Maillage MED_QUAD4'
230
231 print("Creating Iso Surfaces.................", end=' ')
232 isosurfaces2 = IsoSurfacesOnField(med_reader4, cell_entity, scalar_field, 1)
233 if isosurfaces2 is None:
234     print("FAILED")
235 else:
236     print("OK")
237
238 print("Creating Cut Planes...................", end=' ')
239 cutplanes2 = CutPlanesOnField(med_reader4, cell_entity, scalar_field, 1,
240                               orientation=Orientation.YZ)
241 if cutplanes2 is None:
242     print("FAILED")
243 else:
244     print("OK")
245
246 print("Creating Deformed Shape...............", end=' ')
247 defshape3 = DeformedShapeOnField(med_reader4, cell_entity, vectoriel_field, 1, scale_factor=10)
248 if defshape3 is None:
249     print("FAILED")
250 else:
251     print("OK")
252
253 print("Creating Vectors......................", end=' ')
254 vectors4 = VectorsOnField(med_reader4, cell_entity, vectoriel_field, 1)
255 if vectors4 is None:
256     print("FAILED")
257 else:
258     print("OK")
259
260 print("Displaying Iso Surfaces, Def. Shape and Vectors.", end=' ')
261 display_only(isosurfaces2, view)
262 defshape3.Visibility = 1
263 vectors4.Visibility = 1
264 pvsimple.Render()
265 print("OK")
266
267 print('Importing "Tetra4.med"................', end=' ')
268 file_path = datadir + "Tetra4.med"
269 pvsimple.OpenDataFile(file_path)
270 med_reader5 = pvsimple.GetActiveSource()
271
272 if med_reader5 is None:
273     print("FAILED")
274 else:
275     print("OK")
276
277 mesh_name5 = 'Maillage MED_TETRA4'
278
279 print("Creating Scalar Map...................", end=' ')
280 scalarmap2 = ScalarMapOnField(med_reader5, cell_entity, scalar_field, 1)
281 if scalarmap2 is None:
282     print("FAILED")
283 else:
284     print("OK")
285
286 print("Creating Vectors......................", end=' ')
287 vectors5 = VectorsOnField(med_reader5, cell_entity, vectoriel_field, 1)
288 if vectors5 is None:
289     print("FAILED")
290 else:
291     print("OK")
292
293 vectors5.LineWidth = 3
294 vectors5.Input.ScaleFactor = 2
295
296 print("Displaying Scalar Map and Vectoes.....", end=' ')
297 hide_all(view)
298 display_only(scalarmap2, view)
299 vectors5.Visibility = 1
300 reset_view(view)
301 print("OK")
302
303 print('Importing "Tria3.med".................', end=' ')
304 file_path = datadir + "Tria3.med"
305 pvsimple.OpenDataFile(file_path)
306 med_reader6 = pvsimple.GetActiveSource()
307
308 if med_reader6 is None:
309     print("FAILED")
310 else:
311     print("OK")
312
313 mesh_name6 = 'Maillage MED_TRIA3'
314
315 print("Creating Scalar Map...................", end=' ')
316 scalarmap3 = ScalarMapOnField(med_reader6, cell_entity, scalar_field, 1)
317 if scalarmap3 is None:
318     print("FAILED")
319 else:
320     display_only(scalarmap3, view)
321     print("OK")
322
323 reset_view(view)
324
325 print("Creating Iso Surfaces.................", end=' ')
326 isosurfaces3 = IsoSurfacesOnField(med_reader6, cell_entity, scalar_field, 1)
327 if isosurfaces3 is None:
328     print("FAILED")
329 else:
330     display_only(isosurfaces3, view)
331     print("OK")
332
333 reset_view(view)
334
335 print("Creating Deformed Shape...............", end=' ')
336 defshape4 = DeformedShapeOnField(med_reader6, cell_entity, vectoriel_field, 1)
337 if defshape4 is None:
338     print("FAILED")
339 else:
340     display_only(defshape4, view)
341     print("OK")
342
343 reset_view(view)
344
345 print("Creating Vectors......................", end=' ')
346 vectors6 = VectorsOnField(med_reader6, cell_entity, vectoriel_field, 1)
347 if vectors6 is None:
348     print("FAILED")
349 else:
350     glyph = vectors6.Input
351     glyph.GlyphType.Center = [0.5, 0.0, 0.0] # TAIL position
352     vectors6.LineWidth = 2
353     glyph.ScaleFactor = 1
354     display_only(vectors6, view)
355     print("OK")
356
357 reset_view(view)
358
359 print("Displaying only Def. Shape and Vectors", end=' ')
360 display_only(defshape4, view)
361 vectors6.Visibility = 1
362 pvsimple.Render()
363 print("OK")