1 # Copyright (C) 2010-2016 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, or (at your option) any later version.
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/G3 case
21 #%Create animation for Stream Lines for 'vitesse' 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 *
29 # Directory for saving snapshots
30 picturedir = get_picture_dir("Animation/G3")
32 theFileName = datadir + "TimeStamps.med"
33 print(" --------------------------------- ")
34 print("file ", theFileName)
35 print(" --------------------------------- ")
37 OpenDataFile(theFileName)
39 aProxy = GetActiveSource()
41 raise RuntimeError("Error: can't import file.")
44 print("Creating a Viewer.........................", end=' ')
45 aView = GetRenderView()
46 time_value = get_time(aProxy, 0)
47 aView.ViewTime = time_value
48 UpdatePipeline(time=time_value, proxy=aProxy)
52 if aView is None : print("Error")
55 # Stream Lines creation
56 prs= StreamLinesOnField(aProxy,EntityType.NODE,'vitesse' , 1)
59 print("Creating an Animation.....................", end=' ')
61 print("Current format to save snapshots: ",my_format)
62 # Add path separator to the end of picture path if necessery
63 if not picturedir.endswith(os.sep):
66 # Select only the current field:
67 aProxy.AllArrays = ['TS0/dom/ComSup0/vitesse@@][@@P1']
68 time_value = get_time(aProxy, 0)
69 aView.ViewTime = time_value
70 UpdatePipeline(time=time_value, proxy=aProxy)
72 # Animation creation and saving into set of files into picturedir
73 scene = AnimateReader(aProxy,aView,picturedir+"G3_dom."+my_format)
74 nb_frames = len(scene.TimeKeeper.TimestepValues)
76 pics = os.listdir(picturedir)
77 if len(pics) != nb_frames:
78 print("FAILED!!! Number of made pictures is equal to ", len(pics), " instead of ", nb_frames)
81 os.remove(picturedir+pic)
83 # Prepare animation performance
84 scene.PlayMode = 1 # set RealTime mode for animation performance
86 scene.Duration = 30 # correspond to set the speed of animation in VISU
88 print("Animation.................................", end=' ')