[vtk-developers] Problem with Python wrappers

David Gobbi david.gobbi at gmail.com
Fri Jul 15 11:30:25 EDT 2011


On Fri, Jul 15, 2011 at 7:42 AM, Prabhu Ramachandran <prabhu at aero.iitb.ac.in
> wrote:

>
> Don't you already have vtkVector2i, vtkVector2f etc. which really are
> specific instantiations or am I missing something -- I'm away from my laptop
> where I built things so cannot verify?


Those have been defined in the C++ header files as subclasses for some of
the template instantiations.  But they cannot be used in place of the
template instantiations in the wrappers.  For example, tracing the hierarchy
for vtkVector3f:

class vtkVector3f : public vtkVector3<float>

template<typename T>
class vtkVector3 : public vtkVector<T, 3>

template<typename T, int Size>
class vtkVector

To capture the complete hierarchy, it is necessary to wrap all of these:
vtkVector3f, vtkVector3<float>, vtkVector<float, 3>.  Wrapping just the leaf
class vtkVector3f would be insufficient.  Right now, in python I have named
the latter two classes vtkVector3[float32] and vtkVector[float32,3] and they
can be instantiated as such by evaluation, because vtkVector3[] and
vtkVector[] are dicts that take the template parameters 'float32' and
('float32', 3) as keys.  A more thorough explanation is provided in the
template section of this document:
http://vtk.org/gitweb?p=VTK.git;a=blob;f=Wrapping/Python/README_WRAP.txt

I could change the python names of the template instantiations to a mangled
form to make them python-legit,

vtkVector3<float> -> 'T10vtkVector3IfE'
vtkVector<float,3> -> 'T9vtkVectorIfLi3EE'

but I cannot use names like "vtkVector3f" or else there will be collisions.

In actuality I'd like Mayavi to work but installing it is non-trivial so I
> will try and whip up a script for you with no external dependencies later
> tonight (in 3-4 hours from now).  I hope that will work.
>

Thanks, that would help.

 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110715/e37cc204/attachment.html>


More information about the vtk-developers mailing list