[vtkusers] speed up tcl program
Kevin Wright
krw at viz-solutions.com
Wed Jul 17 12:21:24 EDT 2002
>I made some of my vtk applications using TCL. The problem is that the
>applications programmed using C++ is obviously faster than using TCL
>for the same data set. Is there anyone having any idea how to speed up
>tcl program?
The key to using Tcl effectively is realizing its strengths and
weaknesses. Since all data in Tcl is string based, some of the operations
will be significantly slower. For example, getting an array of points
could require several thousand conversions of floating point numbers to
strings, which are then passed up to Tcl. If they are modified and then
sent back to the VTK code, they must then all be converted back to floating
point numbers. On the other hand, if you were to create a file reader
object, connect it to a mapper, actor, renderer, render window, I don't
believe that the Tcl implementation would be noticeably slower at all.
If you must manipulate more than a couple of numbers in your code, I would
suggest using a combination of Tcl and C. Tcl makes it very easy to drop
some functionality down to C, while leaving you free to maintain overall
control from the Tcl level. You can create c functions which take vtk
objects as arguments, and make these functions accessible as Tcl commands.
I would also definitely not say that Tcl is only good for prototyping and
testing. Tcl, used properly is fully capable of supporting a commercial
product. From the looks of Kitware's commercial products, in fact, I
assume that's exactly what they themselves do.
Kevin.
More information about the vtkusers
mailing list