Index: /issm/trunk-jpl/src/c/Container/Constraints.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Constraints.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Constraints.cpp	(revision 14953)
@@ -11,28 +11,11 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
-#include "../shared/shared.h"
-#include "../EnumDefinitions/EnumDefinitions.h"
+#include "./Constraints.h"
+#include "../shared/io/Print/Print.h"
+#include "../toolkits/mpi/mpiincludes.h"
 
 using namespace std;
 /*}}}*/
 
-/*Object constructors and destructor*/
-/*FUNCTION Constraints::Constraints(){{{*/
-Constraints::Constraints(){
-	enum_type=ConstraintsEnum;
-	return;
-}
-/*}}}*/
-/*FUNCTION Constraints::~Constraints(){{{*/
-Constraints::~Constraints(){
-	return;
-}
-/*}}}*/
 
 /*Numerics: */
Index: /issm/trunk-jpl/src/c/Container/Constraints.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Constraints.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Constraints.h	(revision 14953)
@@ -3,4 +3,5 @@
 
 /*forward declarations */
+#include "./DataSet.h"
 class Materials;
 class Parameters;
@@ -9,6 +10,7 @@
 class Loads;
 class Nodes;
-class DataSet;
 class Inputs;
+
+#include "../EnumDefinitions/EnumDefinitions.h"
 
 /*! \brief Declaration of Constraints class. 
@@ -21,7 +23,17 @@
 	public:
 
-		/*constructors, destructors*/
-		Constraints();
-		~Constraints();
+		/*Object constructors and destructor*/
+		/*FUNCTION Constraints::Constraints(){{{*/
+		Constraints(){
+			enum_type=ConstraintsEnum;
+			return;
+		}
+		/*}}}*/
+		/*FUNCTION Constraints::~Constraints(){{{*/
+		~Constraints(){
+			return;
+		}
+		/*}}}*/
+
 
 		/*numerics*/
Index: /issm/trunk-jpl/src/c/Container/DataSet.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/DataSet.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/DataSet.cpp	(revision 14953)
@@ -251,2 +251,64 @@
 }
 /*}}}*/
+
+/*Routines that relate to datasets, but which are not methods: */
+int ExpWrite(DataSet* contours,char* domainname){/*{{{*/
+
+	/*I/O: */
+	FILE* fid=NULL;
+	Contour<double>* contour = NULL;
+
+	/*open domain outline file for writing: */
+	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
+
+	for(int counter=0;counter<contours->Size();counter++){
+		contour=(Contour<double>*)contours->GetObjectByOffset(counter);
+
+		/*Write header: */
+		fprintf(fid,"## Name:%s\n",domainname);
+		fprintf(fid,"## Icon:0\n");
+		fprintf(fid,"# Points Count	Value\n");
+		fprintf(fid,"%u %s\n",contour->nods  ,"1.");
+		fprintf(fid,"# X pos	Y pos\n");
+
+		/*Write vertices: */
+		for(int i=0;i<contour->nods;i++){
+			fprintf(fid,"%lf\t%lf\n",contour->x[i],contour->y[i]);
+		}
+
+		/*Write blank line: */
+		if(counter<contours->Size()-1) fprintf(fid,"\n");
+	}
+
+	/*close Exp file: */
+	fclose(fid);
+
+	return 1;
+}/*}}}*/
+template <class doubletype> DataSet* ExpRead(char* domainname){ /*{{{*/
+
+	/*intermediary: */
+	int                  nprof;
+	int                 *profnvertices = NULL;
+	doubletype         **pprofx        = NULL;
+	doubletype         **pprofy        = NULL;
+
+	/*output: */
+	DataSet *domain = NULL;
+
+	/*If domainname is an empty string, return empty dataset*/
+	if (strcmp(domainname,"")==0){
+		nprof=0;
+	}
+	else{
+		ExpRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname);
+	}
+
+	/*now create dataset of contours: */
+	domain=new DataSet(0);
+
+	for(int i=0;i<nprof;i++){
+		domain->AddObject(new Contour<doubletype>(i,profnvertices[i],pprofx[i],pprofy[i],1));
+	}
+	return domain;
+} /*}}}*/
Index: /issm/trunk-jpl/src/c/Container/DataSet.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/DataSet.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/DataSet.h	(revision 14953)
@@ -60,3 +60,7 @@
 };
 
