Newbie question for SWIG wrapping

  • Thread starter Gheorghe Postelnicu
  • Start date
G

Gheorghe Postelnicu

Hi,

I just discovered Python and I find it much better than Tcl, so I am
porting some code in Python.

I have a question regarding some data passing from Python to a Cpp
module. Sorry, my question must really be trivial.

I have a module which I wrap using SWIG, so it gives:

%module Laplace
%{
extern void do_it(void* data);
%}

extern void do_it(void* data);

----------------
my code is trivial:

#include <iostream>
#include <vtkPolyData.h>

void do_it(void* vdata)
{
vtkPolyData* pdata = reinterpret_cast<vtkPolyData*>(vdata);
std::cout << " hi\n";
}


and in the Python module I just want to pass on some data

data = vtk.vtkPolyData()
data.SetPoints(inputPoints)
data.SetLines(inputLines)
Laplace.do_it(data)


However, the error I get is a little confusing:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib64/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "drawSplines3.py", line 445, in testLaplace
Laplace.do_it(data)
TypeError: Expected a pointer

This is confusing because my understanding is complex types are
considered to be pointers by Python. I haven't checked the VTK
wrapping of Python, nor do I currently use that (SWIG seems simpler),
so I was wondering if there is a way I can pass this data around.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top