Index: /issm/trunk/src/c/Bamgx/Bamgx.cpp
===================================================================
--- /issm/trunk/src/c/Bamgx/Bamgx.cpp	(revision 2854)
+++ /issm/trunk/src/c/Bamgx/Bamgx.cpp	(revision 2855)
@@ -19,5 +19,4 @@
 #include <setjmp.h>
 #include <new>
-#include <cassert>
 #include <iomanip>
 #include <fstream>
Index: /issm/trunk/src/c/Bamgx/Mesh2.h
===================================================================
--- /issm/trunk/src/c/Bamgx/Mesh2.h	(revision 2854)
+++ /issm/trunk/src/c/Bamgx/Mesh2.h	(revision 2855)
@@ -1,33 +1,9 @@
-// -*- Mode : c++ -*-
-//
-// SUMMARY  :      
-// USAGE    :        
-// ORG      : 
-// AUTHOR   : Frederic Hecht
-// E-MAIL   : hecht@ann.jussieu.fr
-//
-
-/*
- 
- This file is part of Freefem++
- 
- Freefem++ is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
- 
- Freefem++  is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public License
- along with Freefem++; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
 #ifndef _MESH2_H_
 #define _MESH2_H_
 
 #include "../objects/objects.h"
+#include "../shared/shared.h"
+#include "../include/macros.h"
+#include "../toolkits/toolkits.h"
 
 //From MeshIo
@@ -38,10 +14,9 @@
 #include <cstdlib>
 #include <cctype>
-using namespace std;
-
 #include <stdlib.h>
 #include <math.h>
 #include <limits.h>
 #include <time.h>
+
 #if  (defined(unix) || defined(__unix)) && !defined(__AIX)
 #define SYSTIMES
@@ -53,4 +28,5 @@
 #include "R2.h"
 
+using namespace std;
 namespace bamg {
 
@@ -262,10 +238,14 @@
   //                                on the curve edge a t in [0:1]
   Edge * adj[2]; // the 2 adj edges if on the same curve 
+
   int Intersection(const  Edge & e) const { 
-    if (!(adj[0]==&e || adj[1]==&e)) 
-      std::cerr << "Bug : Intersection " << (void*) &e <<  "  " 
-	   << adj[0] << " " <<  adj[1] << std::endl;
-    assert(adj[0]==&e || adj[1]==&e);
-    return adj[0]==&e ? 0 : 1;}
+    if (!(adj[0]==&e || adj[1]==&e)){
+		 throw ErrorException(__FUNCT__,exprintf("Intersection bug"));
+	 }
+	 if (adj[0]!=&e && adj[1]!=&e){
+		 throw ErrorException(__FUNCT__,exprintf("adj[0]!=&e && adj[1]!=&e"));
+	 }
+    return adj[0]==&e ? 0 : 1;
+  }
   Real8 MetricLength() const ;  
   inline void Set(const Triangles &,Int4,Triangles &);
@@ -285,5 +265,12 @@
   void  Set(){cas=0;}
   GeometricalVertex() :cas(0), link(this) {};
-  GeometricalVertex * The() { assert(link); return link;}// return a unique vertices
+
+  GeometricalVertex * The() {
+	  if (!link){
+		  throw ErrorException(__FUNCT__,exprintf("!link"));
+	  }
+	  return link;
+  }// return a unique vertices
+
   int IsThe() const { return link == this;}  
   
@@ -496,5 +483,7 @@
   R2 F(Real8 s){ 
     Real8 c01=lEnd-lBegin, c0=(lEnd-s)/c01, c1=(s-lBegin)/c01;
-    assert(lBegin<= s && s <=lEnd);
+	 if (lBegin>s || s>lEnd){
+		 throw ErrorException(__FUNCT__,exprintf("lBegin>s || s>lEnd"));
+	 }
     return e->F(sBegin*c0+sEnd*c1);}
 };
@@ -534,9 +523,11 @@
            int mneo= MaxNbSeg;
            MaxNbSeg *= 2;
-          if (verbosity>3) 
-	    std::cout <<" reshape lSegsI from " << mneo << " to " 
-		 << MaxNbSeg <<std::endl;
+          if (verbosity>3){
+				 printf("   reshape lSegsI from %i to %i\n",mneo,MaxNbSeg);
+			 }
            SegInterpolation * lEn =  new SegInterpolation[MaxNbSeg];
-           assert(lSegsI && NbSeg < MaxNbSeg);
+			  if (!lSegsI || NbSeg>=MaxNbSeg){
+				  throw ErrorException(__FUNCT__,exprintf("!lSegsI || NbSeg>=MaxNbSeg"));
+			  }
            for (int i=0;i< NbSeg;i++) 
               lEn[i] = lSegsI[MaxNbSeg]; // copy old to new            
@@ -557,6 +548,8 @@
   void ReShape() { 
     register int newsize = MaxSize*2;
-    IntersectionTriangles * nw = new IntersectionTriangles[newsize];
-    assert(nw);
+    IntersectionTriangles* nw = new IntersectionTriangles[newsize];
+	 if (!nw){
+		 throw ErrorException(__FUNCT__,exprintf("!nw"));
+	 }
     for (int i=0;i<MaxSize;i++) // recopy
       nw[i] = lIntTria[i];       
@@ -672,5 +665,7 @@
     int i0=VerticesOfTriangularEdge[i][0];
     int i1=VerticesOfTriangularEdge[i][0];
-    assert(New[0] && New[1]);
+	 if (!New[0] && !New[1]){
+		 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]"));
+	 }
     T(i0) = New[0];
     T(i1) = New[1];}    
@@ -679,5 +674,7 @@
     int i0=VerticesOfTriangularEdge[i][0];
     int i1=VerticesOfTriangularEdge[i][0];
-    assert(New[0] && New[1]);
+	 if (!New[0] && !New[1]){
+		 throw ErrorException(__FUNCT__,exprintf("!New[0] && !New[1]"));
+	 }
     T(i0) = TheVertex(T(i0));
     T(i1) = TheVertex(T(i1));} 
@@ -1068,7 +1065,11 @@
 {
   *this = Th.subdomains[i];
-  assert( head - Th.triangles >=0 && head - Th.triangles < Th.nbt);
+  if ( head-Th.triangles<0 || head-Th.triangles>=Th.nbt){
+	  throw ErrorException(__FUNCT__,exprintf("head-Th.triangles<0 || head-Th.triangles>=Th.nbt"));
+  }
   head = ThNew.triangles + Th.Number(head) ; 
-  assert(edge - Th.edges >=0 && edge - Th.edges < Th.nbe); 
+  if (edge-Th.edges<0 || edge-Th.edges>=Th.nbe);{
+	  throw ErrorException(__FUNCT__,exprintf("edge-Th.edges<0 || edge-Th.edges>=Th.nbe"));
+  }
   edge = ThNew.edges+ Th.Number(edge);
 }
@@ -1208,6 +1209,10 @@
   Vertex *v=Th->vertices;
   Int4 nbv = Th->nbv;
-  assert(i >=0 && j >=0 && k >=0);
-  assert(i < nbv && j < nbv && k < nbv);
+  if (i<0 || j<0 || k<0){
+	  throw ErrorException(__FUNCT__,exprintf("i<0 || j<0 || k<0"));
+  }
+  if (i>=nbv || j>=nbv || k>=nbv){
+	  throw ErrorException(__FUNCT__,exprintf("i>=nbv || j>=nbv || k>=nbv"));
+  }
   ns[0]=v+i;
   ns[1]=v+j;
@@ -1282,9 +1287,16 @@
     int i = a->vint;
     TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge
-    assert(t && i>=0 && i < 3);
-    assert( a == (*t)(i));
+	 if (!t || i<0 || i>=3){
+		 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3"));
+	 }
+	 if ( a!=(*t)(i)){
+		 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)"));
+	 }
     int k=0;
     do { // turn around vertex in direct sens (trigo)
-      k++;assert(k< 20000);
+      k++;
+		if (k>=20000){
+			throw ErrorException(__FUNCT__,exprintf("k>=20000"));
+		}
       //  in no crack => ta.EdgeVertex(1) == a otherwise ??? 
       if (ta.EdgeVertex(1) ==  a && ta.EdgeVertex(0) ==  b) return ta; // find 
@@ -1293,6 +1305,6 @@
       --ta;
       } while (t != (Triangle *)ta);
-    assert(0);
-    return TriangleAdjacent(0,0);// error 
+	 throw ErrorException(__FUNCT__,exprintf("FindTriangleAdjacent: triangle not found"));
+    return TriangleAdjacent(0,0);//for compiler
   }
   
@@ -1303,9 +1315,16 @@
     int i = a->vint;
     TriangleAdjacent ta(t,EdgesVertexTriangle[i][0]); // Previous edge
-    assert(t && i>=0 && i < 3);
-    assert( a == (*t)(i));
+	 if (!t || i<0 || i>=3){
+		 throw ErrorException(__FUNCT__,exprintf("!t || i<0 !! i>=3"));
+	 }
+	 if ( a!=(*t)(i)){
+		 throw ErrorException(__FUNCT__,exprintf("a!=(*t)(i)"));
+	 }
     int k=0;
     do { // turn around vertex in direct sens (trigo)
-      k++;assert(k< 20000);
+      k++;
+		if (k>=20000){
+			throw ErrorException(__FUNCT__,exprintf("k>=20000"));
+		}
       //  in no crack => ta.EdgeVertex(1) == a
       if ((rr=ta.EdgeVertex(0)) < r) r = rr;
Index: sm/trunk/src/c/Bamgx/throwassert.hpp
===================================================================
--- /issm/trunk/src/c/Bamgx/throwassert.hpp	(revision 2854)
+++ 	(revision )
@@ -1,50 +1,0 @@
-// -*- Mode : c++ -*-
-//
-// SUMMARY  :      
-// USAGE    :        
-// ORG      : 
-// AUTHOR   : Frederic Hecht
-// E-MAIL   : hecht@ann.jussieu.fr
-//
-
-/*
- 
- This file is part of Freefem++
- 
- Freefem++ is free software; you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
- 
- Freefem++  is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU Lesser General Public License for more details.
- 
- You should have received a copy of the GNU Lesser General Public License
- along with Freefem++; if not, write to the Free Software
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- */
-#ifndef THROWASSERT
-#define THROWASSERT
-#include <iostream>
-
-//#ifdef __INTEL__
-#define cerr cout 
-//#endif
-
-#ifdef NDEBUG
-#define throwassert(i)  ( (void) 0)
-#else
-#define throwassert(condition)  ((condition) ? ( (void) 0) : throw(ErrorAssert(#condition,__FILE__, __LINE__)))
- 
-#undef assert
-#define assert(condition) throwassert(condition)
-#endif
-// an unremovable assert : ffassert
-#define ffassert(condition)  ((condition) ? ( (void) 0) : throw(ErrorAssert(#condition,__FILE__, __LINE__)))
-//#define AFAIRE(str) ( (cerr << " TO be Done " << str << endl), throw(ErrorAssert("AFAIRE)/TO DO  (FH????",__FILE__, __LINE__))) 
-#define AFAIRE(cmm) ( cerr << "FH: A Faire/ To Do  "<< cmm << " file " << __FILE__<< " line "<< __LINE__ << endl, InternalError(cmm))
-
-#define InternalError(message) throw(ErrorInternal(message,__LINE__,__FILE__))
-#endif
