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