Index: /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp
===================================================================
--- /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12117)
+++ /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp	(revision 12118)
@@ -4,42 +4,28 @@
 #include "./InterpFromMeshToMesh2d.h"
 
-void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
 
-	int i;
+WRAPPER(InterpFromMeshToMesh2d){
 
 	/*input: */
 	double* index=NULL;
 	int     index_cols;
-
 	double* x_data=NULL;
 	int     x_data_rows;
-
 	double* y_data=NULL;
 	int     y_data_rows;
-
 	double* data=NULL; 
 	int     data_rows;
 	int     data_cols;
-
 	double* x_interp=NULL;
+	int     x_interp_rows;
 	double* y_interp=NULL;
-
-	int     x_interp_rows;
 	int     y_interp_rows;
-
+	char*   contourname=NULL;
 	double* default_values=NULL;
 	int     num_default_values=0;
-
-	//contours
-	mxArray*  matlabstructure=NULL;
-	Contour** contours=NULL;
-	int       numcontours;
-	Contour*  contouri=NULL;
+	DataSet *contours = NULL;
 
 	/*Intermediary*/
-	int nods_data;
 	int nels_data;
-	int nods_interp;
-	int verbose=0;
 
 	/* output: */
@@ -49,9 +35,12 @@
 	MODULEBOOT();
 
-	/*checks on arguments on the matlab side: */
+	/*checks on output arguments on the matlab side: */
+	#ifdef _HAVE_MATLAB_MODULES_
 	if(nlhs!=NLHS){
 		InterpFromMeshToMesh2dUsage();
 		_error_("InterpFromMeshToMesh2dUsage usage error");
 	}
+	#endif
+	/*check on input arguments: */
 	if((nrhs!=6) & (nrhs!=8)){
 		InterpFromMeshToMesh2dUsage();
@@ -60,54 +49,25 @@
 
 	/*Input datasets: */
-	if (verbose) printf("Fetching inputs\n");
-	FetchData(&index,&nels_data,&index_cols,INDEXHANDLE);
-	FetchData(&x_data,&x_data_rows,NULL,XHANDLE);
-	FetchData(&y_data,&y_data_rows,NULL,YHANDLE);
-	FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
-	FetchData(&x_interp,&x_interp_rows,NULL,XINTERPHANDLE);
-	FetchData(&y_interp,&y_interp_rows,NULL,YINTERPHANDLE);
+	FetchData(&index,&nels_data,&index_cols,INDEX);
+	FetchData(&x_data,&x_data_rows,NULL,X);
+	FetchData(&y_data,&y_data_rows,NULL,Y);
+	FetchData(&data,&data_rows,&data_cols,DATA);
+	FetchData(&x_interp,&x_interp_rows,XINTERP);
+	FetchData(&y_interp,&y_interp_rows,YINTERP);
 
+	/*Figure out contours and default values: */
 	if(nrhs==8){
-		
-		/*Call expread on filename to build a contour array in the matlab workspace: */
-		mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
-
-		/*default values: */
-		FetchData(&default_values,&num_default_values,DEFAULTHANDLE);
-
-		/*contours: */
-		numcontours=mxGetNumberOfElements(matlabstructure);
-		contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
-		for(i=0;i<numcontours;i++){
-			//allocate
-			contouri=(Contour*)xmalloc(sizeof(Contour));
-			//retrieve dimension of this contour.
-			contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
-			//set pointers.
-			contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
-			contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
-			*(contours+i)=contouri;
-		}
-
-		/* Debugging of contours :{{{1*/
-		/*for(i=0;i<numcontours;i++){
-		  printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
-		  contouri=*(contours+i);
-		  printf("   Number of vertices %i\n",contouri->nods);
-		  for (j=0;j<contouri->nods;j++){
-		  printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
-		  }
-		  }*/
-		/*}}}*/
+		FetchData(&default_values,&num_default_values,DEFAULT);
+		FetchData(&contourname,CONTOURNAME);
+		contours=DomainOutlineRead(contourname);
 	}
 	else{
 		num_default_values=0;
 		default_values=NULL;
-		numcontours=0;
-		contours=NULL;
+		contours=new DataSet();
 	}
 
+
 	/*some checks*/
-	if (verbose) printf("Checking inputs\n");
 	if (x_data_rows!=y_data_rows){
 		_error_("vectors x and y should have the same length!");
@@ -120,14 +80,9 @@
 	}
 
-	/*get number of elements and number of nodes in the data*/
-	nods_data=x_data_rows;
-	nods_interp=x_interp_rows;
-
 	/* Run core computations: */
-	if (verbose) printf("Call core\n");
-	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,nods_data,nels_data,data,data_rows,data_cols,x_interp,y_interp,nods_interp,default_values,num_default_values,contours,numcontours);
+	InterpFromMeshToMesh2dx(&data_interp,index,x_data,y_data,x_data_rows,nels_data,data,data_rows,data_cols,x_interp,y_interp,x_interp_rows,default_values,num_default_values,contours);
 
 	/*Write data: */
-	WriteData(DATAINTERP,data_interp,nods_interp,data_cols);
+	WriteData(DATAINTERP,data_interp,x_interp_rows,data_cols);
 
 	/*end module: */
@@ -135,5 +90,6 @@
 }
 
