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
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
63 ScaleVector1.ScaleFactor = 0
64 ScaleVector1.UpdatePipeline()
65 bounds = info.DataInformation.GetBounds()
66 side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]]
68 if side[1] > length : length = side[1]
69 if side[2] > length : length = side[2]
72 if vectorname != None :
73 arrayrange = arrayinfo.GetComponentRange(-1)
74 if arrayrange[1] > 0 :
75 scale = scale / arrayrange[1]
77 WarpByVector1.ScaleFactor = scale
79 AnimationScene1 = GetAnimationScene()
81 TimeAnimationCue1 = GetTimeTrack()
82 TimeAnimationCue1.Enabled = 0
84 KeyFrameAnimationCue1 = KeyFrameAnimationCue()
85 KeyFrameAnimationCue1.AnimatedProxy = ScaleVector1
86 KeyFrameAnimationCue1.AnimatedPropertyName = "ScaleFactor"
87 KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' )
88 KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] )
90 KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ]
92 AnimationScene1.Cues.append(KeyFrameAnimationCue1)
93 AnimationScene1.Loop = 1
94 AnimationScene1.PlayMode = 'Sequence'
95 AnimationScene1.StartTime = 0
96 AnimationScene1.EndTime = 1
97 AnimationScene1.NumberOfFrames = 21
99 WarpByVectorDataRepresentation = Show(WarpByVector1)
100 if rootname != None :
101 pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' )
102 WarpByVectorDataRepresentation.ColorArrayName = rootname
103 WarpByVectorDataRepresentation.LookupTable = pvLookupTable
104 WarpByVectorDataRepresentation.RescaleTransferFunctionToDataRange(True)
106 AnimationScene1.Play()