1 # Copyright (C) 2010-2013 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #This case corresponds to: /visu/animation/D1 case
21 #%Create animation for Gauss Points for 'pression' field of the the given MED file and dumps picture files in PNG format %
25 from paravistest import *
26 from presentations import *
27 from pvsimple import *
31 myParavis = paravis.myParavis
33 # Directory for saving snapshots
34 picturedir = get_picture_dir("Animation/D1")
36 theFileName = datadir + "TimeStamps.med"
38 print " --------------------------------- "
39 print "file ", theFileName
40 print " --------------------------------- "
42 myParavis.ImportFile(theFileName)
43 aProxy = GetActiveSource()
45 raise RuntimeError, "Error: can't import file."
48 print "Creating a Viewer.........................",
49 aView = GetRenderView()
53 if aView is None : print "Error"
56 # Gauss Points creation
57 prs= GaussPointsOnField(aProxy,EntityType.CELL,'pression' , 2, multiplier=0.01)
60 print "Creating an Animation.....................",
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):
67 # Select only the current field:
69 aProxy.UpdatePipeline()
70 aProxy.AllArrays = ['TS0/dom/ComSup0/pression@@][@@P0']
71 aProxy.UpdatePipeline()
73 # Animation creation and saving into set of files into picturedir
74 scene = AnimateReader(aProxy,aView,picturedir+"D1_dom."+my_format)
75 nb_frames = len(scene.TimeKeeper.TimestepValues)
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
82 os.remove(picturedir+pic)
84 # Prepare animation performance
85 scene.PlayMode = 1 # set RealTime mode for animation performance
87 scene.Duration = 30 # correspond to set the speed of animation in VISU
89 print "Animation.................................",