Index: /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 5018)
+++ /issm/trunk/src/mex/ContourToMesh/ContourToMesh.cpp	(revision 5019)
@@ -44,4 +44,5 @@
 
 	//contours
+	mxArray*  matlabstructure=NULL;
 	int numcontours;
 	Contour** contours=NULL;
@@ -58,4 +59,7 @@
 	}
 
+	/*First, call expread on filename to build a contour array in the matlab workspace: */
+	mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
 	/*Fetch inputs: */
 	FetchData(&index,&nel,NULL,INDEXHANDLE);
@@ -64,24 +68,23 @@
 	FetchData(&edgevalue,EDGEVALUEHANDLE);
 
-	/*Recover list of contours from the 'contours' structure: */
-	//number of contours;
-	numcontours=mxGetNumberOfElements(CONTOURSHANDLE);
-	//allocate array:
+	//Fetch contours
+	numcontours=mxGetNumberOfElements(matlabstructure);
 	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
-
-	//go through contours, and populate xcontours and ycontours accordingly.
 	for(i=0;i<numcontours;i++){
 		//allocate
 		contouri=(Contour*)xmalloc(sizeof(Contour));
 		//retrieve dimension of this contour.
-		contouri->nods=(int)mxGetScalar(mxGetField(CONTOURSHANDLE,i,"nods"));
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
 		//set pointers.
-		contouri->x=mxGetPr(mxGetField(CONTOURSHANDLE,i,"x"));
-		contouri->y=mxGetPr(mxGetField(CONTOURSHANDLE,i,"y"));
+		contouri->x=mxGetPr(mxGetField(matlabstructure,i,"x"));
+		contouri->y=mxGetPr(mxGetField(matlabstructure,i,"y"));
 		*(contours+i)=contouri;
 	}
 
-	/*
-	for(i=0;i<numcontours;i++){
+	/*Fetch  interptype: */
+	FetchData(&interptype,INTERPTYPEHANDLE);
+
+	/* Debugging of contours :{{{1*/
+	/*for(i=0;i<numcontours;i++){
 		printf("\nContour echo: contour number  %i / %i\n",i+1,numcontours);
 		contouri=*(contours+i);
@@ -90,9 +93,6 @@
 			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
 		}
-	}
-	*/
-
-	/*Recover  interptype: */
-	FetchData(&interptype,INTERPTYPEHANDLE);
+	}*/
+	/*}}}*/
 
 	/*Run interpolation routine: */
@@ -122,8 +122,8 @@
 	printf("\n");
 	printf("      Usage: \n");
-	printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contours,interptype,edgevalue)\n\n");
+	printf("         [in_nod,in_elem]=ContourToMesh(index,x,y,contourname,interptype,edgevalue)\n\n");
 	printf("\n");
 	printf("         index,x,y: mesh triangulation.\n");
-	printf("         contours: structure holding sets of vertices making open contours.\n");
+	printf("         contourname: name of .exp file containing the contours.\n");
 	printf("         interptype: string definining type of interpolation ('element', or 'node').\n");
 	printf("         edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
Index: /issm/trunk/src/mex/ContourToMesh/ContourToMesh.h
===================================================================
--- /issm/trunk/src/mex/ContourToMesh/ContourToMesh.h	(revision 5018)
+++ /issm/trunk/src/mex/ContourToMesh/ContourToMesh.h	(revision 5019)
@@ -27,5 +27,5 @@
 #define XHANDLE prhs[1]
 #define YHANDLE prhs[2]
-#define CONTOURSHANDLE prhs[3]
+#define FILENAME prhs[3]
 #define INTERPTYPEHANDLE prhs[4]
 #define EDGEVALUEHANDLE prhs[5]
Index: /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp
===================================================================
--- /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 5018)
+++ /issm/trunk/src/mex/ContourToNodes/ContourToNodes.cpp	(revision 5019)
@@ -39,4 +39,5 @@
 
 	//contours
