[vtkusers] Mix Tcl and C++

Kevin Wright Kevin.Wright at ansys.com
Fri Jul 25 09:39:13 EDT 2003


> What I have is a number of tcl scripts that read and process 
> image data (The Visible Human dataset), and create a number 
> of actors. 
> 
> Now I would like to display these images in a VR environment 
> consisting of three displays. For this purpose I will use 
> Performer, and I have found a class called vtkActorToPF who 
> can translate the vtkActor into a node in Performer and then 
> use Performer to render the scene. 
> 
> The Performer file will be written in C++ and this is the 
> file in which I would like to use vtkActorToPF, i.e. make the 
> translation from vtk to pf. Therefore I have to access the 
> actors created in the tcl script from a c++ file, to be able 
> to use vtkActorToPF.

I would suggest starting from Tcl, making your actors, then passing them down to c code by creating a new Tcl command.  If you're unsure how to do that, its very easy, and any Tcl reference will tell you how to do it.  The way that you pass down actors, or any vtk object, from Tcl to C, is to pass down the name of the object as an argument to the command.  Once in C(++), you can take that string and pass it to vtkTclGetPointerFromObject which is included in the Common directory of vtk in vtkTclUtils.h/.cxx.  That will return a pointer to the object, and you can work from there.  For example, if the name of the actor is stored in char *actorName:

int err;
vtkActor *actor = (vtkActor *) vtkTclGetPointerFromObject(actorName,"vtkActor",interp,err);

where interp is a pointer to a Tcl_Interp structure, which will come with the Tcl command.

Hope that's what you need.

Regards,
Kevin.



More information about the vtkusers mailing list