+/*Methods that relate to datasets: */
+int ExpWrite(DataSet* contours,char* domainname);
+template <class doubletype> DataSet* ExpRead(char* domainname);
+
 #endif
Index: /issm/trunk-jpl/src/c/Container/Elements.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Elements.cpp	(revision 14953)
@@ -11,16 +11,9 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
-#include "../shared/shared.h"
+#include "./Elements.h"
+#include "./Parameters.h"
+#include "../classes/classes.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
-#include "../classes/objects/Elements/Element.h"
-#include "../classes/objects/ExternalResults/GenericExternalResult.h"
-#include "../classes/Patch.h"
-#include "../classes/toolkits/Vector.h"
+
 
 using namespace std;
Index: /issm/trunk-jpl/src/c/Container/Elements.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Elements.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Elements.h	(revision 14953)
@@ -3,4 +3,5 @@
 
 /*forward declarations */
+#include "./DataSet.h"
 class Materials;
 class Parameters;
@@ -9,5 +10,4 @@
 class Loads;
 class Nodes;
-class DataSet;
 class Inputs;
 
Index: /issm/trunk-jpl/src/c/Container/Inputs.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Inputs.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Inputs.cpp	(revision 14953)
@@ -11,13 +11,8 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
+#include "./Inputs.h"
+#include "../classes/objects/Inputs/Input.h"
 #include "../shared/shared.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
-#include "../classes/objects/Inputs/Input.h"
 
 using namespace std;
Index: /issm/trunk-jpl/src/c/Container/Inputs.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Inputs.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Inputs.h	(revision 14953)
@@ -4,6 +4,6 @@
 /*forward declarations */
 class Parameters;
-class DataSet;
 class Input;
+#include "./DataSet.h"
 #include "../shared/Numerics/types.h"
 
Index: /issm/trunk-jpl/src/c/Container/Materials.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Materials.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Materials.cpp	(revision 14953)
@@ -11,10 +11,5 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
+#include "./Materials.h"
 #include "../shared/shared.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
Index: /issm/trunk-jpl/src/c/Container/Materials.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Materials.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Materials.h	(revision 14953)
@@ -3,4 +3,5 @@
 
 /*forward declarations */
+#include "./DataSet.h"
 class Parameters;
 class Elements;
@@ -8,5 +9,4 @@
 class Loads;
 class Nodes;
-class DataSet;
 class Inputs;
 
Index: /issm/trunk-jpl/src/c/Container/Nodes.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Nodes.cpp	(revision 14953)
@@ -11,10 +11,5 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
+#include "./Nodes.h"
 #include "../shared/shared.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
Index: /issm/trunk-jpl/src/c/Container/Nodes.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Nodes.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Nodes.h	(revision 14953)
@@ -2,5 +2,5 @@
 #define  _CONTAINER_NODES_H_
 
-class DataSet;
+#include "./DataSet.h"
 
 /*!\brief Declaration of Nodes class.
Index: /issm/trunk-jpl/src/c/Container/Parameters.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Parameters.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Parameters.h	(revision 14953)
@@ -14,4 +14,5 @@
 class DataSet;
 class Inputs;
+#include "../shared/Numerics/types.h"
 
 /*!\brief Declaration of Parameters class.  
Index: /issm/trunk-jpl/src/c/Container/Results.cpp
===================================================================
--- /issm/trunk-jpl/src/c/Container/Results.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Results.cpp	(revision 14953)
@@ -11,10 +11,6 @@
 #endif
 
-#include <vector>
-#include <functional>
-#include <algorithm>
-#include <iostream>
-
-#include "./DataSet.h"
+#include "./Results.h"
+#include "./Parameters.h"
 #include "../shared/shared.h"
 #include "../EnumDefinitions/EnumDefinitions.h"
Index: /issm/trunk-jpl/src/c/Container/Results.h
===================================================================
--- /issm/trunk-jpl/src/c/Container/Results.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/Container/Results.h	(revision 14953)
@@ -1,4 +1,6 @@
 #ifndef _CONTAINER_RESULTS_H_
 #define  _CONTAINER_RESULTS_H_
+
+#include "./DataSet.h"
 
 /*forward declarations */
