1 # Copyright (C) 2010-2012 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
21 except: from paraview.simple import *
22 paraview.simple._DisableFirstRenderCameraReset()
26 source = GetActiveSource()
27 representation = GetDisplayProperties(source)
28 representation.Visibility = 0
32 if source.SMProxy.GetVTKClassName() == 'vtkMedReader' :
33 oldmode = source.AnimationMode
34 source.AnimationMode = 'Modes'
36 ExtractSurface1 = ExtractSurface()
37 ScaleVector1 = ScaleVector()
38 WarpByVector1 = WarpByVector()
40 # first, find the first point-centered vector array.
41 ExtractSurface1.UpdatePipeline()
42 info = ExtractSurface1.GetDataInformation()
43 pinfo = info.DataInformation.GetPointDataInformation()
47 for arrayid in range(0, pinfo.GetNumberOfArrays()) :
48 arrayinfo = pinfo.GetArrayInformation(arrayid)
49 if arrayinfo.GetNumberOfComponents() == 3 :
50 vectorname = arrayinfo.GetName()
51 rootpos = vectorname.rfind("[")
55 rootname = vectorname[0:rootpos-1]
56 ScaleVector1.VectorField = ['POINTS', vectorname]
57 WarpByVector1.Vectors = ['POINTS', rootname]
60 if vectorname == None :
61 source.AnimationMode = oldmode
64 ScaleVector1.ScaleFactor = 0
65 ScaleVector1.UpdatePipeline()
66 bounds = info.DataInformation.GetBounds()
67 side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]]
69 if side[1] > length : length = side[1]
70 if side[2] > length : length = side[2]
73 if vectorname != None :
74 arrayrange = arrayinfo.GetComponentRange(-1)
75 if arrayrange[1] > 0 :
76 scale = scale / arrayrange[1]
78 WarpByVector1.ScaleFactor = scale
80 AnimationScene1 = GetAnimationScene()
82 TimeAnimationCue1 = GetTimeTrack()
83 TimeAnimationCue1.Enabled = 0
85 KeyFrameAnimationCue1 = GetAnimationTrack( ScaleVector1.GetProperty('ScaleFactor'))
86 KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' )
87 KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] )
89 KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ]
91 AnimationScene1.Cues.append(KeyFrameAnimationCue1)
92 AnimationScene1.Loop = 1
93 AnimationScene1.PlayMode = 'Sequence'
94 AnimationScene1.NumberOfFrames = 21
96 WarpByVectorDataRepresentation = Show(WarpByVector1)
98 pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' )
99 WarpByVectorDataRepresentation.ColorArrayName = rootname
100 WarpByVectorDataRepresentation.LookupTable = pvLookupTable
102 AnimationScene1.Play()