[vtkusers] vtk31/local classes, python wrapper

David Gobbi dgobbi at irus.rri.on.ca
Wed Jun 7 22:32:04 EDT 2000


Hi Randall,

Without seeing how you declared the methods in the .h file, I can't
give you specifics about why they weren't wrapped.  But here are
a few general rules that cover the python wrapping (and tcl, Java as
well):

- "parsed" and "wrapped" are two different things, pretty much every
  method can be parsed, but after the parsing is finished the python
  wrappers must make a decision whether the method has an appropriate
  python equivalent

The rules:

- if a method returns "float *" etc, then there must be a corresponding
  and _correctly formatted_ entry in vtk/wrap/hints

- if a method argument is a pointer to anything other than a VTK object,
  the method will not be wrapped (sometime before VTK 3.1, this was
  ammended to allow a python string to be substituted for void *)

- if a method argument is an array, the method will not be wrapped
  (this has changed since vtk 3.1, now const array args will be wrapped)

- finally, protected and private methods are not wrapped for obvious
  reasons

Take a look through some of the other .h files to get a feel for the
kinds of method argument types are used.  And, whenever possible,
use the vtkSetObject, vtkSetVector etc. macros.

 - David

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

On Wed, 7 Jun 2000, Randall A. Jones wrote:

> Hello.
>   I have written/modified a couple of vtk classes and compiled them
> under the vtk31/local area.  
> For the first class (vtkTriPlaneSource), this works nicely. 
> For the second class (vtkLWOBWriter), most of the interface methods for
> the object are (claimed) parsed by vtkWrapPython but do not end up in
> vtk31/local/python/vtkLWOBWriterPython.cxx and as a result are not in
> the resulting libVTKLocalPython.so.
> 
> compile output:
> --
>         rm -f python/vtkLWOBWriterPython.cxx;
> /usr/tmp/src/vtk31/wrap/vtkWrapPython ./vtkLWOBWriter.h ./../wrap/hints
> 0 > python/vtkLWOBWriterPython.cxx
>    Parsed func PrintSelf
>    Parsed func New
>    Parsed func IsSurface
>    Parsed func NewSurface
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func AddSurfaceAttrib
>    Parsed func vtkLWOBWriter
>    Parsed func vtkLWOBWriter
>    Parsed func vtkLWOBWriter
>    Converted operator
>    Parsed func WriteData
> --
> 
> vtk31/local/python/vtkLWOBWriterPython.cxx snippet:
> --
> static PyMethodDef PyvtkLWOBWriterMethods[] = {
>   {"GetClassName",             
> (PyCFunction)PyvtkLWOBWriter_GetClassName, 1},
>   {"SetFileName",              
> (PyCFunction)PyvtkLWOBWriter_SetFileName, 1},
>   {"GetFileName",              
> (PyCFunction)PyvtkLWOBWriter_GetFileName, 1},
>   {NULL,                NULL}
> };





More information about the vtkusers mailing list