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/SWIG_scripts/A1 case
22 from paravistest import datadir
23 from presentations import *
26 #====================Stage1: Importing MED file====================
28 print("**** Stage1: Importing MED file")
30 print('Import "ResOK_0000.med"...............', end=' ')
31 file_path = datadir + "ResOK_0000.med"
32 pvsimple.OpenDataFile(file_path)
33 med_reader = pvsimple.GetActiveSource()
35 if med_reader is None:
40 cell_entity = EntityType.CELL
41 node_entity = EntityType.NODE
43 #====================Stage2: Displaying vector field===============
45 print("**** Stage3: Displaying vector field")
47 print('Get view...................', end=' ')
48 view = pvsimple.GetRenderView()
55 print("Creating Scalar Map.......", end=' ')
56 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
61 bar.Orientation = 'Horizontal'
62 bar.Position = [0.1, 0.1]
63 #bar.Position2 = [0.1, 0.25]
66 display_only(scalarmap, view)
71 print("Creating Stream Lines.....", end=' ')
72 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
73 if streamlines is None:
76 display_only(streamlines, view)
79 print("Creating Vectors..........", end=' ')
80 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
84 display_only(vectors, view)
87 print("Creating Iso Surfaces.....", end=' ')
88 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
89 if isosurfaces is None:
92 display_only(isosurfaces, view)
95 print("Creating Cut Planes.......", end=' ')
96 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
97 nb_planes=30, orientation=Orientation.YZ)
101 display_only(cutplanes, view)
104 print("Creating Scalar Map On Deformed Shape.......", end=' ')
105 scalarmapondefshape = DeformedShapeAndScalarMapOnField(med_reader,
111 if scalarmapondefshape is None:
114 display_only(scalarmapondefshape, view)
117 #====================Stage3: Another Med file import====================
119 print('Import "Fields_group3D.med"...............', end=' ')
120 file_path = datadir + "Fields_group3D.med"
121 pvsimple.OpenDataFile(file_path)
122 med_reader1 = pvsimple.GetActiveSource()
124 if med_reader1 is None:
129 #====================Stage4: Displaying scalar field====================
131 print("**** Stage4: Displaying scalar field")
133 print("Creating Scalar Map.......", end=' ')
134 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar field', 1)
135 if scalarmap1 is None:
138 display_only(scalarmap1, view)
143 print("Creating Iso Surfaces.....", end=' ')
144 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar field', 1)
145 if isosurfaces1 is None:
148 display_only(isosurfaces1, view)
151 print("Creating Cut Planes.......", end=' ')
152 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar field', 1,
153 orientation=Orientation.YZ)
154 if cutplanes1 is None:
159 slice_filter = pvsimple.GetActiveSource()
160 slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
161 display_only(cutplanes1, view)
163 print("Creating Scalar Map On Deformed Shape.......", end=' ')
164 scalarmapondefshape1 = DeformedShapeAndScalarMapOnField(med_reader1,
166 'vectoriel field', 1)
167 if scalarmapondefshape1 is None:
170 display_only(scalarmapondefshape1, view)
173 #====================Stage5: Object browser popup====================
175 print("**** Stage5: Object browser popup")
177 print("Creating mesh.............", end=' ')
179 mesh_name = 'mailles_MED'
180 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
184 display_only(mesh, view)
187 print("Changing type of presentation of mesh:")
188 mesh.Representation = 'Wireframe'
190 prs_type = mesh.Representation
191 print("Presentation type..", prs_type)
193 mesh.Representation = 'Points'
195 prs_type = mesh.Representation
196 print("Presentation type..", prs_type)
198 mesh.Representation = 'Surface'
200 prs_type = mesh.Representation
201 print("Presentation type..", prs_type)
203 shrink = pvsimple.Shrink(med_reader1)
204 mesh_shrinked = pvsimple.GetRepresentation(shrink)
205 display_only(mesh_shrinked, view)
207 print("Changing color of mesh....", end=' ')
209 mesh.DiffuseColor = color
210 display_only(mesh, view)