1 # Copyright (C) 2010-2015 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 *
24 import pvserver as paravis
27 my_paravis = paravis.myParavis
30 print "**** Step1: Import MED file"
32 print 'Import "ResOK_0000.med"...',
33 file_path = datadir + "ResOK_0000.med"
34 OpenDataFile(file_path)
35 med_reader = pvsimple.GetActiveSource()
37 if med_reader is None:
42 print 'Get view...................',
43 view = pvsimple.GetRenderView()
50 cell_entity = EntityType.CELL
51 node_entity = EntityType.NODE
53 # 2. Displaying vector field
54 print "**** Step2: Displaying vector field"
56 print "Creating Scalar Map.......",
57 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
62 bar.Orientation = 'Horizontal'
63 bar.Position = [0.1, 0.1]
64 bar.Position2 = [0.1, 0.25]
67 display_only(scalarmap, view)
72 print "Creating Stream Lines.....",
73 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
74 if streamlines is None:
77 display_only(streamlines, view)
80 print "Creating Vectors..........",
81 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
85 display_only(vectors, view)
88 print "Creating Iso Surfaces.....",
89 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
90 contour_filter = pvsimple.GetActiveSource()
91 if isosurfaces is None:
94 display_only(isosurfaces, view)
97 print "Creating Cut Planes.......",
98 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
99 nb_planes=30, orientation=Orientation.YZ)
100 if cutplanes is None:
103 display_only(cutplanes, view)
106 # 3. Another MED file import
107 print "**** Step3: Import another MED file"
109 print 'Import "Fields_group3D.med"...............',
110 file_path = datadir + "Fields_group3D.med"
111 OpenDataFile(file_path)
112 med_reader1 = pvsimple.GetActiveSource()
114 if med_reader1 is None:
119 # 4. Displaying scalar field
120 print "**** Step4: Displaying scalar field"
122 print "Creating Scalar Map.......",
123 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar field', 1)
124 if scalarmap1 is None:
127 display_only(scalarmap1, view)
132 print "Creating Iso Surfaces.....",
133 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar field', 1)
134 if isosurfaces1 is None:
137 display_only(isosurfaces1, view)
140 print "Creating Cut Planes.......",
141 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar field', 1,
142 orientation=Orientation.YZ)
143 if cutplanes1 is None:
146 slice_filter = pvsimple.GetActiveSource()
147 slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
148 display_only(cutplanes1, view)
151 # 5. Object browser popup
153 print "**** Step5: Object browser popup"
155 mesh_name = 'mailles_MED'
157 print "Creating mesh.............",
158 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
162 display_only(mesh, view)
165 print "Changing type of presentation of mesh:"
166 mesh.Representation = 'Wireframe'
168 prs_type = mesh.Representation
169 print "Presentation type..", prs_type
171 mesh.Representation = 'Points'
173 prs_type = mesh.Representation
174 print "Presentation type..", prs_type
176 mesh.Representation = 'Surface'
178 prs_type = mesh.Representation
179 print "Presentation type..", prs_type
181 shrink = pvsimple.Shrink(med_reader1)
182 mesh_shrinked = pvsimple.GetRepresentation(shrink)
183 display_only(mesh_shrinked, view)
185 print "Changing color of mesh....",
187 mesh.DiffuseColor = color
188 display_only(mesh, view)
191 print "Changing first IsoSurfaces",
192 display_only(isosurfaces, view)
194 rgb_points = isosurfaces.LookupTable.RGBPoints
195 scalar_range = [rgb_points[0], rgb_points[4]]
196 surfaces = get_contours(scalar_range, 25)
197 contour_filter.Isosurfaces = surfaces
198 pvsimple.Render(view=view)
201 print "Hide IsoSurfaces..........",
202 isosurfaces.Visibility = 0
203 pvsimple.Render(view=view)