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/A7 case
24 from paravistest import datadir
25 from presentations import *
28 view = pvsimple.GetRenderView()
32 def after_set(error_string, prop_name, old_value, new_value):
33 print prop_name, ": old_value = ", old_value, "new_value = ", new_value
34 if error_string == "":
37 print prop_name, " error = ", error_string
42 def change_representation(prs, repres, opacity, linew):
49 display_only(prs, view)
54 old_prs_type = prs.Representation
55 if old_prs_type != repres:
58 prs.Representation = repres
61 after_set(err_str, "Representation", old_prs_type, repres)
64 old_opacity = prs.Opacity
65 if old_opacity != opacity:
68 prs.Opacity = opacity # double value [0, 1]
71 after_set(err_str, "Opacity", old_opacity, opacity)
74 old_linew = prs.LineWidth
75 if old_linew != linew:
78 prs.LineWidth = linew # double value, recommended round [1, 10]
81 after_set(err_str, "LineWidth", old_linew, linew)
90 print 'Import "ResOK_0000.med"...............',
91 file_path = datadir + "ResOK_0000.med"
92 field_name = 'vitesse'
93 node_entity = EntityType.NODE
95 pvsimple.OpenDataFile(file_path)
96 med_reader = pvsimple.GetActiveSource()
98 if med_reader is None:
103 print "Creating Scalar Map.......",
104 scmap = ScalarMapOnField(med_reader, node_entity, field_name, 1)
105 change_representation(scmap, 'Surface With Edges', 0.3, 5)
107 print "Creating Stream Lines.......",
108 slines = StreamLinesOnField(med_reader, node_entity, field_name, 1)
109 change_representation(slines, 'Wireframe', 0.5, 3)
111 print "Creating Vectors..........",
112 vec = VectorsOnField(med_reader, node_entity, field_name, 1)
113 change_representation(vec, 'Wireframe', 0.7, 2)
115 print "Creating Iso Surfaces.....",
116 iso = IsoSurfacesOnField(med_reader, node_entity, field_name, 1)
117 change_representation(iso, 'Surface', 0.4, 8)
119 print "Creating Cut Planes.......",
120 clines = CutPlanesOnField(med_reader, node_entity, field_name, 1)
121 change_representation(clines, 'Points', 0.6, 4)
126 print 'Import "fra.med"...............',
127 file_path = datadir + "fra.med"
128 field_name = 'VITESSE'
130 pvsimple.SetActiveSource(None)
131 pvsimple.OpenDataFile(file_path)
132 med_reader = pvsimple.GetActiveSource()
134 if med_reader is None:
139 print "Creating Scalar Map.......",
140 scmap = ScalarMapOnField(med_reader, node_entity, field_name, 1)
141 change_representation(scmap, 'Wireframe', 0.5, 3)
143 print "Creating Iso Surfaces.....",
144 iso = IsoSurfacesOnField(med_reader, node_entity, field_name, 1)
145 change_representation(iso, 'Wireframe', 0.5, 3)
147 print "Creating Cut Planes.......",
148 cplanes = CutPlanesOnField(med_reader, node_entity, field_name, 1)
149 change_representation(cplanes, 'Surface', 0.5, 3)
151 print "Creating Scalar Map On Deformed Shape.......",
152 defmap = DeformedShapeAndScalarMapOnField(med_reader, node_entity,
154 change_representation(defmap, 'Surface', 0.5, 3)
156 print "Creating Deformed Shape.......",
157 defshape = DeformedShapeOnField(med_reader, node_entity, field_name, 1)
158 defshape.ColorArrayName = field_name
159 change_representation(defshape, 'Wireframe', 0.5, 3)
161 print "Creating Cut Lines.......",
162 clines = CutLinesOnField(med_reader, node_entity, field_name, 1)
163 change_representation(clines, 'Wireframe', 0.5, 3)
165 print "Creating Plot 3D.......",
166 plot3d = Plot3DOnField(med_reader, node_entity, field_name, 1)
167 change_representation(plot3d, 'Surface', 0.5, 3)
168 change_representation(plot3d, 'Outline', 0.8, 2)