Salome HOME
Merge branch 'akl/tests_update'
[modules/paravis.git] / test / VisuPrs / united / A5.py
1 # Copyright (C) 2010-2014  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/A5 case
21
22 from paravistest import datadir
23 from presentations import *
24 import paravis
25 import pvsimple
26
27 my_paravis = paravis.myParavis
28
29 cell_entity = EntityType.CELL
30 node_entity = EntityType.NODE
31
32 # 1. Import MED file
33 print "**** Step1: Import MED file"
34
35 print 'Import "ResOK_0000.med"...............',
36 file_path = datadir + "ResOK_0000.med"
37 my_paravis.ImportFile(file_path)
38 med_reader = pvsimple.GetActiveSource()
39
40 if med_reader is None:
41     print "FAILED"
42 else:
43     print "OK"
44
45 mesh_name = 'dom'
46
47 # 2. Creating mesh
48 print "**** Step2: Mesh creation"
49
50 print "Creating mesh.............",
51 mesh = MeshOnEntity(med_reader, mesh_name, cell_entity)
52 if mesh is None:
53     print "FAILED"
54 else:
55     print "OK"
56
57 # 3. Changing type of presentation of mesh
58 print "**** Step3: Changing type of presentation of mesh"
59
60 view = pvsimple.GetRenderView()
61 display_only(mesh, view)
62 reset_view(view)
63
64 mesh.Representation = 'Wireframe'
65 pvsimple.Render()
66 prs_type = mesh.Representation
67 print "Presentation type..", prs_type
68
69 mesh.Representation = 'Points'
70 pvsimple.Render()
71 prs_type = mesh.Representation
72 print "Presentation type..", prs_type
73
74 # make shrink, in PARAVIS it's not a representation type: use shrink filter
75 shrink = pvsimple.Shrink(med_reader)
76 mesh_shrinked = pvsimple.GetRepresentation(shrink)
77 display_only(mesh_shrinked, view)
78
79 display_only(mesh, view)
80 mesh.Representation = 'Surface With Edges'
81 pvsimple.Render()
82 prs_type = mesh.Representation
83 print "Presentation type..", prs_type
84
85 # 4. Changing Cell color of mesh
86 print "**** Step4: Changing Cell color of mesh"
87
88 color = mesh.DiffuseColor
89 print "Mesh Cell color in RGB....(", color[0], ",", color[1], ",", color[2], ")"
90
91 color = [0, 0, 1]
92 mesh.DiffuseColor = color
93 color = mesh.DiffuseColor
94 print "Mesh Cell color in RGB....(", color[0], ",", color[1], ",", color[2], ")"
95 pvsimple.Render()
96
97 # 5. Changing Node color of mesh
98 print "**** Step4: Changing Node color of mesh"
99
100 color = mesh.AmbientColor
101 print "Mesh Node color in RGB....(", color[0], ",", color[1], ",", color[2], ")"
102
103 color = [0, 1, 0]
104 mesh.AmbientColor = color
105 color = mesh.AmbientColor
106 print "Mesh Node color in RGB....(", color[0], ",", color[1], ",", color[2], ")"
107 pvsimple.Render()
108
109 ## Note: no special property for edge color in PARAVIS; skip link color changing ( SetLinkColor()/GetLinkColor() methods )
110