]> SALOME platform Git repositories - modules/paravis.git/blob - test/VisuPrs/imps/A1.py
Salome HOME
Copyright update: 2016
[modules/paravis.git] / test / VisuPrs / imps / A1.py
1 # Copyright (C) 2010-2016  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/imps/A1 case
21
22 import sys
23 import os
24 from paravistest import datadir, pictureext, get_picture_dir
25 from presentations import *
26 import pvsimple
27
28 picturedir = get_picture_dir("imps/A1")
29
30 def set_prs_colored(prs, proxy, entity, field_name, vector_mode, timestamp_nb):
31     # Get time value
32     time_value = get_time(proxy, timestamp_nb)
33
34     # Check vector mode
35     nb_components = get_nb_components(proxy, entity, field_name)
36     check_vector_mode(vector_mode, nb_components)
37
38     # Get lookup table
39     lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
40
41     # Set field range
42     data_range = get_data_range(proxy, entity,
43                                 field_name, vector_mode)
44     lookup_table.LockScalarRange = 1
45     lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
46
47     # Set properties
48     prs.ColorArrayName = (EntityType.get_pvtype(entity), field_name)
49     prs.LookupTable = lookup_table
50
51     # Add scalar bar
52     add_scalar_bar(field_name, nb_components,
53                    vector_mode, lookup_table, time_value)
54
55
56 # 1. Import of the "Penta6.med" file
57 print 'Import "Penta6.med" file........',
58 file_path = datadir + "Penta6.med"
59 pvsimple.OpenDataFile(file_path)
60 med_reader = pvsimple.GetActiveSource()
61 if med_reader is None:
62     raise RuntimeError, "Penta6.med was not imported!!!"
63 else:
64     print "OK"
65
66 view = pvsimple.GetRenderView()
67
68 # 2. Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field
69 print 'Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field....'
70 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "scalar field", 1)
71 if cutplanes is None :
72     raise RuntimeError, "Presentation is None!!!"
73 else:
74     print "OK"
75
76 select_cells_with_data(med_reader, on_cells=["scalar field", "vectoriel field"])
77
78 print "Setting of deformation:"
79 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
80 warp_vector.Vectors = ["scalar field"]
81 warp_vector.ScaleFactor = 5.0
82
83 print "Got scale     : ", warp_vector.ScaleFactor
84 print "Got field name: ", warp_vector.Vectors
85
86 presentation = pvsimple.GetRepresentation(warp_vector)
87 set_prs_colored(presentation, med_reader, EntityType.CELL, "scalar field", 'Magnitude', 1)
88
89 pic_path = os.path.join(picturedir, "deformed_cut_planes_scalar" + "." + pictureext)
90 process_prs_for_test(presentation, view, pic_path)
91
92 # 3. Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field
93 print 'Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field....'
94 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "vectoriel field", 1)
95
96 if cutplanes is None :
97     raise RuntimeError, "Presentation is None!!!"
98 else:
99     print "OK"
100
101 print "Setting of deformation:"
102 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
103 warp_vector.Vectors = ["vectoriel field"]
104 warp_vector.ScaleFactor = 5.0
105
106 print "Got scale     : ", warp_vector.ScaleFactor
107 print "Got field name: ", warp_vector.Vectors
108
109 presentation = pvsimple.GetRepresentation(warp_vector)
110 set_prs_colored(presentation, med_reader, EntityType.CELL, "vectoriel field", 'Magnitude', 1)
111
112 pic_path = os.path.join(picturedir, "deformed_cut_planes_vectorial" + "." + pictureext)
113 process_prs_for_test(presentation, view, pic_path)