Back to index

salome-paravis  6.5.0
Functions | Variables
demo0 Namespace Reference

Functions

def render
def run

Variables

tuple testdir = os.getenv("TESTDIR")
tuple pvdata = os.getenv("PVDATA")

Function Documentation

def demo0.render (   ss,
  v,
  title,
  nframes 
)

Definition at line 29 of file demo0.py.

00029 
00030 def render(ss, v, title, nframes):
00031   print '============================================================'
00032   print title
00033   res = []
00034   res.append(title)
00035   for phires in (500, 1000):
00036     ss.PhiResolution = phires
00037     c = v.GetActiveCamera()
00038     v.CameraPosition = [-3, 0, 0]
00039     v.CameraViewUp = [0, 0, 1]
00040     v.StillRender()
00041     c1 = time.time()
00042     for i in range(nframes):
00043       c.Elevation(0.5)
00044       v.StillRender()
00045       sys.stdout.write(".")
00046       sys.stdout.write("\n")
00047     tpr = (time.time() - c1)/nframes
00048     ncells = ss.GetDataInformation().GetNumberOfCells()
00049     print tpr, " secs/frame"
00050     print ncells, " polys"
00051     print ncells/tpr, " polys/sec"
00052     
00053     res.append((ncells, ncells/tpr))
00054 
00055   return res

Here is the caller graph for this function:

def demo0.run (   filesour,
  impth,
  nframes 
)
Runs the benchmark. If a filename is specified, it will write the
results to that file as csv. The number of frames controls how many times
a particular configuration is rendered. Higher numbers lead to more accurate
averages. 

Definition at line 56 of file demo0.py.

00056 
00057 def run(filesour, impth, nframes):
00058 
00059   """ Runs the benchmark. If a filename is specified, it will write the
00060   results to that file as csv. The number of frames controls how many times
00061   a particular configuration is rendered. Higher numbers lead to more accurate
00062   averages. """
00063 
00064   # Create a sphere source to use in the benchmarks
00065   ss = Sphere(Radius=0.5, ThetaResolution=32, PhiResolution=8)
00066 
00067   # The view and representation
00068   v = GetRenderView()
00069   if not v:
00070     v = CreateRenderView()
00071   rep = None
00072   rep = GetRepresentation(proxy=None, view=v)
00073   results = []
00074 
00075   # Start with these defaults
00076   #v.UseImmediateMode = 0
00077   #v.UseTriangleStrips = 0
00078   
00079   # Test different configurations
00080   title = 'display lists, no triangle strips, solid color'
00081   #v.UseImmediateMode = 0
00082   #v.UseTriangleStrips = 0
00083   results.append(render(ss, v, title, nframes))
00084   WriteImage(filename = (impth + "demo0_1.png"), view=v, Magnification=2)
00085 
00086   title = 'display lists, triangle strips, solid color'
00087   #v.UseTriangleStrips = 1
00088   results.append(render(ss, v, title, nframes))
00089   #WriteImage(filename = (impth + "demo0_2.png"), view=v, Magnification=2)
00090 
00091   title = 'no display lists, no triangle strips, solid color'
00092   #v.UseImmediateMode = 1
00093   #v.UseTriangleStrips = 0
00094   results.append(render(ss, v, title, nframes))
00095   #WriteImage(filename = (impth + "demo0_3.png"), view=v, Magnification=2)
00096 
00097   title = 'no display lists, triangle strips, solid color'
00098   #v.UseTriangleStrips = 1
00099   results.append(render(ss, v, title, nframes))
00100   #WriteImage(filename = (impth + "demo0_4.png"), view=v, Magnification=2)
00101 
00102   # Color by normals
00103   lt = MakeBlueToRedLT(-1, 1)
00104   rep.LookupTable = lt
00105   rep.ColorAttributeType = 0 # point data
00106   rep.ColorArrayName = "Normals"
00107   lt.RGBPoints = [-1, 0, 0, 1, 0.0288, 1, 0, 0]
00108   lt.ColorSpace = 1 # HSV
00109   lt.VectorComponent = 0
00110   
00111   title = 'display lists, no triangle strips, color by array'
00112   #v.UseImmediateMode = 0
00113   #v.UseTriangleStrips = 0
00114   results.append(render(ss, v, title, nframes))
00115   #WriteImage(filename = (impth + "demo0_5.png"), view=v, Magnification=2)
00116 
00117   title = 'display lists, triangle strips, color by array'
00118   #v.UseTriangleStrips = 1
00119   results.append(render(ss, v, title, nframes))
00120   #v.UseImmediateMode = 1
00121   #WriteImage(filename = (impth + "demo0_6.png"), view=v, Magnification=2)
00122 
00123   title = 'no display lists, no triangle strips, color by array'
00124   #v.UseOCImmediateMode = 1
00125   #v.UseTriangleStrips = 0
00126   results.append(render(ss, v, title, nframes))
00127   #WriteImage(filename = (impth + "demo0_7.png"), view=v, Magnification=2)
00128 
00129   title = 'no display lists, triangle strips, color by array'
00130   #v.UseTriangleStrips = 1
00131   results.append(render(ss, v, title, nframes))
00132   WriteImage(filename = (impth + "demo0_8.png"), view=v, Magnification=2)
00133 
00134   newr = []
00135   for r in v.Representations:
00136    if r != rep:
00137      newr.append(r)
00138    v.Representations = newr
00139   
00140   ss = None
00141   rep = None
00142   
00143   v.StillRender()
00144   v = None
00145 
00146   if filesour:
00147     f = open(filesour, "w")
00148   else:
00149     f = sys.stdout
00150   print >>f, 'configuration, %d, %d' % (results[0][1][0], results[0][2][0])
00151   for i in results:
00152     print >>f, '"%s", %g, %g' % (i[0], i[1][1], i[2][1])  
00153 

Here is the call graph for this function:


Variable Documentation

tuple demo0.pvdata = os.getenv("PVDATA")

Definition at line 155 of file demo0.py.

tuple demo0.testdir = os.getenv("TESTDIR")

Definition at line 154 of file demo0.py.