Back to index

salome-paravis  6.5.0
modes.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 try: paraview.simple
00021 except: from paraview.simple import *
00022 paraview.simple._DisableFirstRenderCameraReset()
00023 
00024 source = GetActiveSource()
00025 representation = GetDisplayProperties(source)
00026 representation.Visibility = 0
00027 
00028 if source.SMProxy.GetVTKClassName() == 'vtkMedReader' :
00029   source.AnimationMode = 'Modes'
00030 
00031 ExtractSurface1 = ExtractSurface()
00032 ScaleVector1 = ScaleVector()
00033 WarpByVector1 = WarpByVector()
00034 
00035 # first, find the first point-centered vector array.
00036 ExtractSurface1.UpdatePipeline()
00037 info = ExtractSurface1.GetDataInformation()
00038 pinfo = info.DataInformation.GetPointDataInformation()
00039 arrayinfo = None
00040 vectorname = None
00041 rootname = None
00042 for arrayid in range(0, pinfo.GetNumberOfArrays()) :
00043   arrayinfo = pinfo.GetArrayInformation(arrayid)
00044   if arrayinfo.GetNumberOfComponents() == 3 : 
00045     vectorname = arrayinfo.GetName()
00046     rootpos = vectorname.rfind("[")
00047     if rootpos == -1 :     
00048       rootname = vectorname
00049     else :
00050       rootname = vectorname[0:rootpos-1]
00051     ScaleVector1.VectorField = ['POINTS', vectorname]
00052     WarpByVector1.Vectors = ['POINTS', rootname]
00053     break
00054 
00055 ScaleVector1.ScaleFactor = 0
00056 ScaleVector1.UpdatePipeline()
00057 bounds = info.DataInformation.GetBounds()
00058 side = [bounds[1] - bounds[0], bounds[3] - bounds[2], bounds[5] - bounds[4]]
00059 length = side[0]
00060 if side[1] > length : length = side[1] 
00061 if side[2] > length : length = side[2] 
00062 
00063 scale = length / 20
00064 if vectorname != None :
00065   arrayrange = arrayinfo.GetComponentRange(-1)
00066   if arrayrange[1] > 0 :
00067     scale = scale / arrayrange[1]
00068 
00069 WarpByVector1.ScaleFactor = scale
00070 
00071 AnimationScene1 = GetAnimationScene()
00072 
00073 TimeAnimationCue1 = GetTimeTrack()
00074 TimeAnimationCue1.Enabled = 0
00075 
00076 KeyFrameAnimationCue1 = GetAnimationTrack( ScaleVector1.GetProperty('ScaleFactor'))
00077 KeyFrame0 = CompositeKeyFrame( KeyValues=[1.0], Interpolation='Sinusoid' )
00078 KeyFrame1 = CompositeKeyFrame( KeyTime=1.000000001, KeyValues=[1.0] )
00079 
00080 KeyFrameAnimationCue1.KeyFrames = [ KeyFrame0, KeyFrame1 ]
00081 
00082 AnimationScene1.Cues.append(KeyFrameAnimationCue1)
00083 AnimationScene1.Loop = 1
00084 AnimationScene1.PlayMode = 'Sequence'
00085 AnimationScene1.NumberOfFrames = 21
00086 
00087 WarpByVectorDataRepresentation = Show(WarpByVector1)
00088 if rootname != None :
00089   pvLookupTable = GetLookupTableForArray( rootname, 3, VectorMode='Magnitude' )
00090   WarpByVectorDataRepresentation.ColorArrayName = rootname
00091   WarpByVectorDataRepresentation.LookupTable = pvLookupTable
00092 
00093 AnimationScene1.Play()