VTK - Tcl vs. Python Render speed

David Gobbi dgobbi at irus.rri.on.ca
Fri Apr 28 10:55:48 EDT 2000


Hi Randall,

I get identical results with 3DMorph.tcl and 3DMorph.py, I've attached
a 3DMorph.tcl that prints timings so that you can do the same comparison
on your computer.  Also, it looks like my $150 (Canadian dollars) Celeron
with its $200 TNT2 video card (last year's technology) is trouncing your
Octane ;)

 - David

3DMorph.tcl:

interpolate SetT
0.000260949      (i.e. 0.00 sec)
renWin Render
0.162782         (i.e. 0.16 sec)
interpolate SetT
9.09567e-05
renWin Render
0.160779

3DMorph.py:

interpolate.SetT() - 0.00 sec
renWin.Render()    - 0.16 sec
interpolate.SetT() - 0.00 sec
renWin.Render()    - 0.16 sec

--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Fri, 28 Apr 2000, Randall Hopper wrote:

>      Big differences in Render() times between Tcl and Python.
> 
>      renWin.Render is taking 1/4 of a second, when called from Python.  But
> when called from Tcl, its nearly instantaneous.  Any ideas?
> 
>      For example, attached is a trivial conversion of the 3DMorph.tcl
> example program to Python.  I've inserted timing prints to show how long
> VTK calls are taking.  (See below)
> 
>      Once the update/render loop is complete and the VTK mouse interactor
> takes over, it's fluid 30 fps in both Tcl and Python scripts (this is a H/W
> accelerated SGI Octane).  But in the update/render loop, it takes VTK-Tcl 3
> seconds and VTK-Python 11 seconds to complete all 40 iterations.
> 
>      Thoughts?
> 
> -- 
> Randall Hopper
> aa8vb at yahoo.com
> 
> 
> 
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.25 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.26 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.26 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.26 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.25 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.26 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.28 sec
> interpolate.SetT() - 0.00 sec
> renWin.Render()    - 0.25 sec
> interpolate.SetT() - 0.00 sec
> ...
> 
-------------- next part --------------
catch {load vtktcl}
if { [catch {set VTK_TCL $env(VTK_TCL)}] != 0} { set VTK_TCL "../../examplesTcl" }
if { [catch {set VTK_DATA $env(VTK_DATA)}] != 0} { set VTK_DATA "../../../vtkdata" }

# use implicit modeller / interpolation to perform 3D morphing
#
source $VTK_TCL/vtkInt.tcl

#
# get some nice colors
source $VTK_TCL/colors.tcl

# make the letter v
vtkVectorText letterV
  letterV SetText v

# read the geometry file containing the letter t
vtkVectorText letterT
  letterT SetText t

# read the geometry file containing the letter k
vtkVectorText letterK
  letterK SetText k

# create implicit models of each
vtkImplicitModeller blobbyV
  blobbyV SetInput [letterV GetOutput]
  blobbyV SetMaximumDistance .2
  blobbyV SetSampleDimensions 50 50 12
  blobbyV SetModelBounds -0.5 1.5 -0.5 1.5 -0.5 0.5

# create implicit models of each
vtkImplicitModeller blobbyT
  blobbyT SetInput [letterT GetOutput]
  blobbyT SetMaximumDistance .2
  blobbyT SetSampleDimensions 50 50 12
  blobbyT SetModelBounds -0.5 1.5 -0.5 1.5 -0.5 0.5

# create implicit models of each
vtkImplicitModeller blobbyK
  blobbyK SetInput [letterK GetOutput]
  blobbyK SetMaximumDistance .2
  blobbyK SetSampleDimensions 50 50 12
  blobbyK SetModelBounds -0.5 1.5 -0.5 1.5 -0.5 0.5

# Interpolate the data
vtkInterpolateDataSetAttributes interpolate
  interpolate AddInput [blobbyV GetOutput]
  interpolate AddInput [blobbyT GetOutput]
  interpolate AddInput [blobbyK GetOutput]
  interpolate SetT 0.0

# extract an iso surface
vtkContourFilter blobbyIso
  blobbyIso SetInput [interpolate GetOutput]
  blobbyIso SetValue 0 0.1

# map to rendering primitives
vtkPolyDataMapper blobbyMapper
  blobbyMapper SetInput [blobbyIso GetOutput]
  blobbyMapper ScalarVisibilityOff

# now an actor
vtkActor blobby
  blobby SetMapper blobbyMapper
  eval [blobby GetProperty] SetDiffuseColor $banana

# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
  renWin AddRenderer ren1
vtkRenderWindowInteractor iren
  iren SetRenderWindow renWin

vtkCamera camera
    camera SetClippingRange 0.265 13.2
    camera SetFocalPoint 0.539 0.47464 0
    camera SetPosition 0.539 0.474674 2.644
    camera ComputeViewPlaneNormal
    camera SetViewUp 0 1 0
ren1 SetActiveCamera camera

#  now  make a renderer and tell it about lights and actors
renWin SetSize 300 350
  
ren1 AddActor blobby
ren1 SetBackground 1 1 1
renWin Render 

vtkTimerLog timer

set subIters 20.0
for {set i 0} {$i < 2} {incr i} {
   for {set j 1} {$j <= $subIters} {incr j} {
      set t [expr $i + $j/$subIters]
      timer StartTimer
      interpolate SetT $t
      timer StopTimer
      puts "interpolate SetT" 
      puts [timer GetElapsedTime]
      timer StartTimer
      renWin Render
      timer StopTimer
      puts "renWin Render" 
      puts [timer GetElapsedTime]
   }
}

renWin SetFileName 3DMorph.tcl.ppm
#renWin SaveImageAsPPM

# render the image
#
iren SetUserMethod {wm deiconify .vtkInteract}

# prevent the tk window from showing up then start the event loop
wm withdraw .



More information about the vtkusers mailing list