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