Salome HOME
Update copyrights
[modules/paravis.git] / examples / command_line / run_demo.py
1 # Copyright (C) 2014-2019  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 # To be run in SALOME environment (salome shell)
20 # A SALOME session MUST have been started (salome -t)
21
22 import os
23
24 from dataset import create_geometry, create_meshes, create_field
25
26 out_basename = "smooth_surface"
27 dir_name = os.path.dirname(os.path.abspath(__file__))
28 brep_filename = os.path.join(dir_name, out_basename+".brep")
29 med_filename = os.path.join(dir_name, out_basename+".med")
30 field_filename = os.path.join(dir_name, out_basename+"_and_field.med")
31
32 def generate_data():
33   geometry = create_geometry(out_filename=brep_filename)
34   mesh_tri, mesh_quad = create_meshes(geometry, out_filename=med_filename)
35   field = create_field(med_filename, "Mesh_tri", "field_on_tri_cells", out_filename=field_filename)
36 #
37
38 import salome
39 salome.salome_init()
40
41 generate_data()
42
43 from medio import load_mesh, load_field
44 mesh = load_mesh(med_filename, mesh_name="Mesh_tri")
45 field = load_field(field_filename, field_name="field_on_tri_cells")
46
47 from medviewer import MEDViewer
48 viewer = MEDViewer(interactive=False)
49 viewer.display_mesh(mesh, pause=True)
50
51 viewer2 = MEDViewer(interactive=True)
52 viewer2.display_field(field, pause=False)