Salome HOME
Update ParaVis non-regression test base in the following ways:
[modules/paravis.git] / test / VisuPrs / united / A1.py
1 # Copyright (C) 2010-2015  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20 # This case corresponds to: /visu/united/A1 case
21
22 from paravistest import datadir
23 from presentations import *
24 import pvsimple
25
26 # 1. Import MED file
27 print "**** Step1: Import MED file"
28
29 print 'Import "ResOK_0000.med"...',
30 file_path = datadir + "ResOK_0000.med"
31 pvsimple.OpenDataFile(file_path)
32 med_reader = pvsimple.GetActiveSource()
33
34 if med_reader is None:
35     print "FAILED"
36 else:
37     print "OK"
38
39 print 'Get view...................',
40 view = pvsimple.GetRenderView()
41 if view is None:
42     print "FAILED"
43 else:
44     reset_view(view)
45     print "OK"
46
47 cell_entity = EntityType.CELL
48 node_entity = EntityType.NODE
49
50 # 2. Displaying vector field
51 print "**** Step2: Displaying vector field"
52
53 print "Creating Scalar Map.......",
54 scalarmap = ScalarMapOnField(med_reader, node_entity, 'vitesse', 1)
55 if scalarmap is None:
56     print "FAILED"
57 else:
58     bar = get_bar()
59     bar.Orientation = 'Horizontal'
60     bar.Position = [0.1, 0.1]
61     bar.Position2 = [0.1, 0.25]
62     bar.AspectRatio = 3
63
64     display_only(scalarmap, view)
65     print "OK"
66
67 reset_view(view)
68
69 print "Creating Stream Lines.....",
70 streamlines = StreamLinesOnField(med_reader, node_entity, 'vitesse', 1)
71 if streamlines is None:
72     print "FAILED"
73 else:
74     display_only(streamlines, view)
75     print "OK"
76
77 print "Creating Vectors..........",
78 vectors = VectorsOnField(med_reader, node_entity, 'vitesse', 1)
79 if vectors is None:
80     print "FAILED"
81 else:
82     display_only(vectors, view)
83     print "OK"
84
85 print "Creating Iso Surfaces.....",
86 isosurfaces = IsoSurfacesOnField(med_reader, node_entity, 'vitesse', 1)
87 contour_filter = pvsimple.GetActiveSource()
88 if isosurfaces is None:
89     print "FAILED"
90 else:
91     display_only(isosurfaces, view)
92     print "OK"
93
94 print "Creating Cut Planes.......",
95 cutplanes = CutPlanesOnField(med_reader, node_entity, 'vitesse', 1,
96                              nb_planes=30, orientation=Orientation.YZ)
97 if cutplanes is None:
98     print "FAILED"
99 else:
100     display_only(cutplanes, view)
101     print "OK"
102
103 # 3. Another MED file import
104 print "**** Step3: Import another MED file"
105
106 print 'Import "Fields_group3D.med"...............',
107 file_path = datadir + "Fields_group3D.med"
108 pvsimple.OpenDataFile(file_path)
109 med_reader1 = pvsimple.GetActiveSource()
110
111 if med_reader1 is None:
112     print "FAILED"
113 else:
114     print "OK"
115
116 # 4. Displaying scalar field
117 print "**** Step4: Displaying scalar field"
118
119 print "Creating Scalar Map.......",
120 scalarmap1 = ScalarMapOnField(med_reader1, cell_entity, 'scalar field', 1)
121 if scalarmap1 is None:
122     print "FAILED"
123 else:
124     display_only(scalarmap1, view)
125     print "OK"
126
127 reset_view(view)
128
129 print "Creating Iso Surfaces.....",
130 isosurfaces1 = IsoSurfacesOnField(med_reader1, cell_entity, 'scalar field', 1)
131 if isosurfaces1 is None:
132     print "FAILED"
133 else:
134     display_only(isosurfaces1, view)
135     print "OK"
136
137 print "Creating Cut Planes.......",
138 cutplanes1 = CutPlanesOnField(med_reader1, cell_entity, 'scalar field', 1,
139                               orientation=Orientation.YZ)
140 if cutplanes1 is None:
141     print "FAILED"
142 else:
143     slice_filter = pvsimple.GetActiveSource()
144     slice_filter.SliceType.Normal = [1.0, 0.0, 0.0]
145     display_only(cutplanes1, view)
146     print "OK"
147
148 # 5. Object browser popup
149
150 print "**** Step5: Object browser popup"
151
152 mesh_name = 'mailles_MED'
153
154 print "Creating mesh.............",
155 mesh = MeshOnEntity(med_reader1, mesh_name, cell_entity)
156 if mesh is None:
157     print "FAILED"
158 else:
159     display_only(mesh, view)
160     print "OK"
161
162 print "Changing type of presentation of mesh:"
163 mesh.Representation = 'Wireframe'
164 pvsimple.Render()
165 prs_type = mesh.Representation
166 print "Presentation type..", prs_type
167
168 mesh.Representation = 'Points'
169 pvsimple.Render()
170 prs_type = mesh.Representation
171 print "Presentation type..", prs_type
172
173 mesh.Representation = 'Surface'
174 pvsimple.Render()
175 prs_type = mesh.Representation
176 print "Presentation type..", prs_type
177
178 shrink = pvsimple.Shrink(med_reader1)
179 mesh_shrinked = pvsimple.GetRepresentation(shrink)
180 display_only(mesh_shrinked, view)
181
182 print "Changing color of mesh....",
183 color = [0, 0, 1]
184 mesh.DiffuseColor = color
185 display_only(mesh, view)
186 print "OK"
187
188 print "Changing first IsoSurfaces",
189 display_only(isosurfaces, view)
190 reset_view(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)
196 print "OK"
197
198 print "Hide IsoSurfaces..........",
199 isosurfaces.Visibility = 0
200 pvsimple.Render(view=view)
201 print "OK"