1 # Copyright (C) 2010-2014 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 *
29 my_paravis = paravis.myParavis
30 picturedir = get_picture_dir(sys.argv[1], "imps/A1")
33 def set_prs_colored(prs, proxy, entity, field_name, vector_mode, timestamp_nb):
35 time_value = get_time(proxy, timestamp_nb)
38 nb_components = get_nb_components(proxy, entity, field_name)
39 check_vector_mode(vector_mode, nb_components)
42 lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
45 data_range = get_data_range(proxy, entity,
46 field_name, vector_mode)
47 lookup_table.LockScalarRange = 1
48 lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
51 prs.ColorAttributeType = EntityType.get_pvtype(entity)
52 prs.ColorArrayName = field_name
53 prs.LookupTable = lookup_table
56 add_scalar_bar(field_name, nb_components,
57 vector_mode, lookup_table, time_value)
60 # 1. Import of the "Penta6.med" file
61 print 'Import "Penta6.med" file........',
62 file_path = datadir + "Penta6.med"
63 my_paravis.ImportFile(file_path)
64 med_reader = pvsimple.GetActiveSource()
65 if med_reader is None:
66 raise RuntimeError, "Penta6.med was not imported!!!"
70 view = pvsimple.GetRenderView()
72 # 2. Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field
73 print 'Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field....'
74 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "scalar_field", 1)
75 if cutplanes is None :
76 raise RuntimeError, "Presentation is None!!!"
80 print "Setting of deformation:"
81 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
82 warp_vector.Vectors = ["vectoriel_field"]
83 warp_vector.ScaleFactor = 5.0
85 print "Got scale : ", warp_vector.ScaleFactor
86 print "Got field name: ", warp_vector.Vectors
88 presentation = pvsimple.GetRepresentation(warp_vector)
89 set_prs_colored(presentation, med_reader, EntityType.CELL, "scalar_field", 'Magnitude', 1)
91 pic_path = os.path.join(picturedir, "deformed_cut_planes_scalar" + "." + pictureext)
92 process_prs_for_test(presentation, view, pic_path)
94 # 3. Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field
95 print 'Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field....'
96 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "vectoriel_field", 1)
98 if cutplanes is None :
99 raise RuntimeError, "Presentation is None!!!"
103 print "Setting of deformation:"
104 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
105 warp_vector.Vectors = ["vectoriel_field"]
106 warp_vector.ScaleFactor = 5.0
108 print "Got scale : ", warp_vector.ScaleFactor
109 print "Got field name: ", warp_vector.Vectors
111 presentation = pvsimple.GetRepresentation(warp_vector)
112 set_prs_colored(presentation, med_reader, EntityType.CELL, "vectoriel_field", 'Magnitude', 1)
114 pic_path = os.path.join(picturedir, "deformed_cut_planes_vectorial" + "." + pictureext)
115 process_prs_for_test(presentation, view, pic_path)