Salome HOME
Merge Python 3 porting.
[modules/paravis.git] / test / VisuPrs / SWIG_scripts / B4.py
1
2 # Copyright (C) 2010-2016  CEA/DEN, EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 # This case corresponds to: /visu/SWIG_scripts/B4 case
22
23 import sys
24 import os
25
26 from paravistest import datadir
27 from presentations import *
28 import pvsimple
29
30 # Import MED file
31 med_file_path = datadir + "pointe.med"
32 pvsimple.OpenDataFile(med_file_path)
33 med_reader = pvsimple.GetActiveSource()
34
35 if med_reader is None:
36     raise RuntimeError("MED file was not imported successfully.")
37
38 # Create presentations
39 try:
40     if os.access(med_file_path, os.R_OK) :
41        if os.access(med_file_path, os.W_OK) :
42            mesh_name = "maa1"
43            entity = EntityType.NODE
44            field_name = "fieldnodedouble"
45            timestamp_id = 1
46
47            scalarmap = ScalarMapOnField(med_reader, entity, field_name, timestamp_id)
48            if get_nb_components(med_reader, entity, field_name) > 1:
49                vectors = VectorsOnField(med_reader, entity, field_name, timestamp_id)
50                cutplanes = CutPlanesOnField(med_reader, entity, field_name, timestamp_id)
51
52            mesh = MeshOnEntity(med_reader, mesh_name, entity)
53        else:
54            print("We have no permission to rewrite medFile")
55     else:
56         print("We have no permission to read medFile, it will not be opened");
57 except:
58     print(sys.exc_info()[0])
59     print(sys.exc_info()[1])
60     print(sys.exc_info()[2])
61
62