Back to index

salome-paravis  6.5.0
demo8.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 
00021 if not ('servermanager' in dir()):
00022   from pvsimple import *
00023 
00024 import os
00025 
00026 def demo8(fname, impth):
00027     """This method demonstrates the Glyph filter."""
00028 
00029     reader = ExodusIIReader(FileName=fname)
00030     v=GetActiveView()
00031     Show(reader, view=v)
00032     camera = GetActiveCamera()
00033     camera.SetPosition(0, 5, -45)
00034     camera.Elevation(30)
00035 
00036     #Change the can to be wireframe so we can see the glyphs
00037     dp1 = GetDisplayProperties(reader, view=v)
00038     dp1.Representation = 'Wireframe'
00039     glyphFilter = Glyph(reader)
00040 
00041     #We won't see much if we don't move forward in the animation a little bit
00042     tsteps = reader.TimestepValues
00043     v = GetActiveView()
00044     v.ViewTime = tsteps[20]
00045     glyphFilter.Vectors
00046     ## ['POINTS', 'DISPL']
00047 
00048     #Set the glyphs to use the acceleration vectors and adjust scale factor
00049     glyphFilter.Vectors = 'ACCL'
00050     ##glyphFilter.GetScaleFactor
00051     ##1.0
00052     glyphFilter.SetScaleFactor = 0.0000002
00053     
00054     Show()
00055     Render()
00056     WriteImage(filename = (impth + "glyphFilter_1.png"), view=v, Magnification=2)
00057 
00058     #Set the glyphs to use the velocity vectors and adjust scale factor
00059     glyphFilter.Vectors = 'VEL'
00060     glyphFilter.SetScaleFactor = 3e-4
00061  
00062     #Add some color
00063     dp2 = GetDisplayProperties(glyphFilter)
00064     glyphFilter.PointData[:]
00065     ##[Array: PedigreeNodeId, Array: DISPL, Array: VEL, Array: ACCL, Array: GlobalNodeId, Array: GlyphVector]
00066 
00067     #We'll color by velocity so use that array.
00068     vel = glyphFilter.PointData[2]
00069     vel.GetName()
00070     ##'VEL'
00071 
00072     vel.GetRange()
00073     ##(-2479.9521484375, 1312.5040283203125)
00074     dp2.LookupTable = MakeBlueToRedLT(-2479.9521,1312.5)
00075     dp2.ColorAttributeType = 'POINT_DATA'
00076     dp2.ColorArrayName = 'VEL'
00077     Render()
00078     WriteImage(filename = (impth + "glyphFilter_2.png"), view=v, Magnification=2)
00079 
00080 testdir = os.getenv("TESTDIR")
00081 pvdata = os.getenv("PVDATA")
00082 
00083 if __name__ == "__main__":
00084  demo8(fname=pvdata+"/Data/can.ex2", impth=testdir+"/Pic/")