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