Doubts on how to do a c wrapper for python using SWIG
<h1>Context</h1>

<p>I have a function implemented in c that I would like to test in python environment. After some reads, I decided to use SWIG tool. A just did an simple example presented <a href="http://www.swig.org/Doc1.3/Python.html" rel="nofollow noreferrer">here</a>, but I am still planty of doubts and so I decided to come here. The c project has the following files</p>

<ul>
<li>ransac2Dline.h</li>
<li>ransac2Dline.c</li>
<li>svd.h</li>
<li>svd.c</li>
</ul>

<p>and the fuction that I want to use is </p>

<pre><code>int ransac_2Dline(float **data, int n, int maxT, float threshold,
                    float *bestModel, int *bestInliers, int verbose);
</code></pre>

<p>which is declared in the header ransac2Dline.h with other auxiliary functions. The header contents are</p>

<pre><code>#ifndef RANSAC2DLINE_H
#define RANSAC2DLINE_H

#include &lt;time.h&gt;
#include &lt;math.h&gt;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;

#include "svd.hpp"

int ransac_2Dline(float **data, int n, int maxT, float threshold,
                    float *bestModel, int *bestInliers, int verbose);

int randomSelect(float **sel, int nsel, float **data, int *ndata);

int fitModel_line(float *point, float *l, float threshold);

void estimateModel_line(float *l, float **P, int n);

void twoPointsLine(float *l, float **P);

#endif /* RANSAC2DLINE_H */
</code></pre>

<p>. </p>

<h1>Questions</h1>

<p><strong>i)</strong> I would like to know how exactly should I define the SWIG module .i. Since I want an interface just for <strong>ransac_2Dline</strong> function I guess the SWIG module needs to handle it. I mean someything like this</p>

<pre><code>/* File: ransac.i */
%module ransac

%{
#define SWIG_FILE_WITH_INIT
#include "ransac2Dline.h"
%}

int ransac_2Dline(float **data, int n, int maxT, float threshold,
                      float *bestModel, int *bestInliers, int verbose);
</code></pre>

<p>. Is this right? Or should I do something different?</p>

<p><strong>ii)</strong> The most import data computed by the <strong>ransac_2Dline</strong> function it is not returned by it (the returned int value is just an indicator of the function success in accomplish its task) but it is turned available in the outer scope by the point <strong>*bestModel</strong>. Can an interface be created by SWIG to simulated in python environment this approach?</p>

<p><strong>iii)</strong> Is this approach a good solution or should I go with ctypes or anything else?</p>

<h1>More infos</h1>

<p>I am working with an Ubuntu 14.04.5 LTS, using g++ compiler and the python vesion 2.7.6. </p>

<p>I will really appreciate any help or tip (this subject is a little hard for me since I am a mechanical engineer that had the stupid idea of work with robotcs. :)). </p>