@@ -9,5 +11,4 @@
 class Loads;
 class Nodes;
-class DataSet;
 class Inputs;
 
Index: /issm/trunk-jpl/src/c/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/c/Makefile.am	(revision 14952)
+++ /issm/trunk-jpl/src/c/Makefile.am	(revision 14953)
@@ -787,7 +787,5 @@
 			./shared/Threads/PartitionRange.cpp\
 			./shared/Exp/exp.h\
-			./shared/Exp/IsInPoly.cpp\
-			./shared/Exp/IsInPolySerial.cpp\
-			./shared/Exp/ExpWrite.cpp\
+			./shared/Exp/exp.cpp\
 			./shared/TriMesh/trimesh.h\
 			./shared/TriMesh/AssociateSegmentToElement.cpp\
Index: /issm/trunk-jpl/src/c/classes/objects/Elements/Element.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Elements/Element.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Elements/Element.h	(revision 14953)
@@ -29,5 +29,5 @@
 
 		virtual void   Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0;
-		virtual void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0;
+		virtual void   SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters)=0;
 		virtual void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum)=0;
 		virtual void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>*  Kfs)=0;
Index: /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.cpp	(revision 14953)
@@ -2751,5 +2751,5 @@
 /*}}}*/
 /*FUNCTION Penta::SetCurrentConfiguration {{{*/
-void  Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
+void  Penta::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){
 
 	int analysis_counter;
Index: /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Elements/Penta.h	(revision 14953)
@@ -79,5 +79,5 @@
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters);
-		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
+		void   SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
 		void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
Index: /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.cpp	(revision 14953)
@@ -2532,5 +2532,5 @@
 /*}}}*/
 /*FUNCTION Tria::SetCurrentConfiguration {{{*/
-void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, DataSet* nodesin, Materials* materialsin, Parameters* parametersin){
+void  Tria::SetCurrentConfiguration(Elements* elementsin, Loads* loadsin, Nodes* nodesin, Materials* materialsin, Parameters* parametersin){
 
 	/*go into parameters and get the analysis_counter: */
Index: /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Elements/Tria.h	(revision 14953)
@@ -75,5 +75,5 @@
 		void   ComputeStressTensor();
 		void   Configure(Elements* elements,Loads* loads,Nodes* nodesin,Vertices* verticesin,Materials* materials,Parameters* parameters);
-		void   SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters);
+		void   SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Materials* materials,Parameters* parameters);
 		void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int set1_enum,int set2_enum);
 		void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>* Kfs);
Index: /issm/trunk-jpl/src/c/classes/objects/Inputs/Input.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Inputs/Input.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Inputs/Input.h	(revision 14953)
@@ -14,5 +14,7 @@
 class Parameters;
 class GaussPenta;
+template <class doubletype> class Vector;
 /*}}}*/