-void InterpFromMeshToMesh2dUsage(void)
+void InterpFromMeshToMesh2dUsage(void)//{{{1
+
 {
 	_printf_(true,"INTERFROMMESHTOMESH2D - interpolation from a 2d triangular mesh onto a list of point\n");
@@ -161,2 +117,3 @@
 	_printf_(true,"\n");
 }
+//}}}
Index: /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
===================================================================
--- /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12117)
+++ /issm/trunk-jpl/src/modules/InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h	(revision 12118)
@@ -6,33 +6,66 @@
 #define _INTERPFROMMESHTOMESH2d_H
 
-/* local prototypes: */
-void InterpFromMeshToMesh2dUsage(void);
+#ifdef HAVE_CONFIG_H
+	#include <config.h>
+#else
+#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
+#endif
 
+/*Very important definition in case we are compiling a python module!: needs to come before header files inclusion*/
+#ifdef _HAVE_PYTHON_
+#define PY_ARRAY_UNIQUE_SYMBOL PythonIOSymbol
+#endif
+
+/*Header files: */
 #include "../../c/include/globals.h"
+#include "../../c/toolkits/toolkits.h"
+#include "../../c/include/include.h"
 #include "../../c/modules/modules.h"
 #include "../../c/Container/Container.h"
 #include "../../c/shared/shared.h"
 #include "../../c/issm-binding.h"
+#include "../../c/io/io.h"
+#include "../../c/EnumDefinitions/EnumDefinitions.h"
+
+#ifdef _HAVE_MATLAB_MODULES_
+/* serial input macros: */
+#define INDEX prhs[0]
+#define X prhs[1]
+#define Y prhs[2]
+#define DATA prhs[3]
+#define XINTERP prhs[4]
+#define YINTERP prhs[5]
+#define DEFAULT prhs[6]
+#define CONTOURNAME prhs[7]
+
+/* serial output macros: */
+#define DATAINTERP (mxArray**)&plhs[0]
+#endif
+
+#ifdef _HAVE_PYTHON_MODULES_
+/* serial input macros: */
+#define INDEX PyTuple_GetItem(args,0)
+#define X PyTuple_GetItem(args,1)
+#define Y PyTuple_GetItem(args,2)
+#define DATA PyTuple_GetItem(args,3)
+#define XINTERP PyTuple_GetItem(args,4)
+#define YINTERP PyTuple_GetItem(args,5)
+#define DEFAULT PyTuple_GetItem(args,6)
+#define CONTOURNAME PyTuple_GetItem(args,7)
+/* serial output macros: */
+#define DATAINTERP output,0
+#endif
 
 #undef __FUNCT__ 
 #define __FUNCT__  "InterpFromMeshToMesh2d"
 
-
-/* serial input macros: */
-#define INDEXHANDLE prhs[0]
-#define XHANDLE prhs[1]
-#define YHANDLE prhs[2]
-#define DATAHANDLE prhs[3]
-#define XINTERPHANDLE prhs[4]
-#define YINTERPHANDLE prhs[5]
-#define DEFAULTHANDLE prhs[6]
-#define FILENAME prhs[7]
-
-/* serial output macros: */
-#define DATAINTERP (mxArray**)&plhs[0]
-
 /* serial arg counts: */
 #undef NLHS
 #define NLHS  1
+#undef NRHS
+#define NRHS  6 //can be 8 though
+
+/* local prototypes: */
+void InterpFromMeshToMesh2dUsage(void);
 
 #endif
Index: /issm/trunk-jpl/src/modules/python/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/modules/python/Makefile.am	(revision 12117)
+++ /issm/trunk-jpl/src/modules/python/Makefile.am	(revision 12118)
@@ -3,7 +3,8 @@
 #Bin programs {{{1
 if MODULES
-bin_PROGRAMS = TriMesh \
-			   NodeConnectivity \
-			   ElementConnectivity
+bin_PROGRAMS = ElementConnectivity\
+			   InterpFromMeshToMesh2d \
+			   NodeConnectivity\
+			   TriMesh 
 endif 
 #}}}
@@ -31,4 +32,7 @@
 			  ../ElementConnectivity/ElementConnectivity.h
 
+InterpFromMeshToMesh2d_SOURCES = ../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.cpp\
+							../InterpFromMeshToMesh2d/InterpFromMeshToMesh2d.h
+
 NodeConnectivity_SOURCES = ../NodeConnectivity/NodeConnectivity.cpp\
 										../NodeConnectivity/NodeConnectivity.h
