Salome HOME
Using 'AllArrays' instead of 'CellArrays' and 'PointArrays'.
[modules/paravis.git] / test / VisuPrs / Animation / G4.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/animation/G4case
21 #%Create animation for Stream Lines for 'vitesse' field of the the given MED file and dumps picture files in TIFF format %
22
23 import sys
24 import os
25 from paravistest import * 
26 from presentations import *
27 from pvsimple import *
28 import paravis
29
30 #import file
31 myParavis = paravis.myParavis
32
33 # Directory for saving snapshots
34 picturedir = get_picture_dir("Animation/G3")
35
36 theFileName = datadir +  "TimeStamps.med"
37 print " --------------------------------- "
38 print "file ", theFileName
39 print " --------------------------------- "
40
41 myParavis.ImportFile(theFileName)
42
43 aProxy = GetActiveSource()
44 if aProxy is None:
45         raise RuntimeError, "Error: can't import file."
46 else: print "OK"
47
48 print "Creating a Viewer.........................",
49 aView = GetRenderView()
50 reset_view(aView)
51 Render(aView)
52
53 if aView is None : print "Error"
54 else : print "OK"
55
56 # Stream Lines creation
57 prs= StreamLinesOnField(aProxy,EntityType.NODE,'vitesse' , 1)
58 prs.Visibility=1
59 aView.ResetCamera()
60 print "Creating an Animation.....................",
61 my_format = "tiff"
62 print "Current format to save snapshots: ",my_format
63 # Add path separator to the end of picture path if necessery
64 if not picturedir.endswith(os.sep):
65     picturedir += os.sep
66
67 # Select only the current field:
68 aProxy.AllArrays = []
69 aProxy.UpdatePipeline()
70 aProxy.AllArrays = ['TS0/dom/ComSup0/vitesse@@][@@P1']
71 aProxy.UpdatePipeline()
72    
73 # Animation creation and saving into set of files into picturedir
74 scene = AnimateReader(aProxy,aView,picturedir+"G3_dom."+my_format)
75 nb_frames = len(scene.TimeKeeper.TimestepValues)
76
77 pics = os.listdir(picturedir) 
78 if len(pics) != nb_frames:
79    print "FAILED!!! Number of made pictures is equal to ", len(pics), " instead of ", nb_frames
80     
81 for pic in pics:
82     os.remove(picturedir+pic)    
83     
84 # Prepare animation  performance    
85 scene.PlayMode = 1 #  set RealTime mode for animation performance
86 # set period
87 scene.Duration = 30 # correspond to set the speed of animation in VISU 
88 scene.GoToFirst()
89 print "Animation.................................",
90 scene.Play()
91 scene.GoToFirst()