Back to index

salome-paravis  6.5.0
demo1.py
Go to the documentation of this file.
00001 # Copyright (C) 2010-2012  CEA/DEN, EDF R&D
00002 #
00003 # This library is free software; you can redistribute it and/or
00004 # modify it under the terms of the GNU Lesser General Public
00005 # License as published by the Free Software Foundation; either
00006 # version 2.1 of the License.
00007 #
00008 # This library is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 # Lesser General Public License for more details.
00012 #
00013 # You should have received a copy of the GNU Lesser General Public
00014 # License along with this library; if not, write to the Free Software
00015 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 #
00017 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 #
00019 
00020 if not ('servermanager' in dir()):
00021   from pvsimple import *
00022 
00023 import os
00024 
00025 def demo1(impth):
00026     """Simple demo that create the following pipeline
00027     sphere - shrink - \
00028                        - append
00029     cone            - /
00030     """
00031 
00032     # Create a sphere of radius = 0.5, theta res. = 32
00033     # This object becomes the active source.
00034     ss = Sphere(Radius=0.5, ThetaResolution=32, PhiResolution=8)
00035 
00036     # The view and representation
00037     v = GetRenderView()
00038     if not v:
00039        v = CreateRenderView()
00040     v.CameraPosition = [-3, -3, -3]
00041     v.CameraViewUp = [0, 0, 1]
00042     v.StillRender()
00043 
00044     # Apply the shrink filter. The Input property is optional. If Input
00045     # is not specified, the filter is applied to the active source.
00046     shr = Shrink(Input=ss)
00047  
00048     # Create a cone source. 
00049     cs = Cone()
00050 
00051     # Append cone and shrink
00052     app = AppendDatasets()
00053     app.Input = [shr, cs]
00054 
00055     # Show the output of the append filter. The argument is optional
00056     # as the app filter is now the active object.
00057     Show(app)
00058     WriteImage(filename = (impth + "demo1_1.png"), view=v, Magnification=2) 
00059 
00060     PointData = app.GetDataInformation().GetNumberOfPoints()
00061     CellData = app.GetDataInformation().GetNumberOfCells()
00062     print PointData, " Points"
00063     print CellData, " Cells"
00064 
00065     # Render the default view.
00066     Render()
00067 
00068     
00069 testdir = os.getenv("TESTDIR")
00070 pvdata = os.getenv("PVDATA")
00071 
00072 if __name__ == "__main__":
00073   demo1(impth =testdir+"/Pic/")