Salome HOME
Set dev version marker to 1.
[modules/paravis.git] / test / demo1.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 if not ('servermanager' in dir()):
20   from pvsimple import *
21   
22 import os, inspect
23
24 def demo1(impth):
25     """Simple demo that create the following pipeline
26     sphere - shrink - \
27                        - append
28     cone            - /
29     """
30
31     # Create a sphere of radius = 0.5, theta res. = 32
32     # This object becomes the active source.
33     ss = Sphere(Radius=0.5, ThetaResolution=32, PhiResolution=8)
34
35     # The view and representation
36     v = GetRenderView()
37     if not v:
38        v = CreateRenderView()
39     v.CameraPosition = [-3, -3, -3]
40     v.CameraViewUp = [0, 0, 1]
41     v.StillRender()
42
43     # Apply the shrink filter. The Input property is optional. If Input
44     # is not specified, the filter is applied to the active source.
45     shr = Shrink(Input=ss)
46  
47     # Create a cone source. 
48     cs = Cone()
49
50     # Append cone and shrink
51     app = AppendDatasets()
52     app.Input = [shr, cs]
53
54     # Show the output of the append filter. The argument is optional
55     # as the app filter is now the active object.
56     Show(app)
57     WriteImage(filename = (impth + "demo1_1.png"), view=v, Magnification=2) 
58
59     PointData = app.GetDataInformation().GetNumberOfPoints()
60     CellData = app.GetDataInformation().GetNumberOfCells()
61     print PointData, " Points"
62     print CellData, " Cells"
63
64     # Render the default view.
65     Render()
66
67     
68 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
69 testdir = os.path.dirname( os.path.abspath(scriptdir) )
70
71
72 if __name__ == "__main__":
73     demo1(impth =testdir+"/Pic/")