1 # Copyright (C) 2010-2016 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 *
26 cell_entity = EntityType.CELL
27 node_entity = EntityType.NODE
30 print "**** Step1: Import MED file"
32 print 'Import "Hexa8.med"....................',
33 file_path = datadir + "Hexa8.med"
34 pvsimple.OpenDataFile(file_path)
35 med_reader1 = pvsimple.GetActiveSource()
37 if med_reader1 is None:
42 mesh_name1 = 'Maillage MED_HEXA8'
43 scalar_field = 'scalar field'
44 vectoriel_field = 'vectoriel field'
45 view = pvsimple.GetRenderView()
47 print "Creating Scalar Map...................",
48 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, scalar_field, 1)
49 if scalarmap1 is None:
52 display_only(scalarmap1, view)
56 print "Creating Vectors......................",
57 vectors1 = VectorsOnField(med_reader1, cell_entity, vectoriel_field, 1)
63 print "Creating Deformed Shape...............",
64 defshape1 = DeformedShapeOnField(med_reader1, cell_entity, vectoriel_field, 1)
70 print "Creating mesh.........................",
71 mesh1 = MeshOnEntity(med_reader1, mesh_name1, cell_entity)
75 mesh1.Representation = 'Wireframe'
76 display_only(mesh1, view)
80 print "Displaying vectors....................",
81 display_only(vectors1, view)
84 print "Displaying Deformed Shape.............",
85 display_only(defshape1, view)
88 print "Set scale factor of Deformed Shape...",
89 warp_vector = defshape1.Input
90 warp_vector.ScaleFactor = 10
93 print "Displaying changed Deformed Shape.....",
94 display_only(defshape1, view)
97 print "Editing Vectors.......................",
98 glyph = vectors1.Input
100 vectors1.LineWidth = 2
101 glyph.GlyphType.Center = [0.5, 0.0, 0.0] # TAIL position
104 print "Displaying changed Vectors............",
105 vectors1.Visibility = 1
111 # 2. Second MED file import
113 print 'Importing file "cube_hexa8_quad4.med".',
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()
119 if med_reader2 is None:
124 print "Creating mesh.........................",
125 mesh2 = MeshOnEntity(med_reader2, mesh_name2, cell_entity)
129 display_only(mesh2, view)
132 print "Setting wireframe repr. of mesh.......",
133 mesh2.Representation = 'Wireframe'
136 print "Creating Vectors......................",
137 vectors2 = VectorsOnField(med_reader2, cell_entity, "fieldcelldouble", 1)
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
149 print "Displaying Vectors (with mesh)........",
150 vectors2.Visibility = 1
156 # 3. Third MED file import
158 print 'Importing file "Penta6.med"...........',
159 file_path = datadir + "Penta6.med"
160 pvsimple.OpenDataFile(file_path)
161 med_reader3 = pvsimple.GetActiveSource()
163 if med_reader3 is None:
168 print "Creating Cut Planes...................",
169 cutplanes1 = CutPlanesOnField(med_reader3, cell_entity, scalar_field, 1)
170 if cutplanes1 is None:
173 display_only(cutplanes1, view)
177 print "Creating Deformed Shape...............",
178 defshape2 = DeformedShapeOnField(med_reader3, cell_entity, vectoriel_field, 1)
179 if defshape2 is None:
184 print "Creating Vectors......................",
185 vectors3 = VectorsOnField(med_reader3, cell_entity, vectoriel_field, 1)
191 print "Creating Iso Surfaces.....",
192 isosurfaces1 = IsoSurfacesOnField(med_reader3, cell_entity, vectoriel_field, 1)
193 if isosurfaces1 is None:
198 print "Displaying Vectors (l.w.=2, s.f.=1.5).",
199 glyph3 = vectors3.Input
200 glyph3.ScaleFactor = 1.5
201 vectors3.LineWidth = 2
202 display_only(vectors3, view)
205 print "Displaying Deformed Shape.............",
206 defshape2.Visibility = 1
210 print "Displaying Iso Surfaces...............",
211 isosurfaces1.Visibility = 1
217 # 4. Import Quad4,Tetra4 and Tria3 MED files
219 print 'Importing "Quad4.med".................',
220 file_path = datadir + "Quad4.med"
221 pvsimple.OpenDataFile(file_path)
222 med_reader4 = pvsimple.GetActiveSource()
224 if med_reader4 is None:
229 mesh_name4 = 'Maillage MED_QUAD4'
231 print "Creating Iso Surfaces.................",
232 isosurfaces2 = IsoSurfacesOnField(med_reader4, cell_entity, scalar_field, 1)
233 if isosurfaces2 is None:
238 print "Creating Cut Planes...................",
239 cutplanes2 = CutPlanesOnField(med_reader4, cell_entity, scalar_field, 1,
240 orientation=Orientation.YZ)
241 if cutplanes2 is None:
246 print "Creating Deformed Shape...............",
247 defshape3 = DeformedShapeOnField(med_reader4, cell_entity, vectoriel_field, 1, scale_factor=10)
248 if defshape3 is None:
253 print "Creating Vectors......................",
254 vectors4 = VectorsOnField(med_reader4, cell_entity, vectoriel_field, 1)
260 print "Displaying Iso Surfaces, Def. Shape and Vectors.",
261 display_only(isosurfaces2, view)
262 defshape3.Visibility = 1
263 vectors4.Visibility = 1
267 print 'Importing "Tetra4.med"................',
268 file_path = datadir + "Tetra4.med"
269 pvsimple.OpenDataFile(file_path)
270 med_reader5 = pvsimple.GetActiveSource()
272 if med_reader5 is None:
277 mesh_name5 = 'Maillage MED_TETRA4'
279 print "Creating Scalar Map...................",
280 scalarmap2 = ScalarMapOnField(med_reader5, cell_entity, scalar_field, 1)
281 if scalarmap2 is None:
286 print "Creating Vectors......................",
287 vectors5 = VectorsOnField(med_reader5, cell_entity, vectoriel_field, 1)
293 vectors5.LineWidth = 3
294 vectors5.Input.ScaleFactor = 2
296 print "Displaying Scalar Map and Vectoes.....",
298 display_only(scalarmap2, view)
299 vectors5.Visibility = 1
303 print 'Importing "Tria3.med".................',
304 file_path = datadir + "Tria3.med"
305 pvsimple.OpenDataFile(file_path)
306 med_reader6 = pvsimple.GetActiveSource()
308 if med_reader6 is None:
313 mesh_name6 = 'Maillage MED_TRIA3'
315 print "Creating Scalar Map...................",
316 scalarmap3 = ScalarMapOnField(med_reader6, cell_entity, scalar_field, 1)
317 if scalarmap3 is None:
320 display_only(scalarmap3, view)
325 print "Creating Iso Surfaces.................",
326 isosurfaces3 = IsoSurfacesOnField(med_reader6, cell_entity, scalar_field, 1)
327 if isosurfaces3 is None:
330 display_only(isosurfaces3, view)
335 print "Creating Deformed Shape...............",
336 defshape4 = DeformedShapeOnField(med_reader6, cell_entity, vectoriel_field, 1)
337 if defshape4 is None:
340 display_only(defshape4, view)
345 print "Creating Vectors......................",
346 vectors6 = VectorsOnField(med_reader6, cell_entity, vectoriel_field, 1)
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)
359 print "Displaying only Def. Shape and Vectors",
360 display_only(defshape4, view)
361 vectors6.Visibility = 1