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 if not ('servermanager' in dir()):
22 from pvsimple import *
26 def demo8(fname, impth):
27 """This method demonstrates the Glyph filter."""
29 reader = ExodusIIReader(FileName=fname)
32 camera = GetActiveCamera()
33 camera.SetPosition(0, 5, -45)
36 #Change the can to be wireframe so we can see the glyphs
37 dp1 = GetDisplayProperties(reader, view=v)
38 dp1.Representation = 'Wireframe'
39 glyphFilter = Glyph(reader)
41 #We won't see much if we don't move forward in the animation a little bit
42 tsteps = reader.TimestepValues
44 v.ViewTime = tsteps[20]
46 ## ['POINTS', 'DISPL']
48 #Set the glyphs to use the acceleration vectors and adjust scale factor
49 glyphFilter.Vectors = 'ACCL'
50 ##glyphFilter.GetScaleFactor
52 glyphFilter.SetScaleFactor = 0.0000002
56 WriteImage(filename = (impth + "glyphFilter_1.png"), view=v, Magnification=2)
58 #Set the glyphs to use the velocity vectors and adjust scale factor
59 glyphFilter.Vectors = 'VEL'
60 glyphFilter.SetScaleFactor = 3e-4
63 dp2 = GetDisplayProperties(glyphFilter)
64 glyphFilter.PointData[:]
65 ##[Array: PedigreeNodeId, Array: DISPL, Array: VEL, Array: ACCL, Array: GlobalNodeId, Array: GlyphVector]
67 #We'll color by velocity so use that array.
68 vel = glyphFilter.PointData[2]
73 ##(-2479.9521484375, 1312.5040283203125)
74 dp2.LookupTable = MakeBlueToRedLT(-2479.9521,1312.5)
75 dp2.ColorAttributeType = 'POINT_DATA'
76 dp2.ColorArrayName = 'VEL'
78 WriteImage(filename = (impth + "glyphFilter_2.png"), view=v, Magnification=2)
81 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
82 testdir = os.path.dirname( os.path.abspath(scriptdir) )
83 pvdata = os.getenv("SAMPLES_SRC_DIR")
85 if __name__ == "__main__":
86 demo8(fname=pvdata+"/Data/can.ex2", impth=testdir+"/Pic/")