1 # Copyright (C) 2010-2015 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/imps/A1 case
24 from paravistest import datadir, pictureext, get_picture_dir
25 from presentations import *
28 picturedir = get_picture_dir("imps/A1")
30 def set_prs_colored(prs, proxy, entity, field_name, vector_mode, timestamp_nb):
32 time_value = get_time(proxy, timestamp_nb)
35 nb_components = get_nb_components(proxy, entity, field_name)
36 check_vector_mode(vector_mode, nb_components)
39 lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
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]
48 prs.ColorArrayName = (EntityType.get_pvtype(entity), field_name)
49 prs.LookupTable = lookup_table
52 add_scalar_bar(field_name, nb_components,
53 vector_mode, lookup_table, time_value)
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!!!"
66 view = pvsimple.GetRenderView()
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!!!"
76 select_cells_with_data(med_reader, on_cells=["scalar field", "vectoriel field"])
78 print "Setting of deformation:"
79 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
80 warp_vector.Vectors = ["scalar field"]
81 warp_vector.ScaleFactor = 5.0
83 print "Got scale : ", warp_vector.ScaleFactor
84 print "Got field name: ", warp_vector.Vectors
86 presentation = pvsimple.GetRepresentation(warp_vector)
87 set_prs_colored(presentation, med_reader, EntityType.CELL, "scalar field", 'Magnitude', 1)
89 pic_path = os.path.join(picturedir, "deformed_cut_planes_scalar" + "." + pictureext)
90 process_prs_for_test(presentation, view, pic_path)
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)
96 if cutplanes is None :
97 raise RuntimeError, "Presentation is None!!!"
101 print "Setting of deformation:"
102 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
103 warp_vector.Vectors = ["vectoriel field"]
104 warp_vector.ScaleFactor = 5.0
106 print "Got scale : ", warp_vector.ScaleFactor
107 print "Got field name: ", warp_vector.Vectors
109 presentation = pvsimple.GetRepresentation(warp_vector)
110 set_prs_colored(presentation, med_reader, EntityType.CELL, "vectoriel field", 'Magnitude', 1)
112 pic_path = os.path.join(picturedir, "deformed_cut_planes_vectorial" + "." + pictureext)
113 process_prs_for_test(presentation, view, pic_path)