[vtkusers] How to get the clientData for user defined Tcl commands?

Tomov, Stanimire tomov at bnl.gov
Sat Feb 7 16:21:33 EST 2004


Hi,

I wonder if the following understanding of the VTK Tcl/Tk
wrapping is correct and if somebody could please answer the question
related to the wrapping.

The VTK Tcl/Tk wrapping creates new Tcl commands for the VTK classes.
I think that when a user executes in Tcl a command like
vtkRenderer renderer
a callback function for vtkRenderer creates dynamically another
command (renderer) - in a code like :
   vtkRenderer *ren = vtkRenderer::New();
   ...
   strcpy(interp->result, argv[1]); // where argv[1] is "renderer"
   Tcl_CreateCommand(interp, interp->result, RendererCallback,
                     (ClientData) ren, DeleteRenderer);
   ...

My question is : how to retrieve the ClientData for the newly
created command renderer?
I am trying the following
  ...
  initialize the proper Tcl/Tk and VTK packages
  Tcl_Eval(interp, "vtkRenderer renderer");
  ClientData ren = Tcl_GetAssocData(interp, interp->result, NULL);
  if (ren != NULL)
    {
      vtkRenderer *ren1 = (vtkRenderer *)ren;
      ren1->SetBackground(0, 0, 0);
    }
  else
    cerr << "ren is NULL !!!" << endl;

and ren is allways NULL.

Thanks,
Stan



More information about the vtkusers mailing list