Salome HOME
Porting to Paraview 3.98.1
[modules/paravis.git] / test / VisuPrs / DeformedShape / B3.py
1 # Copyright (C) 2010-2012  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.
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/DeformedShape/B3 case
21
22 from paravistest import datadir
23 from presentations import DeformedShapeOnField, EntityType
24 import paravis
25 import pvsimple
26
27
28 my_paravis = paravis.myParavis
29
30 #====================Stage1: Import from MED file in ParaVis============
31 print "**** Stage1: Import from MED file in ParaVis"
32
33 print 'Import "Tria3.med"....................',
34
35 file_path = datadir + "Tria3.med"
36 my_paravis.ImportFile(file_path)
37 med_reader = pvsimple.GetActiveSource()
38
39 if med_reader is None:
40     print "FAILED"
41 else:
42     print "OK"
43
44 #====================Stage2: Creating Deformed Shape====================
45 print "**** Stage2: Creating Deformed Shape"
46
47 print "Creating Deformed Shape...............",
48
49 cell_entity = EntityType.CELL
50 field_name = 'vectoriel_field'
51 defshape = DeformedShapeOnField(med_reader, cell_entity, field_name, 1)
52 pvsimple.ResetCamera()
53
54 if defshape is None:
55     print "FAILED"
56 else:
57     print "OK"
58
59 #====================Stage3: Scale of Deformed Shape====================
60 print "**** Stage3: Scale of Deformed Shape"
61
62 warp_vector = pvsimple.GetActiveSource()
63 print "Default scale: ", warp_vector.ScaleFactor
64
65 print "Set positive scale of Deformed Shape"
66 scale = 1
67 warp_vector.ScaleFactor = scale
68
69 pvsimple.Render()
70 print "Scale: ", warp_vector.ScaleFactor
71
72 print "Set negative scale of Deformed Shape"
73 scale = -1
74 warp_vector.ScaleFactor = scale
75
76 pvsimple.Render()
77 print "Scale: ", warp_vector.ScaleFactor
78
79 print "Set zero scale of Deformed Shape"
80 scale = 0
81 warp_vector.ScaleFactor = scale
82
83 pvsimple.Render()
84 print "Scale: ", warp_vector.ScaleFactor
85
86 #====================Stage4: Coloring method of Deformed Shape===========
87 print "**** Stage4: Coloring of Deformed Shape"
88
89 color_array = defshape.ColorArrayName
90 if color_array:
91     print "Default shape is colored by array: ", color_array
92 else:
93     print "Default shape is colored by solid color: ", defshape.AmbientColor
94
95 print "Set colored by array mode    .... ",
96 defshape.ColorArrayName = field_name
97 pvsimple.Render()
98
99 if defshape.ColorArrayName == field_name:
100     print "OK"
101 else:
102     print "FAILED"
103
104 print "Set colored by solid color mode .... ",
105 defshape.ColorArrayName = ''
106 pvsimple.Render()
107
108 if defshape.ColorArrayName:
109     print "FAILED"
110 else:
111     print "OK"