+
 
 class Input: public Object{
Index: /issm/trunk-jpl/src/c/classes/objects/Materials/Material.h
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Materials/Material.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Materials/Material.h	(revision 14953)
@@ -8,8 +8,8 @@
 /*Headers:*/
 /*{{{*/
-class Object;
+class Inputs;
+template <class doubletype> class Vector;
 #include "../Object.h"
 #include "../../Update.h"
-#include "../../../toolkits/toolkits.h"
 /*}}}*/
 
Index: /issm/trunk-jpl/src/c/classes/objects/Profiler.cpp
===================================================================
--- /issm/trunk-jpl/src/c/classes/objects/Profiler.cpp	(revision 14952)
+++ /issm/trunk-jpl/src/c/classes/objects/Profiler.cpp	(revision 14953)
@@ -12,4 +12,5 @@
 #include "./Profiler.h"
 #include "./Params/DoubleParam.h"
+#include "../../Container/Parameters.h"
 /*}}}*/
 
Index: /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
===================================================================
--- /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h	(revision 14953)
@@ -8,10 +8,7 @@
 #define RIFTINFOSIZE 12
 
-class DataSet;
-class IoModel;
-class Parameters;
-class DofIndexing;
+#include "../../Container/Container.h"
+#include "../../classes/classes.h"
 
-#include "../../shared/io/io.h"
 
 void ModelProcessorx(Elements** pelements, Nodes** pnodes, Vertices** pvertices, Materials** pmaterials, Constraints** pconstraints, Loads** ploads, Parameters** pparameters, FILE* iomodel_handle,char* rootpath,const int solution_type,const int nummodels,const int* analysis_type_listh);
Index: sm/trunk-jpl/src/c/shared/Exp/ExpWrite.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/ExpWrite.cpp	(revision 14952)
+++ 	(revision )
@@ -1,76 +1,0 @@
-/*!\file:  Exp.cpp
- * \brief Exp.cpp: write the vertex coordinates defined in a domain 
- * outline from Argus (.exp file). The first contour in the file is for 
- * the outside domain outline. 
- */
-#include <stdio.h>
-#include "../MemOps/MemOps.h"
-#include "../Exceptions/exceptions.h"
-#include "../../Container/DataSet.h"
-#include "../../classes/objects/Contour.h"
-
-int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname){/*{{{*/
-
-	/*I/O: */
-	FILE* fid=NULL;
-
-	/*open domain outline file for writing: */
-	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
-
-	/*Start writing profiles: */
-	for(int counter=0;counter<nprof;counter++){
-
-		/*Write header: */
-		fprintf(fid,"## Name:%s\n",domainname);
-		fprintf(fid,"## Icon:0\n");
-		fprintf(fid,"# Points Count	Value\n");
-		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
-		fprintf(fid,"# X pos	Y pos\n");
-
-		/*Write vertices: */
-		for(int i=0;i<profnvertices[counter];i++){
-			fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
-		}
-
-		/*Write blank line: */
-		if(counter<nprof-1) fprintf(fid,"\n");
-	}
-
-	/*close Exp file: */
-	fclose(fid);
-
-	return 1;
-}/*}}}*/
-int ExpWrite(DataSet* contours,char* domainname){/*{{{*/
-
-	/*I/O: */
-	FILE* fid=NULL;
-	Contour<double>* contour = NULL;
-
-	/*open domain outline file for writing: */
-	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
-
-	for(int counter=0;counter<contours->Size();counter++){
-		contour=(Contour<double>*)contours->GetObjectByOffset(counter);
-
-		/*Write header: */
-		fprintf(fid,"## Name:%s\n",domainname);
-		fprintf(fid,"## Icon:0\n");
-		fprintf(fid,"# Points Count	Value\n");
-		fprintf(fid,"%u %s\n",contour->nods  ,"1.");
-		fprintf(fid,"# X pos	Y pos\n");
-
-		/*Write vertices: */
-		for(int i=0;i<contour->nods;i++){
-			fprintf(fid,"%lf\t%lf\n",contour->x[i],contour->y[i]);
-		}
-
-		/*Write blank line: */
-		if(counter<contours->Size()-1) fprintf(fid,"\n");
-	}
-
-	/*close Exp file: */
-	fclose(fid);
-
-	return 1;
-}/*}}}*/
Index: sm/trunk-jpl/src/c/shared/Exp/IsInPoly.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/IsInPoly.cpp	(revision 14952)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*!\file IsInPoly.c
- * \brief:  from a contour, determine which nodes are in  domain.
- */
-
-#include <math.h>
-#include "./exp.h"
-#include "../shared.h"
-
-#ifdef HAVE_CONFIG_H
-	#include <config.h>
-#else
-#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
-#endif
-
-/*pnpoly{{{*/
-int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
-	int i, j, c = 0;
-	double n1, n2, normp, scalar;
-
-	/*first test, are they colinear? if yes, is the point in the middle of the segment*/
-	if (edgevalue != 2 ){
-		for (i = 0, j = npol-1; i < npol; j = i++) {
-			n1=pow(yp[i]-yp[j],2.0)+pow(xp[i]-xp[j],2.0);
-			n2=pow(y-yp[j],2.0)+pow(x-xp[j],2.0);
-			normp=pow(n1*n2,0.5);
-			scalar=(yp[i]-yp[j])*(y-yp[j])+(xp[i]-xp[j])*(x-xp[j]);
-
-			if (scalar == normp){
-				if (n2<=n1){
-					c = edgevalue;
-					return c;
-				}
-			}
-		}
-	}
-	/*second test : point is neither on a vertex, nor on a side, where is it ?*/
-	for (i = 0, j = npol-1; i < npol; j = i++) {
-		if ((((yp[i]<=y) && (y<yp[j])) ||
-					((yp[j]<=y) && (y<yp[i]))) &&
-				(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])){
-			c = !c;
-		}
-	}
-	return c;
-}/*}}}*/
Index: sm/trunk-jpl/src/c/shared/Exp/IsInPolySerial.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/IsInPolySerial.cpp	(revision 14952)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/*
- * IsInPolySerial.c:
- */
-
-#include <math.h>
-#include "./exp.h"
-
-int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue){
-
-	double x0,y0;
-
-	/*Go through all vertices of the mesh:*/
-	for(int i=0;i<nods;i++){
-		if (in[i]){
-			/*this vertex already is inside one of the contours, continue*/
-			continue;
-		}
-		/*pick up vertex: */
-		x0=x[i];
-		y0=y[i];
-		if (pnpoly(numvertices,xc,yc,x0,y0,edgevalue)){
-			in[i]=1.;
-		}
-		else{
-			in[i]=0.;
-		}
-	}
-
-	return 1;
-}
Index: /issm/trunk-jpl/src/c/shared/Exp/exp.cpp
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/exp.cpp	(revision 14953)
+++ /issm/trunk-jpl/src/c/shared/Exp/exp.cpp	(revision 14953)
@@ -0,0 +1,99 @@
+/*!\file:  Exp.cpp
+ * \brief Exp.cpp: write the vertex coordinates defined in a domain 
+ * outline from Argus (.exp file). The first contour in the file is for 
+ * the outside domain outline. 
+ */
+#include <stdio.h>
+#include <math.h>
+
+#include "../MemOps/MemOps.h"
+#include "../Exceptions/exceptions.h"
+#include "./exp.h"
+
+int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname){/*{{{*/
+
+	/*I/O: */
+	FILE* fid=NULL;
+
+	/*open domain outline file for writing: */
+	if((fid=fopen(domainname,"w"))==NULL) _error_("could not open domain file " << domainname); 
+
+	/*Start writing profiles: */
+	for(int counter=0;counter<nprof;counter++){
+
+		/*Write header: */
+		fprintf(fid,"## Name:%s\n",domainname);
+		fprintf(fid,"## Icon:0\n");
+		fprintf(fid,"# Points Count	Value\n");
+		fprintf(fid,"%u %s\n",profnvertices[counter]  ,"1.");
+		fprintf(fid,"# X pos	Y pos\n");
+
+		/*Write vertices: */
+		for(int i=0;i<profnvertices[counter];i++){
+			fprintf(fid,"%lf\t%lf\n",pprofx[counter][i],pprofy[counter][i]);
+		}
+
+		/*Write blank line: */
+		if(counter<nprof-1) fprintf(fid,"\n");
+	}
+
+	/*close Exp file: */
+	fclose(fid);
+
+	return 1;
+}/*}}}*/
+int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue){ /*{{{*/
+
+	double x0,y0;
+
+	/*Go through all vertices of the mesh:*/
+	for(int i=0;i<nods;i++){
+		if (in[i]){
+			/*this vertex already is inside one of the contours, continue*/
+			continue;
+		}
+		/*pick up vertex: */
+		x0=x[i];
+		y0=y[i];
+		if (pnpoly(numvertices,xc,yc,x0,y0,edgevalue)){
+			in[i]=1.;
+		}
+		else{
+			in[i]=0.;
+		}
+	}
+
+	return 1;
+}
+/*}}}*/
+/*pnpoly{{{*/
+int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
+	int i, j, c = 0;
+	double n1, n2, normp, scalar;
+
+	/*first test, are they colinear? if yes, is the point in the middle of the segment*/
+	if (edgevalue != 2 ){
+		for (i = 0, j = npol-1; i < npol; j = i++) {
+			n1=pow(yp[i]-yp[j],2.0)+pow(xp[i]-xp[j],2.0);
+			n2=pow(y-yp[j],2.0)+pow(x-xp[j],2.0);
+			normp=pow(n1*n2,0.5);
+			scalar=(yp[i]-yp[j])*(y-yp[j])+(xp[i]-xp[j])*(x-xp[j]);
+
+			if (scalar == normp){
+				if (n2<=n1){
+					c = edgevalue;
+					return c;
+				}
+			}
+		}
+	}
+	/*second test : point is neither on a vertex, nor on a side, where is it ?*/
+	for (i = 0, j = npol-1; i < npol; j = i++) {
+		if ((((yp[i]<=y) && (y<yp[j])) ||
+					((yp[j]<=y) && (y<yp[i]))) &&
+				(x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i])){
+			c = !c;
+		}
+	}
+	return c;
+}/*}}}*/
Index: /issm/trunk-jpl/src/c/shared/Exp/exp.h
===================================================================
--- /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 14952)
+++ /issm/trunk-jpl/src/c/shared/Exp/exp.h	(revision 14953)
@@ -7,17 +7,12 @@
 
 #include <cstring>
