[vtkusers] Questions on wrapping a C++ library for use in VTK Scripting (eg. TCL)

Markus Neff markus at noodle.med.yale.edu
Thu Oct 24 12:15:51 EDT 2002


Hello dear VTK mailing list readers !

I have a C++ class library (already using some VTK objects like
"vtkImageData" in its interface) that I want to make usable from
within VTK/TCL or VTK/Python etc. scripts. This library however
uses standard C++ exceptions for error reporting to its users and
things like std::string to pass strings in and out.
There is a hierarchy of C++ classes that could be thrown in the
case of some error condition.

I probably have to write a small C++ class derived from
"vtkObject" that internally uses the C++ class library and
translate the interface of the C++ class library to a simpler
form that the VTK Wrapper generator can understand but before
starting to write this class, I wanted to ask you some questions:

1. Is there a way of automatically wrapping C++ exceptions to the
   corresponding exception mechanisms of TCL / JAVA /Python etc. ?
   If there is no such thing (I guess there is nothing like that 
   by now) what would be the best way to provide sophisticated error
   handling facilities to the script writers ?
   
   
2. Is there support for automatically wrapping "std::string" or
   "std::vector" arguments in C++ class-methods ?
   
   
3. Has someone ever used SWIG together with VTK and some scripting
   language (because it seams to support some of the features
   I am asking about) ?
   
   
4. Is it possible to pass out multiple strings to the scripting
   languages with just one call similar to the following C++ code:

   void passOutTwoStrings(std::string& string1, std::string& string2)
   {
     string1 = std::string( "one" );
     string2 = std::string( "two" );
   }
   
   
4. I was playing with the wrapper generator and it seamed that it
   considers the use of the C/C++ keyword "volatile" as a syntax
   error. Is there a reason for this behaviour ? I just used
   the keyword for a private attribute of a class.


Thanks a lot for any help or suggestions in advance !!!

Regards,
Markus Neff




More information about the vtkusers mailing list