1 # Copyright (C) 2010-2013 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.
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 os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
31 picturedir = get_picture_dir("imps/A1")
34 def set_prs_colored(prs, proxy, entity, field_name, vector_mode, timestamp_nb):
36 time_value = get_time(proxy, timestamp_nb)
39 nb_components = get_nb_components(proxy, entity, field_name)
40 check_vector_mode(vector_mode, nb_components)
43 lookup_table = get_lookup_table(field_name, nb_components, vector_mode)
46 data_range = get_data_range(proxy, entity,
47 field_name, vector_mode)
48 lookup_table.LockScalarRange = 1
49 lookup_table.RGBPoints = [data_range[0], 0, 0, 1, data_range[1], 1, 0, 0]
52 prs.ColorAttributeType = EntityType.get_pvtype(entity)
53 prs.ColorArrayName = field_name
54 prs.LookupTable = lookup_table
57 add_scalar_bar(field_name, nb_components,
58 vector_mode, lookup_table, time_value)
61 # 1. Import of the "Penta6.med" file
62 print 'Import "Penta6.med" file........',
63 file_path = datadir + "Penta6.med"
64 my_paravis.ImportFile(file_path)
65 med_reader = pvsimple.GetActiveSource()
66 if med_reader is None:
67 raise RuntimeError, "Penta6.med was not imported!!!"
71 view = pvsimple.GetRenderView()
73 # 2. Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field
74 print 'Creation of "CutPlanes" presentation, based on time stamp of "scalar field" field....'
75 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "scalar_field", 1)
76 if cutplanes is None :
77 raise RuntimeError, "Presentation is None!!!"
81 print "Setting of deformation:"
82 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
83 warp_vector.Vectors = ["vectoriel_field"]
84 warp_vector.ScaleFactor = 5.0
86 print "Got scale : ", warp_vector.ScaleFactor
87 print "Got field name: ", warp_vector.Vectors
89 presentation = pvsimple.GetRepresentation(warp_vector)
90 set_prs_colored(presentation, med_reader, EntityType.CELL, "scalar_field", 'Magnitude', 1)
92 pic_path = os.path.join(picturedir, "deformed_cut_planes_scalar" + "." + pictureext)
93 process_prs_for_test(presentation, view, pic_path)
95 # 3. Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field
96 print 'Creation of "CutPlanes" presentation, based on time stamp of "vectoriel field" field....'
97 cutplanes = CutPlanesOnField(med_reader, EntityType.CELL, "vectoriel_field", 1)
99 if cutplanes is None :
100 raise RuntimeError, "Presentation is None!!!"
104 print "Setting of deformation:"
105 warp_vector = pvsimple.WarpByVector(cutplanes.Input)
106 warp_vector.Vectors = ["vectoriel_field"]
107 warp_vector.ScaleFactor = 5.0
109 print "Got scale : ", warp_vector.ScaleFactor
110 print "Got field name: ", warp_vector.Vectors
112 presentation = pvsimple.GetRepresentation(warp_vector)
113 set_prs_colored(presentation, med_reader, EntityType.CELL, "vectoriel_field", 'Magnitude', 1)
115 pic_path = os.path.join(picturedir, "deformed_cut_planes_vectorial" + "." + pictureext)
116 process_prs_for_test(presentation, view, pic_path)