1 # Copyright (C) 2010-2014 CEA/DEN, EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 if not ('servermanager' in dir()):
22 from pvsimple import *
26 def demo2(fname, impth):
27 """This demo shows the use of readers, data information and display properties."""
32 v = CreateRenderView()
33 v.CameraPosition = [-20, -9, -45]
34 v.CameraFocalPoint = [0.7, 0.3, 1.7]
35 v.CameraViewUp = [-0.75, -0.6, 0.25]
36 v.CameraViewAngle = [30]
39 # Create the exodus reader and specify a file name
40 reader = ExodusIIReader(FileName=fname)
42 # Get the list of point arrays.
43 avail = reader.PointVariables.Available
47 reader.PointVariables = avail
49 # Turn on the visibility of the reader
52 # Set representation to wireframe
53 SetDisplayProperties(Representation = "Wireframe")
56 SetViewProperties(Background = [0., 0., 0.])
59 # Change the elevation of the camera.
60 GetActiveCamera().Elevation(45)
63 # Now that the reader executed, let's get some information about it's output.
64 pdi = reader[0].PointData
66 # This prints a list of all read point data arrays as well as their value ranges.
67 print 'Number of point arrays:', len(pdi)
68 for i in range(len(pdi)):
70 print "----------------"
71 print "Array:", i, " ", ai.Name, ":"
72 numComps = ai.GetNumberOfComponents()
73 print "Number of components:", numComps
74 for j in range(numComps):
75 print "Range:", ai.GetRange(j)
77 # White is boring. Let's color the geometry using a variable. First create a lookup table. This object controls how scalar values are mapped to colors.
78 SetDisplayProperties(LookupTable = MakeBlueToRedLT(0.00678, 0.0288))
80 # Color by point array called Pres
81 SetDisplayProperties(ColorAttributeType = "POINT_DATA")
82 SetDisplayProperties(ColorArrayName = "Pres")
84 WriteImage(filename = (impth + "demo2_1.png"), view=v, Magnification=2)
86 # Set representation to surface
87 SetDisplayProperties(Representation = "Surface")
90 lt = MakeBlueToRedLT(0.00678, 0.0288)
91 ScalarBar = CreateScalarBar(LookupTable = lt, Title = "Sample")
92 GetRenderView().Representations.append(ScalarBar)
93 WriteImage(filename = (impth + "demo2_2.png"), view=v, Magnification=2)
97 scriptdir = inspect.getframeinfo(inspect.currentframe())[0]
98 testdir = os.path.dirname( os.path.abspath(scriptdir) )
99 pvdata = os.getenv("SAMPLES_SRC_DIR")
101 if __name__ == "__main__":
102 demo2(fname=pvdata+"/Data/disk_out_ref.ex2", impth=testdir+"/Pic/")