From: Eric B. P. <ebp...@gm...> - 2009-08-20 02:10:20
|
Please forgive me if this has been coerved before...but I am completely confused... I am trying to understand the best/easiest/any way to hand a n x 3 list/array of coordinates (X,Y,Z) to an existing C routine that wants the imput as double **. After looking into NumPY, Cython, NumPy.i, swig etc and not being much of a C programmer, I am completely lost. The C program stores data in a very complex typedef structure in a seperate module so I have written a basic method to take a 2D array and populate the structre, but can't figure out what I need to do to get the data from Python into my method. I tried defining an interface using numpy.i in an swig interface file as follows: %module pyTIN %{ #define SWIG_FILE_WITH_INIT #include <pyTIN.h> %} %include "numpy.i" %init %{ import_array(); %} %apply(double **IN_ARRAY2, int){(double **dataarray, int num_points)}; %include "pyTIN.h" extern void createTIN(double**, int); With the heard file (pyTIN.h) containing: #include "tinlib.h" double dataarray[500][2]; extern void createTIN(double **dataarray, int num_points); void save_triangleSQL(FILE *outfile,PListT *points,intdex pdex0,intdex pdex1,intdex pdex2); void tin_save_trianglesSQL(tin_contextT *tcontext,char *filename); which seems to present an interface to python (I can import the module and call the method) but I can't figure out how to get my data to the interface - I either get an error message about incorrect type (double**) or a segmentation fault. I guess one of the main issues from the documentation is that I am unclear as to what goes where (e.g what goes in the *.i file, what goes in the C heard file, what goes in a python file). Any guidance would be greatly appreciated. Thanks, Eric |