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/A1 case
22 from paravistest import datadir
23 from presentations import *
27 print("**** Step1: Import MED file")
29 print('Import "ResOK_0000.med"...', end=' ')
30 file_path = datadir + "ResOK_0000.med"
31 pvsimple.OpenDataFile(file_path)
32 med_reader = pvsimple.GetActiveSource()
34 if med_reader is None:
39 print('Get view...................', end=' ')
40 view = pvsimple.GetRenderView()
47 cell_entity = EntityType.CELL
48 node_entity = EntityType.NODE
50 # 2. Displaying vector field
51 print("**** Step2: Displaying vector field")
53 print("Creating Scalar Map.......", end=' ')
54 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
59 bar.Orientation = 'Horizontal'
60 bar.Position = [0.1, 0.1]
61 # bar.Position2 = [0.1, 0.25]
64 display_only(scalarmap, view)
69 print("Creating Stream Lines.....", end=' ')
70 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
71 if streamlines is None:
74 display_only(streamlines, view)
77 print("Creating Vectors..........", end=' ')
78 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
82 display_only(vectors, view)
85 print("Creating Iso Surfaces.....", end=' ')
86 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
87 contour_filter = pvsimple.GetActiveSource()
88 if isosurfaces is None:
91 display_only(isosurfaces, view)
94 print("Creating Cut Planes.......", end=' ')
95 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
96 nb_planes=30, orientation=Orientation.YZ)
100 display_only(cutplanes, view)
103 # 3. Another MED file import
104 print("**** Step3: Import another MED file")
106 print('Import "Fields_group3D.med"...............', end=' ')
107 file_path = datadir + "Fields_group3D.med"
108 pvsimple.OpenDataFile(file_path)
109 med_reader1 = pvsimple.GetActiveSource()
111 if med_reader1 is None:
116 # 4. Displaying scalar field
117 print("**** Step4: Displaying scalar field")
119 print("Creating Scalar Map.......", end=' ')
120 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar field', 1)
121 if scalarmap1 is None:
124 display_only(scalarmap1, view)
129 print("Creating Iso Surfaces.....", end=' ')
130 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar field', 1)
131 if isosurfaces1 is None:
134 display_only(isosurfaces1, view)
137 print("Creating Cut Planes.......", end=' ')
138 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar field', 1,
139 orientation=Orientation.YZ)
140 if cutplanes1 is None:
143 slice_filter = pvsimple.GetActiveSource()
144 slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
145 display_only(cutplanes1, view)
148 # 5. Object browser popup
150 print("**** Step5: Object browser popup")
152 mesh_name = 'mailles_MED'
154 print("Creating mesh.............", end=' ')
155 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
159 display_only(mesh, view)
162 print("Changing type of presentation of mesh:")
163 mesh.Representation = 'Wireframe'
165 prs_type = mesh.Representation
166 print("Presentation type..", prs_type)
168 mesh.Representation = 'Points'
170 prs_type = mesh.Representation
171 print("Presentation type..", prs_type)
173 mesh.Representation = 'Surface'
175 prs_type = mesh.Representation
176 print("Presentation type..", prs_type)
178 shrink = pvsimple.Shrink(med_reader1)
179 mesh_shrinked = pvsimple.GetRepresentation(shrink)
180 display_only(mesh_shrinked, view)
182 print("Changing color of mesh....", end=' ')
184 mesh.DiffuseColor = color
185 display_only(mesh, view)
188 print("Changing first IsoSurfaces", end=' ')
189 display_only(isosurfaces, view)
191 rgb_points = isosurfaces.LookupTable.RGBPoints
192 scalar_range = [rgb_points[0], rgb_points[4]]
193 surfaces = get_contours(scalar_range, 25)
194 contour_filter.Isosurfaces = surfaces
195 pvsimple.Render(view=view)
198 print("Hide IsoSurfaces..........", end=' ')
199 isosurfaces.Visibility = 0
200 pvsimple.Render(view=view)