+	mxArray*  matlabstructure=NULL;
 	int numcontours;
 	Contour** contours=NULL;
@@ -49,4 +50,7 @@
 	CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToNodesUsage);
 
+	/*First, call expread on filename to build a contour array in the matlab workspace: */
+	mexCallMATLAB( 1, &matlabstructure, 1, (mxArray**)&FILENAME, "expread");
+
 	/*Fetch inputs: */
 	FetchData(&x,&nods,NULL,XHANDLE);
@@ -54,21 +58,28 @@
 	FetchData(&edgevalue,EDGEVALUEHANDLE);
 
-	/*Recover list of contours from the 'contours' structure: */
-	//number of contours;
-	numcontours=mxGetNumberOfElements(CONTOURSHANDLE);
-	//allocate array:
+	//Fetch contours
+	numcontours=mxGetNumberOfElements(matlabstructure);
 	contours=(Contour**)xmalloc(numcontours*sizeof(Contour*));
-
-	//go through contours, and populate xcontours and ycontours accordingly.
 	for(i=0;i<numcontours;i++){
 		//allocate
 		contouri=(Contour*)xmalloc(sizeof(Contour));
 		//retrieve dimension of this contour.
-		contouri->nods=(int)mxGetScalar(mxGetField(CONTOURSHANDLE,i,"nods"));
+		contouri->nods=(int)mxGetScalar(mxGetField(matlabstructure,i,"nods"));
 		//set pointers.
-		contouri->x=mxGetPr(mxGetField(CONTOURSHANDLE,i,"x"));
-		contouri->y=mxGetPr(mxGetField(CONTOURSHANDLE,i,"y"));
+		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 grids %i\n",contouri->nods);
+		for (j=0;j<contouri->nods;j++){
+			printf("   %lf %lf\n",*(contouri->x+j),*(contouri->y+j));
+		}
+	}*/
+	/*}}}*/
 
 	/*Run interpolation routine: */
@@ -85,8 +96,8 @@
 void ContourToNodesUsage(void){
 	printf("   usage:\n");
-	printf("   [flags]=ContourToNodes(x,y,contours,edgevalue);\n\n");
+	printf("   [flags]=ContourToNodes(x,y,contourname,edgevalue);\n\n");
 	printf("   where:\n");
 	printf("      x,y: list of nodes.\n");
-	printf("      contours: structure holding sets of vertices making open contours.\n");
+	printf("      contourname: name of .exp file containing the contours.\n");
 	printf("      interptype: string definining type of interpolation ('element', or 'node').\n");
 	printf("      edgevalue: integer (0, 1 or 2) defining the value associated to the nodes on the edges of the polygons.\n");
Index: /issm/trunk/src/mex/ContourToNodes/ContourToNodes.h
===================================================================
--- /issm/trunk/src/mex/ContourToNodes/ContourToNodes.h	(revision 5018)
+++ /issm/trunk/src/mex/ContourToNodes/ContourToNodes.h	(revision 5019)
@@ -26,5 +26,5 @@
 #define XHANDLE prhs[0]
 #define YHANDLE prhs[1]
-#define CONTOURSHANDLE prhs[2]
+#define FILENAME prhs[2]
 #define EDGEVALUEHANDLE prhs[3]
 
Index: /issm/trunk/src/mex/InputToResult/InputToResult.cpp
===================================================================
--- /issm/trunk/src/mex/InputToResult/InputToResult.cpp	(revision 5018)
+++ /issm/trunk/src/mex/InputToResult/InputToResult.cpp	(revision 5019)
@@ -21,5 +21,5 @@
 
 	/*checks on arguments on the matlab side: */
-	//CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&ContourToMeshUsage); Cant' use it here, as we have variable inputs.
+	//CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InputToResultUsage); Cant' use it here, as we have variable inputs.
 	if((nlhs!=NLHS) || (nrhs!=7 && nrhs!=9)){
 		InputToResultUsage();
