Salome HOME
Merge branch V7_3_1_BR
[modules/paravis.git] / test / VisuPrs / bugs / D0.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/bugs3/D0 case
21
22 import sys
23 import os
24 import time
25 from paravistest import datadir, pictureext, get_picture_dir
26 from presentations import *
27 import paravis
28 import pvsimple
29
30 my_paravis = paravis.myParavis
31 picturedir = get_picture_dir(sys.argv[1], "bugs/D0")
32
33 # Aux method
34 def get_group_full_name(source, group_name):
35     result_name = group_name
36     
37     full_names = source.Groups.Available
38     for name in full_names:
39         if name.endswith(group_name):
40             result_name = name
41             break
42
43     return result_name
44
45 # 1. Import of the "Bug619-result_calcul_OCC.med" file
46 med_file_path = datadir + "Bug619-result_calcul_OCC.med"
47
48 my_paravis.ImportFile(med_file_path)
49 med_reader = pvsimple.GetActiveSource()
50
51 if med_reader is None:
52     raise RuntimeError, "Bug619-result_calcul_OCC.med was not imported!!!"
53
54 # 2. Creation of ScalarMap:
55 # iteration1: on the "TU_3D_G1" group
56 # iteration2: on the "TU_3D_D1" group
57 view = pvsimple.GetRenderView()
58 field_name = "MECASTATEQUI_ELNO_SIGM"
59
60 groups = ['TU_3D_G1', 'TU_3D_D1']
61
62 for group_name in groups:
63     extract_group = pvsimple.ExtractGroup(med_reader)
64     extract_group.Groups = [get_group_full_name(med_reader, group_name)]
65     extract_group.UpdatePipeline()
66     
67     scalar_map = ScalarMapOnField(extract_group, EntityType.CELL, field_name, 1)
68     if scalar_map is None :
69         raise RuntimeError, "ScalarMap presentation on '" + group_name + "' group is None!!!"
70
71     pic_path = os.path.join(picturedir, "npal18711_" + group_name + "." + pictureext)
72     process_prs_for_test(scalar_map, view, pic_path)
73