Back to index

salome-paravis  6.5.0
demo3.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 
00021 if not ('servermanager' in dir()):
00022   from pvsimple import *
00023 
00024 import  os
00025 
00026 def demo3(impth):
00027     """This method demonstrates an artificial data sources,
00028     probes it with a line, etc"""
00029 
00030     # The TWO views
00031     rv = GetRenderView()
00032     
00033     v = CreateRenderView()  
00034     v.CameraPosition = [-30, -20, -65]
00035     v.CameraFocalPoint = [0.0, 0.0, 0.0]
00036     v.CameraViewUp = [-0.65, -0.55, 0.5]
00037     v.CameraViewAngle = [30]
00038     SetActiveView(rv)
00039 
00040     src = Wavelet()
00041     # Get some information about the data. First, for the source to execute
00042     UpdatePipeline()
00043 
00044     di = src.GetDataInformation()
00045     print "Data type:", di.GetPrettyDataTypeString()
00046     print "Extent:", di.GetExtent()
00047 
00048     ##src.Representation = 3 # outline
00049     Show(src, view=v)
00050     v.StillRender()
00051 
00052     # Apply a contour filter
00053     cf = Contour(Input = src)
00054     cf.ContourBy = ['POINTS', 'RTData']
00055     cf.Isosurfaces = [37.353099999999998, 63.961533333333335, 90.569966666666673, 117.1784, 143.78683333333333, 170.39526666666666, 
00056                                  197.00370000000001, 223.61213333333333, 250.22056666666668, 276.82900000000001]
00057     Show(cf, view=rv)
00058 
00059     #Set background
00060     SetViewProperties(Background = [.50, .20, .30])
00061     Render()
00062 
00063     # Reset the camera to include the whole thing
00064     rv.StillRender()
00065     rv.ResetCamera()
00066     rv.CameraPosition = [-2.50, 60, -40]
00067     rv.CameraFocalPoint = [1.25, 1.0, 1.35]
00068     rv.CameraViewUp = [-0.955, 0.1, 0.25]
00069     rv.CameraViewAngle = [30]
00070     rv.StillRender()
00071 
00072     # Now, let's probe the data
00073     probe = ResampleWithDataset(Input=src)
00074 
00075     # with a line
00076     line = Line(Resolution=60)
00077 
00078     # that spans the dataset
00079     bounds = di.GetBounds()
00080 
00081     print "Bounds: ", bounds
00082     line.Point1 = bounds[0:6:2]
00083     line.Point2 = bounds[1:6:2]
00084 
00085     probe.Source = line
00086 
00087     # Render with the line
00088     Show(line, view=rv)
00089     rv.StillRender()
00090     WriteImage(filename = (impth + "demo3_1.png"), view=v, Magnification=2)
00091     WriteImage(filename = (impth + "demo3_2.png"), view=rv, Magnification=2)
00092 
00093 testdir = os.getenv("TESTDIR")
00094 pvdata = os.getenv("PVDATA")
00095 
00096 if __name__ == "__main__":
00097  demo3(impth=testdir+"/Pic/")