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,
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,