1 # Copyright (C) 2010-2013 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.
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 *
28 my_paravis = paravis.myParavis
30 #====================Stage1: Importing MED file====================
32 print "**** Stage1: Importing MED file"
34 print 'Import "ResOK_0000.med"...............',
35 file_path = datadir + "ResOK_0000.med"
36 my_paravis.ImportFile(file_path)
37 med_reader = pvsimple.GetActiveSource()
39 if med_reader is None:
44 cell_entity = EntityType.CELL
45 node_entity = EntityType.NODE
47 #====================Stage2: Displaying vector field===============
49 print "**** Stage3: Displaying vector field"
51 print 'Get view...................',
52 view = pvsimple.GetRenderView()
59 print "Creating Scalar Map.......",
60 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
65 bar.Orientation = 'Horizontal'
66 bar.Position = [0.1, 0.1]
67 bar.Position2 = [0.1, 0.25]
70 display_only(scalarmap, view)
75 print "Creating Stream Lines.....",
76 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
77 if streamlines is None:
80 display_only(streamlines, view)
83 print "Creating Vectors..........",
84 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
88 display_only(vectors, view)
91 print "Creating Iso Surfaces.....",
92 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
93 if isosurfaces is None:
96 display_only(isosurfaces, view)
99 print "Creating Cut Planes.......",
100 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
101 nb_planes=30, orientation=Orientation.YZ)
102 if cutplanes is None:
105 display_only(cutplanes, view)
108 print "Creating Scalar Map On Deformed Shape.......",
109 scalarmapondefshape = DeformedShapeAndScalarMapOnField(med_reader,
115 if scalarmapondefshape is None:
118 display_only(scalarmapondefshape, view)
121 #====================Stage3: Another Med file import====================
123 print 'Import "Fields_group3D.med"...............',
124 file_path = datadir + "Fields_group3D.med"
125 my_paravis.ImportFile(file_path)
126 med_reader1 = pvsimple.GetActiveSource()
128 if med_reader1 is None:
133 #====================Stage4: Displaying scalar field====================
135 print "**** Stage4: Displaying scalar field"
137 print "Creating Scalar Map.......",
138 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar_field', 1)
139 if scalarmap1 is None:
142 display_only(scalarmap1, view)
147 print "Creating Iso Surfaces.....",
148 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar_field', 1)
149 if isosurfaces1 is None:
152 display_only(isosurfaces1, view)
155 print "Creating Cut Planes.......",
156 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar_field', 1,
157 orientation=Orientation.YZ)
158 if cutplanes1 is None:
163 slice_filter = pvsimple.GetActiveSource()
164 slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
165 display_only(cutplanes1, view)
167 print "Creating Scalar Map On Deformed Shape.......",
168 scalarmapondefshape1 = DeformedShapeAndScalarMapOnField(med_reader1,
170 'vectoriel_field', 1)
171 if scalarmapondefshape1 is None:
174 display_only(scalarmapondefshape1, view)
177 #====================Stage5: Object browser popup====================
179 print "**** Stage5: Object browser popup"
181 print "Creating mesh.............",
183 mesh_name = 'mailles_MED'
184 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
188 display_only(mesh, view)
191 print "Changing type of presentation of mesh:"
192 mesh.Representation = 'Wireframe'
194 prs_type = mesh.Representation
195 print "Presentation type..", prs_type
197 mesh.Representation = 'Points'
199 prs_type = mesh.Representation
200 print "Presentation type..", prs_type
202 mesh.Representation = 'Surface'
204 prs_type = mesh.Representation
205 print "Presentation type..", prs_type
207 shrink = pvsimple.Shrink(med_reader1)
208 mesh_shrinked = pvsimple.GetRepresentation(shrink)
209 display_only(mesh_shrinked, view)
211 print "Changing color of mesh....",
213 mesh.DiffuseColor = color
214 display_only(mesh, view)