Salome HOME
6ef39bf8ec0b261fcda5ecd5473a90fc28d83736
[modules/paravis.git] / test / VisuPrs / bugs / D1.py
1 # Copyright (C) 2010-2013  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.
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/D1 case
21
22 import sys
23 import os
24 from paravistest import datadir, pictureext, get_picture_dir
25 from presentations import *
26 import paravis
27 import pvsimple
28
29 my_paravis = paravis.myParavis
30 os.environ["PARAVIS_TEST_PICS"] = sys.argv[1]
31 picturedir = get_picture_dir("bugs/D1")
32
33 # 1. Import of the "Bug829_resu_mode.med" file at first time
34 med_file_path = datadir + "Bug829_resu_mode.med"
35 my_paravis.ImportFile(med_file_path)
36 med_reader1 = pvsimple.GetActiveSource()
37 if med_reader1 is None:
38     raise RuntimeError, "Bug829_resu_mode.med was not imported!!!"
39
40 # 2. Creation of a set of "DeformedShape and ScalarMap" presentations, based on time stamps of "MODES_DEPL" field
41 errors=0
42 sizes=[]
43
44 for i in range(1,11):
45     presentation = DeformedShapeAndScalarMapOnField(med_reader1, EntityType.NODE, "MODES_DEPL", i)
46     if presentation is None : 
47         raise RuntimeError, "Presentation is None!!!"
48
49     pic_path = os.path.join(picturedir, "npal19999_1_time_stamp_" + str(i) + "." + pictureext)
50     process_prs_for_test(presentation, pvsimple.GetRenderView(), pic_path)
51
52     sizes.append(os.path.getsize(pic_path))
53
54 if abs(max(sizes)-min(sizes)) > 0.01*max(sizes):
55     print "WARNING!!! Pictures have different sizes!!!"
56     errors += 1
57     for i in range(1,11):
58         picture_name = "npal19999_1_time_stamp_" + str(i) + "." + pictureext
59         print "Picture: " + picture_name + "; size: " + str(sizes[i-1]) 
60     raise RuntimeError
61
62 # 3. Import of the "Bug829_resu_mode.med" file at second time
63 my_paravis.ImportFile(med_file_path)
64 med_reader2 = pvsimple.GetActiveSource()
65 if med_reader2 is None:
66     raise RuntimeError, "Bug829_resu_mode.med was not imported second time!!!"
67
68 # 4. Creation of a set of "DeformedShape and ScalarMap" presentations, based on time stamps of "MODES_DEPL" field
69 errors = 0
70 sizes=[]
71
72 for i in range(1,11):
73     presentation = DeformedShapeAndScalarMapOnField(med_reader2, EntityType.NODE, "MODES_DEPL", 11-i)
74     if presentation is None : 
75         raise RuntimeError, "Presentation is None!!!"
76
77     pic_path = os.path.join(picturedir, "npal19999_2_time_stamp_" + str(i) + "." + pictureext)
78     process_prs_for_test(presentation, pvsimple.GetRenderView(), pic_path)
79
80     sizes.append(os.path.getsize(pic_path))
81
82 if abs(max(sizes)-min(sizes)) > 0.01*max(sizes):
83     print "WARNING!!! Pictures have different sizes!!!"
84     errors += 1
85     for i in range(1,11):
86         picture_name = "npal19999_2_time_stamp_" + str(i) + "." + pictureext
87         print "Picture: " + picture_name + "; size: " + str(sizes[i-1]) 
88     raise RuntimeError