Salome HOME
Merge branch 'master' of salome:modules/paravis
[modules/paravis.git] / test / demo7.py
1 # Copyright (C) 2010-2016  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 demo7(fname, impth):
27     """This method demonstrates the Slice filter."""
28
29     v=GetActiveView()
30     reader = ExodusIIReader(FileName=fname)
31     sliceFilter = Slice(reader)
32     Show(sliceFilter)
33     Render()
34    
35     camera = GetActiveCamera()
36     camera.Elevation(30)
37     camera.SetPosition(17, 40, -25)
38     Render()
39     WriteImage(filename = (impth + "sliceFilter_1.png"), view=v, Magnification=2)
40
41     sliceFilter.SliceType.Normal
42
43     #The origin of the slice needs to be moved to see slices in the Y-plane
44     sliceFilter.SliceType.Origin = [2.5,5,0]
45     sliceFilter.SliceType.Normal = [0,1,0]
46     Render()
47     WriteImage(filename = (impth + "sliceFilter_2.png"), view=v, Magnification=2)
48
49     sliceFilter.SliceType.Normal = [0,0,1]
50     Render()
51     WriteImage(filename = (impth + "sliceFilter_3.png"), view=v, Magnification=2)
52
53     sliceFilter.SliceType.Normal = [0,1,0]
54     sliceFilter.SliceOffsetValues
55     sliceFilter.SliceOffsetValues = [-4,-3.11,-2.22,-1.33,-0.44,0.44,1.33,2.22,3.11,4]
56
57     Render()
58     WriteImage(filename = (impth + "sliceFilter_4.png"), view=v, Magnification=2)
59
60
61 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
62 testdir = os.path.dirname( os.path.abspath(scriptdir) )
63 pvdata = os.getenv("SAMPLES_SRC_DIR")
64
65 if __name__ == "__main__":
66     demo7(fname=pvdata+"/Data/can.ex2", impth=testdir+"/Pic/")