1 # Copyright (C) 2010-2014 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 # This case corresponds to: /visu/united/A4 case
22 from paravistest import datadir
23 from presentations import *
27 my_paravis = paravis.myParavis
29 cell_entity = EntityType.CELL
30 node_entity = EntityType.NODE
33 print "**** Step1: Import MED file"
35 print 'Import "Hexa8.med"....................',
36 file_path = datadir + "Hexa8.med"
37 my_paravis.ImportFile(file_path)
38 med_reader1 = pvsimple.GetActiveSource()
40 if med_reader1 is None:
45 mesh_name1 = 'Maillage_MED_HEXA8'
46 scalar_field = 'scalar_field'
47 vectoriel_field = 'vectoriel_field'
48 view = pvsimple.GetRenderView()
50 print "Creating Scalar Map...................",
51 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, scalar_field, 1)
52 if scalarmap1 is None:
55 display_only(scalarmap1, view)
59 print "Creating Vectors......................",
60 vectors1 = VectorsOnField(med_reader1, cell_entity, vectoriel_field, 1)
66 print "Creating Deformed Shape...............",
67 defshape1 = DeformedShapeOnField(med_reader1, cell_entity, vectoriel_field, 1)
73 print "Creating mesh.........................",
74 mesh1 = MeshOnEntity(med_reader1, mesh_name1, cell_entity)
78 mesh1.Representation = 'Wireframe'
79 display_only(mesh1, view)
83 print "Displaying vectors....................",
84 display_only(vectors1, view)
87 print "Displaying Deformed Shape.............",
88 display_only(defshape1, view)
91 print "Set scale factor of Deformed Shape...",
92 warp_vector = defshape1.Input
93 warp_vector.ScaleFactor = 10
96 print "Displaying changed Deformed Shape.....",
97 display_only(defshape1, view)
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
107 print "Displaying changed Vectors............",
108 vectors1.Visibility = 1
114 # 2. Second MED file import
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()
122 if med_reader2 is None:
127 print "Creating mesh.........................",
128 mesh2 = MeshOnEntity(med_reader2, mesh_name2, cell_entity)
132 display_only(mesh2, view)
135 print "Setting wireframe repr. of mesh.......",
136 mesh2.Representation = 'Wireframe'
139 print "Creating Vectors......................",
140 vectors2 = VectorsOnField(med_reader2, cell_entity, "fieldcelldouble", 1)
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
152 print "Displaying Vectors (with mesh)........",
153 vectors2.Visibility = 1
159 # 3. Third MED file import
161 print 'Importing file "Penta6.med"...........',
162 file_path = datadir + "Penta6.med"
163 my_paravis.ImportFile(file_path)
164 med_reader3 = pvsimple.GetActiveSource()
166 if med_reader3 is None:
171 print "Creating Cut Planes...................",
172 cutplanes1 = CutPlanesOnField(med_reader3, cell_entity, scalar_field, 1)
173 if cutplanes1 is None:
176 display_only(cutplanes1, view)
180 print "Creating Deformed Shape...............",
181 defshape2 = DeformedShapeOnField(med_reader3, cell_entity, vectoriel_field, 1)
182 if defshape2 is None:
187 print "Creating Vectors......................",
188 vectors3 = VectorsOnField(med_reader3, cell_entity, vectoriel_field, 1)
194 print "Creating Iso Surfaces.....",
195 isosurfaces1 = IsoSurfacesOnField(med_reader3, cell_entity, vectoriel_field, 1)
196 if isosurfaces1 is None:
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)
208 print "Displaying Deformed Shape.............",
209 defshape2.Visibility = 1
213 print "Displaying Iso Surfaces...............",
214 isosurfaces1.Visibility = 1
220 # 4. Import Quad4,Tetra4 and Tria3 MED files
222 print 'Importing "Quad4.med".................',
223 file_path = datadir + "Quad4.med"
224 my_paravis.ImportFile(file_path)
225 med_reader4 = pvsimple.GetActiveSource()
227 if med_reader4 is None:
232 mesh_name4 = 'Maillage MED_QUAD4'
234 print "Creating Iso Surfaces.................",
235 isosurfaces2 = IsoSurfacesOnField(med_reader4, cell_entity, scalar_field, 1)
236 if isosurfaces2 is None:
241 print "Creating Cut Planes...................",
242 cutplanes2 = CutPlanesOnField(med_reader4, cell_entity, scalar_field, 1,
243 orientation=Orientation.YZ)
244 if cutplanes2 is None:
249 print "Creating Deformed Shape...............",
250 defshape3 = DeformedShapeOnField(med_reader4, cell_entity, vectoriel_field, 1, scale_factor=10)
251 if defshape3 is None:
256 print "Creating Vectors......................",
257 vectors4 = VectorsOnField(med_reader4, cell_entity, vectoriel_field, 1)
263 print "Displaying Iso Surfaces, Def. Shape and Vectors.",
264 display_only(isosurfaces2, view)
265 defshape3.Visibility = 1
266 vectors4.Visibility = 1
270 print 'Importing "Tetra4.med"................',
271 file_path = datadir + "Tetra4.med"
272 my_paravis.ImportFile(file_path)
273 med_reader5 = pvsimple.GetActiveSource()
275 if med_reader5 is None:
280 mesh_name5 = 'Maillage MED_TETRA4'
282 print "Creating Scalar Map...................",
283 scalarmap2 = ScalarMapOnField(med_reader5, cell_entity, scalar_field, 1)
284 if scalarmap2 is None:
289 print "Creating Vectors......................",
290 vectors5 = VectorsOnField(med_reader5, cell_entity, vectoriel_field, 1)
296 vectors5.LineWidth = 3
297 vectors5.Input.SetScaleFactor = 2
299 print "Displaying Scalar Map and Vectoes.....",
301 display_only(scalarmap2, view)
302 vectors5.Visibility = 1
306 print 'Importing "Tria3.med".................',
307 file_path = datadir + "Tria3.med"
308 my_paravis.ImportFile(file_path)
309 med_reader6 = pvsimple.GetActiveSource()
311 if med_reader6 is None:
316 mesh_name6 = 'Maillage MED_TRIA3'
318 print "Creating Scalar Map...................",
319 scalarmap3 = ScalarMapOnField(med_reader6, cell_entity, scalar_field, 1)
320 if scalarmap3 is None:
323 display_only(scalarmap3, view)
328 print "Creating Iso Surfaces.................",
329 isosurfaces3 = IsoSurfacesOnField(med_reader6, cell_entity, scalar_field, 1)
330 if isosurfaces3 is None:
333 display_only(isosurfaces3, view)
338 print "Creating Deformed Shape...............",
339 defshape4 = DeformedShapeOnField(med_reader6, cell_entity, vectoriel_field, 1)
340 if defshape4 is None:
343 display_only(defshape4, view)
348 print "Creating Vectors......................",
349 vectors6 = VectorsOnField(med_reader6, cell_entity, vectoriel_field, 1)
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)
362 print "Displaying only Def. Shape and Vectors",
363 display_only(defshape4, view)
364 vectors6.Visibility = 1