Salome HOME
Porting to PV500
[modules/paravis.git] / test / demo3.py
1 # Copyright (C) 2010-2015  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 demo3(impth):
27     """This method demonstrates an artificial data sources,
28     probes it with a line, etc"""
29
30     # The TWO views
31     rv = GetRenderView()
32     
33     v = CreateRenderView()  
34     v.CameraPosition = [-30, -20, -65]
35     v.CameraFocalPoint = [0.0, 0.0, 0.0]
36     v.CameraViewUp = [-0.65, -0.55, 0.5]
37     v.CameraViewAngle = [30]
38     SetActiveView(rv)
39
40     src = Wavelet()
41     # Get some information about the data. First, for the source to execute
42     UpdatePipeline()
43
44     di = src.GetDataInformation()
45     print "Data type:", di.GetPrettyDataTypeString()
46     print "Extent:", di.GetExtent()
47
48     ##src.Representation = 3 # outline
49     Show(src, view=v)
50     v.StillRender()
51
52     # Apply a contour filter
53     cf = Contour(Input = src)
54     cf.ContourBy = ['POINTS', 'RTData']
55     cf.Isosurfaces = [37.353099999999998, 63.961533333333335, 90.569966666666673, 117.1784, 143.78683333333333, 170.39526666666666, 
56                                  197.00370000000001, 223.61213333333333, 250.22056666666668, 276.82900000000001]
57     Show(cf, view=rv)
58
59     #Set background
60     SetViewProperties(Background = [.50, .20, .30])
61     Render()
62
63     # Reset the camera to include the whole thing
64     rv.StillRender()
65     rv.ResetCamera()
66     rv.CameraPosition = [-2.50, 60, -40]
67     rv.CameraFocalPoint = [1.25, 1.0, 1.35]
68     rv.CameraViewUp = [-0.955, 0.1, 0.25]
69     rv.CameraViewAngle = [30]
70     rv.StillRender()
71
72     # Now, let's probe the data
73     probe = ResampleWithDataset(Input=src)
74
75     # with a line
76     line = Line(Resolution=60)
77
78     # that spans the dataset
79     bounds = di.GetBounds()
80
81     print "Bounds: ", bounds
82     line.Point1 = bounds[0:6:2]
83     line.Point2 = bounds[1:6:2]
84
85     probe.Source = line
86
87     # Render with the line
88     Show(line, view=rv)
89     rv.StillRender()
90     WriteImage(filename = (impth + "demo3_1.png"), view=v, Magnification=2)
91     WriteImage(filename = (impth + "demo3_2.png"), view=rv, Magnification=2)
92
93
94 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
95 testdir = os.path.dirname( os.path.abspath(scriptdir) )
96
97
98 if __name__ == "__main__":
99     demo3(impth=testdir+"/Pic/")