-#include "../../classes/objects/Contour.h"
-#include "../../shared/Numerics/recast.h"
-#include "../../Container/Container.h"
+#include "../Numerics/recast.h"
 #include "../../toolkits/toolkits.h"
 
 int IsInPolySerial(double* in,double* xc,double* yc,int numvertices,double* x,double* y,int nods, int edgevalue);
 int ExpWrite(int nprof,int* profnvertices,double** pprofx,double** pprofy,char* domainname);
-int ExpWrite(DataSet* contours,char* domainname);
 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
 
-/*IsInPoly {{{*/
-template <class doubletype>
-int IsInPoly(IssmSeqVec<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){
+template <class doubletype> int IsInPoly(IssmSeqVec<doubletype>* in,double* xc,double* yc,int numvertices,double* x,double* y,int i0,int i1, int edgevalue){ /*{{{*/
 
 	int i;
@@ -59,7 +54,5 @@
 	 return 1;
 }/*}}}*/
-/*int      ExpRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){{{*/
-template <class doubletype>
-int ExpRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){
+template <class doubletype> int ExpRead(int* pnprof,int** pprofnvertices,doubletype*** ppprofx,doubletype*** ppprofy,bool** pclosed,char* domainname){ /*{{{*/
 
 	/*indexing: */
@@ -178,33 +171,4 @@
 
 } /*}}}*/
-/*DataSet* ExpRead(char* domainname){{{*/
-template <class doubletype>
-DataSet* ExpRead(char* domainname){
-
-	/*intermediary: */
-	int                  nprof;
-	int                 *profnvertices = NULL;
-	doubletype         **pprofx        = NULL;
-	doubletype         **pprofy        = NULL;
-
-	/*output: */
-	DataSet *domain = NULL;
-
-	/*If domainname is an empty string, return empty dataset*/
-	if (strcmp(domainname,"")==0){
-		nprof=0;
-	}
-	else{
-		ExpRead(&nprof,&profnvertices,&pprofx, &pprofy, NULL,domainname);
-	}
-
-	/*now create dataset of contours: */
-	domain=new DataSet(0);
-
-	for(int i=0;i<nprof;i++){
-		domain->AddObject(new Contour<doubletype>(i,profnvertices[i],pprofx[i],pprofy[i],1));
-	}
-	return domain;
-} /*}}}*/
 
 #endif
