Salome HOME
Merge from BR_PARAVIS_DEV 29Dec09
[modules/paravis.git] / test / demo1.py
1 if not ('servermanager' in dir()):
2   from pvsimple import *
3
4 import os
5
6 def demo1(impth):
7     """Simple demo that create the following pipeline
8     sphere - shrink - \
9                        - append
10     cone            - /
11     """
12
13     # Create a sphere of radius = 0.5, theta res. = 32
14     # This object becomes the active source.
15     ss = Sphere(Radius=0.5, ThetaResolution=32, PhiResolution=8)
16
17     # The view and representation
18     v = GetRenderView()
19     if not v:
20        v = CreateRenderView()
21     v.CameraPosition = [-3, -3, -3]
22     v.CameraViewUp = [0, 0, 1]
23     v.StillRender()
24
25     # Apply the shrink filter. The Input property is optional. If Input
26     # is not specified, the filter is applied to the active source.
27     shr = Shrink(Input=ss)
28  
29     # Create a cone source. 
30     cs = Cone()
31
32     # Append cone and shrink
33     app = AppendDatasets()
34     app.Input = [shr, cs]
35
36     # Show the output of the append filter. The argument is optional
37     # as the app filter is now the active object.
38     Show(app)
39     WriteImage(filename = (impth + "demo1_1.png"), view=v, Magnification=2) 
40
41     PointData = app.GetDataInformation().GetNumberOfPoints()
42     CellData = app.GetDataInformation().GetNumberOfCells()
43     print PointData, " Points"
44     print CellData, " Cells"
45
46     # Render the default view.
47     Render()
48
49     
50 testdir = os.getenv("TESTDIR")
51 pvdata = os.getenv("PVDATA")
52
53 if __name__ == "__main__":
54   demo1(impth =testdir+"/Pic/")