[vtkusers] C++ pointers into Python (fwd)

Carl Hetherington lists at carlh.net
Mon Dec 10 18:10:10 EST 2001


On Mon, 10 Dec 2001, David Gobbi wrote:

> Hi Carl,
> 
> Methods that use pass-by-reference aren't wrapped (except where the
> the parameter being passed is a vtkObject).  The main reason for this
> is that python itself treats references to most basic types (int, float,
> etc) as const.  As a result there is no way to wrap these methods in an
> obvious way, i.e. even if they were wrapped, a Python programmer would
> have a tough time figuring out exactly how to use them.

That makes sense.  This is the first time I've seen how well this "Python
wrappers around C++ classes" method can work, and this would seem to be a
fairly minor limitation.
 
> If your cell array is part of a vtkPolyData (or any vtkDataSet) then
> you can use one of these two vtkPolyData methods instead:
>    vtkCell *GetCell(int cellId);
>    void GetCell(int cellId, vtkGenericCell *cell);

Thanks, I've now got just such a work-around.  I'm gobsmacked by the power
offered by Python/VTK, so a big thumbs-up to all concerned :-)  Having
spent a long time implementing things in OpenGL with C++ this is a welcome
relief.

Cheers
Carl

PS To the moderator: apologies for the two postings from cth at carlh.net, I
keep forgetting to change my From: address.





More information about the vtkusers mailing list