Salome HOME
Modified demos: use of SAMPLES_SRC_DIR instead of PARAVIEWDATA_ROOT_DIR
[modules/paravis.git] / test / demo8.py
1 # Copyright (C) 2010-2014  CEA/DEN, EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19
20
21 if not ('servermanager' in dir()):
22   from pvsimple import *
23
24 import os, inspect
25
26 def demo8(fname, impth):
27     """This method demonstrates the Glyph filter."""
28
29     reader = ExodusIIReader(FileName=fname)
30     v=GetActiveView()
31     Show(reader, view=v)
32     camera = GetActiveCamera()
33     camera.SetPosition(0, 5, -45)
34     camera.Elevation(30)
35
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)
40
41     #We won't see much if we don't move forward in the animation a little bit
42     tsteps = reader.TimestepValues
43     v = GetActiveView()
44     v.ViewTime = tsteps[20]
45     glyphFilter.Vectors
46     ## ['POINTS', 'DISPL']
47
48     #Set the glyphs to use the acceleration vectors and adjust scale factor
49     glyphFilter.Vectors = 'ACCL'
50     ##glyphFilter.GetScaleFactor
51     ##1.0
52     glyphFilter.SetScaleFactor = 0.0000002
53     
54     Show()
55     Render()
56     WriteImage(filename = (impth + "glyphFilter_1.png"), view=v, Magnification=2)
57
58     #Set the glyphs to use the velocity vectors and adjust scale factor
59     glyphFilter.Vectors = 'VEL'
60     glyphFilter.SetScaleFactor = 3e-4
61  
62     #Add some color
63     dp2 = GetDisplayProperties(glyphFilter)
64     glyphFilter.PointData[:]
65     ##[Array: PedigreeNodeId, Array: DISPL, Array: VEL, Array: ACCL, Array: GlobalNodeId, Array: GlyphVector]
66
67     #We'll color by velocity so use that array.
68     vel = glyphFilter.PointData[2]
69     vel.GetName()
70     ##'VEL'
71
72     vel.GetRange()
73     ##(-2479.9521484375, 1312.5040283203125)
74     dp2.LookupTable = MakeBlueToRedLT(-2479.9521,1312.5)
75     dp2.ColorAttributeType = 'POINT_DATA'
76     dp2.ColorArrayName = 'VEL'
77     Render()
78     WriteImage(filename = (impth + "glyphFilter_2.png"), view=v, Magnification=2)
79
80
81 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
82 testdir = os.path.dirname( os.path.abspath(scriptdir) )
83 pvdata = os.getenv("SAMPLES_SRC_DIR")
84
85 if __name__ == "__main__":
86     demo8(fname=pvdata+"/Data/can.ex2", impth=testdir+"/Pic/")