diff --git a/Common/Makefile b/Common/Makefile
index fffa860306b6fe8ab755f09daf9ea5f1d4014c5c..5cf1de051a034c286a5e6d11c94b4e224e1fdc18 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.116 2006-11-16 18:48:00 geuzaine Exp $
+# $Id: Makefile,v 1.117 2006-11-25 02:47:39 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -99,12 +99,8 @@ Options.o: Options.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Options.h \
   ../Common/Message.h ../Fltk/Solvers.h ../Fltk/GUI.h \
   ../Fltk/Opengl_Window.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  ../Fltk/Colorbar_Window.h ../Common/GmshUI.h ../Fltk/Popup_Button.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h ../Fltk/Colorbar_Window.h \
+  ../Common/GmshUI.h ../Fltk/Popup_Button.h \
   ../Fltk/SpherePosition_Widget.h
 CommandLine.o: CommandLine.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
@@ -115,16 +111,17 @@ CommandLine.o: CommandLine.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
   ../Parser/CreateFile.h ../Parser/Parser.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Context.h \
-  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
-  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
-  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h OS.h
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Context.h ../Geo/ExtrudeParams.h ../Geo/GFace.h \
+  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
+  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
+  ../Common/SmoothNormals.h OS.h
 OS.o: OS.cpp Message.h
 ColorTable.o: ColorTable.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
@@ -133,19 +130,19 @@ ColorTable.o: ColorTable.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
 Visibility.o: Visibility.cpp Visibility.h GmshDefines.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h \
-  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h ../Parser/Parser.h \
-  ../DataStr/Tree.h ../DataStr/avl.h
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
+  ../Geo/GRegion.h ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h \
+  ../Parser/Parser.h ../DataStr/Tree.h ../DataStr/avl.h
 Trackball.o: Trackball.cpp Trackball.h
 VertexArray.o: VertexArray.cpp VertexArray.h Context.h ../DataStr/List.h \
   ../Numeric/Numeric.h
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 201af35438eb798669dabff544a7a7f741b93acd..50a4be6ef1db56c79aef4324231d0d187247137b 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.475 2006-11-21 08:01:05 guzik Exp $
+// $Id: Callbacks.cpp,v 1.476 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -3809,7 +3809,8 @@ void mesh_optimize_cb(CALLBACK_ARGS)
     return;
   }
   CTX.threads_lock = 1;
-  Optimize_Netgen();
+  Msg(GERROR, "Mesh optimize has yet to be reinterfaced");
+  //Optimize_Netgen();
   CTX.threads_lock = 0;
   CTX.mesh.changed = ENT_LINE | ENT_SURFACE | ENT_VOLUME;
   Draw();
diff --git a/Fltk/Makefile b/Fltk/Makefile
index 533a1b5ee9b4276a8e06ad84036e4533cf108050..c23e757dca3ee9e4e4057f1eb27d0eb3084b9a15 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.111 2006-11-16 18:48:00 geuzaine Exp $
+# $Id: Makefile,v 1.112 2006-11-25 02:47:39 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -65,11 +65,7 @@ depend:
 # DO NOT DELETE THIS LINE
 Main.o: Main.cpp GUI.h Opengl_Window.h ../Mesh/Mesh.h \
   ../Common/GmshDefines.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Face.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
   Colorbar_Window.h ../Common/GmshUI.h ../Common/ColorTable.h \
   Popup_Button.h SpherePosition_Widget.h ../Common/Gmsh.h \
   ../Common/Message.h ../DataStr/Malloc.h ../DataStr/Tools.h \
@@ -82,27 +78,22 @@ Main.o: Main.cpp GUI.h Opengl_Window.h ../Mesh/Mesh.h \
   ../Plugin/Plugin.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
-  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
-  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
-  ../Geo/SBoundingBox3d.h
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h \
+  ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h \
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/MElement.h \
+  ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h
 Message.o: Message.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Common/GmshUI.h ../Common/Context.h ../Common/Options.h GUI.h \
   Opengl_Window.h ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
-  ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
-  GUI_Extras.h ../Common/OS.h
+  ../Geo/ExtrudeParams.h Colorbar_Window.h ../Common/ColorTable.h \
+  Popup_Button.h SpherePosition_Widget.h GUI_Extras.h ../Common/OS.h
 GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
   ../DataStr/List.h ../DataStr/Tree.h ../Common/GmshUI.h \
@@ -111,52 +102,39 @@ GUI.o: GUI.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../Common/VertexArray.h ../Common/SmoothNormals.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h GUI.h Opengl_Window.h \
   ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
-  Popup_Button.h SpherePosition_Widget.h Callbacks.h Bitmaps.h \
-  Win32Icon.h ../Parser/OpenFile.h ../Common/CommandLine.h Solvers.h \
+  ../Geo/ExtrudeParams.h Colorbar_Window.h Popup_Button.h \
+  SpherePosition_Widget.h Callbacks.h Bitmaps.h Win32Icon.h \
+  ../Parser/OpenFile.h ../Common/CommandLine.h Solvers.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h Shortcut_Window.h
 GUI_Extras.o: GUI_Extras.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Common/GmshUI.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h File_Picker.h \
-  Shortcut_Window.h ../Parser/CreateFile.h ../Common/Options.h \
-  ../Common/Context.h ../Graphics/Draw.h ../Common/Views.h \
-  ../Common/ColorTable.h ../Common/VertexArray.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h File_Picker.h Shortcut_Window.h \
+  ../Parser/CreateFile.h ../Common/Options.h ../Common/Context.h \
+  ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \
+  ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h
 Callbacks.o: Callbacks.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Common/GmshUI.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h ../Geo/ExtractContour.h \
-  ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \
-  ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \
+  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
+  ../Geo/ExtrudeParams.h ../Geo/ExtractContour.h ../Graphics/Draw.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h \
   ../Graphics/SelectBuffer.h ../Geo/GVertex.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
-  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Common/Context.h ../Geo/ExtrudeParams.h ../Geo/GFace.h \
-  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
-  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
+  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Common/Context.h ../Geo/ExtrudeParams.h \
+  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Parser/CreateFile.h \
   ../Parser/OpenFile.h ../Common/CommandLine.h ../Common/Options.h GUI.h \
   Opengl_Window.h Colorbar_Window.h Popup_Button.h \
@@ -175,20 +153,16 @@ Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Common/GmshMatrix.h ../Graphics/SelectBuffer.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
   ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
   ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h GUI.h \
-  Opengl_Window.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
+  Opengl_Window.h ../Mesh/Mesh.h ../Mesh/Vertex.h Colorbar_Window.h \
   Popup_Button.h SpherePosition_Widget.h ../Graphics/gl2ps.h
 Opengl_Window.o: Opengl_Window.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
@@ -200,44 +174,31 @@ Opengl_Window.o: Opengl_Window.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Common/GmshMatrix.h ../Graphics/SelectBuffer.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
   ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
   ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h GUI.h \
-  Opengl_Window.h ../Mesh/Mesh.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
+  Opengl_Window.h ../Mesh/Mesh.h ../Mesh/Vertex.h Colorbar_Window.h \
   Popup_Button.h SpherePosition_Widget.h
 Colorbar_Window.o: Colorbar_Window.cpp ../Common/Gmsh.h \
   ../Common/Message.h ../DataStr/Malloc.h ../DataStr/List.h \
   ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h \
   ../DataStr/Tree.h ../Common/GmshUI.h GUI.h Opengl_Window.h \
   ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
-  ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
-  ../Common/Context.h
+  ../Geo/ExtrudeParams.h Colorbar_Window.h ../Common/ColorTable.h \
+  Popup_Button.h SpherePosition_Widget.h ../Common/Context.h
 Solvers.o: Solvers.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   Solvers.h GmshServer.h ../Parser/OpenFile.h ../Common/GmshUI.h GUI.h \
   Opengl_Window.h ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h Colorbar_Window.h \
-  ../Common/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
-  ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \
-  ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \
+  ../Geo/ExtrudeParams.h Colorbar_Window.h ../Common/ColorTable.h \
+  Popup_Button.h SpherePosition_Widget.h ../Graphics/Draw.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h
diff --git a/Geo/CAD.cpp b/Geo/CAD.cpp
index f098f01331fca035c4c88ff5085368e6f928e4ee..e82d0e2ca3106dc08c2dea13cb1c8d874ab58d0f 100644
--- a/Geo/CAD.cpp
+++ b/Geo/CAD.cpp
@@ -1,4 +1,4 @@
-// $Id: CAD.cpp,v 1.100 2006-11-25 00:44:25 geuzaine Exp $
+// $Id: CAD.cpp,v 1.101 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -26,7 +26,6 @@
 #include "Interpolation.h"
 #include "Create.h"
 #include "CAD.h"
-#include "Edge.h"
 #include "Context.h"
 
 extern Mesh *THEM;
@@ -2161,27 +2160,6 @@ double min1d(double (*funct) (double), double *xmin)
   return (brent(ax, bx, cx, funct, tol, xmin));
 }
 
-static void intersectCS(int N, double x[], double res[])
-{
-  //x[1] = u x[2] = v x[3] = w
-  Vertex s, c;
-  s = InterpolateSurface(SURFACE, x[1], x[2], 0, 0);
-  c = InterpolateCurve(CURVE, x[3], 0);
-  res[1] = s.Pos.X - c.Pos.X;
-  res[2] = s.Pos.Y - c.Pos.Y;
-  res[3] = s.Pos.Z - c.Pos.Z;
-}
-
-static void intersectCC(int N, double x[], double res[])
-{
-  //x[1] = u x[2] = v
-  Vertex c2, c;
-  c2 = InterpolateCurve(CURVE_2, x[2], 0);
-  c = InterpolateCurve(CURVE, x[1], 0);
-  res[1] = c2.Pos.X - c.Pos.X;
-  res[2] = c2.Pos.Y - c.Pos.Y;
-}
-
 static void projectPS(int N, double x[], double res[])
 {
   //x[1] = u x[2] = v
@@ -2449,127 +2427,3 @@ bool ProjectPointOnSurface(Surface * s, Vertex * p, double *u, double *v)
   return true;
 }
 
-// Intersection of curves/surfaces (FIXME: this code is full of crap)
-
-// S = (sx(u,v),sy(u,v),sz(u,v))  C = (cx(w),cy(w),cz(w))
-// sx - cx = 0
-// sy - cy = 0
-// sz - cz = 0
-// 3eqs 3unk
-
-bool IntersectCurveSurface(Curve * c, Surface * s)
-{
-  double x[4];
-  int check;
-  SURFACE = s;
-  CURVE = c;
-  newt(x, 3, &check, intersectCS);
-  if(!check)
-    return false;
-  return true;
-}
-
-void DivideCurve(Curve * c, double u, Vertex * v, Curve ** c1, Curve ** c2)
-{
-  (*c1) = Create_Curve(NEWLINE(), c->Typ, 1, NULL, NULL, -1, -1, 0., 1.);
-  (*c2) = Create_Curve(NEWLINE(), c->Typ, 1, NULL, NULL, -1, -1, 0., 1.);
-  CopyCurve(c, *c1);
-  CopyCurve(c, *c2);
-  (*c1)->uend = u;
-  (*c2)->ubeg = u;
-  (*c1)->end = v;
-  (*c2)->beg = v;
-}
-
-bool IntersectCurves(Curve * c1, Curve * c2,
-                     Curve ** c11, Curve ** c12,
-                     Curve ** c21, Curve ** c22, Vertex ** v)
-{
-  double x[3];
-  Vertex v1, v2;
-  int check;
-
-  if(!compareVertex(&c1->beg, &c2->beg))
-    return false;
-  if(!compareVertex(&c1->end, &c2->end))
-    return false;
-  if(!compareVertex(&c1->beg, &c2->end))
-    return false;
-  if(!compareVertex(&c2->beg, &c1->end))
-    return false;
-
-  CURVE_2 = c2;
-  CURVE = c1;
-  x[1] = x[2] = 0.0;
-  newt(x, 2, &check, intersectCC);
-  if(check)
-    return false;
-  v1 = InterpolateCurve(c1, x[1], 0);
-  v2 = InterpolateCurve(c2, x[2], 0);
-  //  Msg(INFO, "success : %lf %lf,%lf,%lf\n",v1.Pos.X,v1.Pos.Y,x[1],x[2]);
-  if(x[1] <= c1->ubeg)
-    return false;
-  if(x[1] >= c1->uend)
-    return false;
-  if(x[2] <= c2->ubeg)
-    return false;
-  if(x[2] >= c2->uend)
-    return false;
-  if(fabs(v1.Pos.Z - v2.Pos.Z) > 1.e-08 * CTX.lc)
-    return false;
-  *v = Create_Vertex(NEWPOINT(), v1.Pos.X, v1.Pos.Y, v1.Pos.Z, v1.lc, x[1]);
-  Tree_Insert(THEM->Points, v);
-  DivideCurve(c1, x[1], *v, c11, c12);
-  DivideCurve(c2, x[2], *v, c21, c22);
-  return true;
-}
-
-bool IntersectAllSegmentsTogether(void)
-{
-  bool intersectionfound = true;
-  List_T *TempList;
-  Curve *c1, *c2, *c11, *c12, *c21, *c22;
-  Vertex *v;
-  int i, j;
-
-  while(intersectionfound) {
-    TempList = Tree2List(THEM->Curves);
-    if(!List_Nbr(TempList))
-      return true;
-    for(i = 0; i < List_Nbr(TempList); i++) {
-      List_Read(TempList, i, &c1);
-      intersectionfound = false;
-      for(j = 0; j < List_Nbr(TempList); j++) {
-        List_Read(TempList, j, &c2);
-        if(c1->Num > 0 && c2->Num > 0 && i != j && intersectionfound == false) {
-          if(IntersectCurves(c1, c2, &c11, &c12, &c21, &c22, &v)) {
-            Msg(INFO, "Intersection Curve %d->%d", c1->Num, c2->Num);
-            intersectionfound = true;
-            DeleteCurve(c1->Num);
-            DeleteCurve(c2->Num);
-            Tree_Add(THEM->Curves, &c11);
-            Tree_Add(THEM->Curves, &c12);
-            Tree_Add(THEM->Curves, &c21);
-            Tree_Add(THEM->Curves, &c22);
-
-            CreateReversedCurve(c11);
-            CreateReversedCurve(c12);
-            CreateReversedCurve(c21);
-            CreateReversedCurve(c22);
-            return true;
-          }
-        }
-      }
-      if(intersectionfound)
-        break;
-    }
-    List_Delete(TempList);
-  }
-  return false;
-
-}
-
-void IntersectSurfaces(Surface * s1, Surface * s2)
-{
-  ;
-}
diff --git a/Geo/CAD.h b/Geo/CAD.h
index c2543a3e5ddc42ad007e60ccb77f0cb77f213af6..73ed40a7267a695631ae5e32bb5daf044e31f24d 100644
--- a/Geo/CAD.h
+++ b/Geo/CAD.h
@@ -80,7 +80,6 @@ void ReplaceAllDuplicates();
 bool ProjectPointOnCurve(Curve *c, Vertex *v, Vertex *RES, Vertex *DER);
 bool ProjectPointOnSurface(Surface *s, Vertex &p);
 bool ProjectPointOnSurface(Surface *s, Vertex *p,double *u, double *v);
-bool IntersectAllSegmentsTogether(void);
 
 int recognize_seg(int typ, List_T *liste, int *seg);
 int recognize_loop(List_T *liste, int *loop);
diff --git a/Geo/MElement.cpp b/Geo/MElement.cpp
index 435c77e6557df56a0aed6b7900427d2167546f92..d1d436d4cd92ca8538180c91da7a6bdc65b3ca4d 100644
--- a/Geo/MElement.cpp
+++ b/Geo/MElement.cpp
@@ -1,4 +1,4 @@
-// $Id: MElement.cpp,v 1.22 2006-11-04 00:17:08 geuzaine Exp $
+// $Id: MElement.cpp,v 1.23 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -24,6 +24,98 @@
 #include "GEntity.h"
 #include "Numeric.h"
 
+int edges_tetra[6][2] = {
+  {0, 1},
+  {1, 2},
+  {2, 0},
+  {3, 0},
+  {3, 2},
+  {3, 1}
+};
+
+int edges_quad[4][2] = {
+  {0, 1},
+  {1, 2},
+  {2, 3},
+  {3, 0}
+};
+
+int edges_hexa[12][2] = {
+  {0, 1},
+  {0, 3},
+  {0, 4},
+  {1, 2},
+  {1, 5},
+  {2, 3},
+  {2, 6},
+  {3, 7},
+  {4, 5},
+  {4, 7},
+  {5, 6},
+  {6, 7}
+};
+
+int edges_prism[9][2] = {
+  {0, 1},
+  {0, 2},
+  {0, 3},
+  {1, 2},
+  {1, 4},
+  {2, 5},
+  {3, 4},
+  {3, 5},
+  {4, 5}
+};
+
+int edges_pyramid[8][2] = {
+  {0, 1},
+  {0, 3},
+  {0, 4},
+  {1, 2},
+  {1, 4},
+  {2, 3},
+  {2, 4},
+  {3, 4}
+};
+
+int trifaces_tetra[4][3] = {
+  {0, 2, 1},
+  {0, 1, 3},
+  {0, 3, 2},
+  {3, 1, 2}
+};
+
+int trifaces_prism[2][3] = {
+  {0, 2, 1},
+  {3, 4, 5}
+};
+
+int trifaces_pyramid[4][3] = {
+  {0, 1, 4},
+  {3, 0, 4},
+  {1, 2, 4},
+  {2, 3, 4}
+};
+
+int quadfaces_hexa[6][4] = {
+  {0, 3, 2, 1},
+  {0, 1, 5, 4},
+  {0, 4, 7, 3},
+  {1, 2, 6, 5},
+  {2, 3, 7, 6},
+  {4, 5, 6, 7}
+};
+
+int quadfaces_prism[3][4] = {
+  {0, 1, 4, 3},
+  {0, 3, 5, 2},
+  {1, 2, 5, 4}
+};
+
+int quadfaces_pyramid[1][4] = {
+  {0, 3, 2, 1}
+};
+
 int MElement::_globalNum = 0;
 
 double MElement::minEdge()
diff --git a/Geo/MElement.h b/Geo/MElement.h
index bf96e7174ad880350ead1d12b061c5df072f3b40..54e33f287d94c341ac94c8094a42a20977fcf946 100644
--- a/Geo/MElement.h
+++ b/Geo/MElement.h
@@ -28,7 +28,6 @@
 #include "MFace.h"
 #include "Numeric.h"
 
-// the reference topology is defined in Mesh/{Edge,Face}.cpp
 extern int edges_tetra[6][2];
 extern int edges_quad[4][2];
 extern int edges_hexa[12][2];
diff --git a/Geo/Makefile b/Geo/Makefile
index 37d31cd6b58c8ae2df6b2d3abc53642052ebbce5..dd5074085e94a5d74670049f92664459b155b7e6 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.113 2006-11-21 07:51:47 guzik Exp $
+# $Id: Makefile,v 1.114 2006-11-25 02:47:39 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -82,41 +82,29 @@ depend:
 CAD.o: CAD.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
   ../DataStr/List.h ../DataStr/Tree.h ../Numeric/Numeric.h Geo.h \
-  ../DataStr/List.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  ../Mesh/Interpolation.h ../Mesh/Create.h CAD.h ../Mesh/Vertex.h \
-  ExtrudeParams.h ../Mesh/Edge.h ../Common/Context.h
+  ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h ../Mesh/Interpolation.h ../Mesh/Vertex.h \
+  ../Mesh/Mesh.h ../Mesh/Create.h ../Mesh/Vertex.h ../Mesh/Mesh.h CAD.h \
+  ExtrudeParams.h ../Common/Context.h
 ExtrudeParams.o: ExtrudeParams.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Geo.h ../DataStr/List.h CAD.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Mesh/Vertex.h \
-  ExtrudeParams.h
+  Geo.h CAD.h ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h ExtrudeParams.h
 Geo.o: Geo.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Numeric/Numeric.h Geo.h \
-  ../DataStr/List.h CAD.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Mesh/Vertex.h \
-  ExtrudeParams.h ../Parser/Parser.h ../DataStr/List.h ../DataStr/Tree.h \
+  ../DataStr/List.h ../DataStr/Tree.h ../Numeric/Numeric.h Geo.h CAD.h \
+  ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h ExtrudeParams.h ../Parser/Parser.h \
   ../Common/Context.h GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
-  SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
-  GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h GFace.h \
-  GEdgeLoop.h Pair.h GRegion.h ../Common/SmoothNormals.h \
-  ../Numeric/Numeric.h
+  SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
+  MElement.h MEdge.h ../Common/Hash.h MFace.h GFace.h GEdgeLoop.h Pair.h \
+  GRegion.h ../Common/SmoothNormals.h
 GeoUtils.o: GeoUtils.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Geo.h ../DataStr/List.h CAD.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Mesh/Vertex.h \
-  ExtrudeParams.h ../Numeric/Numeric.h
+  Geo.h CAD.h ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h ExtrudeParams.h ../Numeric/Numeric.h
 GEntity.o: GEntity.cpp GEntity.h Range.h SPoint3.h SBoundingBox3d.h \
   ../Common/GmshDefines.h MRep.h GEdge.h GVertex.h MVertex.h GPoint.h \
   SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
@@ -133,7 +121,7 @@ GEdge.o: GEdge.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h
+  ../Common/SmoothNormals.h
 GEdgeLoop.o: GEdgeLoop.cpp GEdgeLoop.h GEdge.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h \
   GPoint.h SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
@@ -144,17 +132,15 @@ GFace.o: GFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h ../Common/Message.h \
-  ../Mesh/Utils.h ../DataStr/List.h ../Mesh/Vertex.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../DataStr/Tree.h ../DataStr/avl.h \
-  ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Matrix.h
+  ../Common/SmoothNormals.h ../Common/Message.h ../Mesh/Utils.h \
+  ../Mesh/Vertex.h ../Mesh/Mesh.h ../DataStr/Tree.h ../DataStr/avl.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h
 GRegion.o: GRegion.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h
+  ../Common/SmoothNormals.h
 MVertex.o: MVertex.cpp MVertex.h SPoint3.h
 MElement.o: MElement.cpp MElement.h ../Common/GmshDefines.h MVertex.h \
   SPoint3.h MEdge.h SVector3.h ../Common/Hash.h MFace.h \
@@ -165,29 +151,23 @@ GModel.o: GModel.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h MRep.h \
-  ../Common/VertexArray.h ../Common/Message.h ../Common/OS.h
+  ../Common/SmoothNormals.h MRep.h ../Common/VertexArray.h \
+  ../Common/Message.h ../Common/OS.h
 GModelIO_Mesh.o: GModelIO_Mesh.cpp ../Common/Message.h \
   ../Common/GmshDefines.h GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h MVertex.h GPoint.h SPoint2.h GEdge.h SVector3.h \
   MElement.h MEdge.h ../Common/Hash.h MFace.h ../Numeric/Numeric.h \
   ../Common/Context.h ../DataStr/List.h ExtrudeParams.h GFace.h \
-  GEdgeLoop.h Pair.h GRegion.h ../Common/SmoothNormals.h \
-  ../Numeric/Numeric.h gmshRegion.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h \
-  ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \
-  ../Mesh/Mesh.h ../Mesh/Matrix.h gmshFace.h gmshVertex.h gmshEdge.h
+  GEdgeLoop.h Pair.h GRegion.h ../Common/SmoothNormals.h gmshRegion.h \
+  ../Mesh/Mesh.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h gmshFace.h gmshVertex.h gmshEdge.h
 GModelIO_Geo.o: GModelIO_Geo.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h \
   SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
   MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h \
-  ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h \
-  ../Mesh/Mesh.h ../Mesh/Matrix.h Geo.h ../DataStr/List.h \
+  ../Common/SmoothNormals.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h Geo.h \
   ../Parser/OpenFile.h ../DataStr/Tools.h ../DataStr/List.h \
   ../DataStr/Tree.h ../Common/Message.h gmshVertex.h gmshFace.h \
   gmshEdge.h gmshRegion.h
@@ -196,104 +176,83 @@ GModelIO_Fourier.o: GModelIO_Fourier.cpp GModel.h GVertex.h GEntity.h \
   GPoint.h SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h \
   ../Common/Hash.h MFace.h ../Numeric/Numeric.h ../Common/Context.h \
   ../DataStr/List.h ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h fourierFace.h \
-  ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \
-  ../Common/VertexArray.h ../Common/SmoothNormals.h \
-  ../Common/AdaptiveViews.h ../Common/GmshMatrix.h
+  ../Common/SmoothNormals.h fourierFace.h ../Common/Message.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
+  ../Common/GmshMatrix.h
 GModelIO_OCC.o: GModelIO_OCC.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h \
   SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
   MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h ../Common/Message.h \
-  OCCIncludes.h OCCVertex.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  OCCEdge.h OCCFace.h OCCRegion.h
+  ../Common/SmoothNormals.h ../Common/Message.h OCCIncludes.h OCCVertex.h \
+  ../Mesh/Mesh.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h OCCEdge.h OCCFace.h OCCRegion.h
 GModelIO_CGNS.o: GModelIO_CGNS.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h \
   SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
   MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h ../Common/Message.h \
-  MNeighbour.h
+  ../Common/SmoothNormals.h ../Common/Message.h MNeighbour.h
 gmshEdge.o: gmshEdge.cpp gmshEdge.h GEdge.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h GVertex.h MVertex.h GPoint.h \
   SPoint2.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
-  ExtrudeParams.h gmshVertex.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  ../Mesh/Interpolation.h CAD.h ../DataStr/List.h ../Mesh/Vertex.h Geo.h \
-  ../Mesh/Create.h
+  ExtrudeParams.h gmshVertex.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
+  ../Mesh/Interpolation.h ../Mesh/Vertex.h ../Mesh/Mesh.h CAD.h Geo.h \
+  ../Mesh/Create.h ../Mesh/Vertex.h ../Mesh/Mesh.h
 gmshFace.o: gmshFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h gmshVertex.h \
-  ../Mesh/Mesh.h ../Common/GmshDefines.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h gmshEdge.h gmshFace.h \
-  ../Mesh/Interpolation.h CAD.h ../DataStr/List.h ../Mesh/Vertex.h Geo.h \
-  ../Mesh/Create.h ../Mesh/Utils.h ../Common/Message.h
+  ../Common/SmoothNormals.h gmshVertex.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h gmshEdge.h \
+  gmshFace.h ../Mesh/Interpolation.h ../Mesh/Vertex.h ../Mesh/Mesh.h \
+  CAD.h Geo.h ../Mesh/Create.h ../Mesh/Vertex.h ../Mesh/Mesh.h \
+  ../Mesh/Utils.h ../Mesh/Vertex.h ../Mesh/Mesh.h ../Common/Message.h
 gmshRegion.o: gmshRegion.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h \
   SPoint2.h GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h \
   MFace.h ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h gmshFace.h gmshVertex.h \
-  ../Mesh/Mesh.h ../Common/GmshDefines.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h gmshRegion.h Geo.h \
-  ../DataStr/List.h ../Mesh/Create.h
+  ../Common/SmoothNormals.h gmshFace.h gmshVertex.h ../Mesh/Mesh.h \
+  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h gmshRegion.h Geo.h ../Mesh/Create.h \
+  ../Mesh/Vertex.h ../Mesh/Mesh.h
 OCCVertex.o: OCCVertex.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h OCCVertex.h \
-  ../Mesh/Mesh.h ../Common/GmshDefines.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h OCCIncludes.h \
+  ../Common/SmoothNormals.h OCCVertex.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h OCCIncludes.h \
   OCCEdge.h OCCFace.h
 OCCEdge.o: OCCEdge.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h ../Common/Message.h \
-  OCCEdge.h OCCVertex.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  OCCIncludes.h OCCFace.h
+  ../Common/SmoothNormals.h ../Common/Message.h OCCEdge.h OCCVertex.h \
+  ../Mesh/Mesh.h ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h OCCIncludes.h OCCFace.h
 OCCFace.o: OCCFace.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h OCCVertex.h \
-  ../Mesh/Mesh.h ../Common/GmshDefines.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h OCCIncludes.h \
-  OCCEdge.h OCCFace.h ../Common/Message.h ../Mesh/Utils.h
+  ../Common/SmoothNormals.h OCCVertex.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h OCCIncludes.h \
+  OCCEdge.h OCCFace.h ../Common/Message.h ../Mesh/Utils.h \
+  ../Mesh/Vertex.h ../Mesh/Mesh.h
 OCCRegion.o: OCCRegion.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   SBoundingBox3d.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
   GEdge.h SVector3.h MElement.h MEdge.h ../Common/Hash.h MFace.h \
   ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
   ExtrudeParams.h GFace.h GEdgeLoop.h Pair.h GRegion.h \
-  ../Common/SmoothNormals.h ../Numeric/Numeric.h OCCVertex.h \
-  ../Mesh/Mesh.h ../Common/GmshDefines.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Simplex.h ../Mesh/Face.h ../Mesh/Edge.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Mesh.h ../Mesh/Matrix.h OCCIncludes.h \
+  ../Common/SmoothNormals.h OCCVertex.h ../Mesh/Mesh.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h OCCIncludes.h \
   OCCEdge.h OCCFace.h OCCRegion.h ../Common/Message.h
 SVector3.o: SVector3.cpp SVector3.h SPoint3.h
 SBoundingBox3d.o: SBoundingBox3d.cpp SBoundingBox3d.h SPoint3.h
@@ -305,9 +264,6 @@ projectionFace.o: projectionFace.cpp projectionFace.h GFace.h GPoint.h \
 ExtractContour.o: ExtractContour.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Geo.h ../DataStr/List.h GeoUtils.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Simplex.h ../Mesh/Face.h \
-  ../Mesh/Edge.h ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h CAD.h ../Mesh/Vertex.h ExtrudeParams.h \
+  Geo.h GeoUtils.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h CAD.h ExtrudeParams.h \
   ../Numeric/Numeric.h
diff --git a/Graphics/Makefile b/Graphics/Makefile
index 26e22ea2faf30a2f6af7bdd7eb80d159f6f3211b..0dde8fa19e9b005c4fb91f12fb6d78fa30988643 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.106 2006-11-16 18:48:00 geuzaine Exp $
+# $Id: Makefile,v 1.107 2006-11-25 02:47:39 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -73,21 +73,17 @@ Draw.o: Draw.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
   ../DataStr/List.h ../DataStr/Tree.h ../Common/GmshUI.h \
   ../Common/GmshDefines.h ../Geo/CAD.h ../Mesh/Mesh.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h \
-  ../Geo/ExtrudeParams.h Draw.h ../Common/Views.h ../Common/ColorTable.h \
-  ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \
+  ../Geo/ExtrudeParams.h ../Geo/ExtrudeParams.h Draw.h ../Common/Views.h \
+  ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
   ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
@@ -98,15 +94,15 @@ Mesh.o: Mesh.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../Common/GmshUI.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../Geo/ExtrudeParams.h ../Geo/GFace.h \
-  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
-  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../Geo/ExtrudeParams.h \
+  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
   ../Common/SmoothNormals.h Draw.h ../Common/Views.h \
   ../Common/ColorTable.h ../Common/VertexArray.h \
@@ -123,15 +119,16 @@ Geom.o: Geom.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   gl2ps.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/GmshDefines.h ../Geo/MVertex.h \
-  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h ../Geo/GEntity.h \
-  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
-  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/SBoundingBox3d.h
 Post.o: Post.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
   ../DataStr/List.h ../DataStr/Tree.h ../Common/GmshUI.h \
@@ -155,11 +152,11 @@ SelectBuffer.o: SelectBuffer.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h \
   SelectBuffer.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
   ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
diff --git a/Mesh/1D_Mesh.cpp b/Mesh/1D_Mesh.cpp
deleted file mode 100644
index 9aab2f951da2dca819a6442d76425aee33d28532..0000000000000000000000000000000000000000
--- a/Mesh/1D_Mesh.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-// $Id: 1D_Mesh.cpp,v 1.50 2006-08-05 13:31:28 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "Utils.h"
-#include "Context.h"
-#include "Interpolation.h"
-
-extern Mesh *THEM;
-extern Context_T CTX;
-
-static Curve *THEC = NULL;
-
-// ipar[0] = nbpoints
-// abs(ipar[1]) = method
-// sign(ipar[1]) = orientation
-// dpar[0] = parameter
-
-double F_One(double t)
-{
-  Vertex der;
-  double d;
-  der = InterpolateCurve(THEC, t, 1);
-  d =
-    sqrt(der.Pos.X * der.Pos.X + der.Pos.Y * der.Pos.Y +
-         der.Pos.Z * der.Pos.Z);
-  return (d);
-}
-
-
-double F_Transfini(double t)
-{
-  Vertex der;
-  double d, a, b, val, r;
-  int i;
-
-  der = InterpolateCurve(THEC, t, 1);
-  d = sqrt(der.Pos.X * der.Pos.X + der.Pos.Y * der.Pos.Y +
-           der.Pos.Z * der.Pos.Z);
-
-  if(THEC->dpar[0] <= 0.0 || THEC->dpar[0] == 1.0) {
-    // dpar[0] < 0 should never happen
-    val = d * (double)THEC->ipar[0] / THEC->l;
-  }
-  else {
-    switch (abs(THEC->ipar[1])) {
-
-    case 1:    // Geometric progression ar^i; Sum of n terms = THEC->l = a (r^n-1)/(r-1)
-      if(sign(THEC->ipar[1]) >= 0)
-	r = THEC->dpar[0];
-      else
-	r = 1. / THEC->dpar[0];
-      a = THEC->l * (r - 1.) / (pow(r, THEC->ipar[0] - 1.) - 1.);
-      i = (int)(log(t * THEC->l / a * (r - 1.) + 1.) / log(r));
-      val = d / (a * pow(r, (double)i));
-      break;
-
-    case 2:    // Bump
-      if(THEC->dpar[0] > 1.0) {
-        a = -4. * sqrt(THEC->dpar[0] - 1.) *
-          atan2(1., sqrt(THEC->dpar[0] - 1.)) /
-          ((double)THEC->ipar[0] * THEC->l);
-      }
-      else {
-        a = 2. * sqrt(1. - THEC->dpar[0]) *
-          log(fabs((1. + 1. / sqrt(1. - THEC->dpar[0]))
-                   / (1. - 1. / sqrt(1. - THEC->dpar[0]))))
-          / ((double)THEC->ipar[0] * THEC->l);
-      }
-      b = -a * THEC->l * THEC->l / (4. * (THEC->dpar[0] - 1.));
-      val = d / (-a * DSQR(t * THEC->l - (THEC->l) * 0.5) + b);
-      break;
-
-    default:
-      Msg(WARNING, "Unknown case in Transfinite Line mesh");
-      val = 1.;
-    }
-  }
-
-  return val;
-}
-
-double F_Lc(double t)
-{
-  Vertex der, point;
-  double Lc, d;
-
-  if(CTX.mesh.bgmesh_type == ONFILE) {
-    der = InterpolateCurve(THEC, t, 1);
-    point = InterpolateCurve(THEC, t, 0);
-    Lc = BGMXYZ(point.Pos.X, point.Pos.Y, point.Pos.Z);
-    d = sqrt(DSQR(der.Pos.X) + DSQR(der.Pos.Y) + DSQR(der.Pos.Z));
-    if(CTX.mesh.constrained_bgmesh)
-      return MAX(d / Lc, THEM->Metric->getLc(t, THEC));
-    else
-      return d / Lc;
-  }
-  else
-    return THEM->Metric->getLc(t, THEC);
-}
-
-void Maillage_Curve(void *data, void *dummy)
-{
-  Curve *c;
-  Simplex *s;
-  double b, a, d, dt, dp, t;
-  int i, N, count, NUMP;
-  Vertex **v, **vexist, *pV, V, *v1, *v2;
-  List_T *Points;
-  IntPoint P1, P2;
-
-  THEC = c = *(Curve **) data;
-
-  if(c->Num < 0)
-    return;
-
-  Msg(STATUS2, "Meshing curve %d", c->Num);
-
-  if(MeshDiscreteCurve(c)){
-    return;
-  }
-  
-  Points = List_Create(10, 10, sizeof(IntPoint));
-  c->l = Integration(c->ubeg, c->uend, F_One, Points, 1.e-4);
-  List_Delete(Points);
-
-  if(!c->l) {
-    Msg(GERROR, "Zero length Curve %d", c->Num);
-    return;
-  }
-
-  if(Extrude_Mesh(c)){
-    return;
-  }
-
-  if(c->Method == TRANSFINI) {
-    Points = List_Create(10, 10, sizeof(IntPoint));
-    a = Integration(c->ubeg, c->uend, F_Transfini, Points, 1.e-7);
-    N = c->ipar[0];
-  }
-  else {
-    Points = List_Create(10, 10, sizeof(IntPoint));
-    a = Integration(c->ubeg, c->uend, F_Lc, Points, 1.e-4);
-    N = IMAX(2, (int)(a + 1.));
-    
-    if(c->Typ == MSH_SEGM_CIRC ||
-       c->Typ == MSH_SEGM_CIRC_INV ||
-       c->Typ == MSH_SEGM_ELLI || c->Typ == MSH_SEGM_ELLI_INV) {
-      N = IMAX(N, (int)(fabs(c->Circle.t1 - c->Circle.t2) *
-			(double)CTX.mesh.min_circ_points / Pi));
-    }
-    else if(c->Typ == MSH_SEGM_NURBS) {
-      N = IMAX(N, 2);
-    }
-  }
-  b = a / (double)(N - 1);
-  
-  v = &c->beg;
-  if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, v))) {
-    (*vexist)->u = c->ubeg;
-    if((*vexist)->ListCurves)
-      List_Add((*vexist)->ListCurves, &c);
-    List_Add(c->Vertices, vexist);
-  }
-  else {
-    pV = Create_Vertex((*v)->Num, (*v)->Pos.X, (*v)->Pos.Y,
-		       (*v)->Pos.Z, (*v)->lc, c->ubeg);
-    pV->ListCurves = List_Create(1, 1, sizeof(Curve *));
-    List_Add(pV->ListCurves, &c);
-    Tree_Add(THEM->Vertices, &pV);
-    List_Add(c->Vertices, &pV);
-  }
-  
-  count = NUMP = 1;
-  while(NUMP < N - 1) {
-    List_Read(Points, count - 1, &P1);
-    List_Read(Points, count, &P2);
-    d = (double)NUMP *b;
-    
-    if((fabs(P2.p) >= fabs(d)) && (fabs(P1.p) < fabs(d))) {
-      dt = P2.t - P1.t;
-      dp = P2.p - P1.p;
-      t = P1.t + dt / dp * (d - P1.p);
-      V = InterpolateCurve(c, t, 0);
-      pV = Create_Vertex(++THEM->MaxPointNum, V.Pos.X, V.Pos.Y, V.Pos.Z, V.lc, t);
-      pV->w = V.w;
-      pV->ListCurves = List_Create(1, 1, sizeof(Curve *));
-      List_Add(pV->ListCurves, &c);
-      Tree_Add(THEM->Vertices, &pV);
-      List_Add(c->Vertices, &pV);
-      NUMP++;
-    }
-    else {
-      count++;
-    }
-  }
-  
-  List_Delete(Points);
-  
-  v = &c->end;
-  if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, v))) {
-    (*vexist)->u = c->uend;
-    if((*vexist)->ListCurves)
-      List_Add((*vexist)->ListCurves, &c);
-    List_Add(c->Vertices, vexist);
-  }
-  else {
-    pV = Create_Vertex((*v)->Num, (*v)->Pos.X, (*v)->Pos.Y,
-		       (*v)->Pos.Z, (*v)->lc, c->uend);
-    pV->ListCurves = List_Create(1, 1, sizeof(Curve *));
-    List_Add(pV->ListCurves, &c);
-    Tree_Add(THEM->Vertices, &pV);
-    List_Add(c->Vertices, &pV);
-  }
-  
-  for(i = 0; i < List_Nbr(c->Vertices) - 1; i++) {
-    List_Read(c->Vertices, i, &v1);
-    List_Read(c->Vertices, i + 1, &v2);
-    s = Create_Simplex(v1, v2, NULL, NULL);
-    s->iEnt = c->Num;
-    Tree_Add(c->Simplexes, &s);
-  }
-
-}
diff --git a/Mesh/2D_BGMesh.cpp b/Mesh/2D_BGMesh.cpp
deleted file mode 100644
index 345acd67887e31a97217e5f7bd12685ce4b2cc56..0000000000000000000000000000000000000000
--- a/Mesh/2D_BGMesh.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-// $Id: 2D_BGMesh.cpp,v 1.17 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-
-extern Mesh *THEM;
-
-// Compute Calcul the charact. length on 1 pt by interpolating in the
-// background mesh
-
-double find_quality(MPoint center, DocRecord * BGMESH)
-{
-  int i;
-  Delaunay *del;
-  PointRecord *pPointArray;
-  PointNumero a, b, c;
-  double qual, q1, q2, q3, X[3], Y[3], u, v, det, Xp, Yp;
-  double Exp = 2., r, deno, nume;
-
-  if((del = Find_Triangle(center, BGMESH, BOF)) == NULL) {
-    Msg(GERROR, "Exterior point (%g,%g)", center.v, center.h);
-    return 1.e-15;
-  }
-
-  pPointArray = BGMESH->points;
-
-  a = del->t.a;
-  b = del->t.b;
-  c = del->t.c;
-
-  Xp = center.h;
-  Yp = center.v;
-
-  X[0] = pPointArray[a].where.h;
-  X[1] = pPointArray[b].where.h;
-  X[2] = pPointArray[c].where.h;
-
-  Y[0] = pPointArray[a].where.v;
-  Y[1] = pPointArray[b].where.v;
-  Y[2] = pPointArray[c].where.v;
-
-  q1 = pPointArray[a].quality;
-  q2 = pPointArray[b].quality;
-  q3 = pPointArray[c].quality;
-
-  det = (X[2] - X[0]) * (Y[1] - Y[0]) - (Y[2] - Y[0]) * (X[1] - X[0]);
-
-  if(det != 0.0) {
-    u = ((Xp - X[0]) * (Y[1] - Y[0]) - (Yp - Y[0]) * (X[1] - X[0])) / det;
-    v = ((X[2] - X[0]) * (Yp - Y[0]) - (Y[2] - Y[0]) * (Xp - X[0])) / det;
-  }
-  else {
-    Msg(WARNING, "Degenerated triangle (det=%g)", det);
-    u = v = 0.0;
-  }
-
-  if(u >= -1.e-8 && v >= -1.e-8 && 1. - u - v >= -1.e-8) {
-    qual = q1 * (1. - u - v) + q2 * v + q3 * u;
-    return (qual);
-  }
-  else {
-    pPointArray = BGMESH->points;
-    deno = nume = 0.0;
-    for(i = 0; i < BGMESH->numPoints; i++) {
-      r = sqrt(DSQR(center.h - pPointArray[i].where.h) +
-               DSQR(center.v - pPointArray[i].where.v));
-      r = pow(r, Exp);
-      if(r < 1.e-10)
-        return (pPointArray[i].quality);
-      nume += pPointArray[i].quality / r;
-      deno += 1. / r;
-    }
-    return (nume / deno);
-  }
-}
diff --git a/Mesh/2D_Bowyer.cpp b/Mesh/2D_Bowyer.cpp
deleted file mode 100644
index 12eaeff90a776cc3a31f859cdec851d6ce12a4b0..0000000000000000000000000000000000000000
--- a/Mesh/2D_Bowyer.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-// $Id: 2D_Bowyer.cpp,v 1.17 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-/*
-   A L G O R I T H M E   D E   B O W Y E R  -  W A T S O N
-
-   definition : il est possible d'obtenir une triangulation de Delaunay en partant 
-   d'une triangulation existante en lui ajoutant un noeud de la facon suivante :
-
-   - on elimine les triangles de la premiere triangulation dont le cercle
-   circonscrit contient le nouveau point
-   - on reconstuit une triangulation en joignant le point aux noeuds du polygone
-   defini par les triangles effaces
-
-   ListEdges = liste liee circulaire et triee contenant les points du polygone
-   listkill = liste des pointeurs des triangles a effacer
-   listDelforLink = liste des triangles a la peripherie du polygone
-   PE_Del_Triangle = Peut-Etre va-t-on effacer le triangle del, si on l'efface alors
-   on appelle recursivement 3 fois PE_Del_Triangle avec ses trois voisins (si il en a)
-   comme argument
-*/
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-
-extern PointRecord *gPointArray;
-
-int Is_pt_in_CircCircle(Delaunay * del, MPoint pt)
-{
-  double rc, dc, Xa, Ya;
-  PointNumero a;
-
-  dc = DSQR(del->t.xc - pt.h) + DSQR(del->t.yc - pt.v);
-
-  a = del->t.a;
-
-  Xa = gPointArray[a].where.h;
-  Ya = gPointArray[a].where.v;
-
-  rc = DSQR(del->t.xc - Xa) + DSQR(del->t.yc - Ya);
-
-  if(rc >= dc)
-    return 1;
-  return 0;
-
-}
-
-int PE_Del_Triangle(Delaunay * del, MPoint pt, DListPeek * ListEdges,
-                    List_T * listkill, List_T * listDelforlink,
-                    int *numlink, int *numdel)
-{
-  int rslt;
-  PointNumero a, b, c;
-  int count, order[3], same;
-  DListPeek p;
-  Delaunay *de1, *de2, *de3;
-
-  rslt = Is_pt_in_CircCircle(del, pt);
-
-  if((!rslt) && (*numdel == 0)) {
-    return (0);
-  }
-  if(!rslt) {
-
-    /* On retient les triangles du pourtour */
-
-    del->t.info = NOTTOLINK;
-    List_Put(listDelforlink, *numlink, &del);
-    (*numlink)++;
-
-    return (1);
-
-  }
-  else {
-
-    List_Put(listkill, *numdel, &del);
-    (*numdel)++;
-
-    a = del->t.a;
-    b = del->t.b;
-    c = del->t.c;
-
-    if(*ListEdges == NULL) {
-
-      rslt = DListInsert(ListEdges, pt, a);
-      rslt &= DListInsert(ListEdges, pt, b);
-      rslt &= DListInsert(ListEdges, pt, c);
-      if(!rslt)
-        Msg(GERROR, "List insert failed in Boyer Watson");
-
-    }
-    else {
-
-      count = 0;
-      p = *ListEdges;
-      order[0] = order[1] = order[2] = 0;
-      same = 0;
-
-      do {
-        if(p->point_num == a) {
-          same = same + 1;
-          order[count] = a;
-          count++;
-        }
-        if(p->point_num == b) {
-          same = same + 10;
-          order[count] = b;
-          count++;
-        }
-        if(p->point_num == c) {
-          same = same + 100;
-          order[count] = c;
-          count++;
-        }
-        p = Pred(p);
-      } while(p != *ListEdges);
-      if(count == 1) {
-        return (0);
-      }
-      else if(count == 2) {
-        if(same == 11) {
-          rslt = DListInsert(ListEdges, pt, c);
-        }
-        if(same == 101) {
-          rslt = DListInsert(ListEdges, pt, b);
-        }
-        if(same == 110) {
-          rslt = DListInsert(ListEdges, pt, a);
-        }
-      }
-      else if(count == 3) {
-        rslt = DListDelete(ListEdges, order[1]);
-      }
-      else {
-        return (0);
-      }
-    }
-
-    de1 = del->v.voisin1;
-    de2 = del->v.voisin2;
-    de3 = del->v.voisin3;
-
-
-    if(de1 != NULL) {
-      if(de1->v.voisin1 == del)
-        de1->v.voisin1 = NULL;
-      else if(de1->v.voisin2 == del)
-        de1->v.voisin2 = NULL;
-      else if(de1->v.voisin3 == del)
-        de1->v.voisin3 = NULL;
-      else
-        Msg(GERROR, "Bad link in Boyer Watson");
-    }
-    if(de2 != NULL) {
-      if(de2->v.voisin1 == del)
-        de2->v.voisin1 = NULL;
-      else if(de2->v.voisin2 == del)
-        de2->v.voisin2 = NULL;
-      else if(de2->v.voisin3 == del)
-        de2->v.voisin3 = NULL;
-      else
-        Msg(GERROR, "Bad link in Boyer Watson");
-    }
-    if(de3 != NULL) {
-      if(de3->v.voisin1 == del)
-        de3->v.voisin1 = NULL;
-      else if(de3->v.voisin2 == del)
-        de3->v.voisin2 = NULL;
-      else if(de3->v.voisin3 == del)
-        de3->v.voisin3 = NULL;
-      else
-        Msg(GERROR, "Bad link in Boyer Watson");
-    }
-
-    del->v.voisin1 = NULL;
-    del->v.voisin2 = NULL;
-    del->v.voisin3 = NULL;
-
-
-    if(de1 != NULL) {
-      if(!PE_Del_Triangle
-         (de1, pt, ListEdges, listkill, listDelforlink, numlink, numdel))
-        return (0);
-    }
-    if(de2 != NULL) {
-      if(!PE_Del_Triangle
-         (de2, pt, ListEdges, listkill, listDelforlink, numlink, numdel))
-        return (0);
-    }
-    if(de3 != NULL) {
-      if(!PE_Del_Triangle
-         (de3, pt, ListEdges, listkill, listDelforlink, numlink, numdel))
-        return (0);
-    }
-    return (1);
-  }
-}
diff --git a/Mesh/2D_Bricks.cpp b/Mesh/2D_Bricks.cpp
deleted file mode 100644
index d39540129c7096eda4b763e60bd66f5eec78c66a..0000000000000000000000000000000000000000
--- a/Mesh/2D_Bricks.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-// $Id: 2D_Bricks.cpp,v 1.15 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-
-static double XmaxGrid, YmaxGrid, XminGrid, YminGrid, ZmaxGrid, ZminGrid;
-static double XminBox, XmaxBox, YminBox, YmaxBox, ZminBox, ZmaxBox;
-static int Nx = 0, Ny = 0, Nz = 0;
-static List_T *GridList = NULL;
-static DocRecord *MyMesh = NULL;
-
-extern PointRecord *gPointArray;
-
-int fcmp_Map(const void *a, const void *b)
-{
-  return ((struct Map *)a)->Num - ((struct Map *)b)->Num;
-}
-
-void Invert_MappingLists(List_T * List1, List_T * List2)
-{
-  struct Map TmpMap1, TmpMap2;
-  struct Map *TmpMap;
-  List_T *TmpList;
-
-  int i, j, Entity, CurrentEntity;
-
-  TmpList = List_Create(10 * List_Nbr(List1), 100, sizeof(int));
-
-  for(i = 0; i < List_Nbr(List1); i++) {
-    List_Read(List1, i, &TmpMap1);
-    for(j = 0; j < List_Nbr(TmpMap1.List); j++) {
-      List_Read(TmpMap1.List, j, &Entity);
-      List_Add(TmpList, &Entity);
-    }
-  }
-
-  List_Sort(TmpList, fcmp_int);
-
-  List_Read(TmpList, 0, &CurrentEntity);
-  TmpMap1.Num = CurrentEntity;
-  TmpMap1.List = List_Create(10, 10, sizeof(int));
-  List_Add(List2, &TmpMap1);
-  for(i = 1; i < List_Nbr(TmpList); i++) {
-    List_Read(TmpList, i, &Entity);
-    if(Entity != CurrentEntity) {
-      CurrentEntity = Entity;
-      TmpMap1.Num = CurrentEntity;
-      TmpMap1.List = List_Create(10, 10, sizeof(int));
-      List_Add(List2, &TmpMap1);
-    }
-  }
-
-  for(i = 0; i < List_Nbr(List1); i++) {
-    List_Read(List1, i, &TmpMap1);
-    for(j = 0; j < List_Nbr(TmpMap1.List); j++) {
-      List_Read(TmpMap1.List, j, &Entity);
-      TmpMap2.Num = Entity;
-      if((TmpMap =
-          (struct Map *)List_PQuery(List2, &TmpMap2, fcmp_Map)) != NULL) {
-        List_Add(TmpMap->List, &TmpMap1.Num);
-      }
-    }
-  }
-
-  List_Delete(TmpList);
-}
-
-int InWhichBrick(double X, double Y, double Z)
-{
-  int Ix, Iy, Iz;
-
-  if(X > XmaxGrid || X < XminGrid || Y > YmaxGrid ||
-     Y < YminGrid || Z > ZmaxGrid || Z < ZminGrid)
-    return (-1);
-
-  Ix = (int)((double)Nx * (X - XminGrid) / (XmaxGrid - XminGrid));
-  Iy = (int)((double)Ny * (Y - YminGrid) / (YmaxGrid - YminGrid));
-  Iz = (int)((double)Nz * (Z - ZminGrid) / (ZmaxGrid - ZminGrid));
-  Ix = (Ix < Nx) ? Ix : Nx - 1;
-  Iy = (Iy < Ny) ? Iy : Ny - 1;
-  Iz = (Iz < Nz) ? Iz : Nz - 1;
-  return (1 + Ix + Iy * Nx + Iz * Nx * Ny);
-}
-
-List_T *AllBricksForABox(void)
-{
-  List_T *List;
-  int Ix1, Ix2, Iy1, Iy2, Iz1, Iz2;
-  int i, j, k, Num;
-
-  Ix1 = (int)((double)Nx * (XminBox - XminGrid) / (XmaxGrid - XminGrid));
-  Ix2 = (int)((double)Nx * (XmaxBox - XminGrid) / (XmaxGrid - XminGrid));
-  Iy1 = (int)((double)Ny * (YminBox - YminGrid) / (YmaxGrid - YminGrid));
-  Iy2 = (int)((double)Ny * (YmaxBox - YminGrid) / (YmaxGrid - YminGrid));
-  Iz1 = (int)((double)Nz * (ZminBox - ZminGrid) / (ZmaxGrid - ZminGrid));
-  Iz2 = (int)((double)Nz * (ZmaxBox - ZminGrid) / (ZmaxGrid - ZminGrid));
-  Ix1 = (Ix1 < Nx) ? Ix1 : Nx - 1;
-  Ix2 = (Ix2 < Nx) ? Ix2 : Nx - 1;
-  Iy1 = (Iy1 < Ny) ? Iy1 : Ny - 1;
-  Iy2 = (Iy2 < Ny) ? Iy2 : Ny - 1;
-  Iz1 = (Iz1 < Nz) ? Iz1 : Nz - 1;
-  Iz2 = (Iz2 < Nz) ? Iz2 : Nz - 1;
-
-  List =
-    List_Create((Ix2 - Ix1 + 1) * (Iy2 - Iy1 + 1) * (Iz2 - Iz1 + 1), 1,
-                sizeof(int));
-
-  for(i = Ix1; i <= Ix2; i++) {
-    for(j = Iy1; j <= Iy2; j++) {
-      for(k = Iz1; k <= Iz2; k++) {
-        Num = 1 + i + j * Nx + k * Nx * Ny;
-        List_Add(List, &Num);
-      }
-    }
-  }
-  return (List);
-}
-
-void InitBricks(DocRecord * MESH)
-{
-  int i, j, a, b, c;
-  List_T *InvList;
-  struct Map InvMap;
-  double X[3], Y[3], dx, dy;
-
-  MyMesh = MESH;
-
-  if(!MyMesh) return;
-
-  Nx = (int)sqrt((double)MESH->numTriangles) + 1;
-  Ny = Nx;
-  Nz = 1;
-  ZminGrid = 0.;
-  ZmaxGrid = 1.;
-
-  if(GridList)
-    List_Delete(GridList);
-  GridList = List_Create(Nx * Ny * Nz, 1, sizeof(struct Map));
-  InvList = List_Create(MESH->numTriangles, 1, sizeof(struct Map));
-
-  for(i = 0; i < MESH->numTriangles; i++) {
-    a = MESH->delaunay[i].t.a;
-    b = MESH->delaunay[i].t.b;
-    c = MESH->delaunay[i].t.c;
-
-    X[0] = MESH->points[a].where.h;
-    X[1] = MESH->points[b].where.h;
-    X[2] = MESH->points[c].where.h;
-    Y[0] = MESH->points[a].where.v;
-    Y[1] = MESH->points[b].where.v;
-    Y[2] = MESH->points[c].where.v;
-
-    if(!i) {
-      XminGrid = XmaxGrid = X[0];
-      YminGrid = YmaxGrid = Y[0];
-    }
-
-    for(j = 0; j < 3; j++) {
-      XmaxGrid = DMAX(XmaxGrid, X[j]);
-      XminGrid = DMIN(XminGrid, X[j]);
-      YmaxGrid = DMAX(YmaxGrid, Y[j]);
-      YminGrid = DMIN(YminGrid, Y[j]);
-    }
-  }
-  dx = XmaxGrid - XminGrid;
-  dy = YmaxGrid - YminGrid;
-  XmaxGrid += 0.01 * dx;
-  YmaxGrid += 0.01 * dy;
-  XminGrid -= 0.01 * dx;
-  YminGrid -= 0.01 * dy;
-
-  for(i = 0; i < MESH->numTriangles; i++) {
-    a = MESH->delaunay[i].t.a;
-    b = MESH->delaunay[i].t.b;
-    c = MESH->delaunay[i].t.c;
-
-    X[0] = XminBox = XmaxBox = MESH->points[a].where.h;
-    X[1] = MESH->points[b].where.h;
-    X[2] = MESH->points[c].where.h;
-    Y[0] = YminBox = YmaxBox = MESH->points[a].where.v;
-    Y[1] = MESH->points[b].where.v;
-    Y[2] = MESH->points[c].where.v;
-
-    for(j = 1; j < 3; j++) {
-      XmaxBox = DMAX(XmaxBox, X[j]);
-      XminBox = DMIN(XminBox, X[j]);
-      YmaxBox = DMAX(YmaxBox, Y[j]);
-      YminBox = DMIN(YminBox, Y[j]);
-    }
-    ZmaxBox = 1.0;
-    ZminBox = 0.0;
-
-    InvMap.Num = i;
-    InvMap.List = AllBricksForABox();
-    List_Add(InvList, &InvMap);
-  }
-
-  Invert_MappingLists(InvList, GridList);
-  List_Delete(InvList);
-}
-
-
-Delaunay *Find_Triangle(MPoint pt, DocRecord * MESH, int typ)
-{
-  int a, b, c, i, found, KeyBrick, j;
-  Delaunay *del, *del2;
-  double Z, Znew;
-  PointRecord *ptr;
-  double Xcg, Ycg;
-  struct Map *pBrick;
-
-  ptr = gPointArray;
-  gPointArray = MESH->points;
-
-  if(MyMesh == MESH) {
-    KeyBrick = InWhichBrick(pt.h, pt.v, 0.0);
-    if((pBrick =
-        (struct Map *)List_PQuery(GridList, &KeyBrick, fcmp_Map)) == NULL) {
-      if(typ == A_TOUT_PRIX) {
-        gPointArray = ptr;
-        return (NULL);
-      }
-    }
-    else {
-      for(i = 0; i < List_Nbr(pBrick->List); i++) {
-        j = *(int *)List_Pointer(pBrick->List, i);
-        a = MESH->delaunay[j].t.a;
-        b = MESH->delaunay[j].t.b;
-        c = MESH->delaunay[j].t.c;
-        if(MESH->delaunay[j].t.position != EXTERN || typ == BOF) {
-          if(PtInTriangle(pt, a, b, c)) {
-            gPointArray = ptr;
-            return (&MESH->delaunay[j]);
-          }
-        }
-      }
-      if(typ == A_TOUT_PRIX) {
-        gPointArray = ptr;
-        return NULL;
-      }
-    }
-  }
-  else {
-    i = 0;
-    found = 0;
-    while(!found && i < MESH->numTriangles) {
-      if((!PtInTriangle(pt, MESH->delaunay[i].t.a, MESH->delaunay[i].t.b,
-                        MESH->delaunay[i].t.c)) ||
-         (MESH->delaunay[i].t.position == EXTERN && typ != BOF))
-        i++;
-      else
-        found = 1;
-    };
-
-    if(found == 1) {
-      gPointArray = ptr;
-      return (&(MESH->delaunay[i]));
-    }
-    if(typ == A_TOUT_PRIX) {
-      gPointArray = ptr;
-      return NULL;
-    }
-  }
-
-  del = &(MESH->delaunay[0]);
-
-  Xcg = gPointArray[del->t.a].where.h +
-    gPointArray[del->t.b].where.h + gPointArray[del->t.c].where.h;
-
-  Ycg = gPointArray[del->t.a].where.v +
-    gPointArray[del->t.b].where.v + gPointArray[del->t.c].where.v;
-
-  Xcg /= 3.;
-  Ycg /= 3.;
-
-  Z = DSQR(Xcg - pt.h) + DSQR(Ycg - pt.v);
-
-  for(i = 1; i < MESH->numTriangles; i++) {
-    del2 = &(MESH->delaunay[i]);
-    Xcg = gPointArray[del2->t.a].where.h +
-      gPointArray[del2->t.b].where.h + gPointArray[del2->t.c].where.h;
-    Ycg = gPointArray[del2->t.a].where.v +
-      gPointArray[del2->t.b].where.v + gPointArray[del2->t.c].where.v;
-    Xcg /= 3.;
-    Ycg /= 3.;
-    Znew = DSQR(Xcg - pt.h) + DSQR(Ycg - pt.v);
-    if(Znew < Z) {
-      del = del2;
-      Z = Znew;
-    }
-  }
-
-  gPointArray = ptr;
-  return del;
-}
-
-int PtInTriangle(MPoint p, PointNumero a, PointNumero b, PointNumero c)
-{
-  double Xmin, Xmax, Ymin, Ymax, Xtr[4], Ytr[4], A[2], B[2], X, Y, Signus[3];
-  int i;
-
-  X = p.h;
-  Y = p.v;
-  Xtr[0] = Xmax = Xmin = gPointArray[a].where.h;
-  Xtr[3] = gPointArray[a].where.h;
-  Xtr[1] = gPointArray[b].where.h;
-  Xtr[2] = gPointArray[c].where.h;
-  Ytr[0] = Ymax = Ymin = gPointArray[a].where.v;
-  Ytr[3] = gPointArray[a].where.v;
-  Ytr[1] = gPointArray[b].where.v;
-  Ytr[2] = gPointArray[c].where.v;
-
-  for(i = 1; i < 3; i++) {
-    Xmin = (Xtr[i] < Xmin) ? Xtr[i] : Xmin;
-    Xmax = (Xtr[i] > Xmax) ? Xtr[i] : Xmax;
-    Ymin = (Ytr[i] < Ymin) ? Ytr[i] : Ymin;
-    Ymax = (Ytr[i] > Ymax) ? Ytr[i] : Ymax;
-  }
-
-  if(X > Xmax || X < Xmin || Y > Ymax || Y < Ymin)
-    return (0);
-
-  for(i = 0; i < 3; i++) {
-    A[0] = Xtr[i + 1] - Xtr[i];
-    A[1] = Ytr[i + 1] - Ytr[i];
-    B[0] = X - Xtr[i];
-    B[1] = Y - Ytr[i];
-    Signus[i] = A[0] * B[1] - A[1] * B[0];
-  }
-  for(i = 0; i < 2; i++) {
-    if((Signus[i] * Signus[i + 1]) <= 0)
-      return (0);
-  }
-  return (1);
-}
diff --git a/Mesh/2D_Cylindrical.cpp b/Mesh/2D_Cylindrical.cpp
deleted file mode 100644
index 7c53788e880f7865858d7f2d96f8cffd0da608ad..0000000000000000000000000000000000000000
--- a/Mesh/2D_Cylindrical.cpp
+++ /dev/null
@@ -1,316 +0,0 @@
-// $Id: 2D_Cylindrical.cpp,v 1.20 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "Context.h"
-
-extern Mesh *THEM;
-extern Context_T CTX;
-
-static Surface *SURF;
-static double THETAMIN, THETAMAX;
-
-void ChangePi(void *a, void *dum)
-{
-  Vertex *v;
-  v = *(Vertex **) a;
-
-  if((v->Pos.X / SURF->Cyl.radius1) >= THETAMIN + .99999 * Pi) {
-    Msg(INFO, "%g -> ", v->Pos.X / SURF->Cyl.radius1);
-    v->Pos.X -= (2. * Pi) * SURF->Cyl.radius1;
-    Msg(INFO, "%g -> ", v->Pos.X / SURF->Cyl.radius1);
-  }
-}
-
-void THETAMINMAX(void *a, void *dum)
-{
-  Vertex *v;
-  double ZRepere, S, C, y[3], teta;
-  double p[3], z[3], x[3], o[3];
-
-  v = *(Vertex **) a;
-
-  p[0] = v->Pos.X - SURF->Cyl.center[0];
-  p[1] = v->Pos.Y - SURF->Cyl.center[1];
-  p[2] = v->Pos.Z - SURF->Cyl.center[2];
-  z[0] = SURF->Cyl.zaxis[0];
-  z[1] = SURF->Cyl.zaxis[1];
-  z[2] = SURF->Cyl.zaxis[2];
-  norme(z);
-  prosca(p, z, &ZRepere);
-
-  //ZRepere = fabs(ZRepere);
-
-  o[0] = p[0] - ZRepere * z[0];
-  o[1] = p[1] - ZRepere * z[1];
-  o[2] = p[2] - ZRepere * z[2];
-  x[0] = SURF->Cyl.xaxis[0];
-  x[1] = SURF->Cyl.xaxis[1];
-  x[2] = SURF->Cyl.xaxis[2];
-
-  norme(o);
-  norme(x);
-  prodve(z, x, y);
-  norme(y);
-  prosca(o, x, &C);
-  prosca(o, y, &S);
-  teta = atan2(S, C);
-  THETAMIN = DMIN(teta, THETAMIN);
-  THETAMAX = DMAX(teta, THETAMAX);
-}
-
-// Cylindrical surfaces
-
-void XYZtoTZ(void *a, void *dum)
-{
-  Vertex *v;
-  double ZRepere, S, C, y[3], teta;
-  double p[3], z[3], x[3], o[3];
-
-  v = *(Vertex **) a;
-
-  p[0] = v->Pos.X - SURF->Cyl.center[0];
-  p[1] = v->Pos.Y - SURF->Cyl.center[1];
-  p[2] = v->Pos.Z - SURF->Cyl.center[2];
-  z[0] = SURF->Cyl.zaxis[0];
-  z[1] = SURF->Cyl.zaxis[1];
-  z[2] = SURF->Cyl.zaxis[2];
-  norme(z);
-  prosca(p, z, &ZRepere);
-
-  //ZRepere = fabs(ZRepere);
-
-  o[0] = p[0] - ZRepere * z[0];
-  o[1] = p[1] - ZRepere * z[1];
-  o[2] = p[2] - ZRepere * z[2];
-  x[0] = SURF->Cyl.xaxis[0];
-  x[1] = SURF->Cyl.xaxis[1];
-  x[2] = SURF->Cyl.xaxis[2];
-
-  norme(o);
-  norme(x);
-  prodve(z, x, y);
-  norme(y);
-  prosca(o, x, &C);
-  prosca(o, y, &S);
-  teta = atan2(S, C);
-  Msg(DEBUG, "pt %d %g %g", v->Num, ZRepere, teta);
-
-  v->Pos.X = teta * SURF->Cyl.radius1;
-  v->Pos.Y = ZRepere;
-  v->Pos.Z = 0.0;
-}
-
-void TZtoXYZ(void *a, void *dum)
-{
-  Vertex *v;
-  double d[3], x[3], prv[3];
-  double XX, YY, ZZ;
-
-  v = *(Vertex **) a;
-  d[0] = SURF->Cyl.zaxis[0];
-  d[1] = SURF->Cyl.zaxis[1];
-  d[2] = SURF->Cyl.zaxis[2];
-  norme(d);
-  x[0] = SURF->Cyl.xaxis[0];
-  x[1] = SURF->Cyl.xaxis[1];
-  x[2] = SURF->Cyl.xaxis[2];
-  norme(x);
-  prodve(d, x, prv);
-  norme(prv);
-
-  XX = SURF->Cyl.center[0] + v->Pos.Y * d[0] +
-    SURF->Cyl.radius1 * cos(v->Pos.X / SURF->Cyl.radius1) * x[0] +
-    SURF->Cyl.radius1 * (sin(v->Pos.X / SURF->Cyl.radius1)) * prv[0];
-  YY = SURF->Cyl.center[1] + v->Pos.Y * d[1] +
-    SURF->Cyl.radius1 * cos(v->Pos.X / SURF->Cyl.radius1) * x[1] +
-    SURF->Cyl.radius1 * (sin(v->Pos.X / SURF->Cyl.radius1)) * prv[1];
-  ZZ = SURF->Cyl.center[2] + v->Pos.Y * d[2] +
-    SURF->Cyl.radius1 * cos(v->Pos.X / SURF->Cyl.radius1) * x[2] +
-    SURF->Cyl.radius1 * (sin(v->Pos.X / SURF->Cyl.radius1)) * prv[2];
-
-  v->Pos.X = XX;
-  v->Pos.Y = YY;
-  v->Pos.Z = ZZ;
-}
-
-// Conical surfaces
-
-void XYZtoCone(void *a, void *dum)
-{
-  Vertex *v;
-  double ZRepere, S, C, y[3], teta;
-  double p[3], z[3], x[3], o[3];
-  double inclinaison, ract;
-
-  v = *(Vertex **) a;
-
-  p[0] = v->Pos.X - SURF->Cyl.center[0];
-  p[1] = v->Pos.Y - SURF->Cyl.center[1];
-  p[2] = v->Pos.Z - SURF->Cyl.center[2];
-  z[0] = SURF->Cyl.zaxis[0];
-  z[1] = SURF->Cyl.zaxis[1];
-  z[2] = SURF->Cyl.zaxis[2];
-  norme(z);
-  prosca(p, z, &ZRepere);
-
-  //ZRepere = fabs(ZRepere);
-
-  o[0] = p[0] - ZRepere * z[0];
-  o[1] = p[1] - ZRepere * z[1];
-  o[2] = p[2] - ZRepere * z[2];
-  x[0] = SURF->Cyl.xaxis[0];
-  x[1] = SURF->Cyl.xaxis[1];
-  x[2] = SURF->Cyl.xaxis[2];
-
-  norme(o);
-  norme(x);
-  prodve(z, x, y);
-  norme(y);
-  prosca(o, x, &C);
-  prosca(o, y, &S);
-  teta = atan2(S, C);
-  if(teta >= THETAMIN + .99999 * Pi)
-    teta -= (2. * Pi);
-
-  inclinaison = Pi * SURF->Cyl.radius2 / 180.;
-
-  ract = SURF->Cyl.radius1 - ZRepere * tan(inclinaison);
-
-  v->Pos.X = ract * cos(teta);
-  v->Pos.Y = ract * sin(teta);
-  v->Pos.Z = 0.0;
-  Msg(DEBUG, "%g %g", ZRepere, v->Pos.X);
-}
-
-void ConetoXYZ(void *a, void *dum)
-{
-  Vertex *v;
-  double d[3], z, x[3], prv[3];
-  double XX, YY, ZZ;
-  double inclinaison, teta, radiusact;
-
-  v = *(Vertex **) a;
-  d[0] = SURF->Cyl.zaxis[0];
-  d[1] = SURF->Cyl.zaxis[1];
-  d[2] = SURF->Cyl.zaxis[2];
-  norme(d);
-  x[0] = SURF->Cyl.xaxis[0];
-  x[1] = SURF->Cyl.xaxis[1];
-  x[2] = SURF->Cyl.xaxis[2];
-  norme(x);
-  prodve(d, x, prv);
-  norme(prv);
-  inclinaison = Pi * SURF->Cyl.radius2 / 180.;
-  z = (SURF->Cyl.radius1 - myhypot(v->Pos.X, v->Pos.Y)) / tan(inclinaison);
-  radiusact = (SURF->Cyl.radius1 + z * tan(inclinaison));
-  teta = atan2(v->Pos.Y, v->Pos.X);
-
-  XX = SURF->Cyl.center[0] + z * d[0] +
-    radiusact * cos(teta) * x[0] + radiusact * (sin(teta)) * prv[0];
-  YY = SURF->Cyl.center[1] + z * d[1] +
-    radiusact * cos(teta) * x[1] + radiusact * (sin(teta)) * prv[1];
-  ZZ = SURF->Cyl.center[2] + z * d[2] +
-    radiusact * cos(teta) * x[2] + radiusact * (sin(teta)) * prv[2];
-
-  v->Pos.X = XX;
-  v->Pos.Y = YY;
-  v->Pos.Z = ZZ;
-
-}
-
-int MeshCylindricalSurface(Surface * s)
-{
-  return 0;
-
-#if 0
-
-  int i, j, ori;
-  Curve *pC;
-  Vertex *v;
-  Tree_T *tnxe;
-  char text[256];
-  extern double MAXIMUM_LC_FOR_SURFACE;
-
-  if(s->Typ != MSH_SURF_CYLNDR && s->Typ != MSH_SURF_CONE
-     && s->Typ != MSH_SURF_TORUS)
-    return 0;
-  if(s->Typ == MSH_SURF_TORUS)
-    return 1;
-
-  Msg(DEBUG, "z %d : %12.5E %12.5E %12.5E", s->Num, s->Cyl.zaxis[0],
-      s->Cyl.zaxis[1], s->Cyl.zaxis[2]);
-  Msg(DEBUG, "x %d : %12.5E %12.5E %12.5E", s->Num, s->Cyl.xaxis[0],
-      s->Cyl.xaxis[1], s->Cyl.xaxis[2]);
-
-  SURF = s;
-
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &pC);
-    for(j = 0; j < List_Nbr(pC->Vertices); j++) {
-      List_Read(pC->Vertices, j, &v);
-      Tree_Insert(s->Vertices, List_Pointer(pC->Vertices, j));
-    }
-  }
-  THETAMIN = 2. * Pi;
-  THETAMAX = -2. * Pi;
-  Tree_Action(s->Vertices, THETAMINMAX);
-  Tree_Action(s->Vertices, Freeze_Vertex);
-
-  if(s->Typ == MSH_SURF_CYLNDR)
-    Tree_Action(s->Vertices, XYZtoTZ);
-  else if(s->Typ == MSH_SURF_CONE)
-    Tree_Action(s->Vertices, XYZtoCone);
-
-  Msg(DEBUG, "%12.5E %12.5E", THETAMAX, THETAMIN);
-
-  if((s->Typ == MSH_SURF_CYLNDR) && (THETAMAX - THETAMIN > Pi * 1.01))
-    Tree_Action(s->Vertices, ChangePi);
-
-  ori = Calcule_Contours(s);
-  MAXIMUM_LC_FOR_SURFACE = SURF->Cyl.radius1 / 3.;
-
-  if(CTX.mesh.algo2d == DELAUNAY_ISO)
-    Maillage_Automatique_VieuxCode(s, THEM, ori);
-  else if(CTX.mesh.algo2d == DELAUNAY_ANISO)
-    AlgorithmeMaillage2DAnisotropeModeJF(s);
-  else
-    Mesh_Triangle(s);
-
-  for(i = 0; i < CTX.mesh.nb_smoothing; i++) {
-    tnxe = Tree_Create(sizeof(NXE), compareNXE);
-    create_NXE(s->Vertices, s->Simplexes, tnxe);
-    Tree_Action(tnxe, ActionLiss);
-    Tree_Delete(tnxe);
-  }
-
-  if(s->Typ == MSH_SURF_CYLNDR)
-    Tree_Action(s->Vertices, TZtoXYZ);
-  else if(s->Typ == MSH_SURF_CONE)
-    Tree_Action(s->Vertices, ConetoXYZ);
-  Tree_Action(s->Vertices, deFreeze_Vertex);
-
-  return 1;
-
-#endif
-}
diff --git a/Mesh/2D_Elliptic.cpp b/Mesh/2D_Elliptic.cpp
deleted file mode 100644
index 31f4b9e09ebeaba26fcb5dd37140c3b0fd67c1d2..0000000000000000000000000000000000000000
--- a/Mesh/2D_Elliptic.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-// $Id: 2D_Elliptic.cpp,v 1.23 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-
-extern Mesh *THEM;
-
-static void getVertices(Vertex *start, Vertex *end, Curve *c[4], List_T *list)
-{
-  for(int i = 0; i < 4; i++) {
-    if(!compareVertex(&c[i]->beg, &start) && 
-       !compareVertex(&c[i]->end, &end)){
-      for(int j = 0; j < List_Nbr(c[i]->Vertices); j++)
-	List_Add(list, List_Pointer(c[i]->Vertices, j));
-      return;
-    }
-    if(!compareVertex(&c[i]->beg, &end) && 
-       !compareVertex(&c[i]->end, &start)){
-      for(int j = 0; j < List_Nbr(c[i]->Vertices); j++)
-	List_Add(list, List_Pointer(c[i]->Vertices, List_Nbr(c[i]->Vertices) - 1 - j));
-      return;
-    }
-  }
-}
-
-int MeshEllipticSurface(Surface * sur)
-{
-  if(sur->Method != ELLIPTIC)
-    return 0;
-
-  if(List_Nbr(sur->Generatrices) != 4 ||
-     List_Nbr(sur->TrsfPoints) != 4)
-    return 0;
-
-  Curve *GG[4];  
-  Vertex *S[4];
-  for(int i = 0; i < 4; i++) {
-    List_Read(sur->Generatrices, i, &GG[i]);
-    List_Read(sur->TrsfPoints, i, &S[i]);
-  }
-
-  List_T *l1 = List_Create(20, 10, sizeof(Vertex *));
-  getVertices(S[0], S[1], GG, l1);
-  List_T *l2 = List_Create(20, 10, sizeof(Vertex *));
-  getVertices(S[1], S[2], GG, l2);
-  List_T *l3 = List_Create(20, 10, sizeof(Vertex *));
-  getVertices(S[2], S[3], GG, l3);
-  List_T *l4 = List_Create(20, 10, sizeof(Vertex *));
-  getVertices(S[3], S[0], GG, l4);
-
-  int N1 = List_Nbr(l1);
-  int N2 = List_Nbr(l2);
-  int N3 = List_Nbr(l3);
-  int N4 = List_Nbr(l4);
-  if(!N1 || !N2 || !N3 || !N4 || (N1 != N3) || (N2 != N4)) {
-    Msg(WARNING, "Wrong definition of Elliptic Surface %d", sur->Num);
-    List_Delete(l1);
-    List_Delete(l2);
-    List_Delete(l3);
-    List_Delete(l4);
-    return 0;
-  }
-
-  sur->Nu = N1;
-  sur->Nv = N2;
-  Vertex **list = (Vertex **) Malloc(N1 * N2 * sizeof(Vertex *));
-
-  for(int i = 0; i < N1; i++) {
-    for(int j = 0; j < N2; j++) {
-      if(i == 0) {
-        List_Read(l4, N2 - j - 1, &list[i + N1 * j]);
-      }
-      else if(i == N1 - 1) {
-        List_Read(l2, j, &list[i + N1 * j]);
-      }
-      else if(j == 0) {
-        List_Read(l1, i, &list[i + N1 * j]);
-      }
-      else if(j == N2 - 1) {
-        List_Read(l3, N1 - i - 1, &list[i + N1 * j]);
-      }
-      else {
-        double u = 1. - 2. * (double)i / double (N1 - 1);
-        double v = 1. - 2. * (double)j / double (N2 - 1);
-        double x = 0.25 * ((S[0]->Pos.X * (1 + u) * (1. + v)) +
-			   (S[1]->Pos.X * (1 - u) * (1. + v)) +
-			   (S[2]->Pos.X * (1 - u) * (1. - v)) +
-			   (S[3]->Pos.X * (1 + u) * (1. - v)));
-        double y = 0.25 * ((S[0]->Pos.Y * (1 + u) * (1. + v)) +
-			   (S[1]->Pos.Y * (1 - u) * (1. + v)) +
-			   (S[2]->Pos.Y * (1 - u) * (1. - v)) +
-			   (S[3]->Pos.Y * (1 + u) * (1. - v)));
-        double z = 0.25 * ((S[0]->Pos.Z * (1 + u) * (1. + v)) +
-			   (S[1]->Pos.Z * (1 - u) * (1. + v)) +
-			   (S[2]->Pos.Z * (1 - u) * (1. - v)) +
-			   (S[3]->Pos.Z * (1 + u) * (1. - v)));
-        double lc = 0.25 * ((S[0]->lc * (1 + u) * (1. + v)) +
-			    (S[1]->lc * (1 - u) * (1. + v)) +
-			    (S[2]->lc * (1 - u) * (1. - v)) +
-			    (S[3]->lc * (1 + u) * (1. - v)));
-        list[i + N1 * j] = Create_Vertex(++THEM->MaxPointNum, x, y, z, lc, 0.0);
-      }
-    }
-  }
-
-  for(int i = 0; i < N1; i++){
-    for(int j = 0; j < N2; j++){
-      Tree_Insert(sur->Vertices, &list[i + N1 * j]);
-      List_Add(sur->TrsfVertices, &list[i + N1 * j]);
-    }
-  }
-
-  List_Delete(l1);
-  List_Delete(l2);
-  List_Delete(l3);
-  List_Delete(l4);
-
-  int k = 0;
-  while(1) {
-    k++;
-    if(k > 1000)
-      break;
-    for(int i = 1; i < N1 - 1; i++) {
-      for(int j = 1; j < N2 - 1; j++) {
-        Vertex *v11 = list[i - 1 + N1 * (j - 1)];
-        Vertex *v12 = list[i + N1 * (j - 1)];
-        Vertex *v13 = list[i + 1 + N1 * (j - 1)];
-        Vertex *v21 = list[i - 1 + N1 * (j)];
-	Vertex *v22 = list[i + N1 * (j)];
-	Vertex *v23 = list[i + 1 + N1 * (j)];
-	Vertex *v31 = list[i - 1 + N1 * (j + 1)];
-	Vertex *v32 = list[i + N1 * (j + 1)];
-	Vertex *v33 = list[i + 1 + N1 * (j + 1)];
-	
-	double alpha = 0.25 * (DSQR(v23->Pos.X - v21->Pos.X) +
-			       DSQR(v23->Pos.Y - v21->Pos.Y));
-        double gamma = 0.25 * (DSQR(v32->Pos.X - v12->Pos.X) +
-			       DSQR(v32->Pos.Y - v12->Pos.Y));
-        double beta = 0.0625 * ((v32->Pos.X - v12->Pos.X) *
-				(v23->Pos.X - v21->Pos.X) +
-				(v32->Pos.Y - v12->Pos.Y) *
-				(v23->Pos.Y - v21->Pos.Y));
-	
-        v22->Pos.X = 0.5 * (alpha * (v32->Pos.X + v12->Pos.X) +
-                            gamma * (v23->Pos.X + v21->Pos.X) -
-                            2. * beta * (v33->Pos.X - v13->Pos.X -
-                                         v31->Pos.X + v11->Pos.X))
-          / (alpha + gamma);
-        v22->Pos.Y = 0.5 * (alpha * (v32->Pos.Y + v12->Pos.Y) +
-                            gamma * (v23->Pos.Y + v21->Pos.Y) -
-                            2. * beta * (v33->Pos.Y - v13->Pos.Y -
-                                         v31->Pos.Y + v11->Pos.Y))
-          / (alpha + gamma);
-        v22->Pos.Z = 0.5 * (alpha * (v32->Pos.Z + v12->Pos.Z) +
-                            gamma * (v23->Pos.Z + v21->Pos.Z) -
-                            2. * beta * (v33->Pos.Z - v13->Pos.Z -
-                                         v31->Pos.Z + v11->Pos.Z))
-          / (alpha + gamma);
-      }
-    }
-  }
-
-  for(int i = 0; i < N1 - 1; i++) {
-    for(int j = 0; j < N2 - 1; j++) {
-      if(sur->Recombine) {
-        Quadrangle *q = Create_Quadrangle
-          (list[(i) + N1 * (j)], list[(i + 1) + N1 * (j)],
-           list[(i + 1) + N1 * (j + 1)], list[i + N1 * (j + 1)]);
-        q->iEnt = sur->Num;
-        Tree_Add(sur->Quadrangles, &q);
-      }
-      else {
-	Simplex *simp = Create_Simplex(list[(i) + N1 * (j)], list[(i + 1) + N1 * (j)],
-				       list[(i) + N1 * (j + 1)], NULL);
-        simp->iEnt = sur->Num;
-        Tree_Add(sur->Simplexes, &simp);
-	
-        simp = Create_Simplex(list[(i + 1) + N1 * (j + 1)],
-			      list[(i) + N1 * (j + 1)], list[(i + 1) + N1 * (j)],
-			      NULL);
-        simp->iEnt = sur->Num;
-        Tree_Add(sur->Simplexes, &simp);
-      }
-    }
-  }
-
-  Free(list);
-
-  return 1;
-}
diff --git a/Mesh/2D_InitMesh.cpp b/Mesh/2D_InitMesh.cpp
deleted file mode 100644
index 4fdcc883f48e80b37752391a0713a4b5ce4bdee2..0000000000000000000000000000000000000000
--- a/Mesh/2D_InitMesh.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-// $Id: 2D_InitMesh.cpp,v 1.22 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-/*
- 
-   Generation du maillage initial 2D
-
-   Dans l'algorithme de maillage, on doit creer un maillage initial a l'aide
-   de contours orientes aire a doite. Deux types de problemes peuvent se presenter :
-
-       1) probleme courant : un triangle se trouve a l'exterieur du contour, il faut
-       que sa variable de localisation soit declaree externe.  
-
-       2) probleme rare : une arete du contour n'a pas ete creee
-
-       On procede comme suit :
-       trouve le triangle, on procede de la facon suivante :
-          - on trie les aretes de tous les triangles ;
-          - Pour chaque contour on prend chaque arete orientee ;
-          - Si cette arete n'existe pas (bsearch return false) alors on cherche
-          les 2 triangles reliant cette arete et on les modifie
-          - Si cette arete possede 2 triangles adjacents, on declare externe 
-          le triangle dont le troisieme noeud se trouve a gauche de l'arete.
-
-          illustration
-          ------------
-
-          probleme 1) + = point du contour
-          
-
-                                        3
-                        - -  + --------+     +
-                   + - -     1 \      /                +
-                                \    /                       +
-                                 \  /                                   +
-             +                     +
-                                   2       3 a gauche de 1-2 -> tr externe
-
-
-           probleme 2) arete inexistante 1-2
-           
-                       +,*,@ contours
-           
-                     +1                      +            
-                    / \                     /|\
-                   /   \                   / | \
-                  /     \                 /  |  \
-                 /       \               /   |   \
-                *         @   --->      *----+----@ 
-                 \       /               \   |   /
-                  \     /                 \  |  /
-                   \   /                   \ | /
-                    \ /                     \|/
-                     +2                      +
-
-*/
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-
-extern PointRecord *gPointArray;
-
-static Tree_T *ETree = NULL, *EDToSwap = NULL;
-static int pointA, pointB, Counter, Stagnant, StopNow;
-static int *permut;
-
-typedef struct
-{
-  int from;
-  int to;
-  int NbOccur;
-  Delaunay *Liste[2];
-}
-ED;
-
-
-void makepermut(int numpoints)
-{
-  int i, ip;
-  permut = (int *)Malloc(numpoints * sizeof(int));      //Memory leak! this is never freed...
-  for(i = 0; i < numpoints; i++) {
-    ip = gPointArray[i].permu;
-    permut[ip] = i;
-  }
-}
-
-int crossED(ED * e)
-{
-  double Xma, Xmb, Yma, Ymb, det, t, q;
-  double XMa, XMb, YMa, YMb;
-  double xa1, xa2, ya1, ya2;
-  double xb1, xb2, yb1, yb2;
-
-  xa1 = gPointArray[pointA].where.h;
-  xa2 = gPointArray[pointB].where.h;
-  ya1 = gPointArray[pointA].where.v;
-  ya2 = gPointArray[pointB].where.v;
-
-  xb1 = gPointArray[e->from].where.h;
-  xb2 = gPointArray[e->to].where.h;
-  yb1 = gPointArray[e->from].where.v;
-  yb2 = gPointArray[e->to].where.v;
-
-  Xma = DMIN(xa1, xa2);
-  Xmb = DMIN(xb1, xb2);
-
-  XMa = DMAX(xa1, xa2);
-  XMb = DMAX(xb1, xb2);
-
-  if(XMa < Xmb || XMb < Xma)
-    return (0);
-
-  Yma = DMIN(ya1, ya2);
-  Ymb = DMIN(yb1, yb2);
-
-  YMa = DMAX(ya1, ya2);
-  YMb = DMAX(yb1, yb2);
-
-  if(YMa < Ymb || YMb < Yma)
-    return (0);
-
-  det = (xa2 - xa1) * (yb1 - yb2) - (xb1 - xb2) * (ya2 - ya1);
-
-  if(det == 0.0) {
-    return (0);
-  }
-
-  t = ((xb1 - xa1) * (yb1 - yb2) - (xb1 - xb2) * (yb1 - ya1)) / det;
-  q = ((xa2 - xa1) * (yb1 - ya1) - (ya2 - ya1) * (xb1 - xa1)) / det;
-
-  if(t > 1. || t < 0.)
-    return (0);
-  if(q > 1. || q < 0.)
-    return (0);
-
-  //printf("t=%g  q=%g  det=%g\n", t, q, det);
-
-  return (1);
-}
-
-int compareED2(const void *a, const void *b)
-{
-  ED *q, *w;
-  q = (ED *) a;
-  w = (ED *) b;
-  if(q->NbOccur > w->NbOccur)
-    return (-1);
-  if(q->NbOccur < w->NbOccur)
-    return (1);
-  if(q->from > w->from)
-    return (1);
-  if(q->from < w->from)
-    return (-1);
-  if(q->to > w->to)
-    return (1);
-  if(q->to < w->to)
-    return (-1);
-  return (0);
-}
-
-int compareED(const void *a, const void *b)
-{
-  ED *q, *w;
-  q = (ED *) a;
-  w = (ED *) b;
-  if(q->from > w->from)
-    return (1);
-  if(q->from < w->from)
-    return (-1);
-  if(q->to > w->to)
-    return (1);
-  if(q->to < w->to)
-    return (-1);
-  return (0);
-}
-
-void DoWeSwapED(void *data, void *dummy)
-{
-  ED *e;
-
-  e = (ED *) data;
-
-  if(e->from == pointA || e->from == pointB ||
-     e->to == pointA || e->to == pointB) {
-    return;
-  }
-  else if(Tree_PQuery(EDToSwap, e)) {
-  }
-  else if(crossED(e)) {
-    Tree_Add(EDToSwap, e);
-  }
-}
-
-void Print(void *data, void *dummy)
-{
-  ED *e;
-
-  e = (ED *) data;
-  Msg(INFO, "%d %d", e->from, e->to);
-}
-
-void SwapED(void *data, void *dummy)
-{
-  ED *e, E;
-  int from = 0, to = 0;
-
-  e = (ED *) data;
-
-  if(Stagnant && Counter <= StopNow)
-    return;
-  else if(Stagnant)
-    Counter++;
-
-  if(!e->Liste[0] || !e->Liste[1]) {
-    Msg(GERROR, "Initial mesh is wrong. Try the new isotropic algorithm.");
-    return;
-  }
-
-  if(e->from != e->Liste[0]->t.a && e->from != e->Liste[0]->t.b &&
-     e->from != e->Liste[0]->t.c)
-    return;
-  if(e->from != e->Liste[1]->t.a && e->from != e->Liste[1]->t.b &&
-     e->from != e->Liste[1]->t.c)
-    return;
-  if(e->to != e->Liste[0]->t.a && e->to != e->Liste[0]->t.b &&
-     e->to != e->Liste[0]->t.c)
-    return;
-  if(e->to != e->Liste[1]->t.a && e->to != e->Liste[1]->t.b &&
-     e->to != e->Liste[1]->t.c)
-    return;
-
-
-  if(e->from != e->Liste[0]->t.a && e->to != e->Liste[0]->t.a)
-    from = e->Liste[0]->t.a;
-  else if(e->from != e->Liste[0]->t.b && e->to != e->Liste[0]->t.b)
-    from = e->Liste[0]->t.b;
-  else if(e->from != e->Liste[0]->t.c && e->to != e->Liste[0]->t.c)
-    from = e->Liste[0]->t.c;
-
-  if(e->from != e->Liste[1]->t.a && e->to != e->Liste[1]->t.a)
-    to = e->Liste[1]->t.a;
-  else if(e->from != e->Liste[1]->t.b && e->to != e->Liste[1]->t.b)
-    to = e->Liste[1]->t.b;
-  else if(e->from != e->Liste[1]->t.c && e->to != e->Liste[1]->t.c)
-    to = e->Liste[1]->t.c;
-
-  pointA = e->from;
-  pointB = e->to;
-  E.from = from;
-  E.to = to;
-  if(!crossED(&E))
-    return;
-
-  e->Liste[0]->t.a = from;
-  e->Liste[0]->t.b = to;
-  e->Liste[0]->t.c = e->from;
-
-  e->Liste[1]->t.a = from;
-  e->Liste[1]->t.b = to;
-  e->Liste[1]->t.c = e->to;
-
-  e->from = IMAX(from, to);
-  e->to = IMIN(from, to);
-}
-
-void SuppressInETree(void *data, void *dummy)
-{
-  if(!Tree_Suppress(ETree, data))
-    Msg(WARNING, "Cannot suppress in ETree");
-}
-
-void AddInETree(void *data, void *dummy)
-{
-  Tree_Add(ETree, data);
-}
-
-int verifie_cas_scabreux(int pa, int pb, ContourRecord ** ListContours,
-                         int Nc)
-{
-  ED Edge;
-  int i, k, a, b;
-  ContourRecord *contour;
-
-
-  Edge.from = IMAX(pa, pb);
-  Edge.to = IMIN(pa, pb);
-  for(k = 0; k < Nc; k++) {
-    contour = ListContours[k];
-    for(i = -1; i < (contour->numpoints - 1); i++) {
-      if(i == -1) {
-        a = permut[contour->oriented_points[0].permu];
-        b = permut[contour->oriented_points[contour->numpoints - 1].permu];
-      }
-      else {
-        a = permut[contour->oriented_points[i].permu];
-        b = permut[contour->oriented_points[i + 1].permu];
-      }
-
-      pointA = IMAX(a, b);
-      pointB = IMIN(a, b);
-      if(a != pa && b != pa && a != pb && b != pb)
-        if(crossED(&Edge))
-          return (1);
-    }
-  }
-  return (0);
-}
-
-void verify_edges(List_T * ListDelaunay, ContourRecord ** ListContour,
-                  int NumContours)
-{
-
-  ED *pEdge;
-  ED Edge;
-  int ok, max, i, k, c, a, b;
-  ContourRecord *contour;
-  Delaunay *del_P;
-
-  max = 100;
-
-  c = 0;
-  do {
-    c++;
-    if(c > max)
-      break;
-    ETree = Tree_Create(sizeof(Edge), compareED);
-    for(i = 0; i < List_Nbr(ListDelaunay); i++) {
-
-      del_P = *(Delaunay **) List_Pointer(ListDelaunay, i);
-
-      Edge.from = IMAX(del_P->t.a, del_P->t.b);
-      Edge.to = IMIN(del_P->t.a, del_P->t.b);
-      Edge.NbOccur = 1;
-
-      if((pEdge = (ED *) Tree_PQuery(ETree, &Edge))) {
-        pEdge->Liste[1] = del_P;
-      }
-      else {
-        Edge.Liste[0] = del_P;
-        Edge.Liste[1] = NULL;
-        Tree_Add(ETree, &Edge);
-      }
-
-      Edge.from = IMAX(del_P->t.a, del_P->t.c);
-      Edge.to = IMIN(del_P->t.a, del_P->t.c);
-
-      if((pEdge = (ED *) Tree_PQuery(ETree, &Edge))) {
-        pEdge->Liste[1] = del_P;
-      }
-      else {
-        Edge.Liste[0] = del_P;
-        Edge.Liste[1] = NULL;
-        Tree_Add(ETree, &Edge);
-      }
-
-      Edge.from = IMAX(del_P->t.c, del_P->t.b);
-      Edge.to = IMIN(del_P->t.c, del_P->t.b);
-
-      if((pEdge = (ED *) Tree_PQuery(ETree, &Edge))) {
-        pEdge->Liste[1] = del_P;
-      }
-      else {
-        Edge.Liste[0] = del_P;
-        Edge.Liste[1] = NULL;
-        Tree_Add(ETree, &Edge);
-      }
-    }
-
-    ok = 0;
-    for(k = 0; k < NumContours; k++) {
-      contour = ListContour[k];
-      for(i = -1; i < contour->numpoints - 1; i++) {
-
-        if(i == -1) {
-          a = permut[contour->oriented_points[0].permu];
-          b = permut[contour->oriented_points[contour->numpoints - 1].permu];
-        }
-        else {
-          a = permut[contour->oriented_points[i].permu];
-          b = permut[contour->oriented_points[i + 1].permu];
-        }
-
-        Edge.from = IMAX(a, b);
-        Edge.to = IMIN(a, b);
-
-        if(!Tree_Search(ETree, &Edge))
-          ok++;;
-      }
-    }
-
-    if(!ok) {
-      return;
-    }
-
-    Msg(INFO, "Swapping (%d missing edges)", ok);
-
-    //EDToSwap = NULL;
-    if(EDToSwap)
-      Tree_Delete(EDToSwap);
-    EDToSwap = Tree_Create(sizeof(ED), compareED2);
-    for(k = 0; k < NumContours; k++) {
-      contour = ListContour[k];
-      for(i = -1; i < contour->numpoints - 1; i++) {
-
-        if(i == -1) {
-          a = permut[contour->oriented_points[0].permu];
-          b = permut[contour->oriented_points[contour->numpoints - 1].permu];
-        }
-        else {
-          a = permut[contour->oriented_points[i].permu];
-          b = permut[contour->oriented_points[i + 1].permu];
-        }
-
-        pointA = IMAX(a, b);
-        pointB = IMIN(a, b);
-
-        Tree_Action(ETree, DoWeSwapED);
-
-      }
-    }
-    Msg(INFO, "Elimination (%d swaps)", Tree_Nbr(EDToSwap));
-
-    Tree_Action(EDToSwap, SuppressInETree);
-    Tree_Action(EDToSwap, SwapED);
-    Tree_Action(EDToSwap, AddInETree);
-  } while(Tree_Nbr(EDToSwap));
-
-  Tree_Delete(EDToSwap);
-  Tree_Delete(ETree);
-
-}
-
-
-
-int comparepermu(const void *i, const void *j)
-{
-  return (gPointArray[*(PointNumero *) i].permu -
-          gPointArray[*(PointNumero *) j].permu);
-}
-
-void verify_inside(Delaunay * ListDelaunay, int NumDelaunay)
-{
-
-  PointNumero pt[3], compare, a, b;
-  int i, inside, cont[3];
-
-  for(i = 0; i < NumDelaunay; i++) {
-
-    pt[0] = ListDelaunay[i].t.a;
-    pt[1] = ListDelaunay[i].t.b;
-    pt[2] = ListDelaunay[i].t.c;
-    qsort(pt, 3, sizeof(PointNumero), comparepermu);
-
-    cont[0] = gPointArray[pt[0]].numcontour;
-    cont[1] = gPointArray[pt[1]].numcontour;
-    cont[2] = gPointArray[pt[2]].numcontour;
-
-
-    if((cont[1] != cont[2]) || (cont[0] != cont[1]) || (cont[0] != cont[2]))
-      inside = 1;
-    else
-      inside = 0;
-
-
-    a = pt[0];
-    b = pt[1];
-    compare = pt[2];
-
-    if((Is_left_of(a, b, compare) && (inside == 0))) {
-      ListDelaunay[i].t.position = EXTERN;
-    }
-
-  }
-  return;
-
-}
diff --git a/Mesh/2D_Links.cpp b/Mesh/2D_Links.cpp
deleted file mode 100644
index af549451145a0c8854339963354b4c4de2d93c37..0000000000000000000000000000000000000000
--- a/Mesh/2D_Links.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-// $Id: 2D_Links.cpp,v 1.21 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-#include "Context.h"
-
-extern Context_T CTX;
-extern PointRecord *gPointArray;
-extern DocRecord *FGMESH;
-
-extern PointNumero First(PointNumero x);
-
-/* compte les points sur le polygone convexe */
-
-int CountPointsOnHull(int n, PointRecord * pPointArray)
-{
-  PointNumero p, p2, temp;
-  int i;
-
-  if(pPointArray[0].adjacent == NULL)
-    return 0;
-  i = 1;
-  p = 0;
-  p2 = First(0);
-  while((p2 != 0) && (i < n)) {
-    i++;
-    temp = p2;
-    p2 = Successor(p2, p);
-    p = temp;
-  }
-  return ((i <= n) ? i : -1);
-}
-
-
-PointNumero *ConvertDlistToArray(DListPeek * dlist, int *n)
-{
-  DListPeek p, temp;
-  int i, max = 0;
-  PointNumero *ptr;
-
-  p = *dlist;
-  do {
-    max++;
-    p = Pred(p);
-  } while(p != *dlist);
-  ptr = (PointNumero *) Malloc((max + 1) * sizeof(PointNumero));
-  if(ptr == NULL)
-    return NULL;
-  p = *dlist;
-  for(i = 0; i < max; i++) {
-    ptr[i] = p->point_num;
-    temp = p;
-    p = Pred(p);
-    Free(temp);
-  }
-  ptr[max] = ptr[0];
-  *dlist = NULL;
-  *n = max;
-  return ptr;
-}
-
-
-/* Convertir les listes d'adjacence en triangles */
-
-int Conversion(DocPeek doc)
-{
-  /* on suppose que n >= 3      gPointArray est suppose OK. */
-
-  Striangle *striangle;
-  int n, i, j;
-  int count = 0, count2 = 0;
-  PointNumero aa, bb, cc;
-  PointRecord *ptemp;
-
-  ptemp = gPointArray;
-  gPointArray = doc->points;
-
-  n = doc->numPoints;
-  striangle = (Striangle *) Malloc(n * sizeof(Striangle));
-  count2 = (int)CountPointsOnHull(n, doc->points);
-
-  /* nombre de triangles que l'on doit obtenir */
-  count2 = 2 * (n - 1) - count2;
-
-  if(doc->delaunay)
-    Free(doc->delaunay);
-
-  doc->delaunay = (Delaunay *) Malloc(2 * count2 * sizeof(Delaunay));
-
-  for(i = 0; i < n; i++) {
-    /* on cree une liste de points connectes au point i (t) + nombre de points (t_length) */
-    striangle[i].t =
-      ConvertDlistToArray(&gPointArray[i].adjacent, &striangle[i].t_length);
-    striangle[i].info = NULL;
-    striangle[i].info_length = 0;
-  }
-
-  /* on balaye les noeuds de gauche a droite -> on cree les triangles  */
-  count = 0;
-  for(i = 0; i < n; i++) {
-    for(j = 0; j < striangle[i].t_length; j++) {
-      if((striangle[i].t[j] > i) && (striangle[i].t[j + 1] > i) &&
-         (Is_right_of(i, striangle[i].t[j], striangle[i].t[j + 1]))) {
-        aa = i;
-        bb = striangle[i].t[j];
-        cc = striangle[i].t[j + 1];
-        filldel(&doc->delaunay[count], aa, bb, cc, gPointArray, NULL);
-        count++;
-      }
-    }
-  }
-  for(i = 0; i < n; i++)
-    Free(striangle[i].t);
-  Free(striangle);
-  doc->numTriangles = count2;
-  gPointArray = ptemp;
-  return (1);
-}
-
-
-int compareedge(const void *e1, const void *e2)
-{
-  PointNumero tmp;
-
-  if((tmp = ((edge *) e1)->from - ((edge *) e2)->from) != 0)
-    return (tmp);
-  return (((edge *) e1)->to - ((edge *) e2)->to);
-}
-
-/* pour la liste de delaunays ListDelaunay, CreateLinks cree les liens entre
-   triangles c.a.d determine les voisins de chaque triangle                  */
-
-int CreateLinks(List_T * ListDelaunay, int NumDelaunay,
-                ContourRecord ** ListContours, int Nc)
-{
-  int i;
-  edge *ListEdges;
-  MPoint pt;
-  Delaunay *del_Pi, *del_Pj;
-
-  ListEdges = (edge *) Malloc((3 * NumDelaunay + 1) * sizeof(edge));
-
-  ListEdges[3 * NumDelaunay].num = 0;
-  ListEdges[3 * NumDelaunay].from = 0;
-  ListEdges[3 * NumDelaunay].to = 0;
-
-  for(i = 0; i < NumDelaunay; i++) {
-
-    del_Pi = *(Delaunay **) List_Pointer(ListDelaunay, i);
-
-    /* arete a b */
-    if(del_Pi->t.a > del_Pi->t.b) {
-      ListEdges[3 * i].from = del_Pi->t.a;
-      ListEdges[3 * i].to = del_Pi->t.b;
-      ListEdges[3 * i].num = i;
-    }
-    else {
-      ListEdges[3 * i].from = del_Pi->t.b;
-      ListEdges[3 * i].to = del_Pi->t.a;
-      ListEdges[3 * i].num = i;
-    }
-
-    /* arete  b c */
-    if(del_Pi->t.b > del_Pi->t.c) {
-      ListEdges[3 * i + 1].from = del_Pi->t.b;
-      ListEdges[3 * i + 1].to = del_Pi->t.c;
-      ListEdges[3 * i + 1].num = i;
-    }
-    else {
-      ListEdges[3 * i + 1].from = del_Pi->t.c;
-      ListEdges[3 * i + 1].to = del_Pi->t.b;
-      ListEdges[3 * i + 1].num = i;
-    }
-
-    /* arete   c a */
-    if(del_Pi->t.c > del_Pi->t.a) {
-      ListEdges[3 * i + 2].from = del_Pi->t.c;
-      ListEdges[3 * i + 2].to = del_Pi->t.a;
-      ListEdges[3 * i + 2].num = i;
-    }
-    else {
-      ListEdges[3 * i + 2].from = del_Pi->t.a;
-      ListEdges[3 * i + 2].to = del_Pi->t.c;
-      ListEdges[3 * i + 2].num = i;
-    }
-
-  }
-
-  qsort(ListEdges, 3 * NumDelaunay, sizeof(edge), compareedge);
-
-  i = 0;
-
-  do {
-
-    if((ListEdges[i].from == ListEdges[i + 1].from) &&
-       (ListEdges[i].to == ListEdges[i + 1].to)) { 
-      /* create link */
-
-      del_Pi = *(Delaunay **) List_Pointer(ListDelaunay, ListEdges[i].num);
-      del_Pj = *(Delaunay **) List_Pointer(ListDelaunay, ListEdges[i + 1].num);
-
-      if((del_Pi->t.position != EXTERN) &&
-         (del_Pj->t.position != EXTERN) &&
-         ((del_Pj->t.info == TOLINK) || (del_Pi->t.info == TOLINK))) {
-
-        if(del_Pi->v.voisin1 == NULL)
-          del_Pi->v.voisin1 = del_Pj;
-        else if(del_Pi->v.voisin2 == NULL)
-          del_Pi->v.voisin2 = del_Pj;
-        else if(del_Pi->v.voisin3 == NULL)
-          del_Pi->v.voisin3 = del_Pj;
-        else
-          Msg(GERROR, "Bad link for triangle");
-
-        if(del_Pj->v.voisin1 == NULL)
-          del_Pj->v.voisin1 = del_Pi;
-        else if(del_Pj->v.voisin2 == NULL)
-          del_Pj->v.voisin2 = del_Pi;
-        else if(del_Pj->v.voisin3 == NULL)
-          del_Pj->v.voisin3 = del_Pi;
-        else
-          Msg(GERROR, "Bad link for triangle");
-      }
-      i += 2;
-    }
-    else{
-      i++;
-    }
-  } while(i < 3 * NumDelaunay);
-
-  Free(ListEdges);
-
-  for(i = 0; i < NumDelaunay; i++) {
-    del_Pi = *(Delaunay **) List_Pointer(ListDelaunay, i);
-
-    if(del_Pi->t.position != EXTERN) {
-      pt.h = del_Pi->t.xc;
-      pt.v = del_Pi->t.yc;
-
-      if(!PtInTriangle(pt, del_Pi->t.a, del_Pi->t.b, del_Pi->t.c)) {
-        if(!Find_Triangle(pt, FGMESH, A_TOUT_PRIX)) {
-          del_Pi->t.quality_value /= 1000.;
-        }
-      }
-    }
-  }
-
-  return (1);
-}
diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
deleted file mode 100644
index 2fafc18fed01dfabd6c951162c46a649484640e1..0000000000000000000000000000000000000000
--- a/Mesh/2D_Mesh.cpp
+++ /dev/null
@@ -1,948 +0,0 @@
-// $Id: 2D_Mesh.cpp,v 1.87 2006-08-19 08:26:47 remacle Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "Utils.h"
-#include "Create.h"
-#include "2D_Mesh.h"
-#include "Context.h"
-#include "Interpolation.h"
-
-extern Mesh *THEM;
-extern Context_T CTX;
-
-PointRecord *gPointArray;
-DocRecord *BGMESH, *FGMESH;
-double LC2D;
-
-static Surface *THESURFACE, *THESUPPORT;
-
-void ProjetteSurface(void *a, void *b)
-{
-  Vertex *v;
-  v = *(Vertex **) a;
-
-  if(!v->ListCurves)
-    ProjectPointOnSurface(THESUPPORT, *v);
-}
-
-void Projette_Plan_Moyen(void *a, void *b)
-{
-  Vertex *v = *(Vertex **) a;
-  Projette(v, THESURFACE->plan);
-}
-
-void Projette_Inverse(void *a, void *b)
-{
-  Vertex *v = *(Vertex **) a;
-  Projette(v, THESURFACE->invplan);
-}
-
-void Plan_Moyen(void *data, void *dum)
-{
-  int i, j;
-  Vertex *v;
-  Curve *pC;
-  static List_T *points;
-  static int deb = 1;
-
-  Surface *s = *(Surface **) data;
-
-  if(deb) {
-    points = List_Create(10, 10, sizeof(Vertex *));
-    deb = 0;
-  }
-  else
-    List_Reset(points);
-
-  switch (s->Typ) {
-  case MSH_SURF_PLAN:
-  case MSH_SURF_TRIC:
-  case MSH_SURF_REGL:
-  case MSH_SURF_NURBS:
-  case MSH_SURF_TRIMMED:
-    for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-      List_Read(s->Generatrices, i, &pC);
-      for(j = 0; j < List_Nbr(pC->Vertices); j++) {
-        List_Read(pC->Vertices, j, &v);
-        List_Add(points, &v);
-        Tree_Insert(s->Vertices, List_Pointer(pC->Vertices, j));
-      }
-    }
-    break;
-  }
-
-  MeanPlane(points, s);
-}
-
-
-int Calcule_Contours(Surface * s)
-{
-  int i, j, ori, ORI = 0;
-  Vertex *v, *first, *last;
-  List_T *l, *linv;
-  Curve *c;
-  double n[] = { 0., 0., 1. };
-
-  l = List_Create(10, 10, sizeof(Vertex *));
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &c);
-    if(!List_Nbr(c->Vertices)) {
-      Msg(GERROR, "Curve %d has no mesh", c->Num);
-      return 0;
-    }
-    if(!List_Nbr(l)) {
-      List_Read(c->Vertices, 0, &first);
-    }
-    for(j = 1; j < List_Nbr(c->Vertices); j++) {
-      List_Read(c->Vertices, j, &v);
-      List_Add(l, &v);
-      if(j == List_Nbr(c->Vertices) - 1) {
-        last = v;
-      }
-    }
-    if(!compareVertex(&last, &first)) {
-      ori = Oriente(l, n);
-
-      /* Le premier contour est oriente aire a droite
-         Les autes sont des trous orientes aire a gauche */
-
-      if(!List_Nbr(s->Contours))
-        ORI = ori;
-
-      if((!List_Nbr(s->Contours) && !ori) || (List_Nbr(s->Contours) && ori)) {
-        linv = List_Create(10, 10, sizeof(Vertex *));
-        List_Invert(l, linv);
-        List_Delete(l);
-        l = linv;
-      }
-      List_Add(s->Contours, &l);
-      l = List_Create(10, 10, sizeof(Vertex *));
-    }
-  }
-  return ORI;
-}
-
-
-void Calcule_Z(void *data, void *dum)
-{
-  Vertex **pv, *v;
-  double Z, U, V;
-
-  pv = (Vertex **) data;
-  v = *pv;
-  if(v->Frozen || v->Num < 0)
-    return;
-
-  XYtoUV(THESUPPORT, &v->Pos.X, &v->Pos.Y, &U, &V, &Z, 1.0);
-  v->Pos.Z = Z;
-}
-
-void Calcule_Z_Plan(void *data, void *dum)
-{
-  Vertex **pv, *v;
-  Vertex V;
-
-  V.Pos.X = THESURFACE->a;
-  V.Pos.Y = THESURFACE->b;
-  V.Pos.Z = THESURFACE->c;
-
-  Projette(&V, THESURFACE->plan);
-
-  pv = (Vertex **) data;
-  v = *pv;
-  if(V.Pos.Z != 0.0)
-    v->Pos.Z = (THESURFACE->d - V.Pos.X * v->Pos.X - V.Pos.Y * v->Pos.Y)
-      / V.Pos.Z;
-  else
-    v->Pos.Z = 0.0;
-}
-
-
-void Add_In_Mesh(void *a, void *b)
-{
-  if(!Tree_Search(THEM->Vertices, a))
-    Tree_Add(THEM->Vertices, a);
-}
-
-void Freeze_Vertex(void *a, void *b)
-{
-  Vertex *pv;
-  pv = *(Vertex **) a;
-  pv->Freeze.X = pv->Pos.X;
-  pv->Freeze.Y = pv->Pos.Y;
-  pv->Freeze.Z = pv->Pos.Z;
-  pv->Frozen = 1;
-}
-
-void deFreeze_Vertex(void *a, void *b)
-{
-  Vertex *pv;
-  pv = *(Vertex **) a;
-  if(!pv->Frozen)
-    return;
-  pv->Pos.X = pv->Freeze.X;
-  pv->Pos.Y = pv->Freeze.Y;
-  pv->Pos.Z = pv->Freeze.Z;
-  pv->Frozen = 0;
-}
-
-void PutVertex_OnSurf(void *a, void *b)
-{
-  Vertex *pv;
-  pv = *(Vertex **) a;
-  if(!pv->ListSurf)
-    pv->ListSurf = List_Create(1, 1, sizeof(Surface *));
-  List_Add(pv->ListSurf, &THESURFACE);
-}
-
-
-/* remplis la structure Delaunay d'un triangle cree */
-
-Delaunay *testconv(avlptr *root, int *conv, DocRecord * ptr)
-{
-  double qual;
-  Delaunay *pdel = NULL;
-
-  *conv = 0;
-  if(*root == NULL)
-    *conv = 1;
-  else {
-    pdel = findrightest(*root, ptr);
-    qual = pdel->t.quality_value;
-    if(qual < CONV_VALUE)
-      *conv = 1;
-  }
-  return pdel;
-}
-
-
-int mesh_domain(ContourPeek * ListContours, int numcontours,
-                maillage * mai, int *numpoints, int OnlyTheInitialMesh)
-{
-  List_T *kill_L, *del_L;
-  MPoint pt;
-  DocRecord docm, *doc;
-  int conv, i, j, nump, numact, numlink, numkil, numaloc, numtri, numtrr,
-    numtrwait;
-  Delaunay *del, *del_P, *deladd;
-  PointNumero aa, bb, cc, a, b, c;
-  DListPeek list, p, q;
-  avlptr *root, *root_w;
-  double volume_old, volume_new;
-
-  root = (avlptr *) Malloc(sizeof(avlptr));
-  root_w = (avlptr *) Malloc(sizeof(avlptr));
-
-  nump = 0;
-  for(i = 0; i < numcontours; i++)
-    nump += ListContours[i]->numpoints;
-
-  /* creation du maillage initial grace au puissant algorithme "divide and conquer" */
-
-  doc = &docm;
-  FGMESH = &docm;
-  doc->points = (PointRecord *) Malloc((nump + 100) * sizeof(PointRecord));
-  gPointArray = doc->points;
-
-  numaloc = nump;
-  doc->delaunay = 0;
-  doc->numPoints = nump;
-  doc->numTriangles = 0;
-  mai->numtriangles = 0;
-  mai->numpoints = 0;
-
-  if(!numcontours) {
-    Msg(GERROR, "No contour");
-    return -1;
-  }
-
-  numact = 0;
-  for(i = 0; i < numcontours; i++) {
-    for(j = 0; j < ListContours[i]->numpoints; j++) {
-      doc->points[numact + j].where.h =
-        ListContours[i]->oriented_points[j].where.h
-        + ListContours[i]->perturbations[j].h;
-      doc->points[numact + j].where.v =
-        ListContours[i]->oriented_points[j].where.v
-        + ListContours[i]->perturbations[j].v;
-      doc->points[numact + j].quality =
-        ListContours[i]->oriented_points[j].quality;
-      doc->points[numact + j].initial =
-        ListContours[i]->oriented_points[j].initial;
-      ListContours[i]->oriented_points[j].permu = numact + j;
-      doc->points[numact + j].permu = numact + j;
-      doc->points[numact + j].numcontour = ListContours[i]->numerocontour;
-      doc->points[numact + j].adjacent = NULL;
-      //      Msg(INFO, "pt %g %g ",doc->points[numact + j].where.h,doc->points[numact + j].where.v);
-    }
-    numact += ListContours[i]->numpoints;
-  }
-
-  DelaunayAndVoronoi(doc);
-  Conversion(doc);
-  remove_all_dlist(doc->numPoints, doc->points);
-
-  if(CTX.mesh.bgmesh_type != ONFILE || CTX.mesh.constrained_bgmesh)
-    BGMESH = doc;
-  else
-    BGMESH = NULL;
-
-  InitBricks(BGMESH);
-
-  /* elimination des triangles exterieurs + verification de l'existence
-     des edges (coherence) */
-
-  makepermut(nump);
-  del_L = List_Create(doc->numTriangles, 1000, sizeof(Delaunay *));
-
-  //  Msg(INFO, "%d triangles in the initial mesh, %d points",doc->numTriangles,nump);
-
-  for(i = 0; i < doc->numTriangles; i++) {
-    del_P = &doc->delaunay[i];
-    if((del_P->t.a == del_P->t.b) && (del_P->t.a == del_P->t.c)) {
-      Msg(GERROR, "Initial mesh is wrong. Try the new isotropic algorithm.");
-    }
-    else
-      List_Add(del_L, &del_P);
-  }
-  doc->numTriangles = List_Nbr(del_L);
-  verify_edges(del_L, ListContours, numcontours);
-  verify_inside(doc->delaunay, doc->numTriangles);
-
-  /* creation des liens ( triangles voisins ) */
-
-  CreateLinks(del_L, doc->numTriangles, ListContours, numcontours);
-
-  /* initialisation de l'arbre  */
-
-  (*root) = (*root_w) = NULL;
-
-  int onlyinit = OnlyTheInitialMesh;
-
-  if(doc->numTriangles == 1) {
-    doc->delaunay[0].t.position = INTERN;
-    Msg(INFO, "Only one triangle in initial mesh (skipping refinement)");
-    onlyinit = 1;
-  }
-
-  for(i = 0; i < doc->numTriangles; i++) {
-    if(doc->delaunay[i].t.position != EXTERN) {
-      del = &doc->delaunay[i];
-      Insert_Triangle(root, del);
-    }
-  }
-
-  /* maillage proprement dit :
-     1) Les triangles sont tries dans l'arbre suivant leur qualite
-     2) on ajoute un noeud au c.g du plus mauvais
-     3) on reconstruit le delaunay par Bowyer-Watson
-     4) on ajoute les triangles dans l'arbre et on recommence
-     jusque quand tous les triangles sont OK */
-
-  del = testconv(root, &conv, doc);
-
-  PushgPointArray(doc->points);
-
-  List_Reset(del_L);
-  kill_L = List_Create(1000, 1000, sizeof(Delaunay *));
-
-  if(onlyinit)
-    conv = 1;
-
-  while(conv != 1) {
-
-    pt = Localize(del, doc);
-
-    numlink = 0;
-    numkil = 0;
-    list = NULL;
-
-    if(!PE_Del_Triangle(del, pt, &list, kill_L, del_L, &numlink, &numkil)) {
-      Msg(WARNING, "Triangle non deleted");
-      Delete_Triangle(root, del);
-      Delete_Triangle(root_w, del);
-      del->t.quality_value /= 10.;
-      Insert_Triangle(root, del);
-      numlink = numkil = 0;
-      if(list != NULL) {
-        p = list;
-        do {
-          q = p;
-          p = Pred(p);
-          Free(q);
-        }
-        while(p != list);
-      }
-      list = NULL;
-      del = testconv(root, &conv, doc);
-      continue;
-    }
-
-    /* Test du Volume */
-
-    i = 0;
-    p = list;
-    volume_new = 0.0;
-    do {
-      q = p->next;
-      bb = p->point_num;
-      cc = q->point_num;
-      volume_new += fabs((doc->points[bb].where.h - pt.h) *
-                         (doc->points[cc].where.v - doc->points[bb].where.v) -
-                         (doc->points[cc].where.h - doc->points[bb].where.h) *
-                         (doc->points[bb].where.v - pt.v));
-      p = q;
-    } while(p != list);
-
-    volume_old = 0.0;
-    for(i = 0; i < numkil; i++) {
-      del_P = *(Delaunay **) List_Pointer(kill_L, i);
-      aa = del_P->t.a;
-      bb = del_P->t.b;
-      cc = del_P->t.c;
-      volume_old += fabs((doc->points[bb].where.h - doc->points[aa].where.h) *
-                         (doc->points[cc].where.v - doc->points[bb].where.v) -
-                         (doc->points[cc].where.h - doc->points[bb].where.h) *
-                         (doc->points[bb].where.v - doc->points[aa].where.v));
-    }
-
-    if((volume_old - volume_new) / (volume_old + volume_new) > 1.e-6) {
-      Msg(WARNING, "Volume has changed (%g->%g)", volume_old, volume_new);
-      Delete_Triangle(root, del);
-      Delete_Triangle(root_w, del);
-      del->t.quality_value /= 10.;
-      Insert_Triangle(root, del);
-      numlink = numkil = 0;
-      if(list != NULL) {
-        p = list;
-        do {
-          q = p;
-          p = Pred(p);
-          Free(q);
-        } while(p != list);
-      }
-      list = NULL;
-      del = testconv(root, &conv, doc);
-      continue;
-    }
-
-    /* Fin test du volume */
-
-    for(i = 0; i < numkil; i++) {
-      del_P = *(Delaunay **) List_Pointer(kill_L, i);
-      Delete_Triangle(root, del_P);
-      // MEMORY_LEAK -JF
-      // Free(del_P);
-    }
-
-    *numpoints = doc->numPoints;
-    Insert_Point(pt, numpoints, &numaloc, doc, BGMESH);
-    doc->points = gPointArray;
-    doc->numPoints = *numpoints;
-
-    i = 0;
-    p = list;
-
-    do {
-      q = p->next;
-
-      aa = doc->numPoints - 1;
-      bb = p->point_num;
-      cc = q->point_num;
-
-      deladd = (Delaunay *) Malloc(sizeof(Delaunay));
-
-      filldel(deladd, aa, bb, cc, doc->points, BGMESH);
-
-      List_Put(del_L, numlink + i, &deladd);
-      i++;
-      p = q;
-
-    } while(p != list);
-
-    p = list;
-
-    do {
-      q = p;
-      p = Pred(p);
-      Free(q);
-    } while(p != list);
-
-    CreateLinks(del_L, i + numlink, ListContours, numcontours);
-
-    for(j = 0; j < i; j++) {
-      del_P = *(Delaunay **) List_Pointer(del_L, j + numlink);
-      Insert_Triangle(root, del_P);
-    }
-
-    del = testconv(root, &conv, doc);
-
-  }
-
-  List_Delete(kill_L);
-
-  numtrwait = 0;
-  if(*root_w != NULL)
-    avltree_count(*root_w, &numtrwait);
-
-  numtrr = 0;
-  avltree_count(*root, &numtrr);
-
-  mai->listdel = (delpeek *) Malloc((numtrr + numtrwait + 1) * sizeof(delpeek));
-
-  numtri = 0;
-  avltree_print(*root, mai->listdel, &numtri);
-  if(numtrwait != 0) {
-    numtri = 0;
-    avltree_print(*root_w, (Delaunay **) del_L->array, &numtri);
-    for(i = 0; i < numtrwait; i++) {
-      mai->listdel[i + numtrr] = *(Delaunay **) List_Pointer(del_L, i);
-    }
-    avltree_remove(root_w);
-  }
-  avltree_remove(root);
-
-  List_Delete(del_L);
-
-  mai->numtriangles = numtrr + numtrwait;
-  mai->numpoints = doc->numPoints;
-  mai->points = doc->points;
-
-  /* Tous Les Triangles doivent etre orientes */
-
-  if(!mai->numtriangles) {
-    Msg(GERROR, "No triangles in surface mesh");
-    return 0;
-    //mai->numtriangles = 1;
-  }
-
-  for(i = 0; i < mai->numtriangles; i++) {
-    a = mai->listdel[i]->t.a;
-    b = mai->listdel[i]->t.b;
-    c = mai->listdel[i]->t.c;
-
-    mai->listdel[i]->v.voisin1 = NULL;
-    if(((doc->points[b].where.h - doc->points[a].where.h) *
-        (doc->points[c].where.v - doc->points[b].where.v) -
-        (doc->points[c].where.h - doc->points[b].where.h) *
-        (doc->points[b].where.v - doc->points[a].where.v)) > 0.0) {
-      mai->listdel[i]->t.a = b;
-      mai->listdel[i]->t.b = a;
-    }
-  }
-  // MEMORY LEAK (JF)
-  //  Free(doc->delaunay);
-  //  doc->delaunay = 0;
-  return 1;
-}
-
-void Maillage_Automatique_VieuxCode(Surface * pS, int ori)
-{
-  ContourRecord *cp, **liste;
-  List_T *c;
-  Vertex *v, V[3], *ver[3], **pp[3];
-  maillage M;
-  int err, i, j, k, N, a, b, d;
-  Simplex *s;
-  double Xmin = 0., Xmax = 0., Ymin = 0., Ymax = 0.;
-
-  liste = (ContourPeek *) Malloc(List_Nbr(pS->Contours) * sizeof(ContourPeek));
-
-  k = 0;
-
-  for(i = 0; i < List_Nbr(pS->Contours); i++) {
-    cp = (ContourRecord *) Malloc(sizeof(ContourRecord));
-    List_Read(pS->Contours, i, &c);
-    cp->oriented_points =
-      (PointRecord *) Malloc(List_Nbr(c) * sizeof(PointRecord));
-    cp->perturbations = (MPoint *) Malloc(List_Nbr(c) * sizeof(MPoint));
-    cp->numerocontour = i;
-
-    for(j = 0; j < List_Nbr(c); j++) {
-      List_Read(c, j, &v);
-      if(!j) {
-        Xmin = Xmax = v->Pos.X;
-        Ymin = Ymax = v->Pos.Y;
-      }
-      else {
-        Xmin = DMIN(Xmin, v->Pos.X);
-        Xmax = DMAX(Xmax, v->Pos.X);
-        Ymin = DMIN(Ymin, v->Pos.Y);
-        Ymax = DMAX(Ymax, v->Pos.Y);
-      }
-    }
-
-    LC2D = sqrt(DSQR(Xmax - Xmin) + DSQR(Ymax - Ymin));
-
-    for(j = 0; j < List_Nbr(c); j++) {
-      List_Read(c, j, &v);
-      cp->oriented_points[j].where.h = v->Pos.X;
-      cp->oriented_points[j].where.v = v->Pos.Y;
-
-      // On pourrait imaginer diviser les perturbations par un facteur
-      // dependant de v->lc, mais ca n'a pas l'air d'ameliorer le bignou
-
-      cp->perturbations[j].h = CTX.mesh.rand_factor * LC2D *
-        (double)rand() / (double)RAND_MAX;
-      cp->perturbations[j].v = CTX.mesh.rand_factor * LC2D *
-        (double)rand() / (double)RAND_MAX;
-
-      cp->oriented_points[j].numcontour = i;
-      cp->oriented_points[j].quality = v->lc;
-      cp->oriented_points[j].permu = k++;
-      cp->oriented_points[j].initial = v->Num;
-    }
-    cp->numpoints = List_Nbr(c);
-    liste[i] = cp;
-  }
-
-  int res_mesh_domain = 1;
-  if(pS->Method)
-    res_mesh_domain = mesh_domain(liste, List_Nbr(pS->Contours), &M, &N,
-				  (CTX.mesh.initial_only == 2));
-
-  for(i = 0; i < M.numpoints; i++) {
-    if(gPointArray[i].initial < 0) {
-      gPointArray[i].initial = ++THEM->MaxPointNum;
-      v = Create_Vertex(gPointArray[i].initial, gPointArray[i].where.h,
-                        gPointArray[i].where.v, 0.0, gPointArray[i].quality,
-                        0.0);
-      if(!Tree_Search(pS->Vertices, &v))
-        Tree_Add(pS->Vertices, &v);
-    }
-  }
-  for(i = 0; i < 3; i++)
-    ver[i] = &V[i];
-
-  for(i = 0; i < M.numtriangles; i++) {
-
-    a = M.listdel[i]->t.a;
-    b = M.listdel[i]->t.b;
-    d = M.listdel[i]->t.c;
-
-    ver[0]->Num = gPointArray[a].initial;
-    ver[1]->Num = gPointArray[b].initial;
-    ver[2]->Num = gPointArray[d].initial;
-    err = 0;
-    for(j = 0; j < 3; j++) {
-      if(!(pp[j] = (Vertex **) Tree_PQuery(pS->Vertices, &ver[j]))) {
-        err = 1;
-        Msg(GERROR, "Unknown vertex %d", ver[j]->Num);
-      }
-    }
-
-    /*
-       Je n'ai pas l'impression que ceci fonctionne comme voulu (essaie
-       e.g. avec demos/machine.geo)...
-       if (ori && !err)
-       s = Create_Simplex (*pp[0], *pp[1], *pp[2], NULL);
-       else if (!err)
-       s = Create_Simplex (*pp[0], *pp[2], *pp[1], NULL);
-       if (!err){
-       s->iEnt = pS->Num;
-       Tree_Insert (pS->Simplexes, &s);
-       } 
-     */
-    if(!err) {
-      s = Create_Simplex(*pp[0], *pp[2], *pp[1], NULL);
-      s->iEnt = pS->Num;
-      Tree_Insert(pS->Simplexes, &s);
-    }
-
-    // MEMORY LEAK (JF)
-    //printf("%d %d %d\n", M.listdel[i]->t.a, M.listdel[i]->t.b, M.listdel[i]->t.c);
-    //xxxxFree(M.listdel[i]);
-
-  }
-  
-  if(res_mesh_domain >= 0)
-    Free(M.listdel);
-  Free(gPointArray);
-}
-
-
-void Make_Mesh_With_Points(DocRecord * ptr, PointRecord * Liste,
-                           int Numpoints)
-{
-  ptr->numTriangles = 0;
-  ptr->points = Liste;
-  ptr->numPoints = Numpoints;
-  ptr->delaunay = 0;
-  DelaunayAndVoronoi(ptr);
-  Conversion(ptr);
-  remove_all_dlist(ptr->numPoints, ptr->points);
-}
-
-void filldel(Delaunay * deladd, int aa, int bb, int cc,
-             PointRecord * points, DocRecord * mesh)
-{
-  double qual, newqual;
-  MPoint pt2;
-  Vertex *v, *dum;
-
-  deladd->t.a = aa;
-  deladd->t.b = bb;
-  deladd->t.c = cc;
-  deladd->v.voisin1 = NULL;
-  deladd->v.voisin2 = NULL;
-  deladd->v.voisin3 = NULL;
-
-  CircumCircle(points[aa].where.h, points[aa].where.v,
-               points[bb].where.h, points[bb].where.v,
-               points[cc].where.h, points[cc].where.v, 
-	       &deladd->t.xc, &deladd->t.yc);
-
-  pt2.h = deladd->t.xc;
-  pt2.v = deladd->t.yc;
-
-  if(CTX.mesh.bgmesh_type == ONFILE) {
-    v = Create_Vertex(-1, pt2.h, pt2.v, 0.0, 0.0, 0.0);
-    Calcule_Z_Plan(&v, &dum);
-    Projette_Inverse(&v, &dum);
-    qual = BGMXYZ(v->Pos.X, v->Pos.Y, v->Pos.Z);
-    if(CTX.mesh.constrained_bgmesh) {
-      if(mesh) {
-        newqual = MIN(qual, find_quality(pt2, mesh));
-      }
-      else {
-        newqual =
-          MIN(qual,
-              (points[aa].quality + points[bb].quality +
-               points[cc].quality) / 3.);
-      }
-    }
-    else
-      newqual = qual;
-    Free_Vertex(&v, 0);
-  }
-  else{
-    if(mesh)
-      newqual = find_quality(pt2, mesh);
-    else
-      newqual = (points[aa].quality + points[bb].quality + 
-		 points[cc].quality) / 3.;
-    //    v = Create_Vertex(-1, pt2.h, pt2.v, 0.0, 0.0, 0.0);
-    //    Calcule_Z_Plan(&v, &dum);
-    //    Projette_Inverse(&v, &dum);
-    //    Free_Vertex(&v, 0);
-  }
-
-  deladd->t.quality_value =
-    sqrt((deladd->t.xc - points[cc].where.h) * (deladd->t.xc -
-						points[cc].where.h) +
-	 (deladd->t.yc - points[cc].where.v) * (deladd->t.yc -
-						points[cc].where.v)
-	 ) / newqual;
-  deladd->t.position = INTERN;
-}
-
-void ActionEndTheCurve(void *a, void *b)
-{
-  Curve *c = *(Curve **) a;
-  End_Curve(c);
-}
-
-void ActionInvertTri(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  Vertex *tmp = s->V[1];
-  s->V[1] = s->V[2];
-  s->V[2] = tmp;
-}
-
-void ActionInvertQua(void *a, void *b)
-{
-  Quadrangle *q = *(Quadrangle **) a;
-  Vertex *tmp = q->V[1];
-  q->V[1] = q->V[3];
-  q->V[3] = tmp;
-}
-
-// A little routine that re-orients the surface meshes so that they
-// match the geometrical orientations. It would be better to generate
-// the meshes correctly in the first place (!), but it's actually
-// pretty nice to do it here since we use many algorithms (some
-// closed) and since the mean plane computation doesn't take the
-// original orientation into account.
-
-void ReOrientSurfaceMesh(Surface *s)
-{
-  if(!List_Nbr(s->Generatrices))
-    return;
-
-  Curve *c;
-  List_Read(s->Generatrices, 0, &c);
-
-  if(List_Nbr(c->Vertices) < 2)
-    return;
-
-  // take the first edge (even if there are holes, we know that this
-  // edge belongs to the exterior loop, due to the ordering of
-  // s->Generatrices)
-  Vertex *v1, *v2;
-  List_Read(c->Vertices, 0, &v1);
-  List_Read(c->Vertices, 1, &v2);
-  Edge edge;
-  edge.V[0] = v1;
-  edge.V[1] = v2;
-
-  if(Tree_Nbr(s->Simplexes)){
-    EdgesContainer edges;
-    edges.AddSimplexTree(s->Simplexes);
-    Edge *e = (Edge*)Tree_PQuery(edges.AllEdges, &edge);
-    if(e && e->V[0]->Num == v2->Num && e->V[1]->Num == v1->Num){
-      Tree_Action(s->Simplexes, ActionInvertTri);
-      if(Tree_Nbr(s->Quadrangles)) // for partially recombined meshes
-	Tree_Action(s->Quadrangles, ActionInvertQua);
-    }
-  }
-
-  if(Tree_Nbr(s->Quadrangles)){
-    EdgesContainer edges;
-    edges.AddQuadrangleTree(s->Quadrangles);
-    Edge *e = (Edge*)Tree_PQuery(edges.AllEdges, &edge);
-    if(e && e->V[0]->Num == v2->Num && e->V[1]->Num == v1->Num){
-      Tree_Action(s->Quadrangles, ActionInvertQua);
-      if(Tree_Nbr(s->Simplexes)) // for partially recombined meshes
-	Tree_Action(s->Simplexes, ActionInvertTri);
-    }
-  }
-}
-
-void Maillage_Surface(void *data, void *dum)
-{
-  Tree_T *tnxe;
-  int ori;
-
-  Surface *s = *(Surface **) data;
-
-  if(!s->Support)
-    return;
-
-  Msg(STATUS2, "Meshing surface %d", s->Num);
-
-  int tag = MeshDiscreteSurface(s);
-
-  if(tag == 1){
-    Tree_Action(THEM->Points, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, Add_In_Mesh);
-    return;
-  }
-  else if (tag == 2)
-    {
-      return;
-    }
-
-  THESUPPORT = s->Support;
-  THESURFACE = s;
-
-  if(Tree_Nbr(s->Simplexes))
-    Tree_Delete(s->Simplexes);
-  s->Simplexes = Tree_Create(sizeof(Simplex *), compareQuality);
-  if(Tree_Nbr(s->Vertices))
-    Tree_Delete(s->Vertices);
-  s->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
-
-  if(MeshTransfiniteSurface(s) ||
-     MeshEllipticSurface(s) ||
-     MeshCylindricalSurface(s) ||
-     MeshParametricSurface(s) ||
-     Extrude_Mesh(s)) {
-    Tree_Action(THEM->Points, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, Add_In_Mesh);
-  }
-  else{
-
-    if(!List_Nbr(s->Generatrices)){
-      Msg(GERROR, "Cannot mesh surface with no boundary");
-      return;
-    }
-
-    int TypSurface = s->Typ;
-    Plan_Moyen(&s, dum);
-    Tree_Action(THEM->Points, Freeze_Vertex);
-    Tree_Action(s->Vertices, Freeze_Vertex);
-    Tree_Action(THEM->Points, Projette_Plan_Moyen);
-    Tree_Action(s->Vertices, Projette_Plan_Moyen);
-    Tree_Action(THEM->Curves, ActionEndTheCurve);
-    s->Typ = MSH_SURF_PLAN;
-    End_Surface(s, 0);
-
-    ori = Calcule_Contours(s);
-    
-    if(CTX.mesh.algo2d == DELAUNAY_ISO)
-      Maillage_Automatique_VieuxCode(s, ori);
-    else if(CTX.mesh.algo2d == DELAUNAY_ANISO)
-      AlgorithmeMaillage2DAnisotropeModeJF(s);
-    else
-      Mesh_Triangle(s);
-    
-    if(CTX.mesh.nb_smoothing) {
-      Msg(STATUS2, "Smoothing surface %d", s->Num);
-      tnxe = Tree_Create(sizeof(NXE), compareNXE);
-      create_NXE(s->Vertices, s->Simplexes, tnxe);
-      for(int i = 0; i < CTX.mesh.nb_smoothing; i++)
-	Tree_Action(tnxe, ActionLiss);
-      delete_NXE(tnxe);
-    }
-    
-    if(s->Recombine){
-      Msg(STATUS2, "Recombining surface %d", s->Num);
-      Recombine(s->Vertices, s->Simplexes, s->Quadrangles, s->RecombineAngle);
-    }
-
-    s->Typ = TypSurface;
-    
-    if(s->Typ != MSH_SURF_PLAN) {
-      if(s->Extrude)
-	s->Extrude->Rotate(s->plan);
-      Tree_Action(s->Vertices, Calcule_Z);
-      if(s->Extrude)
-	s->Extrude->Rotate(s->invplan);
-    }
-    else
-      Tree_Action(s->Vertices, Calcule_Z_Plan);
-
-    Tree_Action(s->Vertices, Projette_Inverse);
-    Tree_Action(THEM->Points, Projette_Inverse);
-    
-    Tree_Action(THEM->Points, deFreeze_Vertex);
-    Tree_Action(s->Vertices, deFreeze_Vertex);
-    
-    Tree_Action(THEM->Points, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, PutVertex_OnSurf);
-    Tree_Action(s->Vertices, Add_In_Mesh);
-    
-    Tree_Action(THEM->Curves, ActionEndTheCurve);
-    End_Surface(s->Support, 0);
-    End_Surface(s, 0);
-    
-    ReOrientSurfaceMesh(s);
-  }
-
-}
diff --git a/Mesh/2D_Mesh.h b/Mesh/2D_Mesh.h
deleted file mode 100644
index ba6c3daece65a3e963d3e7d8da841b92ae12647b..0000000000000000000000000000000000000000
--- a/Mesh/2D_Mesh.h
+++ /dev/null
@@ -1,101 +0,0 @@
-#ifndef _2D_MESH_H_
-#define _2D_MESH_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "List.h"
-#include "Tree.h"
-#include "Mesh.h"
-
-typedef struct avl{
-  void *treedata;
-  int balance;
-  struct avl *left;
-  struct avl *right;
-}avlstruct;
-
-typedef avlstruct *avlptr;
-
-int  remove_tree (avlstruct ** root);
-int  insert_avltree (avlstruct ** root, void *item, 
-                     int (*fcmp)(void *a, void *b));
-int  delete_avltree (avlstruct ** root, void *item, 
-                     int (*fcmp)(void *a, void *b));
-int  avltree_remove (avlstruct **root);
-void avltree_count (avlptr root, int *numtri);
-void avltree_print (avlptr root, Delaunay **listdel, int *numtri);
-int  avltree_insert (avlstruct **root, void *item, 
-                     int (*fcmp)(void *a, void *b));
-int  avltree_delete (avlstruct **root, void *item, 
-                     int (*fcmp)(void *a, void *b));
-void findtree(avlptr root, double *qualm, 
-              Delaunay **delf, DocRecord *MESH);
-Delaunay *findrightest(avlptr root, DocRecord *MESH);
-
-
-PointNumero Successor(PointNumero a,PointNumero b);
-
-Delaunay * Find_Triangle (MPoint pt, DocRecord *MESH, int typ);
-int Insert_Triangle (avlstruct **root, Delaunay * del);
-int Delete_Triangle ( avlstruct **root, Delaunay * del );
-int Insert_Point (MPoint pt, int *numpoints, int *numalloc, 
-                  DocRecord *doc, DocRecord *BGM);
-MPoint Localize (Delaunay * del , DocRecord *MESH);
-
-void InitBricks (DocRecord *MESH);
-int PtInTriangle(MPoint p , PointNumero a , PointNumero b , PointNumero c);
-int DelaunayAndVoronoi(DocPeek doc);
-
-int Conversion(DocPeek doc );
-int CreateLinks(List_T * ListDelaunay , int NumDelaunay, 
-                ContourRecord **ListContours , int Nc);
-
-void makepermut (int numpoints);
-void verify_edges (List_T *ListDelaunay, ContourRecord **ListContour, 
-                   int NumContours);
-void verify_inside (Delaunay * ListDelaunay ,  int NumDelaunay );
-
-void PushgPointArray(PointRecord *ptr);
-void remove_all_dlist(int n, PointRecord *pPointArray);
-
-int PE_Del_Triangle (Delaunay *del , MPoint pt, DListPeek *ListEdges ,
-                     List_T *listkill, List_T *listDelforlink,
-                     int *numlink, int *numdel);
-
-void filldel (Delaunay * deladd, int aa, int bb, int cc,
-              PointRecord * points, DocRecord * mesh);
-
-int CircumCircle(double x1,double y1,double x2,double y2,double x3,double y3,
-                 double *xc,double *yc);
-double find_quality (MPoint center, DocRecord * BGMESH);
-void create_NXE (Tree_T * TreeAllNod, Tree_T * TreeAllElg,
-                 Tree_T * TreeAllNXE);
-void delete_NXE (Tree_T * TreeAllNXE);
-
-int Is_left_of(PointNumero x,PointNumero y,PointNumero check);
-int Is_right_of(PointNumero x,PointNumero y,PointNumero check);
-int DListInsert(DListRecord **dlist, MPoint center, PointNumero newPoint);
-int DListDelete(DListPeek *dlist,PointNumero oldPoint);
-int mesh_domain(ContourPeek * ListContours, int numcontours,
-                maillage * mai, int *numpoints, int OnlyTheInitialMesh);
-void Make_Mesh_With_Points(DocRecord * ptr, PointRecord * Liste,
-                           int Numpoints);
-
-#endif
diff --git a/Mesh/2D_Mesh_Aniso.cpp b/Mesh/2D_Mesh_Aniso.cpp
deleted file mode 100644
index 75734869788b32c1c65ff498caa5d60706602133..0000000000000000000000000000000000000000
--- a/Mesh/2D_Mesh_Aniso.cpp
+++ /dev/null
@@ -1,1209 +0,0 @@
-// $Id: 2D_Mesh_Aniso.cpp,v 1.57 2006-11-25 00:44:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-// Anisotropic Delaunay mesh generator
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "Interpolation.h"
-#include "Create.h"
-#include "Context.h"
-
-extern Context_T CTX;
-extern double LC2D;
-
-inline void cgsmpl(Simplex * s, double &x, double &y)
-{
-  x = (1. / 3.) * (s->V[0]->Pos.X + s->V[1]->Pos.X + s->V[2]->Pos.X);
-  y = (1. / 3.) * (s->V[0]->Pos.Y + s->V[1]->Pos.Y + s->V[2]->Pos.Y);
-}
-
-extern Simplex MyNewBoundary;
-extern Mesh *THEM;
-extern double MAXIMUM_LC_FOR_SURFACE;
-extern int Alerte_Point_Scabreux;
-extern PointRecord *gPointArray;
-extern Surface *PARAMETRIC;
-
-static Tree_T *Tsd, *Sim_Sur_Le_Bord;
-static List_T *Simplexes_Destroyed, *Simplexes_New, *Suppress;
-static Simplex *THES;
-static Vertex *THEV;
-static Surface *SURF;
-static Tree_T *FacesTree;
-static int ZONEELIMINEE, Methode = 0;
-static double volume;
-static List_T *coquille;
-static Edge *THEEDGE;
-
-double Interpole_lcTriangle(Simplex * s, Vertex * vv)
-{
-  double Xp, Yp, X[3], Y[3], det, u, v, q1, q2, q3;
-
-  if(CTX.mesh.bgmesh_type == ONFILE){
-    Vertex *v2 = Create_Vertex(-1, vv->Pos.X, vv->Pos.Y, 0.0, 0.0, 0.0);
-    Vertex *dum;
-    Calcule_Z_Plan(&v2, &dum);
-    Projette_Inverse(&v2, &dum);
-    double val = BGMXYZ(v2->Pos.X, v2->Pos.Y, v2->Pos.Z);
-    Free_Vertex(&v2, 0);
-    return val;
-  }
-
-  Xp = vv->Pos.X;
-  Yp = vv->Pos.Y;
-
-  X[0] = s->V[0]->Pos.X;
-  X[1] = s->V[1]->Pos.X;
-  X[2] = s->V[2]->Pos.X;
-
-  Y[0] = s->V[0]->Pos.Y;
-  Y[1] = s->V[1]->Pos.Y;
-  Y[2] = s->V[2]->Pos.Y;
-
-  q1 = s->V[0]->lc;
-  q2 = s->V[1]->lc;
-  q3 = s->V[2]->lc;
-
-  det = (X[2] - X[0]) * (Y[1] - Y[0]) - (Y[2] - Y[0]) * (X[1] - X[0]);
-
-  if(det != 0.0) {
-    u = ((Xp - X[0]) * (Y[1] - Y[0]) - (Yp - Y[0]) * (X[1] - X[0])) / det;
-    v = ((X[2] - X[0]) * (Yp - Y[0]) - (Y[2] - Y[0]) * (Xp - X[0])) / det;
-  }
-  else {
-    u = v = 0.0;
-  }
-  return (q1 * (1. - u - v) + q2 * v + q3 * u);
-}
-
-
-/* Au sens Riemannien, trouver le centre de l'ellipse
-   triangle de sommets (x1,x2,x3)
-
-   T                   T
-   (x-x1)  M (x-x1) = (x-x2)  M (x-x2)
-   T                   T
-   (x-x1)  M (x-x1) = (x-x3)  M (x-x3)
- */
-
-void matXmat(int n, double mat1[3][3], double mat2[3][3], double Res[3][3])
-{
-  for(int i = 0; i < n; i++) {
-    for(int j = 0; j < n; j++) {
-      Res[i][j] = 0.0;
-      for(int k = 0; k < n; k++)
-        Res[i][j] += mat1[i][k] * mat2[k][j];
-    }
-  }
-}
-
-void TmatXmat(int n, double mat1[3][3], double mat2[3][3], double Res[3][3])
-{
-  for(int i = 0; i < n; i++) {
-    for(int j = 0; j < n; j++) {
-      Res[i][j] = 0.0;
-      for(int k = 0; k < n; k++)
-        Res[i][j] += mat1[k][i] * mat2[k][j];
-    }
-  }
-}
-
-Simplex *Create_Simplex_For2dmesh(Vertex * v1, Vertex * v2, Vertex * v3,
-                                  Vertex * v4)
-{
-  Simplex *s;
-  double p12, p23, p13;
-  double srf = ((v2->Pos.X - v1->Pos.X) *
-                (v3->Pos.Y - v2->Pos.Y) -
-                (v3->Pos.X - v2->Pos.X) * (v2->Pos.Y - v1->Pos.Y));
-  if(srf > 0)
-    s = Create_Simplex(v3, v2, v1, v4);
-  else
-    s = Create_Simplex(v1, v2, v3, v4);
-
-  THEM->Metric->setSimplexQuality(s, PARAMETRIC);
-
-  if(PARAMETRIC) {
-    if((!v2->ListCurves && !v3->ListCurves && !v3->ListCurves)) {
-      prosca(v1->us, v2->us, &p12);
-      p12 = fabs(p12);
-      prosca(v1->us, v3->us, &p13);
-      p13 = fabs(p13);
-      prosca(v2->us, v3->us, &p23);
-      p23 = fabs(p23);
-      if(s->Quality < CONV_VALUE &&
-         (p12 < THEM->Metric->min_cos || p13 < THEM->Metric->min_cos ||
-          p23 < THEM->Metric->min_cos))
-        s->Quality = 1.0;
-    }
-  }
-  return s;
-}
-
-/*En l'honneur de ma femme Stephanie... */
-
-void VSIM_2D(void *a, void *b)
-{
-  Simplex *S;
-
-  S = *(Simplex **) a;
-  if(S->V[2])
-    volume += fabs(S->Volume_Simplexe2D());
-}
-
-void Box_2_Triangles(List_T * P, Surface * s)
-{
-#define FACT 1.1
-#define LOIN 0.2
-
-  int i, j;
-  static int pts[4][2] = { {0, 0},
-			   {1, 0},
-			   {1, 1},
-			   {0, 1} };
-  static int tri[2][3] = { {1, 4, 2},
-			   {2, 4, 3} };
-  double Xm = 0., Ym = 0., XM = 0., YM = 0., Xc = 0., Yc = 0.;
-  Simplex *S, *ps;
-  Vertex *V, *v, *pv;
-  List_T *smp;
-
-  smp = List_Create(2, 1, sizeof(Simplex *));
-
-  V = (Vertex *) Malloc(4 * sizeof(Vertex));
-
-  for(i = 0; i < List_Nbr(P); i++) {
-    List_Read(P, i, &v);
-    if(!i) {
-      Xm = XM = v->Pos.X;
-      Ym = YM = v->Pos.Y;
-    }
-    else {
-      Xm = DMIN(Xm, v->Pos.X);
-      XM = DMAX(XM, v->Pos.X);
-      Ym = DMIN(Ym, v->Pos.Y);
-      YM = DMAX(YM, v->Pos.Y);
-    }
-  }
-  if(Xm == XM)
-    XM = Xm + 1.;
-  if(Ym == YM)
-    YM = Ym + 1.;
-
-  Xc = XM - Xm;
-  Yc = YM - Ym;
-
-  /* Longueur Caracteristique */
-
-  LC2D = sqrt(Xc * Xc + Yc * Yc);
-
-  for(i = 0; i < 4; i++) {
-    if(pts[i][0])
-      V[i].Freeze.X = V[i].Pos.X = Xm - LOIN * Xc;
-    else
-      V[i].Freeze.X = V[i].Pos.X = XM + LOIN * Xc;
-    if(pts[i][1])
-      V[i].Freeze.Y = V[i].Pos.Y = Ym - LOIN * Yc;
-    else
-      V[i].Freeze.Y = V[i].Pos.Y = YM + LOIN * Yc;
-
-    V[i].Freeze.Z = V[i].Pos.Z = 0.0;
-
-    V[i].Num = -(++THEM->MaxPointNum);
-    V[i].ListSurf = NULL;
-    pv = &V[i];
-    pv->lc = 1.0;
-    pv->Mov = NULL;
-    Tree_Replace(s->Vertices, &pv);
-  }
-
-  /* 2 Triangles forment le maillage de la boite */
-
-  for(i = 0; i < 2; i++) {
-    S = Create_Simplex_For2dmesh(&V[tri[i][0] - 1], &V[tri[i][1] - 1],
-                                 &V[tri[i][2] - 1], NULL);
-    List_Add(smp, &S);
-    S->iEnt = s->Num;
-  }
-
-  Link_Simplexes(smp, NULL);
-  for(i = 0; i < List_Nbr(smp); i++) {
-    List_Read(smp, i, &ps);
-    for(j = 0; j < 3; j++)
-      if(ps->S[j] == NULL)
-        ps->S[j] = &MyNewBoundary;
-    Tree_Replace(s->Simplexes, &ps);
-  }
-
-  List_Delete(smp);
-
-}
-
-
-int Intersect_Edges_2d(Edge * a, Edge * b)
-{
-  double mat[2][2];
-  double rhs[2], x[2];
-  mat[0][0] = (a->V[1]->Pos.X - a->V[0]->Pos.X);
-  mat[0][1] = -(b->V[1]->Pos.X - b->V[0]->Pos.X);
-  mat[1][0] = (a->V[1]->Pos.Y - a->V[0]->Pos.Y);
-  mat[1][1] = -(b->V[1]->Pos.Y - b->V[0]->Pos.Y);
-  rhs[0] = b->V[0]->Pos.X - a->V[0]->Pos.X;
-  rhs[1] = b->V[0]->Pos.Y - a->V[0]->Pos.Y;
-  if(!sys2x2(mat, rhs, x))
-    return 0;
-  if(x[0] > 0.0 && x[0] < 1.0 && x[1] > 0.0 && x[1] < 1.0)
-    return 1;
-  return 0;
-}
-
-void putaindecoquille_2D(void *a, void *b)
-{
-  Edge *e = (Edge *) a;
-  if(!compareVertex(&e->V[0], &THEEDGE->V[0]) ||
-     !compareVertex(&e->V[0], &THEEDGE->V[1]) ||
-     !compareVertex(&e->V[1], &THEEDGE->V[0]) ||
-     !compareVertex(&e->V[1], &THEEDGE->V[1])) {
-    return;
-  }
-  if(Intersect_Edges_2d(e, THEEDGE))
-    List_Add(coquille, &e);
-}
-
-void Recover_Edge(Surface * s, Edge * e, EdgesContainer & Edges)
-{
-  THEEDGE = e;
-  int i;
-  Edge *me, E;
-  Vertex *v[2];
-
-  coquille = List_Create(3, 3, sizeof(Edge *));
-  /*On cherche la coquille */
-  Tree_Action(Edges.AllEdges, putaindecoquille_2D);
-  Msg(INFO, "Edge %d->%d, %d intersections",
-      e->V[0]->Num, e->V[1]->Num, List_Nbr(coquille));
-
-  if(List_Nbr(coquille) == 1) {
-    Msg(WARNING, "Unable to swap edge");
-    List_Delete(coquille);
-    return;
-  }
-
-  /*on swappe au hasard jusqu'a ce qu l'arete soit recuperee */
-  while(List_Nbr(coquille)) {
-
-    i = (int)(List_Nbr(coquille) * rand() / (RAND_MAX + 1.0));
-    //i = rand () % List_Nbr (coquille);
-    List_Read(coquille, i, &me);
-    v[0] = me->V[0];
-    v[1] = me->V[1];
-    List_Suppress(coquille, &me, compareEdgePtr);
-    Edges.SwapEdge(v);
-    if(Edges.Search(e->V[0], e->V[1]))
-      break;
-    E.V[0] = v[0];
-    E.V[1] = v[1];
-    me = (Edge *) Tree_PQuery(Edges.AllEdges, &E);
-    putaindecoquille_2D(me, NULL);
-  }
-
-  List_Delete(coquille);
-
-  Msg(INFO, "Edge recovered");
-  /*On swappe */
-}
-
-void constraint_the_edge(int isurf, int iv1, int iv2)
-{
-  Vertex *v1 = FindVertex(iv1);
-  Vertex *v2 = FindVertex(iv2);
-  Surface *s = FindSurface(isurf);
-  Edge e;
-
-  if(!v1 || !v2)
-    return;
-  EdgesContainer EdgesOnSurface(s->Simplexes);
-  e.V[0] = v1;
-  e.V[1] = v2;
-  if(!EdgesOnSurface.Search(v1, v2)) {
-    Recover_Edge(s, &e, EdgesOnSurface);
-  }
-}
-
-void missing_edges_2d(Surface * s)
-{
-  int i, j;
-  Curve *c;
-  Vertex *v1, *v2;
-  Edge e;
-
-  EdgesContainer EdgesOnSurface(s->Simplexes);
-
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &c);
-    for(j = 1; j < List_Nbr(c->Vertices); j++) {
-      List_Read(c->Vertices, j - 1, &v1);
-      List_Read(c->Vertices, j, &v2);
-      e.V[0] = v1;
-      e.V[1] = v2;
-      if(!EdgesOnSurface.Search(v1, v2)) {
-        Msg(INFO, "Missing edge %d->%d", v1->Num, v2->Num);
-        Recover_Edge(s, &e, EdgesOnSurface);
-      }
-    }
-  }
-}
-
-int Restore_Boundary(Surface * s)
-{
-  missing_edges_2d(s);
-  return 1;
-}
-
-int Maillage_Edge(Vertex * v1, Vertex * v2, List_T * Points)
-{
-  int i;
-  static int qq = 1;
-  Simplex S, *s;
-
-  s = &S;
-  s->F[0].V[0] = v1;
-  s->F[0].V[1] = v2;
-
-  if(Tree_Search(FacesTree, &s))
-    return 0;
-
-  s = Create_Simplex_For2dmesh(v1, v2, NULL, NULL);
-  Tree_Add(FacesTree, &s);
-
-  Curve *c = Create_Curve(qq++, MSH_SEGM_LINE, 1, NULL, NULL, -1, -1, 0, 1);
-  Vertex *v;
-  c->Control_Points = List_Create(2, 1, sizeof(Vertex *));
-  List_Add(c->Control_Points, &v1);
-  List_Add(c->Control_Points, &v2);
-  c->beg = v1;
-  c->end = v2;
-  Maillage_Curve(&c, NULL);
-  for(i = 1; i < List_Nbr(c->Vertices) - 1; i++) {
-    List_Read(c->Vertices, i, &v);
-    List_Delete(v->ListCurves);
-    v->ListCurves = NULL;
-    List_Add(Points, &v);
-  }
-  List_Delete(c->Vertices);
-  List_Delete(c->Control_Points);
-  Free_Curve(&c, 0);
-  return 1;
-}
-
-void Action_First_Simplexes_2D(void *a, void *b)
-{
-  Simplex *q;
-
-  if(!THES) {
-    q = *(Simplex **) a;
-    if(q->Pt_In_Ellipse(THEV, THEM->Metric->m)) {
-      THES = q;
-    }
-  }
-}
-
-void Fill_Sim_Des_2D(void *a, void *b)
-{
-  Simplex *S;
-  S = *(Simplex **) a;
-  if(S->Pt_In_Ellipse(THEV, THEM->Metric->m))
-    List_Add(Simplexes_Destroyed, a);
-}
-
-void TStoLS_2D(void *a, void *b)
-{
-  List_Add(Simplexes_Destroyed, a);
-}
-
-void TAtoLA_2D(void *a, void *b)
-{
-  List_Add(Simplexes_New, a);
-}
-
-void CrSi_2D(void *a, void *b)
-{
-  SxF *S;
-  Simplex *s;
-  S = (SxF *) a;
-  if(S->NumFaceSimpl == 1) {
-    s = Create_Simplex_For2dmesh(THEV, S->F.V[0], S->F.V[1], NULL);
-    s->iEnt = ZONEELIMINEE;
-    List_Add(Simplexes_New, &s);
-  }
-  else if(S->NumFaceSimpl != 2) {
-    Msg(GERROR, "Panic in CrSi_2D...");
-  }
-}
-
-void NewSimplexes_2D(Surface * s, List_T * Sim, List_T * news)
-{
-  int i, j;
-  Tree_T *SimXFac;
-  Simplex *S;
-  SxF SXF, *pSXF;
-
-  SimXFac = Tree_Create(sizeof(SxF), compareSxF);
-
-  for(i = 0; i < List_Nbr(Sim); i++) {
-    List_Read(Sim, i, &S);
-    if(!i)
-      ZONEELIMINEE = S->iEnt;
-    else {
-      if(S->iEnt != ZONEELIMINEE) {
-        Msg(WARNING, "Huh! The elimination failed %d %d",
-            S->iEnt, ZONEELIMINEE);
-      }
-    }
-    for(j = 0; j < 3; j++) {
-      SXF.F = S->F[j];
-
-      if((pSXF = (SxF *) Tree_PQuery(SimXFac, &SXF))) {
-        (pSXF->NumFaceSimpl)++;
-      }
-      else {
-        SXF.NumFaceSimpl = 1;
-        Tree_Add(SimXFac, &SXF);
-      }
-    }
-  }
-
-  /* Les faces non communes sont obligatoirement a la frontiere ...
-     -> Nouveaux simplexes */
-
-  Tree_Action(SimXFac, CrSi_2D);
-  Tree_Delete(SimXFac);
-}
-
-int recur_bowyer_2D(Simplex * s)
-{
-  int i;
-
-  Tree_Insert(Tsd, &s);
-  for(i = 0; i < 3; i++) {
-    if(s->S[i] && s->S[i] != &MyNewBoundary && !Tree_Query(Tsd, &s->S[i])) {
-      if(s->S[i]->Pt_In_Ellipse(THEV, THEM->Metric->m)
-         && (s->iEnt == s->S[i]->iEnt)) {
-        recur_bowyer_2D(s->S[i]);
-      }
-      else {
-        if(s->iEnt != s->S[i]->iEnt) {
-          Alerte_Point_Scabreux = 1;
-        }
-        Tree_Insert(Sim_Sur_Le_Bord, &s->S[i]);
-      }
-    }
-  }
-  return 1;
-}
-
-
-bool draw_simplex2d(Surface * sur, Simplex * s, bool nouv)
-{
-  if(!CTX.mesh.interactive)
-    return false;
-
-  if(s == &MyNewBoundary || !s || !s->iEnt)
-    return false;
-
-#if defined(HAVE_FLTK)
-  Vertex v1 = InterpolateSurface(sur->Support, s->V[0]->Pos.X, s->V[0]->Pos.Y, 0, 0);
-  Vertex v2 = InterpolateSurface(sur->Support, s->V[1]->Pos.X, s->V[1]->Pos.Y, 0, 0);
-  Vertex v3 = InterpolateSurface(sur->Support, s->V[2]->Pos.X, s->V[2]->Pos.Y, 0, 0);
-
-  Vertex *pv1 = &v1, *pv2 = &v2, *pv3 = &v3, *dum;
-  Calcule_Z_Plan(&pv1, &dum);
-  Projette_Inverse(&pv1, &dum);
-  Calcule_Z_Plan(&pv2, &dum);
-  Projette_Inverse(&pv2, &dum);
-  Calcule_Z_Plan(&pv3, &dum);
-  Projette_Inverse(&pv3, &dum);
-
-  void Draw_Triangle_Overlay(double, double, double, double*, double*, double*);
-  double p1[3] = {pv1->Pos.X, pv1->Pos.Y, pv1->Pos.Z};
-  double p2[3] = {pv2->Pos.X, pv2->Pos.Y, pv2->Pos.Z};
-  double p3[3] = {pv3->Pos.X, pv3->Pos.Y, pv3->Pos.Z};
-  if(nouv)
-    Draw_Triangle_Overlay(1., 0., 0., p1, p2, p3);
-  else
-    Draw_Triangle_Overlay(0., 0., 0., p1, p2, p3);
-#endif
-
-  return true;
-}
-
-bool Bowyer_Watson_2D(Surface * sur, Vertex * v, Simplex * S, int force)
-{
-  int i;
-  Simplex *s;
-  static int init = 1;
-  double volumeold, volumenew;
-
-  THEV = v;
-
-  double x = (S->V[0]->Pos.X + S->V[1]->Pos.X + S->V[2]->Pos.X) / 3.;
-  double y = (S->V[0]->Pos.Y + S->V[1]->Pos.Y + S->V[2]->Pos.Y) / 3.;
-
-  if(force)
-    THEM->Metric->setMetricMin(x, y, sur->Support);
-  else
-    THEM->Metric->setMetric(x, y, sur->Support);
-
-  Tsd = Tree_Create(sizeof(Simplex *), compareSimplex);
-  Sim_Sur_Le_Bord = Tree_Create(sizeof(Simplex *), compareSimplex);
-  if(init) {
-    Simplexes_New = List_Create(10, 10, sizeof(Simplex *));
-    Simplexes_Destroyed = List_Create(10, 10, sizeof(Simplex *));
-    init = 0;
-  }
-
-  if(Methode) {
-    Tree_Action(sur->Simplexes, Fill_Sim_Des_2D);
-    S = NULL;
-  }
-  else {
-    recur_bowyer_2D(S);
-  }
-
-  Tree_Action(Tsd, TStoLS_2D);
-  NewSimplexes_2D(sur, Simplexes_Destroyed, Simplexes_New);
-
-  /* calcul des volumes des simplexes crees */
-
-  if(Alerte_Point_Scabreux || !CTX.mesh.speed_max) {
-    volume = 0.0;
-    for(i = 0; i < List_Nbr(Simplexes_Destroyed); i++) {
-      VSIM_2D(List_Pointer(Simplexes_Destroyed, i), NULL);
-    }
-    volumeold = volume;
-    volume = 0.0;
-    for(i = 0; i < List_Nbr(Simplexes_New); i++) {
-      VSIM_2D(List_Pointer(Simplexes_New, i), NULL);
-    }
-    volumenew = volume;
-    if(volumeold + volumenew == 0.0)
-      volumenew = 1.0;
-  }
-  else {
-    volumeold = 1.0;
-    volumenew = 1.0;
-  }
-
-  /* critere du volume */
-
-  if((fabs(volumeold - volumenew) / (volumeold + volumenew)) > 1.e-8) {
-    if(S) {
-      Tree_Suppress(sur->Simplexes, &S);
-      S->Quality /= 2.;
-      Tree_Add(sur->Simplexes, &S);
-    }
-    if(force) {
-      List_Reset(Simplexes_New);
-      List_Reset(Simplexes_Destroyed);
-      Tree_Delete(Sim_Sur_Le_Bord);
-      Tree_Delete(Tsd);
-      return false;
-    }
-  }
-  else {
-    Tree_Add(sur->Vertices, &THEV);
-
-    /* Suppression des simplexes elimines */
-    for(i = 0; i < List_Nbr(Simplexes_Destroyed); i++) {
-      List_Read(Simplexes_Destroyed, i, &s);
-      draw_simplex2d(sur, s, 0);
-      if(!Tree_Suppress(sur->Simplexes, &s)) {
-        Msg(WARNING, "Failed to suppress simplex %d", s->Num);
-      }
-      Free_Simplex(&s, 0);
-    }
-    for(i = 0; i < List_Nbr(Simplexes_New); i++) {
-      List_Read(Simplexes_New, i, &s);
-      if(0 || !force) {
-        double xc = s->Center.X;
-        double yc = s->Center.Y;
-        double rd = s->Radius;
-        cgsmpl(s, x, y);
-        THEM->Metric->setMetric(x, y, sur->Support);
-        THEM->Metric->setSimplexQuality(s, sur->Support);
-        s->Center.X = xc;
-        s->Center.Y = yc;
-        s->Radius = rd;
-        if(force)
-          THEM->Metric->Identity();
-      }
-      draw_simplex2d(sur, s, 1);
-      Tree_Add(sur->Simplexes, &s);
-    }
-
-    /* Creation des liens entre nouveaux simplexes */
-
-    Tree_Action(Sim_Sur_Le_Bord, TAtoLA_2D);
-    Link_Simplexes(Simplexes_New, sur->Simplexes);
-  }
-
-  List_Reset(Simplexes_New);
-  List_Reset(Simplexes_Destroyed);
-  Tree_Delete(Sim_Sur_Le_Bord);
-  Tree_Delete(Tsd);
-  return true;
-}
-
-void Convex_Hull_Mesh_2D(List_T * Points, Surface * s)
-{
-  int i, N;
-
-  N = List_Nbr(Points);
-
-  Box_2_Triangles(Points, s);
-  for(i = 0; i < N; i++) {
-    THES = NULL;
-    List_Read(Points, i, &THEV);
-    Tree_Action(s->Simplexes, Action_First_Simplexes_2D);
-    /*
-       if(i%n == n-1){
-       volume = 0.0;
-       Tree_Action(s->Simplexes,VSIM_2D);
-       Msg(STATUS2, %d->%d Nodes, %d Elements",i+1,N,Tree_Nbr(s->Simplexes));
-       } 
-     */
-    if(!THES) {
-      Msg(GERROR, "Vertex (%g,%g,%g) in no simplex", THEV->Pos.X, THEV->Pos.Y,
-          THEV->Pos.Z);
-      THEV->Pos.X +=
-        CTX.mesh.rand_factor * LC2D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.Y +=
-        CTX.mesh.rand_factor * LC2D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.Z +=
-        CTX.mesh.rand_factor * LC2D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      Tree_Action(s->Simplexes, Action_First_Simplexes_2D);
-    }
-    bool ca_marche = Bowyer_Watson_2D(s, THEV, THES, 1);
-    while(!ca_marche) {
-      double dx =
-        CTX.mesh.rand_factor * LC2D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      double dy =
-        CTX.mesh.rand_factor * LC2D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.X += dx;
-      THEV->Pos.Y += dy;
-      ca_marche = Bowyer_Watson_2D(s, THEV, THES, 1);
-      THEV->Pos.X -= dx;
-      THEV->Pos.Y -= dy;
-    }
-  }
-
-}
-
-/* recuperation de la surface */
-
-static List_T *ListCurves, *ListAllCurves;
-static Tree_T *keep;
-static Simplex *SIMP;
-static int iSurface;
-
-void attribueSurface(void *a, void *b)
-{
-  Simplex *s;
-  s = *(Simplex **) a;
-  s->iEnt = iSurface;
-}
-
-void Trouve_Simplex_2D(void *a, void *b)
-{
-  Simplex *s;
-  if(SIMP != NULL)
-    return;
-  s = *(Simplex **) a;
-  if(s->iEnt < 0)
-    SIMP = s;
-}
-
-void Trouve_Simplex_Bord_2D(void *a, void *b)
-{
-  Simplex *s;
-
-  if(SIMP != NULL)
-    return;
-  s = *(Simplex **) a;
-  if(s->V[0]->Num < 0 || s->V[1]->Num < 0 || s->V[2]->Num < 0)
-    SIMP = s;
-}
-
-void CourbesDansSurface(Surface * s, List_T * ListAllCurves)
-{
-  int i, iseg;
-  Curve *c;
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &c);
-    iseg = abs(c->Num);
-    List_Replace(ListAllCurves, &iseg, fcmp_int);
-  }
-}
-
-int isListaSurface(List_T * ListSurf, Surface * s)
-{
-  int NN, j, srf;
-  bool found;
-  Curve *c;
-  NN = 0;
-  found = true;
-  for(j = 0; j < List_Nbr(s->Generatrices); j++) {
-    List_Read(s->Generatrices, j, &c);
-    srf = abs(c->Num);
-    if(!List_Search(ListSurf, &srf, fcmp_int)) {
-      found = false;
-    }
-    else
-      NN++;
-  }
-  if(found && NN == List_Nbr(ListSurf))
-    return s->Num;
-  return 0;
-}
-
-static List_T *StackSimp;
-#define MAX_DEPTH 500
-
-void recur_trouve_surface(Simplex * s, int *Depth)
-{
-  int i, j;
-  Simplex *pS, S;
-
-  if(s->iEnt != -1)
-    return;
-
-  if((*Depth) > MAX_DEPTH) {
-    List_Add(StackSimp, &s);
-    return;
-  }
-
-  (*Depth)++;
-  s->iEnt = -2;
-  Tree_Add(keep, &s);
-  for(i = 0; i < 3; i++) {
-    pS = &S;
-    pS->F[0] = s->F[i];
-    if(Tree_Query(FacesTree, &pS)
-       && List_Search(ListAllCurves, &pS->iEnt, fcmp_int)) {
-      j = abs(pS->iEnt);
-      List_Replace(ListCurves, &j, fcmp_int);
-    }
-    else if(s->S[i] && s->S[i] != &MyNewBoundary) {
-      recur_trouve_surface(s->S[i], Depth);
-    }
-  }
-  (*Depth)--;
-}
-
-extern int compareSimpSurf(const void *a, const void *b);
-
-void Restore_Surface(Surface * s)
-{
-  int N;
-  int i, depth;
-
-  StackSimp = List_Create(100, 100, sizeof(Simplex *));
-  ListCurves = List_Create(2, 2, sizeof(int));
-  iSurface = -1;
-  Tree_Action(s->Simplexes, attribueSurface);
-
-  /* Les simplexes sur le bord exterieur sont elimines */
-  ListAllCurves = List_Create(10, 3, sizeof(int));
-  CourbesDansSurface(s, ListAllCurves);
-
-
-  SIMP = NULL;
-  Tree_Action(s->Simplexes, Trouve_Simplex_Bord_2D);
-
-  if(SIMP) {
-    List_Add(StackSimp, &SIMP);
-    keep = Tree_Create(sizeof(Simplex *), compareQuality);
-    depth = 0;
-    i = 0;
-    do {
-      List_Read(StackSimp, i, &SIMP);
-      recur_trouve_surface(SIMP, &depth);
-    }
-    while(++i < List_Nbr(StackSimp));
-    List_Reset(StackSimp);
-
-    N = Tree_Nbr(keep);
-
-    iSurface = 0;
-    Tree_Action(keep, attribueSurface);
-    Tree_Delete(keep);
-    List_Reset(ListCurves);
-  }
-
-  while(1) {
-    SIMP = NULL;
-    keep = Tree_Create(sizeof(Simplex *), compareQuality);
-    Tree_Action(s->Simplexes, Trouve_Simplex_2D);
-    if(!SIMP)
-      break;
-    List_Add(StackSimp, &SIMP);
-    depth = 0;
-    i = 0;
-    do {
-      List_Read(StackSimp, i, &SIMP);
-      recur_trouve_surface(SIMP, &depth);
-    } while(++i < List_Nbr(StackSimp));
-
-    iSurface = isListaSurface(ListCurves, s);
-
-    N = Tree_Nbr(keep);
-    Msg(INFO,
-        "Initial mesh of Surface %d: %d simplices, %d/%d curves, %d faces",
-        iSurface, N, List_Nbr(ListCurves), List_Nbr(ListAllCurves),
-        Tree_Nbr(FacesTree));
-
-    Tree_Action(keep, attribueSurface);
-    Tree_Delete(keep);
-    List_Reset(ListCurves);
-    List_Reset(StackSimp);
-  }
-  // MEMORY LEAK (JF)
-  List_Delete(StackSimp);
-  List_Delete(ListCurves);
-  List_Delete(ListAllCurves);
-
-}
-
-void suppress_simplex_2D(void *data, void *dum)
-{
-  Simplex **pv;
-
-  pv = (Simplex **) data;
-  if((*pv)->iEnt == 0)
-    List_Add(Suppress, pv);
-}
-
-Vertex *NewVertex_2D(Simplex * s)
-{
-  Vertex *v = NULL;
-  double lc;
-  lc = (s->V[0]->lc + s->V[1]->lc + s->V[2]->lc) / 3.;
-
-  //lc = DMIN(MAXIMUM_LC_FOR_SURFACE,lc);
-
-  /*v = Create_Vertex(  ++THEM->MaxPointNum,
-     (s->V[0]->Pos.X + s->V[1]->Pos.X + s->V[2]->Pos.X)/3.,
-     (s->V[0]->Pos.Y + s->V[1]->Pos.Y + s->V[2]->Pos.Y)/3.,
-     0.0, lc, 0.0);
-   */
-
-  if(1){ // INSERTION_CENTROID
-    v = Create_Vertex(++THEM->MaxPointNum, s->Center.X, s->Center.Y, 0.0, lc, 0.0);
-  }
-  else{ // INSERTION_EDGE
-    Vertex *vv[2];
-    double l = THEM->Metric->getWorstEdge(s, PARAMETRIC, vv);
-    double f = 0.5;
-
-    if(vv[0]->lc <= vv[1]->lc)
-      f = vv[0]->lc / l;
-    else
-      f = 1. - (vv[1]->lc / l);
-
-    if(f >= 1)
-      v =
-        Create_Vertex(++THEM->MaxPointNum, s->Center.X, s->Center.Y, 0.0, lc,
-                      0.0);
-    else
-      v = Create_Vertex(++THEM->MaxPointNum,
-                        f * vv[0]->Pos.X + (1. - f) * vv[1]->Pos.X,
-                        f * vv[0]->Pos.Y + (1. - f) * vv[1]->Pos.Y, 0.0, lc,
-                        0.0);
-  }
-
-  v->lc = Interpole_lcTriangle(s, v);
-
-  if(PARAMETRIC) {
-    if(!v->ListCurves)
-      Normal2Surface(PARAMETRIC->Support, v->Pos.X, v->Pos.Y, v->us);
-    else {
-      v->us[0] = v->us[1] = v->us[2] = 0.0;
-    }
-  }
-  return (v);
-}
-
-void TRIE_MON_GARS(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  s->Fourre_Simplexe(s->V[0], s->V[1], s->V[2], s->V[3]);
-  s->iEnt = SURF->Num;
-  s->S[0] = s->S[1] = s->S[2] = NULL;
-  THEM->Metric->setSimplexQuality(s, PARAMETRIC);
-  //SURF->Num;
-  //qsort(s->F[0].V,3,sizeof(Vertex*),compareVertex);
-}
-
-void RandomSwapEdges2d(Surface * s)
-{
-  int i, j = 1, k;
-  List_T *AllTrg = Tree2List(s->Simplexes);
-  Simplex *t;
-  for(i = 0; i < List_Nbr(AllTrg); i++) {
-    k = rand() % List_Nbr(AllTrg);
-    List_Read(AllTrg, k, &t);
-    j = rand() % 3;
-    if(draw_simplex2d(s, t, false))
-      draw_simplex2d(s, t->S[j], false);
-    t->SwapEdge(j);
-    if(draw_simplex2d(s, t, true))
-      draw_simplex2d(s, t->S[j], true);
-  }
-}
-
-void IntelligentSwapEdges(Surface * s, GMSHMetric * m)
-{
-  int i, j, k;
-  List_T *AllTrg = Tree2List(s->Simplexes);
-  Vertex *p[4], *q[4];
-  Simplex *t;
-  for(i = 0; i < List_Nbr(AllTrg); i++) {
-    k = rand() % List_Nbr(AllTrg);
-    List_Read(AllTrg, k, &t);
-    j = rand() % 3;
-    if(t->ExtractOppositeEdges(j, p, q)) {
-      double qp = 2. * m->EdgeLengthOnSurface(s, p, 1)
-        / (RacineDeTrois * (p[0]->lc + p[1]->lc));
-      double qq = 2. * m->EdgeLengthOnSurface(s, q, 1)
-        / (RacineDeTrois * (q[0]->lc + q[1]->lc));
-      if(fabs(qp) > fabs(qq)) {
-        if(draw_simplex2d(s, t, false))
-          draw_simplex2d(s, t->S[j], false);
-        t->SwapEdge(j);
-        if(draw_simplex2d(s, t, true))
-          draw_simplex2d(s, t->S[j], true);
-      }
-    }
-  }
-  List_Delete(AllTrg);
-}
-
-int AlgorithmeMaillage2DAnisotropeModeJF(Surface * s)
-{
-  List_T *Points = List_Create(100, 100, sizeof(Vertex *));
-  int j, i, N, n;
-  List_T *c;
-  Curve *cur, *curinv;
-  extern int FACE_DIMENSION;
-  Simplex *simp;
-  Vertex *newv;
-  static int COUNT = 0;
-
-  FACE_DIMENSION = 1;
-
-  SURF = s;
-
-  if(s->Typ == MSH_SURF_PLAN || s->Typ == MSH_SURF_REGL
-     || s->Typ == MSH_SURF_TRIC)
-    PARAMETRIC = NULL;
-
-  ZONEELIMINEE = s->Num;
-
-  for(i = 0; i < List_Nbr(s->Contours); i++) {
-    List_Read(s->Contours, i, &c);
-    for(j = 0; j < List_Nbr(c); j++) {
-      Vertex *pv;
-      List_Read(c, j, &pv);
-      List_Add(Points, &pv);
-    }
-  }
-
-  N = List_Nbr(Points);
-  n = N + 100;
-
-  Msg(STATUS1, "Mesh 2D... (initial)");
-
-  Convex_Hull_Mesh_2D(Points, s);
-  List_Reset(Points);
-  Link_Simplexes(NULL, s->Simplexes);
-
-  //return 1;
-
-  if(!Restore_Boundary(s)) {
-    //s->Simplexes = Tree_Create(sizeof(Simplex*),compareSimplex);
-    FACE_DIMENSION = 2;
-    Tree_Action(s->Simplexes, TRIE_MON_GARS);
-    return 1;
-  }
-
-  Tree_Action(s->Simplexes, TRIE_MON_GARS);
-  Link_Simplexes(NULL, s->Simplexes);
-  List_T *List = Tree2List(s->Simplexes);
-  Tree_Delete(s->Simplexes);
-  s->Simplexes = Tree_Create(sizeof(Simplex *), compareQuality);
-  for(i = 0; i < List_Nbr(List); i++)
-    Tree_Add(s->Simplexes, List_Pointer(List, i));
-  List_Delete(List);
-
-  //  return 1;
-
-  FacesTree = Tree_Create(sizeof(Simplex *), compareSimpSurf);
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &cur);
-    curinv = FindCurve(abs(cur->Num));
-    List_T *temp = Tree2List(curinv->Simplexes);
-    for(j = 0; j < List_Nbr(temp); j++) {
-      Tree_Add(FacesTree, List_Pointer(temp, j));
-    }
-    List_Delete(temp);
-  }
-
-  Restore_Surface(s);
-
-  // MEMORY LEAK (JF)
-  Tree_Delete(FacesTree);
-
-  Suppress = List_Create(10, 10, sizeof(Simplex *));
-  Tree_Action(s->Simplexes, suppress_simplex_2D);
-  for(i = 0; i < List_Nbr(Suppress); i++) {
-    Tree_Suppress(s->Simplexes, List_Pointer(Suppress, i));
-  }
-
-  if(CTX.mesh.initial_only == 2){
-    List = Tree2List(s->Vertices);
-    for(i = 0; i < List_Nbr(List); i++) {
-      List_Read(List, i, &THEV);
-      if(THEV->Num < 0)
-	Tree_Suppress(s->Vertices, &THEV);
-    }
-    List_Delete(List);
-    List_Delete(Points);
-    for(i = 0; i < List_Nbr(Suppress); i++)
-      Free_Simplex(List_Pointer(Suppress, i), 0);
-    List_Delete(Suppress);
-    return 1;
-  }
-
-  Msg(STATUS1, "Mesh 2D... (final)");
-
-  if(!Tree_Right(s->Simplexes, &simp))
-    Msg(WARNING, "No simplex left");
-  else {
-    i = 0;
-    while(simp->Quality > CONV_VALUE) {
-      newv = NewVertex_2D(simp);
-      while(!simp->Pt_In_Simplex_2D(newv) &&
-            (simp->S[0] == &MyNewBoundary
-             || !simp->S[0]->Pt_In_Simplex_2D(newv))
-            && (simp->S[1] == &MyNewBoundary
-                || !simp->S[1]->Pt_In_Simplex_2D(newv))
-            && (simp->S[2] == &MyNewBoundary
-                || !simp->S[2]->Pt_In_Simplex_2D(newv))) {
-        /*
-           Msg(INFO,"pt : %12.5E %12.5E",newv->Pos.X,newv->Pos.Y);
-           Msg(INFO,"not in : (%12.5E %12.5E) (%12.5E %12.5E) (%12.5E %12.5E)",
-           simp->V[0]->Pos.X,simp->V[0]->Pos.Y,simp->V[1]->Pos.X,
-           simp->V[1]->Pos.Y,simp->V[2]->Pos.X,simp->V[2]->Pos.Y);
-         */
-        Tree_Suppress(s->Simplexes, &simp);
-        simp->Quality /= 2.;
-        Tree_Insert(s->Simplexes, &simp);
-        Tree_Right(s->Simplexes, &simp);
-        if(simp->Quality < CONV_VALUE)
-          break;
-        newv = NewVertex_2D(simp);
-      }
-      if(simp->Quality < CONV_VALUE)
-        break;
-      i++;
-      if(i % n == n - 1) {
-        volume = 0.0;
-        Tree_Action(s->Simplexes, VSIM_2D);
-        Msg(STATUS2, "Nod=%d Elm=%d Sur=%g Conv=%g->%g",
-            Tree_Nbr(s->Vertices), Tree_Nbr(s->Simplexes),
-	    volume, simp->Quality, CONV_VALUE);
-      }
-      Bowyer_Watson_2D(s, newv, simp, 0);
-      Tree_Right(s->Simplexes, &simp);
-      //if(i>COUNT)break;
-    }
-  }
-
-  //for(i=0;i<3;i++)RandomSwapEdges2d(s);
-  //for(i=0;i<2;i++)IntelligentSwapEdges(s,THEM->Metric);
-
-  List_Reset(Points);
-  FACE_DIMENSION = 2;
-  COUNT++;
-
-  Tree_Action(s->Simplexes, TRIE_MON_GARS);
-  Link_Simplexes(NULL, s->Simplexes);
-  List = Tree2List(s->Simplexes);
-  Tree_Delete(s->Simplexes);
-  s->Simplexes = Tree_Create(sizeof(Simplex *), compareSimplex);
-  for(i = 0; i < List_Nbr(List); i++)
-    Tree_Add(s->Simplexes, List_Pointer(List, i));
-  List_Delete(List);
-
-  /*suppression des points de la boite */
-  List = Tree2List(s->Vertices);
-  for(i = 0; i < List_Nbr(List); i++) {
-    List_Read(List, i, &THEV);
-    if(THEV->Num < 0) {
-      Tree_Suppress(s->Vertices, &THEV);
-      // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG 
-      // MEMORY LEAK (JF) BUT THIS CAUSES PROBLEMS AFTER !!      
-      // Free(THEV);
-      // BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG BUG 
-    }
-  }
-  List_Delete(List);
-
-  if(!Tree_Nbr(s->Simplexes))
-    Msg(GERROR, "No triangles in surface %d", s->Num);
-
-  /*
-     RandomSwapEdges2d(s);
-     for(i=0;i<1;i++)IntelligentSwapEdges(s,THEM->Metric);
-   */
-  //IntelligentSwapEdges(s,THEM->Metric);
-
-  List_Delete(Points);
-
-
-  // WAS A MEMORY LEAK
-  for(i = 0; i < List_Nbr(Suppress); i++) {
-    Free_Simplex(List_Pointer(Suppress, i), 0);
-  }
-  List_Delete(Suppress);
-
-
-  return 1;
-}
diff --git a/Mesh/2D_Mesh_Triangle.cpp b/Mesh/2D_Mesh_Triangle.cpp
deleted file mode 100644
index ea481819e345ead3be34ebe0ec81c28f9223317e..0000000000000000000000000000000000000000
--- a/Mesh/2D_Mesh_Triangle.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-// $Id: 2D_Mesh_Triangle.cpp,v 1.16 2006-08-05 13:31:28 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Mesh.h"
-#include "Numeric.h"
-#include "Context.h"
-
-#if !defined(HAVE_TRIANGLE)
-
-int Mesh_Triangle(Surface * s)
-{
-  Msg(GERROR, "Triangle is not compiled in this version of Gmsh");
-  return 1;
-}
-
-#else
-
-#define ANSI_DECLARATORS
-#define REAL double
-#define VOID void
-
-extern "C"
-{
-#include "triangle.h"
-}
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-void AddInMesh(Surface * sur, int nbbound, Vertex ** vertexbound,
-               struct triangulateio *out)
-{
-  int i;
-  Vertex **vtable;
-  Simplex *s;
-
-  //Msg(INFO, "Add in database...");
-
-  vtable = (Vertex **) Malloc(out->numberofpoints * sizeof(Vertex *));
-
-  for(i = 0; i < nbbound; i++)
-    vtable[i] = vertexbound[i];
-  Free(vertexbound);
-
-  for(i = nbbound; i < out->numberofpoints; i++) {
-    vtable[i] = Create_Vertex(++(THEM->MaxPointNum),
-                              out->pointlist[i * 2],
-                              out->pointlist[i * 2 + 1], 0.0,
-                              out->pointattributelist[i], 0.0);
-    Tree_Add(sur->Vertices, &vtable[i]);
-  }
-
-  Free(out->pointlist);
-  Free(out->pointattributelist);
-
-  for(i = 0; i < out->numberoftriangles; i++) {
-    s = Create_Simplex(vtable[out->trianglelist[i * out->numberofcorners + 0]],
-		       vtable[out->trianglelist[i * out->numberofcorners + 1]],
-		       vtable[out->trianglelist[i * out->numberofcorners + 2]],
-		       NULL);
-    s->iEnt = sur->Num;
-    Tree_Add(sur->Simplexes, &s);
-  }
-
-  Free(vtable);
-  Free(out->trianglelist);
-  Free(out->triangleattributelist);
-
-  //Msg(INFO, "...done");
-}
-
-// This is horrible...
-
-void FindPointInHole(List_T * verts, REAL * x, REAL * y)
-{
-  Vertex *v1, *v2;
-  double a[3], b[3], c[3];
-  List_Read(verts, 0, &v1);
-  List_Read(verts, 1, &v2);
-  a[0] = v2->Pos.X - v1->Pos.X;
-  a[1] = v2->Pos.Y - v1->Pos.Y;
-  a[2] = 0.;
-  b[0] = 0.;
-  b[1] = 0.;
-  b[2] = 1.;
-  prodve(b, a, c);
-  norme(c);
-  *x = 0.5 * (v1->Pos.X + v2->Pos.X) + 1.e-12 * CTX.lc * c[0];
-  *y = 0.5 * (v1->Pos.Y + v2->Pos.Y) + 1.e-12 * CTX.lc * c[1];
-}
-
-int Mesh_Triangle(Surface * s)
-{
-  char opts[128];
-  int i, j, k, l, NbPts = 0, first;
-  double val;
-  List_T *list;
-  Vertex *v, **vtable;
-  struct triangulateio in, mid, out;
-
-  for(i = 0; i < List_Nbr(s->Contours); i++) {
-    List_Read(s->Contours, i, &list);
-    NbPts += List_Nbr(list);
-  }
-
-  in.numberofpoints = NbPts;
-  in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL));
-  vtable = (Vertex **) Malloc(in.numberofpoints * sizeof(Vertex *));
-  in.numberofpointattributes = 1;
-  in.pointattributelist = (REAL *) Malloc(in.numberofpoints *
-                                          in.numberofpointattributes *
-                                          sizeof(REAL));
-  in.pointmarkerlist = NULL;
-  in.numberofsegments = NbPts;
-  in.segmentlist = (int *)Malloc(in.numberofsegments * 2 * sizeof(int));
-  in.segmentmarkerlist = (int *)Malloc(in.numberofsegments * sizeof(int));
-  in.numberofregions = 0;
-  in.regionlist = NULL;
-
-  k = 0;
-  l = 0;
-  double lc_max = -1.0;
-  for(i = 0; i < List_Nbr(s->Contours); i++) {
-    List_Read(s->Contours, i, &list);
-    first = l;
-    for(j = 0; j < List_Nbr(list); j++) {
-      List_Read(list, j, &v);
-      in.pointlist[k] = v->Pos.X;
-      in.pointlist[k + 1] = v->Pos.Y;
-      in.pointattributelist[l] = v->lc;
-      if(v->lc > lc_max) lc_max = v->lc;
-      vtable[l] = v;
-      in.segmentlist[k] = l;
-      in.segmentlist[k + 1] = (j == List_Nbr(list) - 1) ? (first) : (l + 1);
-      in.segmentmarkerlist[l] = i;
-      k += 2;
-      l++;
-    }
-  }
-
-  if(List_Nbr(s->Contours) > 1) {
-    in.numberofholes = List_Nbr(s->Contours) - 1;
-    in.holelist = (REAL *) Malloc(in.numberofholes * 2 * sizeof(REAL));
-    for(i = 1; i < List_Nbr(s->Contours); i++) {
-      List_Read(s->Contours, i, &list);
-      FindPointInHole(list, &in.holelist[(i - 1) * 2],
-                      &in.holelist[(i - 1) * 2 + 1]);
-    }
-  }
-  else {
-    in.numberofholes = 0;
-    in.holelist = NULL;
-  }
-
-  mid.pointlist = NULL;
-  mid.pointattributelist = NULL;
-  mid.pointmarkerlist = NULL;
-  mid.trianglelist = NULL;
-  mid.triangleattributelist = NULL;
-  mid.neighborlist = NULL;
-  mid.segmentlist = NULL;
-  mid.segmentmarkerlist = NULL;
-  mid.edgelist = NULL;
-  mid.edgemarkerlist = NULL;
-
-  // triangulate the points with minimum angle > 20 deg, with no
-  // boundary breaking, and with an area constraint related to the
-  // maximum char. length allowed (this last constraint is to avoid an
-  // extremely coarse initial grid, on which the interpolation of the
-  // final char. lengths would be awful).
-
-  double a = lc_max*lc_max / 1.2; // FIXME: bof
-  if(a > 1.e-6)
-    sprintf(opts, "pqzYa%f", a);
-  else
-    strcpy(opts, "pqzY");
-  if(CTX.verbosity < 4)
-    strcat(opts, "Q");
-  triangulate(opts, &in, &mid, NULL);
-
-  Free(in.pointlist);
-  Free(in.pointattributelist);
-  Free(in.pointmarkerlist);
-  Free(in.regionlist);
-  Free(in.segmentlist);
-  Free(in.segmentmarkerlist);
-  Free(in.holelist);
-
-  if(CTX.mesh.initial_only == 2) {
-    AddInMesh(s, NbPts, vtable, &mid);
-    return 0;
-  }
-
-  mid.trianglearealist =
-    (REAL *) Malloc(mid.numberoftriangles * sizeof(REAL));
-  for(i = 0; i < mid.numberoftriangles; i++) {
-    if(CTX.mesh.bgmesh_type == ONFILE) {
-      double xx = 0.0, yy = 0.0;
-      for(j = 0; j < mid.numberofcorners; j++) {
-	k = mid.trianglelist[i * mid.numberofcorners + j];
-	xx += mid.pointlist[2 * k];
-	yy += mid.pointlist[2 * k + 1];
-      }
-      xx /= mid.numberofcorners;
-      yy /= mid.numberofcorners;
-      Vertex *v, *dum;
-      v = Create_Vertex(-1, xx, yy, 0.0, 0.0, 0.0);
-      Calcule_Z_Plan(&v, &dum);
-      Projette_Inverse(&v, &dum);
-      val = BGMXYZ(v->Pos.X, v->Pos.Y, v->Pos.Z);
-      val = val * val / 1.2;  // FIXME: bof
-      Free_Vertex(&v, 0);
-    }
-    else {
-      val = 0;
-      for(j = 0; j < mid.numberofcorners; j++) {
-	k = mid.trianglelist[i * mid.numberofcorners + j];
-	val += mid.pointattributelist[k];
-      }
-      val /= mid.numberofcorners;
-      val = val * val / 1.5;  // FIXME: bof
-    }
-    mid.trianglearealist[i] = val;
-  }
-
-  out.pointlist = NULL;
-  out.pointattributelist = NULL;
-  out.trianglelist = NULL;
-  out.triangleattributelist = NULL;
-
-  // refine the triangulation according to the triangle area
-  // constraints
-
-  //strcpy(opts, "praqzBPY");
-  strcpy(opts, CTX.mesh.triangle_options);
-  if(CTX.verbosity < 4)
-    strcat(opts, "Q");
-  triangulate(opts, &mid, &out, NULL);
-
-  // free all allocated arrays + those allocated by Triangle
-
-  Free(mid.pointlist);
-  Free(mid.pointattributelist);
-  Free(mid.pointmarkerlist);
-  Free(mid.trianglelist);
-  Free(mid.triangleattributelist);
-  Free(mid.trianglearealist);
-  Free(mid.segmentlist);
-  Free(mid.segmentmarkerlist);
-
-  AddInMesh(s, NbPts, vtable, &out);
-
-  return 0;
-
-}
-
-#endif // !HAVE_TRIANGLE
diff --git a/Mesh/2D_Parametric.cpp b/Mesh/2D_Parametric.cpp
deleted file mode 100644
index 107ce02be8cc6bc181ed09dc7e7f2619dd4825b2..0000000000000000000000000000000000000000
--- a/Mesh/2D_Parametric.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-// $Id: 2D_Parametric.cpp,v 1.17 2006-07-12 07:24:14 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Interpolation.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-#include "Create.h"
-#include "Context.h"
-
-extern Mesh *THEM;
-extern Context_T CTX;
-
-static Surface *SURF;
-
-Surface *PARAMETRIC;
-
-/* SURFACES CYLINDRIQUES */
-
-void XYZtoUV(void *a, void *dum)
-{
-  Vertex *v;
-  double uu, vv;
-  v = *(Vertex **) a;
-  ProjectPointOnSurface(SURF->Support, v, &uu, &vv);
-  v->Pos.X = uu;
-  v->Pos.Y = vv;
-  v->Pos.Z = 0.0;
-}
-
-void UVtoXYZ(void *a, void *dum)
-{
-  Vertex *v, n;
-  v = *(Vertex **) a;
-
-  n = InterpolateSurface(SURF->Support, v->Pos.X, v->Pos.Y, 0, 0);
-
-  v->Pos.X = n.Pos.X;
-  v->Pos.Y = n.Pos.Y;
-  v->Pos.Z = n.Pos.Z;
-}
-
-void printMetric(Surface * s, char *name)
-{
-  int N = 10, M = 10, i, j;
-  double u, v;
-  FILE *f = fopen(name, "w");
-  if(!f)
-    return;
-  fprintf(f, "View \"metric\" Offset{0,0,0} {\n");
-  for(i = 0; i < N; i++) {
-    u = (s->ku[0]) + (s->ku[s->Nu + s->OrderU] - s->ku[0])
-      * (double)i / (double)(N - 1);
-    for(j = 0; j < M; j++) {
-      v = (s->kv[0]) + (s->kv[s->Nv + s->OrderV] - s->kv[0])
-        * (double)j / (double)(M - 1);
-      THEM->Metric->setMetric(u, v, s);
-      fprintf(f, "VT (%f,%f,0,%f,%f,0,%f,%f,0)"
-              "{%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
-              u, v, u, v, u, v,
-              THEM->Metric->m[0][0], THEM->Metric->m[0][1], 0.0,
-              THEM->Metric->m[0][0], THEM->Metric->m[0][1], 0.0,
-              THEM->Metric->m[0][0], THEM->Metric->m[0][1], 0.0);
-      fprintf(f, "VT (%f,%f,0,%f,%f,0,%f,%f,0)"
-              "{%g,%g,%g,%g,%g,%g,%g,%g,%g};\n",
-              u, v, u, v, u, v,
-              THEM->Metric->m[1][0], THEM->Metric->m[1][1], 0.0,
-              THEM->Metric->m[1][0], THEM->Metric->m[1][1], 0.0,
-              THEM->Metric->m[1][0], THEM->Metric->m[1][1], 0.0);
-    }
-  }
-  fprintf(f, "};\n");
-  fclose(f);
-}
-
-int MeshParametricSurface(Surface * s)
-{
-  int i, j, ori;
-  Curve *pC;
-  Vertex *v;
-  Tree_T *tnxe;
-
-  PARAMETRIC = s;
-
-  if(s->Typ == MSH_SURF_NURBS)
-    return 1;
-  if(s->Typ != MSH_SURF_TRIMMED || s->Support->Typ != MSH_SURF_NURBS)
-    return 0;
-
-  SURF = s;
-  if(!List_Nbr(s->Generatrices))
-    return 1;
-  for(i = 0; i < List_Nbr(s->Generatrices); i++) {
-    List_Read(s->Generatrices, i, &pC);
-    for(j = 0; j < List_Nbr(pC->Vertices); j++) {
-      List_Read(pC->Vertices, j, &v);
-      Tree_Insert(s->Vertices, List_Pointer(pC->Vertices, j));
-    }
-  }
-
-  //printMetric(THEM,s,"metric.pos");
-
-  Tree_Action(s->Vertices, Freeze_Vertex);
-
-  Tree_Action(s->Vertices, XYZtoUV);
-  ori = Calcule_Contours(s);
-
-  if(!AlgorithmeMaillage2DAnisotropeModeJF(s))
-    Maillage_Automatique_VieuxCode(s, ori);
-
-  if(CTX.mesh.nb_smoothing) {
-    tnxe = Tree_Create(sizeof(NXE), compareNXE);
-    create_NXE(s->Vertices, s->Simplexes, tnxe);
-
-    for(i = 0; i < CTX.mesh.nb_smoothing; i++)
-      Tree_Action(tnxe, ActionLiss);
-
-    //AmelioreSurface_EliminationTripet (s, THEM, tnxe);
-
-    Tree_Delete(tnxe);
-  }
-
-  Tree_Action(s->Vertices, UVtoXYZ);
-  Tree_Action(s->Vertices, deFreeze_Vertex);
-
-  PARAMETRIC = NULL;
-
-  return 1;
-}
diff --git a/Mesh/2D_Recombine.cpp b/Mesh/2D_Recombine.cpp
deleted file mode 100644
index e9a6b66092881d22b440e9369d6ba35476ff8d53..0000000000000000000000000000000000000000
--- a/Mesh/2D_Recombine.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-// $Id: 2D_Recombine.cpp,v 1.30 2006-08-22 01:58:34 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "Interpolation.h"
-#include "Utils.h"
-#include "2D_Mesh.h"
-#include "Create.h"
-#include "Context.h"
-
-extern Context_T CTX;
-
-static Tree_T *RecEdges, *Triangles, *RecSimplex, *TREEELM;
-static List_T *SimplexesToRemove;
-static double ALPHA;
-static int RECNUM;
-
-// Note: these routines temporarily leave quads in the simplex tree,
-// and only remove them at the end...
-
-void addTriangles(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  if(s->V[2] && !s->V[3])
-    Tree_Add(Triangles, &s);
-}
-
-void addRecEdges(void *a, void *b)
-{
-  Edge *ed = (Edge *) a;
-  if(ed->a < ALPHA)
-    Tree_Add(RecEdges, ed);
-}
-
-void computeAngles(void *a, void *b)
-{
-  Edge *ed = (Edge *) a;
-  if(List_Nbr(ed->Simplexes) != 2) {
-    ed->a = 180.;
-    return;
-  }
-
-  double Angle;
-  Angle = fabs(90. - angle_3pts(ed->O[0], ed->V[0], ed->O[1]));
-  Angle = DMAX(fabs(90. - angle_3pts(ed->V[0], ed->O[1], ed->V[1])), Angle);
-  Angle = DMAX(fabs(90. - angle_3pts(ed->O[1], ed->V[1], ed->O[0])), Angle);
-  Angle = DMAX(fabs(90. - angle_3pts(ed->V[0], ed->O[0], ed->V[1])), Angle);
-  ed->a = Angle;
-}
-
-void recombineFace(void *a, void *b)
-{
-  Edge *ed = (Edge *) a;
-
-  if(List_Nbr(ed->Simplexes) != 2)
-    return;
-
-  if(ed->a < ALPHA) {
-    Simplex *s1, *s2;
-    List_Read(ed->Simplexes, 0, &s1);
-    List_Read(ed->Simplexes, 1, &s2);
-    if(Tree_Search(RecSimplex, &s1))
-      return;
-    if(s1->V[3])
-      return;
-    if(Tree_Search(RecSimplex, &s2))
-      return;
-    if(s2->V[3])
-      return;
-    Tree_Add(RecSimplex, &s1);
-    Tree_Suppress(TREEELM, &s1);
-    s2->V[3] = ed->V[0];
-    s2->V[2] = ed->O[0];
-    s2->V[1] = ed->V[1];
-    s2->V[0] = ed->O[1];
-    RECNUM++;
-  }
-}
-
-void removeQuads(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  if(s->V[3])
-    List_Add(SimplexesToRemove, &s);
-}
-
-int Recombine(Tree_T * Vertices, Tree_T * Simplexes, Tree_T * Quadrangles, 
-	      double a)
-{
-  Tree_T *tnxe;
-  int ntot;
-
-  ALPHA = a;
-  TREEELM = Simplexes;
-  ntot = 0;
-
-  while(1) {
-
-    // Initialization
-    RECNUM = 0;
-    RecEdges = Tree_Create(sizeof(Edge), compareEdgeAngle);
-    RecSimplex = Tree_Create(sizeof(Simplex *), compareSimplex);
-    Triangles = Tree_Create(sizeof(Simplex *), compareSimplex);
-
-    // Recombination
-    Tree_Action(Simplexes, addTriangles);
-    EdgesContainer edges(Triangles);
-    Tree_Action(edges.AllEdges, computeAngles);
-    Tree_Action(edges.AllEdges, addRecEdges);
-    Tree_Action(RecEdges, recombineFace);
-
-    // Smoothing
-    if(CTX.mesh.nb_smoothing) {
-      tnxe = Tree_Create(sizeof(NXE), compareNXE);
-      create_NXE(Vertices, Simplexes, tnxe);
-      for(int i = 0; i < CTX.mesh.nb_smoothing; i++)
-        Tree_Action(tnxe, ActionLissSurf);
-      delete_NXE(tnxe);
-    }
-
-    // Destruction
-    Tree_Delete(RecEdges);
-    Tree_Action(RecSimplex, Free_Simplex);
-    Tree_Delete(RecSimplex);
-    Tree_Delete(Triangles);
-
-    ntot += RECNUM;
-    if(!RECNUM)
-      break;
-  }
-
-  // remove the quads from the simplex tree
-  SimplexesToRemove = List_Create(100, 100, sizeof(Simplex*));
-  Tree_Action(Simplexes, removeQuads);
-  for(int i = 0; i < List_Nbr(SimplexesToRemove); i++){
-    Simplex *s;
-    List_Read(SimplexesToRemove, i, &s);
-    Quadrangle *q = Create_Quadrangle(s->V[0], s->V[1], s->V[2], s->V[3]);
-    q->iEnt = s->iEnt;
-    Tree_Add(Quadrangles, &q);
-    Tree_Suppress(Simplexes, &s);
-    Free_Simplex(&s, NULL);
-  }
-  List_Delete(SimplexesToRemove);
-
-  Msg(STATUS2, "Recombined %d quadrangles", ntot);
-
-  return ntot;
-}
-
-/*
-  This function recombines EVERYTHING. 
-
-  First, all characteristic lengths are divided by 2.
-
-  This is done in 3 steps.
-  -) the previous technique is applied to every surface
-  -) remainder triangles are split into 3 quads and all recombined quads
-     are split into 4 quads
-  -) Enhancements are performned on the quad mesh.
- */
-
-int Recombine_All(Mesh *M)
-{
-  if(!Tree_Nbr(M->Surfaces)) 
-    return 0;
-
-  List_T *surfaces = Tree2List(M->Surfaces);
-
-  // check if we need to do something
-  int to_do = 0;
-  for(int i = 0; i < List_Nbr(surfaces); i++){
-    Surface *s;
-    List_Read(surfaces, i, &s);
-    if(s->Recombine){
-      to_do = 1;
-      break;
-    }
-  }
-  
-  if(!to_do){
-    List_Delete(surfaces);
-    return 0;
-  }
-  
-  // add 2nd order nodes to all elements 
-  Degre2();
-
-  Msg(STATUS2, "Splitting all elements");
-
-  // then split everybody
-  for(int i = 0; i < List_Nbr(surfaces); i++){
-    Surface *s;
-    List_Read(surfaces, i, &s);
-
-    List_T *Quadrangles = Tree2List(s->Quadrangles);
-    for(int j=0 ; j<List_Nbr(Quadrangles); j++){
-      Quadrangle *q;
-      List_Read(Quadrangles, j, &q);
-      Quadrangle *q1 = Create_Quadrangle(q->V[0], q->VSUP[0], q->VSUP[4], q->VSUP[3]);
-      Quadrangle *q2 = Create_Quadrangle(q->V[1], q->VSUP[1], q->VSUP[4], q->VSUP[0]);
-      Quadrangle *q3 = Create_Quadrangle(q->V[2], q->VSUP[2], q->VSUP[4], q->VSUP[1]);
-      Quadrangle *q4 = Create_Quadrangle(q->V[3], q->VSUP[3], q->VSUP[4], q->VSUP[2]);
-      q1->iEnt = q2->iEnt = q3->iEnt = q4->iEnt = q->iEnt;      
-      for(int k = 0; k < 5; k++){
-	q->VSUP[k]->Degree = 1;
-	Tree_Insert(s->Vertices, &q->VSUP[k]);
-      }
-      Tree_Add(s->Quadrangles, &q1);
-      Tree_Add(s->Quadrangles, &q2);
-      Tree_Add(s->Quadrangles, &q3);
-      Tree_Add(s->Quadrangles, &q4);
-      Tree_Suppress(s->Quadrangles, &q);
-      Free_Quadrangle(&q, 0);
-    }
-    List_Delete(Quadrangles);
-    
-    List_T *Triangles = Tree2List(s->Simplexes);
-    if(s->Recombine){
-      for(int j=0 ; j<List_Nbr(Triangles); j++){
-	Simplex *t;
-	List_Read(Triangles, j, &t);
-	Vertex *c;
-	if(s->Typ == MSH_SURF_PLAN || s->Typ == MSH_SURF_DISCRETE){
-	  c = Create_Vertex(++M->MaxPointNum, 
-			    (t->V[0]->Pos.X+t->V[1]->Pos.X+t->V[2]->Pos.X)/3.,
-			    (t->V[0]->Pos.Y+t->V[1]->Pos.Y+t->V[2]->Pos.Y)/3.,
-			    (t->V[0]->Pos.Z+t->V[1]->Pos.Z+t->V[2]->Pos.Z)/3.,
-			    (t->V[0]->lc+t->V[1]->lc+t->V[2]->lc)/3.,
-			    (t->V[0]->u+t->V[1]->u+t->V[2]->u)/3.);
-	}
-	else{
-	  double U1, U2, U3, V1, V2, V3;
-	  XYZtoUV(s, t->V[0]->Pos.X, t->V[0]->Pos.Y, t->V[0]->Pos.Z, &U1, &V1, 1.0);
-	  XYZtoUV(s, t->V[1]->Pos.X, t->V[1]->Pos.Y, t->V[1]->Pos.Z, &U2, &V2, 1.0);
-	  XYZtoUV(s, t->V[2]->Pos.X, t->V[2]->Pos.Y, t->V[2]->Pos.Z, &U3, &V3, 1.0);
-	  double U = (U1 + U2 + U3)/.3;
-	  double V = (V1 + V2 + V3)/3.;
-	  Vertex v = InterpolateSurface(s, U, V, 0, 0);
-	  c = Create_Vertex(++M->MaxPointNum, v.Pos.X, v.Pos.Y, v.Pos.Z, v.lc, v.u);
-	}  
-        Tree_Add(M->Vertices, &c);
-        Tree_Insert(s->Vertices, &c);
-	Quadrangle *q1 = Create_Quadrangle(t->V[0], t->VSUP[0], c, t->VSUP[2]);
-	Quadrangle *q2 = Create_Quadrangle(t->V[1], t->VSUP[1], c, t->VSUP[0]);
-	Quadrangle *q3 = Create_Quadrangle(t->V[2], t->VSUP[2], c, t->VSUP[1]);
-	q1->iEnt = q2->iEnt = q3->iEnt = t->iEnt;
-	for(int k = 0; k < 3; k++){
-	  t->VSUP[k]->Degree = 1;
-	  Tree_Insert(s->Vertices, &t->VSUP[k]);
-	}
-	Tree_Add(s->Quadrangles, &q1);
-	Tree_Add(s->Quadrangles, &q2);
-	Tree_Add(s->Quadrangles, &q3);
-	Tree_Suppress(s->Simplexes, &t);
-	Free_Simplex(&t, 0);
-      }
-    }
-    else{
-      for(int j=0 ; j<List_Nbr(Triangles); j++){
-	Simplex *t;
-	List_Read(Triangles, j, &t);
-	Simplex *t1 = Create_Simplex(t->V[0], t->VSUP[0],t->VSUP[2], 0);
-	Simplex *t2 = Create_Simplex(t->V[1], t->VSUP[1],t->VSUP[0], 0);
-	Simplex *t3 = Create_Simplex(t->V[2], t->VSUP[2],t->VSUP[1], 0);
-	Simplex *t4 = Create_Simplex(t->VSUP[0], t->VSUP[1],t->VSUP[2], 0);
-	t1->iEnt = t2->iEnt = t3->iEnt = t4->iEnt = t->iEnt;
-	for(int k = 0; k < 3; k++){
-	  t->VSUP[k]->Degree = 1;
-	  Tree_Insert(s->Vertices, &t->VSUP[k]);
-	}
-	Tree_Add(s->Simplexes, &t1);
-	Tree_Add(s->Simplexes, &t2);
-	Tree_Add(s->Simplexes, &t3);
-	Tree_Add(s->Simplexes, &t4);
-	Tree_Suppress(s->Simplexes, &t);
-	Free_Simplex(&t, 0);
-      }
-    }
-    List_Delete(Triangles);
-  }
-
-  List_Delete(surfaces);
-
-  List_T *curves = Tree2List(M->Curves);
-  for(int i = 0; i < List_Nbr(curves); i++){
-    Curve *c;
-    List_Read(curves, i, &c);
-
-    List_T *Lines = Tree2List(c->Simplexes);
-    for(int j=0 ; j<List_Nbr(Lines); j++){
-      Simplex *l;
-      List_Read(Lines, j, &l);
-      Simplex *l1 = Create_Simplex(l->V[0], l->VSUP[0], 0, 0);
-      Simplex *l2 = Create_Simplex(l->VSUP[0], l->V[1], 0, 0);
-      l1->iEnt = l2->iEnt = l->iEnt;
-      l->VSUP[0]->Degree = 1;
-      Tree_Add(c->Simplexes, &l1);
-      Tree_Add(c->Simplexes, &l2);
-      Tree_Suppress(c->Simplexes, &l);
-      Free_Simplex(&l, 0);
-    }
-    List_Delete(Lines);
-  }
-  
-  List_Delete(curves);
-
-  Degre1();
-
-  return 1;
-}
diff --git a/Mesh/2D_Transfinite.cpp b/Mesh/2D_Transfinite.cpp
deleted file mode 100644
index df5581e06612047b65f823cbd03debcb89149858..0000000000000000000000000000000000000000
--- a/Mesh/2D_Transfinite.cpp
+++ /dev/null
@@ -1,306 +0,0 @@
-// $Id: 2D_Transfinite.cpp,v 1.5 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-/*  
-  Maillage transfini surfacique                                                 
-                                            *s2
-       s3     c2    s2                     /|  
-        *-----------*                     / |
-        |           |                  c2/  |c1   
-      c3|           |c1                 /   |  
-        |           |                  /    |
-  v     *-----------*                 *-----*
-  |    s0     c0    s1               s0  c0  s1
-  *--u
-
-  Decoupages :  |
-                *--*
-                |\ |
-                | \|   
-                *--*-- 
-               s0    -> s1
-*/
-
-#include "Gmsh.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "Numeric.h"
-#include "Interpolation.h"
-
-extern Mesh *THEM;
-
-int index1d(int flag, int N, int n)
-{
-  switch (flag) {
-  case 0:
-    return n;
-  case 1:
-    return (N - n - 1);
-  default:
-    return -1;
-  }
-}
-
-int MeshTransfiniteSurface(Surface * sur)
-{
-
-  int i, j, k, flag, nb, N1, N2, issphere;
-  Curve *G[4], *GG[4];
-  Vertex V, *c1, *c2, **list, *CP[2];
-  Simplex *simp;
-  Quadrangle *quad;
-  double u, v;
-  int C_flag[4];
-  Vertex *C[4], *S[4];
-
-  static int tab1qua[] = { 0, 1, 1, 2, 3, 2, 0, 3 };
-  static int tab1tri[] = { 0, 1, 1, 2, 0, 2 };
-  static int tab2[] = { 0, 1, 1, 0 };
-
-  if(sur->Method != TRANSFINI)
-    return 0;
-
-  nb = List_Nbr(sur->Generatrices);
-  if(nb != 3 && nb != 4)
-    return 0;
-  if(nb != List_Nbr(sur->TrsfPoints))
-    return 0;
-  
-  for(i = 0; i < 4; i++)
-    G[i] = NULL;
-  
-  for(i = 0; i < nb; i++){
-    List_Read(sur->TrsfPoints, i, &S[i]);
-    List_Read(sur->Generatrices, i, &GG[i]);
-  }
-  
-  for(i = 0; i < nb; i++) {
-    List_Read(GG[i]->Control_Points, 0, &CP[0]);
-    List_Read(GG[i]->Control_Points, List_Nbr(GG[i]->Control_Points) - 1, &CP[1]);
-    
-    for(flag = 0; flag < 2; flag++) {
-      for(k = 0; k < nb; k++) {
-	if(nb == 4) {
-	  if(S[tab1qua[2 * k]]->Num == CP[tab2[2 * flag]]->Num &&
-	     S[tab1qua[2 * k + 1]]->Num == CP[tab2[2 * flag + 1]]->Num) {
-	    G[k] = GG[i];
-	    C_flag[k] = flag;
-	  }
-	}
-	else {
-	  if(S[tab1tri[2 * k]]->Num == CP[tab2[2 * flag]]->Num &&
-	     S[tab1tri[2 * k + 1]]->Num == CP[tab2[2 * flag + 1]]->Num) {
-	    G[k] = GG[i];
-	    C_flag[k] = flag;
-	  }
-	}
-      }
-    }
-  }
-  
-  for(i = 0; i < nb; i++)
-    if(G[i] == NULL) {
-      Msg(WARNING, "Wrong definition of Transfinite Surface %d", sur->Num);
-      return 0;
-    }
-  
-  if(nb == 4) {
-    if((N1 = List_Nbr(G[0]->Vertices)) != List_Nbr(G[2]->Vertices))
-      return 0;
-    if((N2 = List_Nbr(G[1]->Vertices)) != List_Nbr(G[3]->Vertices))
-      return 0;
-  }
-  else {
-    if((N1 = List_Nbr(G[0]->Vertices)) != List_Nbr(G[2]->Vertices))
-      return 0;
-    N2 = List_Nbr(G[1]->Vertices);
-  }
-  
-  sur->Nu = N1;
-  sur->Nv = N2;
-  list = (Vertex **) Malloc(N1 * N2 * sizeof(Vertex *));
-  
-  issphere = 1;
-  for(i = 0; i < nb; i++) {
-    if(G[i]->Typ != MSH_SEGM_CIRC && G[i]->Typ != MSH_SEGM_CIRC_INV) {
-      issphere = 0;
-    }
-    else if(issphere) {
-      if(!i) {
-	List_Read(G[i]->Control_Points, 1, &c1);
-      }
-      else {
-	List_Read(G[i]->Control_Points, 1, &c2);
-	if(compareVertex(&c1, &c2))
-	  issphere = 0;
-      }
-    }
-  }
-  
-  for(i = 0; i < N1; i++) {
-    List_Read(G[0]->Vertices, index1d(C_flag[0], N1, i), &C[0]);
-    List_Read(G[2]->Vertices, index1d(C_flag[2], N1, i), &C[2]);
-    
-    if((G[0]->Num > 0 && C_flag[0]) || (G[0]->Num < 0 && !C_flag[0]))
-      u = 1. - C[0]->u;
-    else
-      u = C[0]->u;
-    
-    for(j = 0; j < N2; j++) {
-      List_Read(G[1]->Vertices, index1d(C_flag[1], N2, j), &C[1]);
-      if(nb == 4)
-	List_Read(G[3]->Vertices, index1d(C_flag[3], N2, j), &C[3]);
-      
-      if((G[1]->Num > 0 && C_flag[1]) || (G[1]->Num < 0 && !C_flag[1]))
-	v = 1. - C[1]->u;
-      else
-	v = C[1]->u;
-      
-      if(i && j && i != N1 - 1 && j != N2 - 1) {
-	if(sur->Typ == MSH_SURF_NURBS)
-	  V = InterpolateSurface(sur, u, v, 0, 0);
-	else if(nb == 4)
-	  V = TransfiniteQua(*C[0], *C[1], *C[2], *C[3], *S[0], *S[1], *S[2],
-			     *S[3], u, v);
-	else
-	  V = TransfiniteTri(*C[0], *C[1], *C[2], *S[0], *S[1], *S[2], u, v);
-	if(issphere)
-	  TransfiniteSph(*C[0], *c1, &V);
-	list[i + N1 * j] =
-	  Create_Vertex(++THEM->MaxPointNum, V.Pos.X, V.Pos.Y, V.Pos.Z, V.lc, 0.0);
-      }
-      else if(!i)
-	list[i + N1 * j] = (nb == 4) ? C[3] : C[2];
-      else if(!j)
-	list[i + N1 * j] = C[0];
-      else if(i == N1 - 1)
-	list[i + N1 * j] = C[1];
-      else if(j == N2 - 1)
-	list[i + N1 * j] = C[2];
-      
-      list[i + N1 * j]->us[0] = u;
-      list[i + N1 * j]->us[1] = v;
-    }
-  }
-  
-  for(i = 0; i < N1; i++) {
-    for(j = 0; j < N2; j++) {
-      List_Add(sur->TrsfVertices, &list[i + N1 * j]);
-    }
-  }
-  
-  if(nb == 4) {
-    for(i = 0; i < N1; i++) {
-      for(j = 0; j < N2; j++) {
-	Tree_Insert(sur->Vertices, &list[i + N1 * j]);
-      }
-    }
-    for(i = 0; i < N1 - 1; i++) {
-      for(j = 0; j < N2 - 1; j++) {
-	if(sur->Recombine) {
-	  quad = Create_Quadrangle(list[(i) + N1 * (j)],
-				   list[(i + 1) + N1 * (j)],
-				   list[(i + 1) + N1 * (j + 1)],
-				   list[(i) + N1 * (j + 1)]);
-	  quad->iEnt = sur->Num;
-	  Tree_Add(sur->Quadrangles, &quad);
-	}
-	else {
-	  if (sur->Recombine_Dir == 1 ||
-	      (sur->Recombine_Dir == 0 && 
-	       ( ( i % 2 == 0 && j % 2 == 1 ) ||
-		 ( i % 2 == 1 && j % 2 == 0 ) ) ) ) {  
-	    // DECOUPAGE1
-	    simp = Create_Simplex(list[(i) + N1 * (j)], 
-				  list[(i + 1) + N1 * (j)],
-				  list[(i) + N1 * (j + 1)], NULL);
-	    simp->iEnt = sur->Num;
-	    Tree_Add(sur->Simplexes, &simp);
-	    
-	    simp = Create_Simplex(list[(i + 1) + N1 * (j + 1)],
-				  list[(i) + N1 * (j + 1)],
-				  list[(i + 1) + N1 * (j)], NULL);
-	    simp->iEnt = sur->Num;
-	    Tree_Add(sur->Simplexes, &simp);
-	  }
-	  else {
-	    // DECOUPAGE2
-	    simp = Create_Simplex(list[(i) + N1 * (j)], 
-				  list[(i + 1) + N1 * (j)],
-				  list[(i + 1) + N1 * (j + 1) ], NULL);
-	    simp->iEnt = sur->Num;
-	    Tree_Add(sur->Simplexes, &simp);
-	    
-	    simp = Create_Simplex(list[(i) + N1 * (j + 1)],
-				  list[(i) + N1 * j ],
-				  list[(i + 1) + N1 * (j + 1)], NULL);
-	    simp->iEnt = sur->Num;
-	    Tree_Add(sur->Simplexes, &simp);
-	  }
-	}
-      }
-    }
-  }
-  else if(nb == 3) {
-    Tree_Insert(sur->Vertices, &list[0]);
-    for(i = 1; i < N1; i++) {
-      for(j = 0; j < N2; j++) {
-	Tree_Insert(sur->Vertices, &list[i + N1 * j]);
-      }
-    }
-    for(j = 0; j < N2 - 1; j++) {
-      simp = Create_Simplex(list[1 + N1 * (j + 1)], 
-			    list[N1 * (j + 1)],
-			    list[1 + N1 * (j)], NULL);
-      simp->iEnt = sur->Num;
-      Tree_Add(sur->Simplexes, &simp);
-    }
-    for(i = 1; i < N1 - 1; i++) {
-      for(j = 0; j < N2 - 1; j++) {
-	if(sur->Recombine) {
-	  quad = Create_Quadrangle(list[(i) + N1 * (j)],
-				   list[(i + 1) + N1 * (j)],
-				   list[(i + 1) + N1 * (j + 1)],
-				   list[i + N1 * (j + 1)]);
-	  quad->iEnt = sur->Num;
-	  Tree_Add(sur->Quadrangles, &quad);
-	}
-	else {
-	  simp = Create_Simplex(list[(i) + N1 * (j)], 
-				list[(i + 1) + N1 * (j)],
-				list[(i) + N1 * (j + 1)], NULL);
-	  simp->iEnt = sur->Num;
-	  Tree_Add(sur->Simplexes, &simp);
-	  
-	  simp = Create_Simplex(list[(i + 1) + N1 * (j + 1)],
-				list[(i) + N1 * (j + 1)],
-				list[(i + 1) + N1 * (j)], NULL);
-	  simp->iEnt = sur->Num;
-	  Tree_Add(sur->Simplexes, &simp);
-	}
-      }
-    }
-    
-  }
-  Free(list);
-
-  return 1;
-}
diff --git a/Mesh/2D_Tree.cpp b/Mesh/2D_Tree.cpp
deleted file mode 100644
index 86a3580f13ee8ec315e0a50c63d82b17fc2fd385..0000000000000000000000000000000000000000
--- a/Mesh/2D_Tree.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-// $Id: 2D_Tree.cpp,v 1.15 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-
-// deletes the tree (*not* the data! only the links)
-
-int avltree_remove(avlstruct ** root)
-{
-  int delete_this_node = 0;
-
-  if(*root == NULL)
-    return (1);
-
-  if(((*root)->left == NULL) && ((*root)->right == NULL))
-    delete_this_node = 1;
-  else {
-    if((*root)->left == NULL)
-      if(avltree_remove(&(*root)->left)) {
-        Free((*root)->left);
-        (*root)->left = NULL;
-      }
-    if((*root)->right == NULL)
-      if(avltree_remove(&(*root)->right)) {
-        Free((*root)->right);
-        (*root)->right = NULL;
-      }
-    if(((*root)->left == NULL) && ((*root)->right == NULL))
-      delete_this_node = 1;
-  }
-  return delete_this_node;
-}
-
-// inserts a node
-
-int avltree_insert(avlstruct ** root, void *item,
-                   int (*fcmp) (void *a, void *b))
-{
-  int cmpresult = 0;
-
-  if(*root != NULL)
-    cmpresult = fcmp(item, (*root)->treedata);
-
-  if(*root == NULL) {
-    *root = (avlstruct *) Malloc(sizeof(avlstruct));
-    (*root)->treedata = item;
-    (*root)->left = NULL;
-    (*root)->right = NULL;
-  }
-  else if(cmpresult < 0)
-    avltree_insert(&(*root)->left, item, fcmp);
-  else
-    avltree_insert(&(*root)->right, item, fcmp);
-  return (1);
-}
-
-// deletes a node
-
-int avltree_delete(avlstruct ** root, void *item,
-                   int (*fcmp) (void *a, void *b))
-{
-  avlstruct *t1, *t12;
-  int cmpresult = 0;
-
-  if(*root != NULL)
-    cmpresult = fcmp(item, (*root)->treedata);
-
-  if(*root == NULL) {
-    return (1);
-  }
-  if(cmpresult < 0) {
-    return (avltree_delete(&(*root)->left, item, fcmp));
-  }
-  else if(cmpresult > 0) {
-    return (avltree_delete(&(*root)->right, item, fcmp));
-  }
-  else if((cmpresult == 0)) {
-    if(((*root)->right == NULL) && (&(*root)->left == NULL)) {
-      Free(*root);
-      *root = NULL;
-      return (1);
-    }
-    else if((*root)->right == NULL) {
-      t1 = (*root)->left;
-      Free(*root);
-      *root = t1;
-      return (1);
-    }
-    else if((*root)->left == NULL) {
-      t1 = (*root)->right;
-      Free(*root);
-      *root = t1;
-      return (1);
-    }
-    else {
-      t1 = t12 = (*root)->right;
-      while(t12->left != NULL)
-        t12 = t12->left;
-      t12->left = (*root)->left;
-      Free(*root);
-      *root = t1;
-      return (1);
-    }
-  }
-  else {
-    return (avltree_delete(&(*root)->left, item, fcmp));
-  }
-
-}
-
-// counts the number of nodes
-
-void avltree_count(avlptr root, int *numtri)
-{
-  if(root != NULL) {
-    avltree_count(root->left, numtri);
-
-    (*numtri)++;
-
-    avltree_count(root->right, numtri);
-  }
-}
-
-// unrolls the tree into a vector
-
-void avltree_print(avlptr root, Delaunay ** listdel, int *numtri)
-{
-  if(root != NULL) {
-    avltree_print(root->left, listdel, numtri);
-    listdel[(*numtri)++] = (Delaunay *) (root)->treedata;
-    avltree_print(root->right, listdel, numtri);
-  }
-}
diff --git a/Mesh/2D_Util.cpp b/Mesh/2D_Util.cpp
deleted file mode 100644
index 3c5eb39d2ca8b23be93f2002a8483a44536d3d63..0000000000000000000000000000000000000000
--- a/Mesh/2D_Util.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-// $Id: 2D_Util.cpp,v 1.26 2006-08-05 13:31:28 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "2D_Mesh.h"
-#include "Context.h"
-
-extern Context_T CTX;
-extern PointRecord *gPointArray;
-extern Mesh *THEM;
-
-int Comparekey(void *d1, void *d2)
-{
-  double val;
-  PointNumero a, b, c, aa, bb, cc;
-
-  a = ((Delaunay *) d1)->t.a;
-  b = ((Delaunay *) d1)->t.b;
-  c = ((Delaunay *) d1)->t.c;
-  aa = ((Delaunay *) d2)->t.a;
-  bb = ((Delaunay *) d2)->t.b;
-  cc = ((Delaunay *) d2)->t.c;
-
-  val =
-    ((Delaunay *) d2)->t.quality_value - ((Delaunay *) d1)->t.quality_value;
-
-  if((aa == a) && (bb == b) && (cc == c)) {
-    return 0;
-  }
-  else if(val > 1.e-21)
-    return 1;
-  else if(val < -1.e-21)
-    return -1;
-  else {
-    if(((Delaunay *) d1)->t.xc > ((Delaunay *) d2)->t.xc)
-      return -1;
-    else
-      return 1;
-  }
-}
-
-int Insert_Triangle(avlstruct ** root, Delaunay * del)
-{
-  if(!avltree_insert(root, del, Comparekey))
-    return (0);
-
-  return (1);
-}
-
-int Delete_Triangle(avlstruct ** root, Delaunay * del)
-{
-  if(!avltree_delete(root, del, Comparekey))
-    return (0);
-
-  if(*root == NULL)
-    return (0);
-  return (1);
-}
-
-int Insert_Point(MPoint pt, int *numpoints, int *numalloc,
-                 DocRecord * doc, DocRecord * BGM)
-{
-  Vertex *v, *dum;
-  double qual;
-
-  if(*numpoints >= *numalloc) {
-    gPointArray = (PointRecord *) Realloc(gPointArray,
-                                          (*numalloc +
-                                           1000) * sizeof(PointRecord));
-    *numalloc += 1000;
-    doc->points = gPointArray;
-  }
-  PushgPointArray(gPointArray);
-  gPointArray[*numpoints].where.h = pt.h;
-  gPointArray[*numpoints].where.v = pt.v;
-  gPointArray[*numpoints].numcontour = -1;
-  gPointArray[*numpoints].initial = -1;
-  if(CTX.mesh.bgmesh_type == ONFILE){
-    v = Create_Vertex(-1, pt.h, pt.v, 0.0, 0.0, 0.0);
-    Calcule_Z_Plan(&v, &dum);
-    Projette_Inverse(&v, &dum);
-    qual = BGMXYZ(v->Pos.X, v->Pos.Y, v->Pos.Z);
-    if(CTX.mesh.constrained_bgmesh)
-      gPointArray[*numpoints].quality = MIN(find_quality(pt, BGM), qual);
-    else
-      gPointArray[*numpoints].quality = qual;
-    Free_Vertex(&v, 0);
-  }
-  else
-    gPointArray[*numpoints].quality = find_quality(pt, BGM);
-
-  (*numpoints)++;
-
-  return 1;
-}
-
-void findtree(avlptr root, double *qualm, Delaunay ** delf, DocRecord * MESH)
-{
-  /* 
-     trouve le triangle possedant le facteur de qualite max 
-     modif : le centre du cercle circonscrit de ce triangle
-     doit etre dans le domaine   
-   */
-
-  MPoint pt;
-  double q;
-  Delaunay *del;
-
-  if(root != NULL) {
-    findtree((root)->left, qualm, delf, MESH);
-    del = (Delaunay *) root->treedata;
-    q = del->t.quality_value;
-    pt.h = del->t.xc;
-    pt.v = del->t.yc;
-    if((q > *qualm) && (Find_Triangle(pt, MESH, A_TOUT_PRIX) != NULL)) {
-      *qualm = q;
-      *delf = del;
-    }
-    findtree((root)->right, qualm, delf, MESH);
-  }
-}
-
-Delaunay *findrightest(avlptr root, DocRecord * MESH)
-{
-  Delaunay *del, **dee;
-  MPoint pt;
-  avlptr exroot;
-  double qualm;
-
-  exroot = root;
-
-  while((exroot)->left != NULL) {
-    exroot = (exroot)->left;
-  }
-
-  del = (Delaunay *) (exroot)->treedata;
-  pt.h = del->t.xc;
-  pt.v = del->t.yc;
-
-  if(Find_Triangle(pt, MESH, A_TOUT_PRIX) != NULL)
-    return del;
-
-  exroot = root;
-  del = (Delaunay *) (root)->treedata;
-  qualm = del->t.quality_value;
-  dee = &del;
-  findtree(exroot, &qualm, dee, MESH);
-  del = *dee;
-
-  return (del);
-}
-
-MPoint Localize(Delaunay * del, DocRecord * MESH)
-{
-  MPoint pt;
-
-  switch (CTX.mesh.point_insertion) {
-  case BARYCENTER:
-    pt.h = (gPointArray[del->t.a].where.h + gPointArray[del->t.b].where.h
-            + gPointArray[del->t.c].where.h) / 3.;
-    pt.v = (gPointArray[del->t.a].where.v + gPointArray[del->t.b].where.v
-            + gPointArray[del->t.c].where.v) / 3.;
-    return pt;
-  case CENTER_CIRCCIRC:
-  default:
-    pt.h = del->t.xc;
-    pt.v = del->t.yc;
-    return pt;
-  }
-}
diff --git a/Mesh/3D_Coherence.cpp b/Mesh/3D_Coherence.cpp
deleted file mode 100644
index bebc978a123b884dcbff5082a896beb0394f0b2c..0000000000000000000000000000000000000000
--- a/Mesh/3D_Coherence.cpp
+++ /dev/null
@@ -1,1571 +0,0 @@
-// $Id: 3D_Coherence.cpp,v 1.37 2006-08-05 10:05:45 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "3D_Mesh.h"
-#include "Create.h"
-
-extern Mesh *THEM;
-extern int FACE_DIMENSION;
-extern Simplex MyNewBoundary;
-extern int edges_tetra[6][2];
-extern int edges_non[3];
-
-static Volume *THEVOL;
-static Edge *TheEdge;
-static Face *TheFace;
-static List_T *Teti;
-
-List_T *Missing, *MissingF, *MissingS;
-Tree_T *EdgesTree, *FacesTree, *swaps, *touchedvertex;
-
-int memesens(Vertex * v1, Vertex * v2, Vertex * v3,
-             Vertex * c1, Vertex * c2, Vertex * c3)
-{
-  double v12[3], v13[3], n1[3], n2[3], p;
-
-  v12[0] = c1->Pos.X - c2->Pos.X;
-  v12[1] = c1->Pos.Y - c2->Pos.Y;
-  v12[2] = c1->Pos.Z - c2->Pos.Z;
-
-  v13[0] = c1->Pos.X - c3->Pos.X;
-  v13[1] = c1->Pos.Y - c3->Pos.Y;
-  v13[2] = c1->Pos.Z - c3->Pos.Z;
-
-  prodve(v12, v13, n1);
-
-  v12[0] = v1->Pos.X - v2->Pos.X;
-  v12[1] = v1->Pos.Y - v2->Pos.Y;
-  v12[2] = v1->Pos.Z - v2->Pos.Z;
-
-  v13[0] = v1->Pos.X - v3->Pos.X;
-  v13[1] = v1->Pos.Y - v3->Pos.Y;
-  v13[2] = v1->Pos.Z - v3->Pos.Z;
-
-  prodve(v12, v13, n2);
-
-  prosca(n1, n2, &p);
-
-  return ((p > 0) ? 1 : 0);
-}
-
-static void pvertex(void *a, void *b)
-{
-  /*
-     Vertex *v;
-     v = (Vertex *) a;
-     printf ("noeud %d = (%12.5E,%12.5E,%12.5E)\n", v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z);
-   */
-}
-
-static void pedge(void *a, void *b)
-{
-  /*
-     Edge *e;
-     e = (Edge *) a;
-     printf ("arete %d (%12.5E,%12.5E,%12.5E) -> %d (%12.5E,%12.5E,%12.5E)\n",
-     e->V[0]->Num, e->V[0]->Pos.X, e->V[0]->Pos.Y, e->V[0]->Pos.Z,
-     e->V[1]->Num, e->V[1]->Pos.X, e->V[1]->Pos.Y, e->V[1]->Pos.Z);
-   */
-}
-
-void find_quads(void *a, void *b)
-{
-  Edge *q;
-  Edge diag;
-  Simplex *s1, *s2;
-  q = (Edge *) a;
-
-  if(!List_Search(Missing, q, compareEdge))
-    return;
-
-  if(List_Nbr(q->Simplexes) != 2)
-    return;
-
-  List_Read(q->Simplexes, 0, &s1);
-  List_Read(q->Simplexes, 1, &s2);
-  if(s1->iEnt != s2->iEnt)
-    return;
-  if(!q->O[1])
-    return;
-
-  diag.V[0] = q->O[0];
-  diag.V[1] = q->O[1];
-
-  if(Tree_Search(EdgesTree, &diag)) {
-    Tree_Add(swaps, q);
-  }
-}
-
-void swap_quads(void *a, void *b)
-{
-  Edge *q;
-  Simplex *s1, *s2;
-
-  q = (Edge *) a;
-  List_Read(q->Simplexes, 0, &s1);
-  List_Read(q->Simplexes, 1, &s2);
-
-  if(Tree_Query(touchedvertex, &q->V[0]))
-    return;
-  if(Tree_Query(touchedvertex, &q->V[1]))
-    return;
-  if(Tree_Query(touchedvertex, &q->O[0]))
-    return;
-  if(Tree_Query(touchedvertex, &q->O[1]))
-    return;
-
-  Tree_Add(touchedvertex, &q->V[0]);
-  Tree_Add(touchedvertex, &q->V[1]);
-  Tree_Add(touchedvertex, &q->O[0]);
-  Tree_Add(touchedvertex, &q->O[1]);
-
-  if(memesens(s1->V[0], s1->V[1], s1->V[2], q->O[0], q->O[1], q->V[0])) {
-    s1->V[0] = q->O[0];
-    s1->V[1] = q->O[1];
-    s1->V[2] = q->V[0];
-  }
-  else {
-    s1->V[0] = q->O[1];
-    s1->V[1] = q->O[0];
-    s1->V[2] = q->V[0];
-  }
-
-  if(memesens(s2->V[0], s2->V[1], s2->V[2], q->O[0], q->O[1], q->V[1])) {
-    s2->V[0] = q->O[0];
-    s2->V[1] = q->O[1];
-    s2->V[2] = q->V[1];
-  }
-  else {
-    s2->V[0] = q->O[1];
-    s2->V[1] = q->O[0];
-    s2->V[2] = q->V[1];
-  }
-
-  s1->F[0].V[0] = s1->V[0];
-  s1->F[0].V[1] = s1->V[1];
-  s1->F[0].V[2] = s1->V[2];
-
-  s2->F[0].V[0] = s2->V[0];
-  s2->F[0].V[1] = s2->V[1];
-  s2->F[0].V[2] = s2->V[2];
-
-  qsort(s1->F[0].V, 3, sizeof(Vertex *), compareVertex);
-  qsort(s2->F[0].V, 3, sizeof(Vertex *), compareVertex);
-
-  List_Suppress(Missing, q, compareEdge);
-  q->V[0] = q->O[0];
-  q->V[1] = q->O[1];
-
-}
-
-int create_Quads(Volume * V)
-{
-  int i, n;
-  Surface *S;
-  swaps = Tree_Create(sizeof(Edge), compareEdge);
-  touchedvertex = Tree_Create(sizeof(Vertex *), compareVertex);
-  for(i = 0; i < List_Nbr(V->Surfaces); i++) {
-    List_Read(V->Surfaces, i, &S);
-    Tree_Action(S->Edges, find_quads);
-  }
-  Tree_Action(swaps, swap_quads);
-  n = Tree_Nbr(swaps);
-  Tree_Delete(swaps);
-  Tree_Delete(touchedvertex);
-  return n;
-}
-
-void create_Fac(void *a, void *b)
-{
-  Simplex **ps, *s;
-  int i;
-  ps = (Simplex **) a;
-  s = *ps;
-  for(i = 0; i < 4; i++) {
-    Tree_Insert(FacesTree, &s->F[i]);
-  }
-}
-
-
-void create_Faces(Volume * V)
-{
-  if(V->Faces) {
-    Tree_Delete(V->Faces);
-  }
-  V->Faces = Tree_Create(sizeof(Face), compareFace);
-  FacesTree = V->Faces;
-  Tree_Action(V->Simplexes, create_Fac);
-}
-
-void create_Edge(void *a, void *b)
-{
-  Simplex **ps, *s;
-  int N, i, j;
-  Edge E, *pE;
-  ps = (Simplex **) a;
-  s = *ps;
-  int edges[6][2];
-
-  if(s->V[3]) {
-    N = 6;
-    for(i = 0; i < N; i++)
-      for(j = 0; j < 2; j++)
-        edges[i][j] = edges_tetra[i][j];
-  }
-  else if(s->V[2]) {
-    N = 3;
-    for(i = 0; i < N; i++)
-      for(j = 0; j < 2; j++)
-        edges[i][j] = edges_tetra[i][j];
-  }
-  else {
-    N = 1;
-    for(i = 0; i < N; i++)
-      for(j = 0; j < 2; j++)
-        edges[i][j] = edges_tetra[i][j];
-  }
-
-  for(i = 0; i < N; i++) {
-    E.V[0] = s->V[edges[i][0]];
-    E.V[1] = s->V[edges[i][1]];
-    if((pE = (Edge *) Tree_PQuery(EdgesTree, &E))) {
-      List_Add(pE->Simplexes, ps);
-      if(N == 3)
-        pE->O[1] = s->V[edges_non[i]];
-    }
-    else {
-      E.Simplexes = List_Create(2, 1, sizeof(Simplex *));
-      if(N == 3)
-        E.O[0] = s->V[edges_non[i]];
-      if(N == 3)
-        E.O[1] = NULL;
-      List_Add(E.Simplexes, &s);
-      E.newv = NULL;
-      Tree_Replace(EdgesTree, &E);
-    }
-  }
-}
-
-void create_Edges(Volume * V)
-{
-  int i;
-  Surface *S;
-
-  // MEMORY LEAK (JF)
-  if(V->Edges) {
-    Tree_Action(V->Edges, Free_Edge);
-    Tree_Delete(V->Edges);
-  }
-
-  V->Edges = Tree_Create(sizeof(Edge), compareEdge);
-  EdgesTree = V->Edges;
-
-  Tree_Action(V->Simplexes, create_Edge);
-  for(i = 0; i < List_Nbr(V->Surfaces); i++) {
-    List_Read(V->Surfaces, i, &S);
-    // MEMORY LEAK (JF)
-    if(S->Edges) {
-      // BUG BUG BUG (This causes crash)
-      //Tree_Action(S->Edges,Free_Edge);
-      Tree_Delete(S->Edges);
-    }
-    S->Edges = Tree_Create(sizeof(Edge), compareEdge);
-    EdgesTree = S->Edges;
-    Tree_Action(S->Simplexes, create_Edge);
-  }
-}
-
-void find_missing(void *a, void *b)
-{
-  Edge *e;
-
-  e = (Edge *) a;
-
-  if(!Tree_Search(EdgesTree, e)) {
-    List_Add(Missing, e);
-    Tree_Add(EdgesTree, e);
-  }
-}
-
-void find_missingf(void *a, void *b)
-{
-  Simplex *s;
-  s = *(Simplex **) a;
-
-  if(!FacesTree || !Tree_Search(FacesTree, &s->F[0])) {
-    List_Add(MissingF, &s->F[0]);
-    List_Add(MissingS, &s);
-  }
-}
-
-
-List_T *Missing_Edges(Volume * V)
-{
-  int i;
-  Surface *S;
-  Missing = List_Create(10, 10, sizeof(Edge));
-
-  EdgesTree = V->Edges;
-  for(i = 0; i < List_Nbr(V->Surfaces); i++) {
-    List_Read(V->Surfaces, i, &S);
-    Tree_Action(S->Edges, find_missing);
-  }
-  return Missing;
-}
-
-List_T *Missing_Faces(Volume * V)
-{
-  int i;
-  Surface *S;
-  MissingF = List_Create(10, 10, sizeof(Face));
-  MissingS = List_Create(10, 10, sizeof(Simplex *));
-
-  for(i = 0; i < List_Nbr(V->Surfaces); i++) {
-    List_Read(V->Surfaces, i, &S);
-    Tree_Action(S->Simplexes, find_missingf);
-  }
-  return MissingF;
-}
-
-/* Creation de listes de tetraedres qui intersectent
-   l'arete TheEdge */
-
-List_T *traite;
-Tree_T *traited;
-
-void Ajoute_traite(Simplex ** s)
-{
-  if(!Tree_Search(traited, s)) {
-    List_Add(traite, s);
-    Tree_Add(traited, s);
-  }
-}
-
-Intersection *thei;
-Vertex *m1, *m2, *e1, *e2;
-Face *f1;
-int Cloture;
-
-void fillRi(void *a, void *b)
-{
-  int i, c;
-  Simplex *s;
-
-  s = *(Simplex **) a;
-  c = 0;
-  for(i = 0; i < 4; i++) {
-    if(!compareVertex(&e1, &s->V[i]))
-      c++;
-    if(!compareVertex(&e2, &s->V[i]))
-      c++;
-  }
-  if(c == 2) {
-    Ajoute_traite(&s);
-  }
-}
-
-void fillTeti(void *a, void *b)
-{
-  int i;
-  Simplex *s;
-
-  s = *(Simplex **) a;
-  for(i = 0; i < 4; i++) {
-    if(!compareVertex(&m1, &s->V[i])) {
-      List_Add(Teti, &s);
-      return;
-    }
-  }
-}
-
-Tree_T *TreexNewv;
-
-typedef struct{
-  int ef;
-  Edge e;
-  Face *f;
-  Vertex *newv;
-}xNewv;
-
-int compxNewv(const void *a, const void *b)
-{
-  xNewv *q, *w;
-
-  q = (xNewv *) a;
-  w = (xNewv *) b;
-  if(q->ef != w->ef)
-    return (q->ef - w->ef);
-  if(q->ef == 1)
-    return compareEdge(&q->e, &w->e);
-  if(q->ef == 2)
-    return compareFace(q->f, w->f);
-  return 1;
-}
-
-/* 
-   ---------------------------------------------------
-   Pour + de details, voir les travaux de P.L. George.
-   ---------------------------------------------------
-
-   Les routines ci dessous ont pour but de retrouver les
-   aretes manquantes d'un maillage initial 3-D.
-
-   En resume, il faut d'abord trouver ces aretes : find_missing
-
-   Ensuite, il faut decouvrir les intersections des aretes manquantes
-   avec les tetraedres du maillage, les intersections sont de plusieurs 
-   types :
-
-   intersection noeud-noeud (type 1)
-   intersection arete-face  (type 2)
-   intersection face -face  (type 3)
-   intersection arete-arete (type 4)
-   intersection face -noeud (type 5)
-   intersection arete-noeud (type 6)
-   intersection noeud seul  (type 7)
-   intersection arete seule (type 8)
-
-   Selon le type d'intersection, on appliquera une transformation locale au maillage
-   de telle sorte que l'arete manquante est recouvree.
- */
-
-
-#define eps_prec (-1.e-10)
-
-int Edge_Node(Edge * e, Vertex * v)
-{
-  double u = 0.0, lc;
-
-  if(!compareVertex(&e->V[0], &v))
-    return 1;
-  if(!compareVertex(&e->V[1], &v))
-    return 1;
-  lc =
-    myhypot(myhypot
-            (e->V[0]->Pos.X - e->V[1]->Pos.X,
-             e->V[0]->Pos.Y - e->V[1]->Pos.Y),
-            e->V[0]->Pos.Z - e->V[1]->Pos.Z);
-
-  if(e->V[0]->Pos.X != e->V[1]->Pos.X) {
-    u = (v->Pos.X - e->V[0]->Pos.X) / (e->V[1]->Pos.X - e->V[0]->Pos.X);
-  }
-  else if(e->V[0]->Pos.Y != e->V[1]->Pos.Y) {
-    u = (v->Pos.Y - e->V[0]->Pos.Y) / (e->V[1]->Pos.Y - e->V[0]->Pos.Y);
-  }
-  else if(e->V[0]->Pos.Z != e->V[1]->Pos.Z) {
-    u = (v->Pos.Z - e->V[0]->Pos.Z) / (e->V[1]->Pos.Z - e->V[0]->Pos.Z);
-  }
-
-  if(u < -eps_prec || u > 1. + eps_prec)
-    return 0;
-  if(fabs((1. - u) * e->V[0]->Pos.X + u * e->V[1]->Pos.X - v->Pos.X) >
-     1.e-7 * lc) {
-    return 0;
-  }
-  if(fabs((1. - u) * e->V[0]->Pos.Y + u * e->V[1]->Pos.Y - v->Pos.Y) >
-     1.e-7 * lc) {
-    return 0;
-  }
-  if(fabs((1. - u) * e->V[0]->Pos.Z + u * e->V[1]->Pos.Z - v->Pos.Z) >
-     1.e-7 * lc) {
-    return 0;
-  }
-  return 2;
-}
-
-List_T *SurfComm(List_T * S1, List_T * S2)
-{
-  int i;
-  List_T *List;
-  Surface *s;
-  List = List_Create(2, 2, sizeof(Surface *));
-
-  if(!S1 || !S2)
-    return List;
-
-  for(i = 0; i < List_Nbr(S1); i++) {
-    List_Read(S1, i, &s);
-    if(List_Search(S2, &s, compareSurface))
-      List_Add(List, &s);
-  }
-  return List;
-}
-
-
-Vertex *Edge_Face(Edge * e, Face * f)
-{
-  Vertex *v;
-
-  double mat[3][3], det;
-  double b[3], res[3];
-
-  if(!compareVertex(&e->V[0], &f->V[0]))
-    return NULL;
-  if(!compareVertex(&e->V[0], &f->V[1]))
-    return NULL;
-  if(!compareVertex(&e->V[0], &f->V[2]))
-    return NULL;
-  if(!compareVertex(&e->V[1], &f->V[0]))
-    return NULL;
-  if(!compareVertex(&e->V[1], &f->V[1]))
-    return NULL;
-  if(!compareVertex(&e->V[1], &f->V[2]))
-    return NULL;
-
-  mat[0][0] = f->V[1]->Pos.X - f->V[0]->Pos.X;
-  mat[0][1] = f->V[2]->Pos.X - f->V[0]->Pos.X;
-  mat[0][2] = e->V[0]->Pos.X - e->V[1]->Pos.X;
-
-  mat[1][0] = f->V[1]->Pos.Y - f->V[0]->Pos.Y;
-  mat[1][1] = f->V[2]->Pos.Y - f->V[0]->Pos.Y;
-  mat[1][2] = e->V[0]->Pos.Y - e->V[1]->Pos.Y;
-
-  mat[2][0] = f->V[1]->Pos.Z - f->V[0]->Pos.Z;
-  mat[2][1] = f->V[2]->Pos.Z - f->V[0]->Pos.Z;
-  mat[2][2] = e->V[0]->Pos.Z - e->V[1]->Pos.Z;
-
-  b[0] = e->V[0]->Pos.X - f->V[0]->Pos.X;
-  b[1] = e->V[0]->Pos.Y - f->V[0]->Pos.Y;
-  b[2] = e->V[0]->Pos.Z - f->V[0]->Pos.Z;
-
-  if(!sys3x3_with_tol(mat, b, res, &det))       //???TOLERANCE?????????????
-    return NULL;
-
-  /* res donne les coordonnees u,v de l'intersection dans la
-     face et donne w la coordonnee de l'intersection dans
-     l'arete
-   */
-  /* coordonnees dans l'arete */
-  if(res[2] >= 1.0 - eps_prec || res[2] <= eps_prec)
-    return NULL;
-
-  /* coordonnees dans la face */
-  if(res[0] >= 1.0 + eps_prec || res[0] <= -eps_prec)
-    return NULL;
-  if(res[1] <= -eps_prec || res[1] >= 1. + eps_prec - res[0])
-    return NULL;
-
-
-  if(res[0] == 1.0 || res[2] == 0.0 || res[0] == 0.0 ||
-     res[1] == 1. - res[0] || res[1] == 0.0 || res[0] == 1.0) {
-    Msg(DEBUG1, "Face p1  %g %g %g", f->V[0]->Pos.X, f->V[0]->Pos.Y,
-        f->V[0]->Pos.Z);
-    Msg(DEBUG2, "facette p2  %g %g %g", f->V[1]->Pos.X, f->V[1]->Pos.Y,
-        f->V[1]->Pos.Z);
-    Msg(DEBUG2, "facette p3  %g %g %g", f->V[2]->Pos.X, f->V[2]->Pos.Y,
-        f->V[2]->Pos.Z);
-    Msg(DEBUG2, "edge    e2  %g %g %g", e->V[0]->Pos.X, e->V[0]->Pos.Y,
-        e->V[0]->Pos.Z);
-    Msg(DEBUG2, "edge    e3  %g %g %g", e->V[1]->Pos.X, e->V[1]->Pos.Y,
-        e->V[1]->Pos.Z);
-    Msg(DEBUG3, "%g %g %g", res[0], res[1], res[2]);
-  }
-
-  v = Create_Vertex(++THEM->MaxPointNum,
-                    (1. - res[2]) * e->V[0]->Pos.X + res[2] * e->V[1]->Pos.X,
-                    (1. - res[2]) * e->V[0]->Pos.Y + res[2] * e->V[1]->Pos.Y,
-                    (1. - res[2]) * e->V[0]->Pos.Z + res[2] * e->V[1]->Pos.Z,
-                    (1. - res[2]) * e->V[0]->lc + res[2] * e->V[1]->lc, 0.0);
-  v->ListSurf = List_Create(1, 1, sizeof(Surface *));
-
-  return v;
-}
-
-
-Vertex *Edge_Edge(Edge * e, Vertex * v1, Vertex * v2)
-{
-  Vertex *v;
-  int dir;
-  //int dx1, dx2, dy1, dy2, dz1, dz2;
-  double mat[2][2];
-  double b[3], res[3];
-  double XmaxS, XminS, YmaxS, YminS, ZmaxS, ZminS, lc;
-  double XmaxV, XminV, YmaxV, YminV, ZmaxV, ZminV, val = 0.;
-
-  if(!compareVertex(&e->V[0], &v1))
-    return NULL;
-  if(!compareVertex(&e->V[1], &v1))
-    return NULL;
-  if(!compareVertex(&e->V[0], &v2))
-    return NULL;
-  if(!compareVertex(&e->V[1], &v2))
-    return NULL;
-
-  XminS = DMIN(e->V[0]->Pos.X, e->V[1]->Pos.X);
-  XmaxS = DMAX(e->V[0]->Pos.X, e->V[1]->Pos.X);
-  YminS = DMIN(e->V[0]->Pos.Y, e->V[1]->Pos.Y);
-  YmaxS = DMAX(e->V[0]->Pos.Y, e->V[1]->Pos.Y);
-  ZminS = DMIN(e->V[0]->Pos.Z, e->V[1]->Pos.Z);
-  ZmaxS = DMAX(e->V[0]->Pos.Z, e->V[1]->Pos.Z);
-
-  XminV = DMIN(v1->Pos.X, v2->Pos.X);
-  XmaxV = DMAX(v1->Pos.X, v2->Pos.X);
-  YminV = DMIN(v1->Pos.Y, v2->Pos.Y);
-  YmaxV = DMAX(v1->Pos.Y, v2->Pos.Y);
-  ZminV = DMIN(v1->Pos.Z, v2->Pos.Z);
-  ZmaxV = DMAX(v1->Pos.Z, v2->Pos.Z);
-
-  if(XmaxS < XminV || XmaxV < XminS)
-    return NULL;
-  if(YmaxS < YminV || YmaxV < YminS)
-    return NULL;
-  if(ZmaxS < ZminV || ZmaxV < ZminS)
-    return NULL;
-
-  lc = myhypot(myhypot(XminV - XmaxV, YminV - YmaxV), ZminV - ZmaxV);
-
-  /*
-     if (e->V[1]->Pos.X != e->V[0]->Pos.X &&
-     fabs (e->V[1]->Pos.X - e->V[0]->Pos.X) / lc > 1.e-2)
-     dx1 = 1;
-     else
-     dx1 = 0;
-     if (e->V[1]->Pos.Y != e->V[0]->Pos.Y &&
-     fabs (e->V[1]->Pos.Y - e->V[0]->Pos.Y) / lc > 1.e-2)
-     dy1 = 1;
-     else
-     dy1 = 0;
-     if (e->V[1]->Pos.Z != e->V[0]->Pos.Z &&
-     fabs (e->V[1]->Pos.Z - e->V[0]->Pos.Z) / lc > 1.e-2)
-     dz1 = 1;
-     else
-     dz1 = 0;
-
-     if (v1->Pos.X != v2->Pos.X &&
-     fabs (v1->Pos.X - v2->Pos.X) / lc > 1.e-2)
-     dx2 = 1;
-     else
-     dx2 = 0;
-     if (v1->Pos.Y != v2->Pos.Y &&
-     fabs (v1->Pos.Y - v2->Pos.Y) / lc > 1.e-2)
-     dy2 = 1;
-     else
-     dy2 = 0;
-     if (v1->Pos.Z != v2->Pos.Z &&
-     fabs (v1->Pos.Z - v2->Pos.Z) / lc > 1.e-2)
-     dz2 = 1;
-     else
-     dz2 = 0;
-
-     if(dx1 && dx2){
-     mat[0][0] = e->V[1]->Pos.X - e->V[0]->Pos.X;
-     mat[0][1] = v1->Pos.X - v2->Pos.X;
-     b[0] = - e->V[0]->Pos.X + v1->Pos.X;
-     if(dy1 || dy2){
-     mat[1][0] = e->V[1]->Pos.Y - e->V[0]->Pos.Y;
-     mat[1][1] = v1->Pos.Y - v2->Pos.Y;
-     b[1] = - e->V[0]->Pos.Y + v1->Pos.Y;
-     dir = 2;
-     }
-     else if(dz1 || dz2){
-     mat[1][0] = e->V[1]->Pos.Z - e->V[0]->Pos.Z;
-     mat[1][1] = v1->Pos.Z - v2->Pos.Z;
-     b[1] = - e->V[0]->Pos.Z + v1->Pos.Z;
-     dir = 3;
-     }
-     }
-     else if (dy1 && dy2){
-     mat[0][0] = e->V[1]->Pos.Y - e->V[0]->Pos.Y;
-     mat[0][1] = v1->Pos.Y - v2->Pos.Y;
-     b[0] = - e->V[0]->Pos.Y + v1->Pos.Y;
-     if(dy1 || dy2){
-     mat[1][0] = e->V[1]->Pos.Y - e->V[0]->Pos.Y;
-     mat[1][1] = v1->Pos.Y - v2->Pos.Y;
-     b[1] = - e->V[0]->Pos.Y + v1->Pos.Y;
-     dir = 2;
-     }
-     else if(dz1 || dz2){
-     mat[1][0] = e->V[1]->Pos.Z - e->V[0]->Pos.Z;
-     mat[1][1] = v1->Pos.Z - v2->Pos.Z;
-     b[1] = - e->V[0]->Pos.Z + v1->Pos.Z;
-     dir = 3;
-     }
-     }
-   */
-
-
-  mat[0][0] = e->V[1]->Pos.X - e->V[0]->Pos.X;
-  mat[0][1] = v1->Pos.X - v2->Pos.X;
-  b[0] = -e->V[0]->Pos.X + v1->Pos.X;
-  mat[1][0] = e->V[1]->Pos.Y - e->V[0]->Pos.Y;
-  mat[1][1] = v1->Pos.Y - v2->Pos.Y;
-  b[1] = -e->V[0]->Pos.Y + v1->Pos.Y;
-
-  if(!sys2x2(mat, b, res)) {
-    mat[1][0] = e->V[1]->Pos.Z - e->V[0]->Pos.Z;
-    mat[1][1] = v1->Pos.Z - v2->Pos.Z;
-    b[1] = -e->V[0]->Pos.Z + v1->Pos.Z;
-    if(!sys2x2(mat, b, res)) {
-      mat[0][0] = e->V[1]->Pos.Y - e->V[0]->Pos.Y;
-      mat[0][1] = v1->Pos.Y - v2->Pos.Y;
-      b[0] = -e->V[0]->Pos.Y + v1->Pos.Y;
-      if(!sys2x2(mat, b, res)) {
-        /* SEGMENTS PARALLELES */
-        /* printf("systeme singulier\n");
-           printf("arete %d -> %d\n",v1->Num,v2->Num);
-           printf("arete %g %g %g --> %g %g %g\n",
-           v1->Pos.X,v1->Pos.Y,v1->Pos.Z,v2->Pos.X,v2->Pos.Y,v2->Pos.Z);
-           printf("arete %g %g %g --> %g %g %g\n",
-           e->V[0]->Pos.X,e->V[0]->Pos.Y,e->V[0]->Pos.Z,
-           e->V[1]->Pos.X,e->V[1]->Pos.Y,e->V[1]->Pos.Z);
-           printf("%g %g\n",mat[0][0],mat[0][1]);
-           printf("%g %g\n",mat[1][0],mat[1][1]);
-           getchar();
-         */
-        return NULL;
-      }
-      else {
-        dir = 1;
-      }
-    }
-    else {
-      dir = 2;
-    }
-  }
-  else {
-    dir = 3;
-  }
-
-  if(res[0] <= eps_prec || res[0] >= 1.0 - eps_prec)
-    return NULL;
-  if(res[1] <= eps_prec || res[1] >= 1.0 - eps_prec)
-    return NULL;
-
-  switch (dir) {
-  case 1:
-    val = e->V[0]->Pos.X * (1. - res[0]) + e->V[1]->Pos.X * res[0] -
-      v1->Pos.X * (1. - res[1]) - v2->Pos.X * res[1];
-    break;
-  case 2:
-    val = e->V[0]->Pos.Y * (1. - res[0]) + e->V[1]->Pos.Y * res[0] -
-      v1->Pos.Y * (1. - res[1]) - v2->Pos.Y * res[1];
-    break;
-  case 3:
-    val = e->V[0]->Pos.Z * (1. - res[0]) + e->V[1]->Pos.Z * res[0] -
-      v1->Pos.Z * (1. - res[1]) - v2->Pos.Z * res[1];
-    break;
-  }
-  if(fabs(val / lc) > 1.e-08 /*08 */ )
-    return NULL;
-  v = Create_Vertex(++THEM->MaxPointNum,
-                    (1. - res[0]) * e->V[0]->Pos.X + res[0] * e->V[1]->Pos.X,
-                    (1. - res[0]) * e->V[0]->Pos.Y + res[0] * e->V[1]->Pos.Y,
-                    (1. - res[0]) * e->V[0]->Pos.Z + res[0] * e->V[1]->Pos.Z,
-                    (1. - res[0]) * e->V[0]->lc + res[0] * e->V[1]->lc, 0.0);
-
-  v->ListSurf = List_Create(1, 1, sizeof(Surface *));
-  return v;
-
-}
-
-int intersection_2_aretes(double Xa, double Ya, double Za,
-                          double Xb, double Yb, double Zb,
-                          double Xc, double Yc, double Zc,
-                          double Xd, double Yd, double Zd,
-                          int p1, int p2, int p3, int p4,
-                          double *X, double *Y, double *Z)
-{
-  Vertex *v1, *v2, *v3, *v4, *v;
-  Edge e;
-  v1 = Create_Vertex(p1, Xa, Ya, Za, 0.0, 0.0);
-  v2 = Create_Vertex(p2, Xb, Yb, Zb, 0.0, 0.0);
-  v3 = Create_Vertex(p3, Xc, Yc, Zc, 0.0, 0.0);
-  v4 = Create_Vertex(p4, Xd, Yd, Zd, 0.0, 0.0);
-
-  e.V[0] = v3;
-  e.V[1] = v4;
-
-  if((v = Edge_Edge(&e, v1, v2))) {
-
-    *X = v->Pos.X;
-    *Y = v->Pos.Y;
-    *Z = v->Pos.Z;
-
-    Free(v1);
-    Free(v2);
-    Free(v3);
-    Free(v4);
-    Free(v);
-    return 1;
-  }
-  else {
-    Free(v1);
-    Free(v2);
-    Free(v3);
-    Free(v4);
-    Free(v);
-    return 0;
-  }
-
-}
-
-List_T *NewPoints;
-
-void Intersect_Edge_Simplexe(Edge * e, Simplex * s, Intersection * I)
-{
-  int i, NbInt = 0, NbVer = 0, NbEdg = 0, NbFac = 0, j;
-  Vertex *v;
-  double XminS, YminS, ZminS, XmaxS, YmaxS, ZmaxS;
-  double XminE, YminE, ZminE, XmaxE, YmaxE, ZmaxE;
-  xNewv x;
-
-  /* On initialise l'intersection */
-
-  I->NbVertex = I->NbFace = I->NbEdge = 0;
-  I->s = s;
-  I->e = e;
-  I->NbIntersect = 0;
-
-  /*
-     On regarde d'abord si une intersection est possible en
-     calculant les boites de l'arete et du simplexe 
-   */
-
-  if(s->V[3]) {
-    NbVer = 4;
-    NbEdg = 6;
-    NbFac = 4;
-    NbInt = 2;
-  }
-  else if(s->V[2]) {
-    NbVer = 3;
-    NbEdg = 3;
-    NbFac = 1;
-    NbInt = 2;
-  }
-
-  XminE = DMIN(e->V[0]->Pos.X, e->V[1]->Pos.X);
-  XmaxE = DMAX(e->V[0]->Pos.X, e->V[1]->Pos.X);
-  YminE = DMIN(e->V[0]->Pos.Y, e->V[1]->Pos.Y);
-  YmaxE = DMAX(e->V[0]->Pos.Y, e->V[1]->Pos.Y);
-  ZminE = DMIN(e->V[0]->Pos.Z, e->V[1]->Pos.Z);
-  ZmaxE = DMAX(e->V[0]->Pos.Z, e->V[1]->Pos.Z);
-
-  XminS = s->V[0]->Pos.X;
-  XmaxS = s->V[0]->Pos.X;
-  YminS = s->V[0]->Pos.Y;
-  YmaxS = s->V[0]->Pos.Y;
-  ZminS = s->V[0]->Pos.Z;
-  ZmaxS = s->V[0]->Pos.Z;
-
-  for(i = 1; i < NbVer; i++) {
-    XminS = DMIN(XminS, s->V[i]->Pos.X);
-    XmaxS = DMAX(XmaxS, s->V[i]->Pos.X);
-    YminS = DMIN(YminS, s->V[i]->Pos.Y);
-    YmaxS = DMAX(YmaxS, s->V[i]->Pos.Y);
-    ZminS = DMIN(ZminS, s->V[i]->Pos.Z);
-    ZmaxS = DMAX(ZmaxS, s->V[i]->Pos.Z);
-  }
-  if(XmaxS < XminE || XmaxE < XminS)
-    return;
-  if(YmaxS < YminE || YmaxE < YminS)
-    return;
-  if(ZmaxS < ZminE || ZmaxE < ZminS)
-    return;
-
-  /*
-     On regarde si l'arete coupe un des 4 noeuds du
-     simplexe
-   */
-
-  for(i = 0; i < NbVer; i++) {
-    if((j = Edge_Node(e, s->V[i]))) {
-      I->V[I->NbVertex] = s->V[i];
-      I->iV[I->NbVertex++] = i;
-      (I->NbIntersect)++;
-      if(j == 2) {
-        List_Replace(NewPoints, &s->V[i], compareVertex);
-        //printf("l'arete intersecte un noeud\n");
-        pvertex(s->V[i], s->V[i]);
-        pedge(e, e);
-      }
-    }
-  }
-
-  if(I->NbIntersect == NbInt) {
-    Msg(WARNING, "If the mesh is still correct after this, contact us :-)");
-    return;
-  }
-  /* On regarde si l'arete coupe une autre arete */
-  for(i = 0; i < NbEdg; i++) {
-    x.ef = 1;
-    x.e.V[0] = s->V[edges_tetra[i][0]];
-    x.e.V[1] = s->V[edges_tetra[i][1]];
-    if(Tree_Query(TreexNewv, &x)) {
-      v = x.newv;
-      I->E[I->NbEdge] = i;
-      I->VE[(I->NbEdge)++] = v;
-      (I->NbIntersect)++;
-    }
-    else if((v = Edge_Edge(e, s->V[edges_tetra[i][0]],
-                           s->V[edges_tetra[i][1]]))) {
-      List_Add(NewPoints, &v);
-      I->E[I->NbEdge] = i;
-      I->VE[(I->NbEdge)++] = v;
-      (I->NbIntersect)++;
-      x.newv = v;
-      Tree_Add(TreexNewv, &x);
-    }
-  }
-
-  if(I->NbIntersect == NbInt)
-    return;
-
-  /*
-     On regarde si l'arete coupe une face
-   */
-
-  for(i = 0; i < NbFac; i++) {
-    x.ef = 2;
-    x.f = &s->F[i];
-    if(Tree_Query(TreexNewv, &x)) {
-      v = x.newv;
-      I->VF[I->NbFace] = v;
-      I->F[I->NbFace] = &s->F[i];
-      I->iF[(I->NbFace)++] = i;
-      (I->NbIntersect)++;
-    }
-    else if((v = Edge_Face(e, &s->F[i]))) {
-      I->VF[I->NbFace] = v;
-      List_Add(NewPoints, &v);
-      I->F[I->NbFace] = &s->F[i];
-      I->iF[I->NbFace++] = i;
-      (I->NbIntersect)++;
-      x.newv = v;
-      Tree_Add(TreexNewv, &x);
-    }
-  }
-}
-
-
-void Intersect_Face_Simplexe(Face * f, Simplex * s, Intersection * I)
-{
-  int i;
-  Vertex *v;
-  double XminS, YminS, ZminS, XmaxS, YmaxS, ZmaxS;
-  double XminE, YminE, ZminE, XmaxE, YmaxE, ZmaxE;
-  xNewv x;
-
-  /* On initialise l'intersection */
-
-  I->NbVertex = I->NbFace = I->NbEdge = 0;
-  I->s = s;
-  I->f = f;
-  I->NbIntersect = 0;
-
-  /*
-     On regarde d'abord si une intersection est possible en
-     calculant les boites de l'arete et du simplexe
-   */
-
-  XminE = DMIN(DMIN(f->V[0]->Pos.X, f->V[1]->Pos.X), f->V[2]->Pos.X);
-  XmaxE = DMAX(DMAX(f->V[0]->Pos.X, f->V[1]->Pos.X), f->V[2]->Pos.X);
-  YminE = DMIN(DMIN(f->V[0]->Pos.Y, f->V[1]->Pos.Y), f->V[2]->Pos.Y);
-  YmaxE = DMAX(DMAX(f->V[0]->Pos.Y, f->V[1]->Pos.Y), f->V[2]->Pos.Y);
-  ZminE = DMIN(DMIN(f->V[0]->Pos.Z, f->V[1]->Pos.Z), f->V[2]->Pos.Z);
-  ZmaxE = DMAX(DMAX(f->V[0]->Pos.Z, f->V[1]->Pos.Z), f->V[2]->Pos.Z);
-
-  XminS = s->V[0]->Pos.X;
-  XmaxS = s->V[0]->Pos.X;
-  YminS = s->V[0]->Pos.Y;
-  YmaxS = s->V[0]->Pos.Y;
-  ZminS = s->V[0]->Pos.Z;
-  ZmaxS = s->V[0]->Pos.Z;
-
-  for(i = 1; i < 4; i++) {
-    XminS = DMIN(XminS, s->V[i]->Pos.X);
-    XmaxS = DMAX(XmaxS, s->V[i]->Pos.X);
-    YminS = DMIN(YminS, s->V[i]->Pos.Y);
-    YmaxS = DMAX(YmaxS, s->V[i]->Pos.Y);
-    ZminS = DMIN(ZminS, s->V[i]->Pos.Z);
-    ZmaxS = DMAX(ZmaxS, s->V[i]->Pos.Z);
-  }
-  if(XmaxS < XminE || XmaxE < XminS)
-    return;
-  if(YmaxS < YminE || YmaxE < YminS)
-    return;
-  if(ZmaxS < ZminE || ZmaxE < ZminS)
-    return;
-
-  /* On regarde si l'arete coupe la facette */
-  for(i = 0; i < 6; i++) {
-    x.ef = 1;
-    x.e.V[0] = s->V[edges_tetra[i][0]];
-    x.e.V[1] = s->V[edges_tetra[i][1]];
-    if(Tree_Query(TreexNewv, &x)) {
-      v = x.newv;
-      I->E[I->NbEdge] = i;
-      I->VE[(I->NbEdge)++] = v;
-      (I->NbIntersect)++;
-    }
-    else if((v = Edge_Face(&x.e, f))) {
-      /* printf("%d %d %d %d\n",s->V[0]->Num,s->V[1]->Num,s->V[2]->Num,s->V[3]->Num); */
-      List_Add(NewPoints, &v);
-      I->E[I->NbEdge] = i;
-      I->VE[I->NbEdge] = v;
-      (I->NbEdge)++;
-      (I->NbIntersect)++;
-      x.newv = v;
-      Tree_Add(TreexNewv, &x);
-    }
-  }
-}
-
-Tree_T *Actual_Tree, *TetAdd, *TetDel;
-
-static void _Add(void *data, void *dum)
-{
-  Tree_Add(Actual_Tree, data);
-}
-static void _Del(void *data, void *dum)
-{
-  Tree_Suppress(Actual_Tree, data);
-}
-
-void Recover_Edge(void *a, void *b)
-{
-  Simplex *s;
-  Intersection I;
-
-  s = *(Simplex **) a;
-  Intersect_Edge_Simplexe(TheEdge, s, &I);
-  if(I.NbIntersect) {
-    cut_tetraedre(&I, TetAdd, TetDel, THEVOL->Vertices);
-  }
-}
-
-void Recover_Face(void *a, void *b)
-{
-  Simplex *s;
-  Intersection I;
-
-  s = *(Simplex **) a;
-  Intersect_Face_Simplexe(TheFace, s, &I);
-  if(I.NbEdge) {
-    cut_tetraedre(&I, TetAdd, TetDel, THEVOL->Vertices);
-  }
-}
-
-static double volume;
-
-static void VSIM(void *a, void *b)
-{
-  Simplex *S;
-  S = *(Simplex **) a;
-  if(S->V[3])
-    volume += fabs(S->Volume_Simplexe());
-}
-
-Vertex *DEPART;
-
-int comparePos(const void *a, const void *b)
-{
-  Vertex *q, *w;
-  double d1, d2;
-  q = *(Vertex **) a;
-  w = *(Vertex **) b;
-
-  d1 = DSQR(q->Pos.X - DEPART->Pos.X) +
-    DSQR(q->Pos.Y - DEPART->Pos.Y) + DSQR(q->Pos.Z - DEPART->Pos.Z);
-  d2 = DSQR(w->Pos.X - DEPART->Pos.X) +
-    DSQR(w->Pos.Y - DEPART->Pos.Y) + DSQR(w->Pos.Z - DEPART->Pos.Z);
-  if(d1 < d2)
-    return 1;
-  if(d1 > d2)
-    return -1;
-
-  exit(1);
-  return 1;
-}
-
-List_T *ListFaces;
-
-void findFaces(void *a, void *b)
-{
-  Simplex *s;
-  int i;
-  s = *(Simplex **) a;
-  if(List_Search(NewPoints, &s->V[0], compareVertex) ||
-     List_Search(NewPoints, &s->V[1], compareVertex) ||
-     List_Search(NewPoints, &s->V[2], compareVertex) ||
-     List_Search(NewPoints, &s->V[3], compareVertex))
-    /*
-       printf("%d %d %d %d\n",s->V[0]->Num,s->V[1]->Num,s->V[2]->Num,s->V[3]->Num);
-     */
-    for(i = 0; i < 4; i++) {
-      if(List_Search(NewPoints, &s->F[i].V[0], compareVertex) &&
-         List_Search(NewPoints, &s->F[i].V[1], compareVertex) &&
-         List_Search(NewPoints, &s->F[i].V[2], compareVertex))
-        List_Replace(ListFaces, &s->F[i], compareFace);
-    }
-}
-
-void findEdges(void *a, void *b)
-{
-}
-
-Simplex *Create_Simplex_MemeSens(Simplex * sold, Vertex * v1, Vertex * v2,
-                                 Vertex * v3)
-{
-  Simplex *s;
-
-  if(memesens(sold->V[0], sold->V[1], sold->V[2], v1, v2, v3) > 0.0) {
-    s = Create_Simplex(v1, v2, v3, NULL);
-  }
-  else {
-    s = Create_Simplex(v2, v1, v3, NULL);
-  }
-  s->iEnt = sold->iEnt;
-  return s;
-}
-
-int Coherence(Volume * v, Mesh * m)
-{
-  int i, j, k, Np, Nh, nb_swaps = 0;
-  Surface *s;
-  //Vertex V1, V2, *ver1, *ver2 ;
-  Face Face;
-  static Edge E, *pE1, *pE2, *pE3;
-  Simplex *simp, *simp1;
-  List_T *MissingEdges, *MissingFaces;
-
-  FACE_DIMENSION = 2;
-
-  //ver1 = &V1;
-  //ver2 = &V2;
-
-  THEVOL = v;
-
-  Remise_A_Zero();
-
-  /* Edge Swapping */
-  do {
-    create_Edges(v);
-    MissingEdges = Missing_Edges(v);
-    nb_swaps = create_Quads(v);
-    Msg(INFO, "Swapped %d edges", nb_swaps);
-  } while(nb_swaps);
-
-  /* Missing Edges */
-  create_Edges(v);
-  MissingEdges = Missing_Edges(v);
-
-  /* Missing Faces */
-  create_Faces(v);
-  MissingFaces = Missing_Faces(v);
-
-  /* Edges Recovery */
-  Msg(STATUS2, "Boundary edges recovery");
-
-  volume = 0;
-  Tree_Action(v->Simplexes, VSIM);
-  Msg(INFO, "Volume = %g", volume);
-
-  Msg(INFO1, "===================================================");
-  Msg(INFO2, "Number of missing edges = %d", List_Nbr(Missing));
-  Msg(INFO3, "===================================================");
-
-  for(i = 0; i < List_Nbr(Missing); i++) {
-
-    pE1 = (Edge *) List_Pointer(Missing, i);
-    TheEdge = pE1;
-
-    TreexNewv = Tree_Create(sizeof(xNewv), compxNewv);
-    NewPoints = List_Create(1, 1, sizeof(Vertex *));
-    TetAdd = Tree_Create(sizeof(Simplex *), compareSimplex);
-    TetDel = Tree_Create(sizeof(Simplex *), compareSimplex);
-
-    Tree_Action(v->Simplexes, Recover_Edge);
-    Actual_Tree = v->Simplexes;
-    Tree_Action(TetAdd, _Add);
-    Tree_Action(TetDel, _Del);
-    pE1->Liste = NewPoints;
-    /*
-       if(CTX.mesh.nb_smoothing){
-       DEPART = pE1->V[0];
-       List_Tri(NewPoints,comparePos);
-       for(j=0;j<List_Nbr(NewPoints);j++){
-       List_Read(NewPoints,j,&ver1);
-       u = (double)(j+1) / (double)(List_Nbr(NewPoints)+1);
-       ver1->Pos.X = u * pE1->V[1]->Pos.X + (1.-u) * pE1->V[0]->Pos.X;
-       ver1->Pos.Y = u * pE1->V[1]->Pos.Y + (1.-u) * pE1->V[0]->Pos.Y;
-       ver1->Pos.Z = u * pE1->V[1]->Pos.Z + (1.-u) * pE1->V[0]->Pos.Z;
-       }
-       }
-     */
-    Msg(INFO, "%d/%d: Edge %d->%d => %d division(s)",
-        i + 1, List_Nbr(Missing), pE1->V[0]->Num, pE1->V[1]->Num,
-        List_Nbr(NewPoints));
-
-    if(!List_Nbr(NewPoints))
-      Msg(GERROR,
-          "Missing edge without any intersection (%g,%g,%g) (%g,%g,%g)",
-          pE1->V[0]->Pos.X, pE1->V[0]->Pos.Y, pE1->V[0]->Pos.Z,
-          pE1->V[1]->Pos.X, pE1->V[1]->Pos.Y, pE1->V[1]->Pos.Z);
-
-  }
-
-  Msg(STATUS2, "Boundary faces recovery");
-  volume = 0;
-  Tree_Action(v->Simplexes, VSIM);
-  Msg(INFO, "Volume = %g", volume);
-
-  /* Missing Faces */
-
-  Msg(INFO1, "===================================================");
-  Msg(INFO2, "Number of missing faces = %d", List_Nbr(MissingFaces));
-  Msg(INFO3, "===================================================");
-
-  for(i = 0; i < List_Nbr(MissingS); i++) {
-    List_Read(MissingS, i, &simp);
-    TheFace = &simp->F[0];
-    Msg(INFO, "%d/%d: Face %d %d %d",
-        i + 1, List_Nbr(MissingS), simp->F[0].V[0]->Num,
-        simp->F[0].V[1]->Num, simp->F[0].V[2]->Num);
-    E.V[0] = simp->F[0].V[0];
-    E.V[1] = simp->F[0].V[1];
-    pE1 = (Edge *) List_PQuery(Missing, &E, compareEdge);
-    E.V[0] = simp->F[0].V[1];
-    E.V[1] = simp->F[0].V[2];
-    pE2 = (Edge *) List_PQuery(Missing, &E, compareEdge);
-    E.V[0] = simp->F[0].V[2];
-    E.V[1] = simp->F[0].V[0];
-    pE3 = (Edge *) List_PQuery(Missing, &E, compareEdge);
-
-    /* On verifie si c'est simple c a d si les tetraedres
-       couvrent entierement la face */
-    NewPoints = List_Create(3, 1, sizeof(Vertex *));
-    List_Add(NewPoints, &simp->F[0].V[0]);
-    if(pE1)
-      for(j = 0; j < List_Nbr(pE1->Liste); j++)
-        List_Add(NewPoints, List_Pointer(pE1->Liste, j));
-    List_Add(NewPoints, &simp->F[0].V[1]);
-    if(pE2)
-      for(j = 0; j < List_Nbr(pE2->Liste); j++)
-        List_Add(NewPoints, List_Pointer(pE2->Liste, j));
-    List_Add(NewPoints, &simp->F[0].V[2]);
-    if(pE3)
-      for(j = 0; j < List_Nbr(pE3->Liste); j++)
-        List_Add(NewPoints, List_Pointer(pE3->Liste, j));
-    ListFaces = List_Create(2, 2, sizeof(Face));
-    Tree_Action(v->Simplexes, findFaces);
-
-    Nh = List_Nbr(NewPoints);
-
-    /* il reste des intersections */
-
-    if(List_Nbr(ListFaces) != Nh - 2) {
-
-      Msg(INFO,
-          "Intersections left (the face contains %d initial faces, divided in %d points)",
-          List_Nbr(ListFaces), List_Nbr(NewPoints));
-
-      TreexNewv = Tree_Create(sizeof(xNewv), compxNewv);
-      TetAdd = Tree_Create(sizeof(Simplex *), compareSimplex);
-      TetDel = Tree_Create(sizeof(Simplex *), compareSimplex);
-      Tree_Action(v->Simplexes, Recover_Face);
-
-      Msg(INFO,
-          "The face is divided in %d points (simplexes added=%d, deleted=%d)",
-          List_Nbr(NewPoints), Tree_Nbr(TetAdd), Tree_Nbr(TetDel));
-
-      Actual_Tree = v->Simplexes;
-      Tree_Action(TetAdd, _Add);
-      Tree_Action(TetDel, _Del);
-      ListFaces = List_Create(2, 2, sizeof(Face));
-      Tree_Action(v->Simplexes, findFaces);
-    }
-
-    Np = List_Nbr(NewPoints);
-
-    if(1 || List_Nbr(ListFaces) == 2 * (Np - 1) - Nh) {
-
-      // provisoire!!!
-      if(List_Nbr(ListFaces) != 2 * (Np - 1) - Nh) {
-        Msg(WARNING, "*Unrecoverable* face (%d <--> %d=2*(%d-1)-%d)",
-            List_Nbr(ListFaces), 2 * (Np - 1) - Nh, Np, Nh);
-      }
-      else
-        Msg(INFO, "Recoverable face (%d <--> %d=2*(%d-1)-%d)",
-            List_Nbr(ListFaces), 2 * (Np - 1) - Nh, Np, Nh);
-
-      for(j = 0; j < List_Nbr(v->Surfaces); j++) {
-        List_Read(v->Surfaces, j, &s);
-        if(Tree_Search(s->Simplexes, &simp)) {
-          for(k = 0; k < List_Nbr(ListFaces); k++) {
-            List_Read(ListFaces, k, &Face);
-            simp1 =
-              Create_Simplex_MemeSens(simp, Face.V[0], Face.V[1], Face.V[2]);
-            Tree_Add(s->Simplexes, &simp1);
-            Tree_Replace(s->Vertices, &Face.V[0]);
-            Tree_Replace(s->Vertices, &Face.V[1]);
-            Tree_Replace(s->Vertices, &Face.V[2]);
-            Tree_Replace(v->Vertices, &Face.V[0]);
-            Tree_Replace(v->Vertices, &Face.V[1]);
-            Tree_Replace(v->Vertices, &Face.V[2]);
-          }
-          Tree_Suppress(s->Simplexes, &simp);
-        }
-      }
-    }
-    else {
-      Msg(GERROR, "*Unrecoverable* face (%d <--> %d=2*(%d-1)-%d)",
-          List_Nbr(ListFaces), 2 * (Np - 1) - Nh, Np, Nh);
-      for(k = 0; k < List_Nbr(ListFaces); k++) {
-        List_Read(ListFaces, k, &Face);
-        Msg(STATUS2, "Face %d %d %d", Face.V[0]->Num, Face.V[1]->Num,
-            Face.V[2]->Num);
-      }
-      Tree_Action(v->Simplexes, findEdges);
-    }
-  }
-
-  volume = 0;
-  Tree_Action(v->Simplexes, VSIM);
-  Msg(INFO, "Volume after edge/face recovery = %g", volume);
-
-  /* Missing Edges */
-  create_Edges(v);
-  MissingEdges = Missing_Edges(v);
-
-  /* Missing Faces */
-  create_Faces(v);
-  MissingFaces = Missing_Faces(v);
-
-  Msg(INFO, "Final check: %d missing edges, %d missing faces",
-      List_Nbr(MissingEdges), List_Nbr(MissingFaces));
-
-  Impression_Resultats();
-
-  if(List_Nbr(MissingFaces) || List_Nbr(MissingEdges)) {
-    Msg(GERROR, "Could not restore all edges/faces");
-    return 0;
-  }
-
-  Link_Simplexes(NULL, v->Simplexes);
-  Msg(STATUS2, "Volume recovery");
-  Restore_Volume(v);
-
-  return 1;
-}
-
-/* A partir d'un maillage de volume qui respecte la 
-   frontiere, on attribue a chaque tetraedre son 
-   numero de volume */
-
-List_T *ListSurfaces, *ListAllSurf;
-Tree_T *keep;
-Simplex *SIMP;
-int iVolume;
-
-void attribueVolume(void *a, void *b)
-{
-  Simplex *s;
-  s = *(Simplex **) a;
-  s->iEnt = iVolume;
-}
-
-void Trouve_Simplex(void *a, void *b)
-{
-  Simplex *s;
-  if(SIMP != NULL)
-    return;
-  s = *(Simplex **) a;
-  if(s->iEnt < 0)
-    SIMP = s;
-}
-
-void Trouve_Simplex_Bord(void *a, void *b)
-{
-  Simplex *s;
-
-  if(SIMP != NULL)
-    return;
-  s = *(Simplex **) a;
-  if(s->V[0]->Num < 0 || s->V[1]->Num < 0 || s->V[2]->Num < 0
-     || s->V[3]->Num < 0)
-    SIMP = s;
-}
-
-void SurfacesDansVolume(Volume * v, List_T * ListAllSurf)
-{
-  int i, iseg;
-  Surface *s;
-  for(i = 0; i < List_Nbr(v->Surfaces); i++) {
-    List_Read(v->Surfaces, i, &s);
-    iseg = abs(s->Num);
-    List_Replace(ListAllSurf, &iseg, fcmp_int);
-  }
-}
-
-int isListaVolume(List_T * ListSurf, Mesh * M)
-{
-  int NN, i, j, srf;
-  bool found;
-  Surface *Surf;
-  Volume *v;
-  List_T *AllVolumes = Tree2List(M->Volumes);
-
-  for(i = 0; i < List_Nbr(AllVolumes); i++) {
-    List_Read(AllVolumes, i, &v);
-    found = true;
-    NN = 0;
-    if(v->Typ == MSH_VOLUME) {
-      for(j = 0; j < List_Nbr(v->Surfaces); j++) {
-        List_Read(v->Surfaces, j, &Surf);
-        srf = abs(Surf->Num);
-        if(!List_Search(ListSurf, &srf, fcmp_int)) {
-          found = false;
-        }
-        else
-          NN++;
-      }
-      if(found && NN == List_Nbr(ListSurf))
-        return v->Num;
-    }
-  }
-  return 0;
-}
-
-int compareSimpSurf(const void *a, const void *b)
-{
-  Simplex *q, *w;
-  q = *(Simplex **) a;
-  w = *(Simplex **) b;
-  return compareFace(&q->F[0], &w->F[0]);
-}
-
-List_T *StackSimp;
-#define MAX_DEPTH 500
-
-void recur_trouve_volume(Simplex * s, int *Depth)
-{
-  int i, j;
-  Simplex *pS, S;
-
-  if(s->iEnt != -1)
-    return;
-
-  if((*Depth) > MAX_DEPTH) {
-    List_Add(StackSimp, &s);
-    return;
-  }
-
-  (*Depth)++;
-  s->iEnt = -2;
-  Tree_Add(keep, &s);
-  for(i = 0; i < 4; i++) {
-    pS = &S;
-    pS->F[0] = s->F[i];
-    if(Tree_Query(FacesTree, &pS)
-       && List_Search(ListAllSurf, &pS->iEnt, fcmp_int)) {
-      j = abs(pS->iEnt);
-      List_Replace(ListSurfaces, &j, fcmp_int);
-    }
-    else if(s->S[i] && s->S[i] != &MyNewBoundary) {
-      recur_trouve_volume(s->S[i], Depth);
-    }
-  }
-  (*Depth)--;
-}
-
-void Restore_Volume(Volume * v)
-{
-  int N;
-  int j, i, depth;
-  Surface *s;
-
-  StackSimp = List_Create(100, 100, sizeof(Simplex *));
-
-  FacesTree = Tree_Create(sizeof(Simplex *), compareSimpSurf);
-  Actual_Tree = FacesTree;
-  for(j = 0; j < List_Nbr(v->Surfaces); j++) {
-    List_Read(v->Surfaces, j, &s);
-    Tree_Action(s->Simplexes, _Add);
-  }
-
-  ListSurfaces = List_Create(2, 2, sizeof(int));
-  iVolume = -1;
-  Tree_Action(v->Simplexes, attribueVolume);
-
-  /* Les simplexes sur le bord exterieur sont elimines */
-
-  ListAllSurf = List_Create(10, 3, sizeof(int));
-  SurfacesDansVolume(v, ListAllSurf);
-
-  SIMP = NULL;
-  Tree_Action(v->Simplexes, Trouve_Simplex_Bord);
-
-  if(SIMP) {
-    List_Add(StackSimp, &SIMP);
-    keep = Tree_Create(sizeof(Simplex *), compareQuality);
-    depth = 0;
-    i = 0;
-    do {
-      List_Read(StackSimp, i, &SIMP);
-      recur_trouve_volume(SIMP, &depth);
-    } while(++i < List_Nbr(StackSimp));
-    List_Reset(StackSimp);
-
-    for(i = 0; i < List_Nbr(ListSurfaces); i++) {
-      List_Read(ListSurfaces, i, &j);
-      Msg(STATUS2, "Surface %d", j);
-    }
-
-    iVolume = 0;
-    Tree_Action(keep, attribueVolume);
-    Tree_Delete(keep);
-    List_Reset(ListSurfaces);
-  }
-
-  while(1) {
-    SIMP = NULL;
-    keep = Tree_Create(sizeof(Simplex *), compareQuality);
-    Tree_Action(v->Simplexes, Trouve_Simplex);
-    if(!SIMP)
-      break;
-    List_Add(StackSimp, &SIMP);
-    depth = 0;
-    i = 0;
-    do {
-      List_Read(StackSimp, i, &SIMP);
-      recur_trouve_volume(SIMP, &depth);
-    } while(++i < List_Nbr(StackSimp));
-
-    iVolume = isListaVolume(ListSurfaces, THEM);
-
-    for(i = 0; i < List_Nbr(ListSurfaces); i++) {
-      List_Read(ListSurfaces, i, &j);
-      Msg(STATUS2, "Surface %d", j);
-    }
-
-    N = Tree_Nbr(keep);
-    Msg(INFO, "Initial mesh of volume %d: %d simplices", iVolume, N);
-    Tree_Action(keep, attribueVolume);
-    Tree_Delete(keep);
-    List_Reset(ListSurfaces);
-    List_Reset(StackSimp);
-  }
-}
diff --git a/Mesh/3D_Divide.cpp b/Mesh/3D_Divide.cpp
deleted file mode 100644
index 24caf4ca7208bcb4c12d45855c87a9887378327b..0000000000000000000000000000000000000000
--- a/Mesh/3D_Divide.cpp
+++ /dev/null
@@ -1,758 +0,0 @@
-// $Id: 3D_Divide.cpp,v 1.24 2006-01-06 00:34:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-/* Routine de division des elements tetraedriques
-   ou triangulaires
-
-        1 triangle -> 4 triangles ;
-        1 tetraedre -> noeuds 1 2 3 4
-                       faces  1 4 2
-                              1
-*/
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-
-extern Mesh *THEM;
-extern int edges_tetra[6][2];
-
-static Tree_T *New_Edges = NULL;
-static int IENT;
-
-typedef struct{
-  int i;
-  int j;
-}nxn;
-
-static int are_exists(Vertex * v1, Vertex * v2)
-{
-  nxn nx;
-  nx.i = IMAX(v1->Num, v2->Num);
-  nx.j = IMIN(v1->Num, v2->Num);
-  return Tree_Search(New_Edges, &nx);
-}
-
-static void are_add(Vertex * v1, Vertex * v2)
-{
-  nxn nx;
-  nx.i = IMAX(v1->Num, v2->Num);
-  nx.j = IMIN(v1->Num, v2->Num);
-  Tree_Add(New_Edges, &nx);
-}
-
-static int compnxn(const void *a, const void *b)
-{
-  nxn *q, *w;
-  q = (nxn *) a;
-  w = (nxn *) b;
-  if(q->i > w->i)
-    return 1;
-  if(q->i < w->i)
-    return -1;
-  if(q->j > w->j)
-    return 1;
-  if(q->j < w->j)
-    return -1;
-  return 0;
-}
-
-static int FF, FV, EV, EE, FE, EEE, EEEE;
-void Remise_A_Zero(void)
-{
-  FF = EE = FV = EV = FE = EEE = EEEE = 0;
-}
-
-void Impression_Resultats(void)
-{
-  Msg(INFO1, "===================================================");
-  Msg(INFO2, "Surface coherence results (number of intersections)");
-  Msg(INFO2, "%d EV, %d EE, %d FV, %d FF, %d FE, %d EEE, %d EEEE",
-      EV, EE, FV, FF, FE, EEE, EEEE);
-  Msg(INFO3, "===================================================");
-
-}
-
-int PARLE = 0;
-
-void cut_prism(Vertex * v1, Vertex * v2, Vertex * v3,
-               Vertex * v4, Vertex * v5, Vertex * v6,
-               Tree_T * newpoints, Tree_T * AddedTet)
-{
-  Simplex *news;
-  Vertex *e1;
-
-  //Msg(INFO, "Prism cut");
-
-#if 0
-  /* test des meilleures aretes a creer */
-  if(!are_exists(v1,v6) &&
-     !are_exists(v4,v3)){
-    
-    if(fabs(angle_3p(v1,v4,v6)) >
-       fabs(angle_3p(v4,v6,v3))){
-      are_add(v4,v3);
-    }
-    else{
-      are_add(v1,v6);
-    }
-  }
-  
-  if(!are_exists(v3,v5) &&
-     !are_exists(v6,v2)){
-    
-    if(fabs(angle_3p(v6,v5,v2)) >
-       fabs(angle_3p(v5,v2,v3))){
-      are_add(v5,v3);
-    }
-    else{
-      are_add(v2,v6);
-    }
-  }
-  
-  if(!are_exists(v1,v5) &&
-     !are_exists(v4,v2)){
-    
-    if(fabs(angle_3p(v1,v4,v5)) >
-       fabs(angle_3p(v4,v5,v2))){
-      are_add(v4,v2);
-    }
-    else{
-      are_add(v1,v5);
-    }
-  }
-#endif
-
-  if(!are_exists(v1, v5) &&     //OK
-     !are_exists(v6, v2) && !are_exists(v6, v1)) {
-    news = Create_Simplex(v1, v2, v3, v4);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v2, v4, v5, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v4, v2);
-    are_add(v5, v3);
-    are_add(v4, v3);
-  }
-  else if(!are_exists(v1, v5) &&        //OK
-          !are_exists(v3, v5) && !are_exists(v1, v6)) {
-    news = Create_Simplex(v1, v2, v3, v4);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v2);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v2, v6, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v4, v2);
-    are_add(v2, v6);
-    are_add(v4, v3);
-  }
-  else if(!are_exists(v1, v5) &&        //OK
-          !are_exists(v3, v5) && !are_exists(v4, v3)) {
-    news = Create_Simplex(v1, v2, v3, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v2);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v2, v4, v6, v1);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v4, v2);
-    are_add(v2, v6);
-    are_add(v6, v1);
-  }
-  else if(!are_exists(v4, v2) &&        //OK
-          !are_exists(v6, v2) && !are_exists(v6, v1)) {
-    news = Create_Simplex(v1, v2, v3, v5);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v1, v4, v5, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v5, v1);
-    are_add(v5, v3);
-    are_add(v4, v3);
-  }
-  else if(!are_exists(v4, v2) &&        //OK
-          !are_exists(v6, v2) && !are_exists(v4, v3)) {
-    news = Create_Simplex(v1, v2, v3, v5);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v1);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v1, v3, v5, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v5, v1);
-    are_add(v5, v3);
-    are_add(v6, v1);
-  }
-  else if(!are_exists(v4, v2) &&        //OK
-          !are_exists(v3, v5) && !are_exists(v4, v3)) {
-    news = Create_Simplex(v1, v2, v3, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v4, v5, v6, v1);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(v1, v2, v5, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    are_add(v5, v1);
-    are_add(v2, v6);
-    are_add(v6, v1);
-  }
-
-  else if(are_exists(v6, v1) && are_exists(v5, v3) && are_exists(v4, v2)) {
-    Msg(INFO, "Found steiner prism 1!");
-
-    e1 = Create_Vertex
-      (++THEM->MaxPointNum,
-       (v1->Pos.X + v2->Pos.X + v3->Pos.X + v4->Pos.X + v5->Pos.X +
-        v6->Pos.X) / 6.,
-       (v1->Pos.Y + v2->Pos.Y + v3->Pos.Y + v4->Pos.Y + v5->Pos.Y +
-        v6->Pos.Y) / 6.,
-       (v1->Pos.Z + v2->Pos.Z + v3->Pos.Z + v4->Pos.Z + v5->Pos.Z +
-        v6->Pos.Z) / 6.,
-       (v1->lc + v2->lc + v3->lc + v4->lc + v5->lc + v6->lc) / 6., 0.0);
-    Tree_Add(newpoints, &e1);
-    news = Create_Simplex(e1, v6, v1, v4);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v6, v1, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v5, v3, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v5, v3, v2);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v4, v2, v1);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v4, v2, v5);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-  }
-
-  else if(are_exists(v4, v3) && are_exists(v6, v2) && are_exists(v5, v1)) {
-    Msg(INFO, "Found steiner prism 2!");
-
-    e1 = Create_Vertex
-      (++THEM->MaxPointNum,
-       (v1->Pos.X + v2->Pos.X + v3->Pos.X + v4->Pos.X + v5->Pos.X +
-        v6->Pos.X) / 6.,
-       (v1->Pos.Y + v2->Pos.Y + v3->Pos.Y + v4->Pos.Y + v5->Pos.Y +
-        v6->Pos.Y) / 6.,
-       (v1->Pos.Z + v2->Pos.Z + v3->Pos.Z + v4->Pos.Z + v5->Pos.Z +
-        v6->Pos.Z) / 6.,
-       (v1->lc + v2->lc + v3->lc + v4->lc + v5->lc + v6->lc) / 6., 0.0);
-    Tree_Add(newpoints, &e1);
-    news = Create_Simplex(e1, v4, v3, v6);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v4, v3, v1);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v6, v2, v5);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v6, v2, v3);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v5, v1, v4);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-    news = Create_Simplex(e1, v5, v1, v2);
-    news->iEnt = IENT;
-    Tree_Add(AddedTet, &news);
-
-  }
-  else {
-    Msg(GERROR, "Uncoherent prism");
-  }
-}
-
-
-void cut_tetraedre(Intersection * pI, Tree_T * AddedTet, Tree_T * TetDel,
-                   Tree_T * newpoints)
-{
-  int i;
-  nxn nx;
-  Simplex *s;
-  Vertex *common, *other1, *other2, *lonely = NULL, *e1, *e2;
-  Vertex *point1 = NULL, *point2 = NULL, *point3 = NULL, *point4 = NULL;
-  Vertex *v1 = NULL, *v2 = NULL, *v3 = NULL, *v4 = NULL, *v5 = NULL, *v6 =
-    NULL, *v7 = NULL, *v8 = NULL;
-
-  if(!New_Edges)
-    New_Edges = Tree_Create(sizeof(nxn), compnxn);
-
-  IENT = pI->s->iEnt;
-
-  /* 1 tetraedre -> 2 tetraedres */
-
-  if((pI->NbEdge == 0) && (pI->NbFace == 0)) {
-  }
-  else if(pI->NbEdge == 1 && pI->NbFace == 0) {
-
-    Tree_Add(TetDel, &pI->s);
-
-
-    EV++;
-    if(pI->E[0] == 0) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[2], pI->s->V[3], pI->s->V[0], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s = Create_Simplex(pI->s->V[1], pI->s->V[3], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    if(pI->E[0] == 1) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[0], pI->s->V[3], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[3], pI->s->V[1], pI->s->V[0], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    if(pI->E[0] == 2) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[0], pI->s->V[1], pI->s->V[3], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->s->V[3], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    if(pI->E[0] == 3) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[0], pI->s->V[1], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->s->V[2], pI->s->V[3], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    if(pI->E[0] == 4) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[2], pI->s->V[0], pI->s->V[1], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->s->V[3], pI->s->V[0], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    if(pI->E[0] == 5) {
-      /* Verifie */
-      s = Create_Simplex(pI->s->V[0], pI->s->V[3], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[0], pI->s->V[1], pI->s->V[2], pI->VE[0]);
-      if(PARLE)
-        printf("ajout %d %d %d %d\n",
-               s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-  }
-  else if(pI->NbVertex == 1 && pI->NbFace == 1) {
-    FV++;
-    Tree_Add(TetDel, &pI->s);
-    s = Create_Simplex(pI->V[0], pI->VF[0], pI->F[0]->V[0], pI->F[0]->V[1]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    s = Create_Simplex(pI->V[0], pI->VF[0], pI->F[0]->V[1], pI->F[0]->V[2]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    s = Create_Simplex(pI->V[0], pI->VF[0], pI->F[0]->V[2], pI->F[0]->V[0]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-  }
-
-  /* DU CUL LES COPINES
-     TROIS ARETES QUI PENETRENT LA MEME FACE
-     TRIPLETTE, TRIPLE PENETRATION */
-
-  else if(pI->NbEdge == 3) {
-    EEE++;
-    /*
-       printf("tet %d %d %d %d\n",
-       pI->s->V[0]->Num,pI->s->V[1]->Num,pI->s->V[2]->Num,pI->s->V[3]->Num);
-       printf("ed %d %d\n",pI->s->V[edges_tetra[pI->E[0]][0]]->Num,
-       pI->s->V[edges_tetra[pI->E[0]][1]]->Num);
-       printf("ed %d %d\n",pI->s->V[edges_tetra[pI->E[1]][0]]->Num,
-       pI->s->V[edges_tetra[pI->E[1]][1]]->Num);
-       printf("ed %d %d\n",pI->s->V[edges_tetra[pI->E[2]][0]]->Num,
-       pI->s->V[edges_tetra[pI->E[2]][1]]->Num);
-     */
-    Tree_Add(TetDel, &pI->s);
-    v4 = pI->VE[0];
-    v5 = pI->VE[1];
-    v6 = pI->VE[2];
-    if(pI->E[0] == 0 && pI->E[1] == 1 && pI->E[2] == 5) {
-      v1 = pI->s->V[0];
-      v2 = pI->s->V[2];
-      v3 = pI->s->V[3];
-      v7 = pI->s->V[1];
-    }
-    else if(pI->E[0] == 0 && pI->E[1] == 2 && pI->E[2] == 3) {
-      v1 = pI->s->V[1];
-      v2 = pI->s->V[2];
-      v3 = pI->s->V[3];
-      v7 = pI->s->V[0];
-    }
-    else if(pI->E[0] == 1 && pI->E[1] == 2 && pI->E[2] == 4) {
-      v1 = pI->s->V[1];
-      v2 = pI->s->V[0];
-      v3 = pI->s->V[3];
-      v7 = pI->s->V[2];
-    }
-    else if(pI->E[0] == 3 && pI->E[1] == 4 && pI->E[2] == 5) {
-      v1 = pI->s->V[0];
-      v2 = pI->s->V[2];
-      v3 = pI->s->V[1];
-      v7 = pI->s->V[3];
-    }
-    else {
-      Msg(GERROR, "Three edges cut without common point!");
-      return;
-    }
-
-    s = Create_Simplex(v4, v5, v6, v7);
-    Tree_Add(AddedTet, &s);
-    cut_prism(v1, v2, v3, v4, v5, v6, newpoints, AddedTet);
-
-  }
-
-  else if(pI->NbFace == 2) {
-    FF++;
-    point3 = NULL;
-    Tree_Add(TetDel, &pI->s);
-    if(PARLE) {
-      printf("simp  = %d %d %d %d\n",
-             pI->s->V[0]->Num, pI->s->V[1]->Num, pI->s->V[2]->Num,
-             pI->s->V[3]->Num);
-      printf("are   = %d %d\n", pI->VF[0]->Num, pI->VF[1]->Num);
-      printf("face1 = %d %d %d\n",
-             pI->F[0]->V[0]->Num, pI->F[0]->V[1]->Num, pI->F[0]->V[2]->Num);
-      printf("face2 = %d %d %d\n",
-             pI->F[1]->V[0]->Num, pI->F[1]->V[1]->Num, pI->F[1]->V[2]->Num);
-    }
-    for(i = 0; i < 4; i++) {
-      if(compareVertex(&pI->F[0]->V[0], &pI->s->V[i]) &&
-         compareVertex(&pI->F[0]->V[1], &pI->s->V[i]) &&
-         compareVertex(&pI->F[0]->V[2], &pI->s->V[i]))
-        point1 = pI->s->V[i];
-      else if(compareVertex(&pI->F[1]->V[0], &pI->s->V[i]) &&
-              compareVertex(&pI->F[1]->V[1], &pI->s->V[i]) &&
-              compareVertex(&pI->F[1]->V[2], &pI->s->V[i]))
-        point2 = pI->s->V[i];
-      else if(point3)
-        point4 = pI->s->V[i];
-      else
-        point3 = pI->s->V[i];
-    }
-    s = Create_Simplex(point3, point4, pI->VF[0], pI->VF[1]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    if(PARLE)
-      printf("simp  = %d %d %d %d\n",
-             s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-    s = Create_Simplex(point1, point4, pI->VF[0], pI->VF[1]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    if(PARLE)
-      printf("simp  = %d %d %d %d\n",
-             s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-    s = Create_Simplex(point1, point3, pI->VF[0], pI->VF[1]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    if(PARLE)
-      printf("simp  = %d %d %d %d\n",
-             s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-    s = Create_Simplex(point2, point4, point1, pI->VF[0]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    if(PARLE)
-      printf("simp  = %d %d %d %d\n",
-             s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-    s = Create_Simplex(point2, point3, point1, pI->VF[0]);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    if(PARLE)
-      printf("simp  = %d %d %d %d\n",
-             s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-  }
-
-  else if(pI->NbEdge == 2) {
-    EE++;
-    Tree_Add(TetDel, &pI->s);
-    if(pI->E[0] == 1 && pI->E[1] == 3) {
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[1], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[2], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[2], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      return;
-    }
-    else if(pI->E[0] == 2 && pI->E[1] == 5) {
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[1], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->VE[1], pI->s->V[2], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[2], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      return;
-    }
-
-    else if(pI->E[0] == 0 && pI->E[1] == 4) {
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[2], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->VE[1], pI->s->V[2], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[0], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(pI->s->V[1], pI->VE[1], pI->s->V[3], pI->VE[0]);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      return;
-    }
-
-    e1 = pI->VE[0];
-    e2 = pI->VE[1];
-
-    if(!compareVertex(&pI->s->V[edges_tetra[pI->E[0]][0]],
-                      &pI->s->V[edges_tetra[pI->E[1]][0]])) {
-      common = pI->s->V[edges_tetra[pI->E[0]][0]];
-      other1 = pI->s->V[edges_tetra[pI->E[0]][1]];
-      other2 = pI->s->V[edges_tetra[pI->E[1]][1]];
-    }
-    else if(!compareVertex(&pI->s->V[edges_tetra[pI->E[0]][0]],
-                           &pI->s->V[edges_tetra[pI->E[1]][1]])) {
-      common = pI->s->V[edges_tetra[pI->E[0]][0]];
-      other1 = pI->s->V[edges_tetra[pI->E[0]][1]];
-      other2 = pI->s->V[edges_tetra[pI->E[1]][0]];
-    }
-    else if(!compareVertex(&pI->s->V[edges_tetra[pI->E[0]][1]],
-                           &pI->s->V[edges_tetra[pI->E[1]][0]])) {
-      common = pI->s->V[edges_tetra[pI->E[0]][1]];
-      other1 = pI->s->V[edges_tetra[pI->E[0]][0]];
-      other2 = pI->s->V[edges_tetra[pI->E[1]][1]];
-    }
-    else if(!compareVertex(&pI->s->V[edges_tetra[pI->E[0]][1]],
-                           &pI->s->V[edges_tetra[pI->E[1]][1]])) {
-      common = pI->s->V[edges_tetra[pI->E[0]][1]];
-      other1 = pI->s->V[edges_tetra[pI->E[0]][0]];
-      other2 = pI->s->V[edges_tetra[pI->E[1]][0]];
-    }
-
-    for(i = 0; i < 4; i++) {
-      if(compareVertex(&pI->s->V[i], &common) &&
-         compareVertex(&pI->s->V[i], &other1) &&
-         compareVertex(&pI->s->V[i], &other2))
-        lonely = pI->s->V[i];
-    }
-
-    nx.i = IMAX(e1->Num, other2->Num);
-    nx.j = IMIN(e1->Num, other2->Num);
-
-    if(Tree_Search(New_Edges, &nx)) {
-      s = Create_Simplex(e1, other1, other2, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(e2, e1, common, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(e2, other2, e1, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-    else {
-      nx.i = IMAX(e2->Num, other1->Num);
-      nx.j = IMIN(e2->Num, other1->Num);
-      Tree_Add(New_Edges, &nx);
-      s = Create_Simplex(e1, other1, e2, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(e2, e1, common, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-      s = Create_Simplex(e2, other1, other2, lonely);
-      s->iEnt = IENT;
-      Tree_Add(AddedTet, &s);
-    }
-  }
-  else if(pI->NbFace == 1 && pI->NbEdge == 1) {
-    FE++;
-
-    Tree_Add(TetDel, &pI->s);
-    for(i = 0; i < 4; i++)
-      if(compareVertex(&pI->s->V[i], &pI->F[0]->V[0]) &&
-         compareVertex(&pI->s->V[i], &pI->F[0]->V[1]) &&
-         compareVertex(&pI->s->V[i], &pI->F[0]->V[2]))
-        v1 = pI->s->V[i];
-    v2 = NULL;
-    v3 = NULL;
-
-    for(i = 0; i < 4; i++) {
-      if(compareVertex(&pI->s->V[i], &v1)) {
-        if(compareVertex(&pI->s->V[i], &pI->s->V[edges_tetra[pI->E[0]][0]]) &&
-           compareVertex(&pI->s->V[i], &pI->s->V[edges_tetra[pI->E[0]][1]])) {
-          if(v2)
-            v3 = pI->s->V[i];
-          else
-            v2 = pI->s->V[i];
-        }
-        else {
-          v4 = pI->s->V[i];
-        }
-      }
-    }
-
-    e1 = pI->VE[0];
-    e2 = pI->VF[0];
-
-    s = Create_Simplex(e1, e2, v3, v4);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    s = Create_Simplex(e1, e2, v2, v4);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    s = Create_Simplex(e1, e2, v2, v3);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-    s = Create_Simplex(e1, v1, v2, v3);
-    s->iEnt = IENT;
-    Tree_Add(AddedTet, &s);
-
-  }
-  else if(pI->NbEdge == 4) {
-    EEEE++;
-
-    // Allez j-f il faut le faire !
-
-    Tree_Add(TetDel, &pI->s);
-    if(pI->E[0] == 1 && pI->E[1] == 2 && pI->E[2] == 3 && pI->E[3] == 5) {
-      v1 = pI->s->V[0];
-      v2 = pI->s->V[1];
-      v3 = pI->s->V[2];
-      v4 = pI->s->V[3];
-      v5 = pI->VE[1];
-      v6 = pI->VE[2];
-      v7 = pI->VE[0];
-      v8 = pI->VE[3];
-    }
-    else if(pI->E[0] == 0 && pI->E[1] == 2 && pI->E[2] == 4 && pI->E[3] == 5) {
-      v1 = pI->s->V[1];
-      v2 = pI->s->V[2];
-      v3 = pI->s->V[0];
-      v4 = pI->s->V[3];
-      v5 = pI->VE[0];
-      v6 = pI->VE[3];
-      v7 = pI->VE[1];
-      v8 = pI->VE[2];
-    }
-    else if(pI->E[0] == 0 && pI->E[1] == 1 && pI->E[2] == 3 && pI->E[3] == 4) {
-      v1 = pI->s->V[0];
-      v2 = pI->s->V[2];
-      v3 = pI->s->V[1];
-      v4 = pI->s->V[3];
-      v5 = pI->VE[0];
-      v6 = pI->VE[2];
-      v7 = pI->VE[1];
-      v8 = pI->VE[3];
-    }
-    else {
-      Msg(GERROR, "Incoherent 4 edges intersection");
-      return;
-    }
-    cut_prism(v8, v4, v6, v7, v3, v5, newpoints, AddedTet);
-    cut_prism(v2, v8, v7, v1, v6, v5, newpoints, AddedTet);
-  }
-  else {
-    Msg(GERROR, "Error on cut %d %d %d", pI->NbVertex, pI->NbEdge,
-        pI->NbFace);
-  }
-}
diff --git a/Mesh/3D_Extrude.cpp b/Mesh/3D_Extrude.cpp
deleted file mode 100644
index 6aac1b87b0971a71be866a65b1e67dcdff9b31a0..0000000000000000000000000000000000000000
--- a/Mesh/3D_Extrude.cpp
+++ /dev/null
@@ -1,1165 +0,0 @@
-// $Id: 3D_Extrude.cpp,v 1.94 2006-11-25 00:44:25 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "Context.h"
-#include "Create.h"
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-static int DIM, NUM;            // current dimension of parent entity
-static int BAD_TETS;
-static Tree_T *Tree_Ares = NULL, *Tree_Swaps = NULL;
-static Curve *THEC = NULL;
-static Surface *THES = NULL;
-static Volume *THEV = NULL;
-static ExtrudeParams *ep;
-
-// Point_Bound and Vertex_Bound contain the points and vertices on the
-// "boundaries". We cannot check for duplicates in THEM->Points and
-// THEM->Vertices directly since the comparison function for these
-// trees are on the point/vertex numbers, not the position.
-static Tree_T *Point_Bound = NULL, *Vertex_Bound = NULL;
-
-typedef struct
-{
-  int Dim, Num;
-  List_T *List;
-}
-nxl;
-
-static int compnxl(const void *a, const void *b)
-{
-  int val;
-  nxl *q = (nxl *) a, *w = (nxl *) b;
-
-  if((val = q->Dim - w->Dim) != 0)
-    return val;
-  return q->Num - w->Num;
-}
-
-List_T *getnxl(Vertex * v, Curve * c)
-{
-  nxl NXL;
-  NXL.Dim = 1;
-  NXL.Num = abs(c->Num);
-  nxl *NXLP = (nxl *) List_PQuery(v->Extruded_Points, &NXL, compnxl);
-  if(NXLP)
-    return NXLP->List;
-  return NULL;
-}
-
-List_T *getnxl(Vertex * v, Surface * s)
-{
-  nxl NXL;
-  NXL.Dim = 2;
-  NXL.Num = s->Num;
-  nxl *NXLP = (nxl *) List_PQuery(v->Extruded_Points, &NXL, compnxl);
-  if(NXLP)
-    return NXLP->List;
-  return NULL;
-}
-
-List_T *getnxl(Vertex * v, Volume * vol)
-{
-  nxl NXL;
-  NXL.Dim = 3;
-  NXL.Num = vol->Num;
-  nxl *NXLP = (nxl *) List_PQuery(v->Extruded_Points, &NXL, compnxl);
-  if(NXLP)
-    return NXLP->List;
-  return NULL;
-}
-
-List_T *getnxl(Vertex * v, int dim)
-{
-  Curve *c;
-  Surface *s;
-  List_T *list;
-
-  // the test on the source entity is in case we extrude a
-  // curve/surface resulting from the extrusion of a point/curve...
-
-  if(dim == 1) {
-    if((list = getnxl(v, THEC)))
-      return list;
-  }
-  else if(dim == 2) {
-    if((list = getnxl(v, THES)))
-      return list;
-    else {
-      for(int i = 0; i < List_Nbr(THES->Generatrices); i++) {
-        if((abs(ep->geo.Source) != c->Num) && (list = getnxl(v, c)))
-          return list;
-      }
-    }
-  }
-  else if(dim == 3) {
-    if((list = getnxl(v, THEV)))
-      return list;
-    else {
-      for(int i = 0; i < List_Nbr(THEV->Surfaces); i++) {
-        List_Read(THEV->Surfaces, i, &s);
-        if((ep->geo.Source != s->Num) && (list = getnxl(v, s)))
-          return list;
-      }
-      for(int i = 0; i < List_Nbr(THEV->Surfaces); i++) {
-        List_Read(THEV->Surfaces, i, &s);
-        if(ep->geo.Source != s->Num) {
-          for(int j = 0; j < List_Nbr(s->Generatrices); j++) {
-            List_Read(s->Generatrices, j, &c);
-            if((list = getnxl(v, c)))
-              return list;
-          }
-        }
-      }
-    }
-  }
-
-  Msg(GERROR, "Could not find extruded list for vertex %d", v->Num);
-  return NULL;
-}
-
-void Free_ExtrudedPoints(List_T * Extruded_Points)
-{
-  nxl *NXL;
-  for(int i = 0; i < List_Nbr(Extruded_Points); i++) {
-    NXL = (nxl *) List_Pointer(Extruded_Points, i);
-    List_Delete(NXL->List);
-  }
-  List_Delete(Extruded_Points);
-}
-
-typedef struct
-{
-  int a, b;
-}
-nxn;
-
-static int compnxn(const void *a, const void *b)
-{
-  nxn *q, *w;
-  q = (nxn *) a;
-  w = (nxn *) b;
-  if(q->a > w->a)
-    return 1;
-  if(q->a < w->a)
-    return -1;
-  if(q->b > w->b)
-    return 1;
-  if(q->b < w->b)
-    return -1;
-  return 0;
-}
-
-void InsertInVertexBound(void *a, void *b)
-{
-  Tree_Insert(Vertex_Bound, a);
-}
-
-void InsertInPointBound(void *a, void *b)
-{
-  Tree_Insert(Point_Bound, a);
-}
-
-void InitExtrude()
-{
-  if(!Tree_Ares)
-    Tree_Ares = Tree_Create(sizeof(nxn), compnxn);
-  if(!Tree_Swaps)
-    Tree_Swaps = Tree_Create(sizeof(nxn), compnxn);
-
-  if(Point_Bound)
-    Tree_Delete(Point_Bound);
-  Point_Bound = Tree_Create(sizeof(Vertex *), comparePosition);
-
-  if(Vertex_Bound)
-    Tree_Delete(Vertex_Bound);
-  Vertex_Bound = Tree_Create(sizeof(Vertex *), comparePosition);
-
-  Tree_Action(THEM->Points, InsertInPointBound);
-  Tree_Action(THEM->Vertices, InsertInVertexBound);
-}
-
-void ExitExtrude()
-{
-  if(Tree_Ares)
-    Tree_Delete(Tree_Ares);
-  if(Tree_Swaps)
-    Tree_Delete(Tree_Swaps);
-  if(Point_Bound)
-    Tree_Delete(Point_Bound);
-  if(Vertex_Bound)
-    Tree_Delete(Vertex_Bound);
-  Tree_Ares = Tree_Swaps = Point_Bound = Vertex_Bound = NULL;
-}
-
-int are_exist(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  return Tree_Search(t, &n);
-}
-
-void are_cree(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  Tree_Replace(t, &n);
-}
-
-void are_del(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  Tree_Suppress(t, &n);
-}
-
-
-void Extrude_Simplex_Phase1(void *data, void *dum)
-{
-  Vertex *v1, *v2, *v3, *v4, *v5, *v6;
-
-  Simplex *s = *(Simplex **) data;
-
-  List_T *L0 = getnxl(s->V[0], DIM);
-  List_T *L1 = getnxl(s->V[1], DIM);
-  List_T *L2 = getnxl(s->V[2], DIM);
-
-  if(!L0 || !L1 || !L2) return;
-
-  int k = 0;
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      List_Read(L0, k, &v1);
-      List_Read(L1, k, &v2);
-      List_Read(L2, k, &v3);
-      List_Read(L0, k + 1, &v4);
-      List_Read(L1, k + 1, &v5);
-      List_Read(L2, k + 1, &v6);
-      k++;
-      if(!are_exist(v1, v5, Tree_Ares))
-        are_cree(v2, v4, Tree_Ares);
-      if(!are_exist(v5, v3, Tree_Ares))
-        are_cree(v2, v6, Tree_Ares);
-      if(!are_exist(v4, v3, Tree_Ares))
-        are_cree(v1, v6, Tree_Ares);
-    }
-  }
-}
-
-void Extrude_Simplex_Phase2(void *data, void *dum)
-{
-  Vertex *v1, *v2, *v3, *v4, *v5, *v6;
-
-  Simplex *s = *(Simplex **) data;
-
-  List_T *L0 = getnxl(s->V[0], DIM);
-  List_T *L1 = getnxl(s->V[1], DIM);
-  List_T *L2 = getnxl(s->V[2], DIM);
-
-  if(!L0 || !L1 || !L2) return;
-
-  int k = 0;
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      List_Read(L0, k, &v1);
-      List_Read(L1, k, &v2);
-      List_Read(L2, k, &v3);
-      List_Read(L0, k + 1, &v4);
-      List_Read(L1, k + 1, &v5);
-      List_Read(L2, k + 1, &v6);
-      k++;
-      if(are_exist(v4, v2, Tree_Ares) &&
-         are_exist(v5, v3, Tree_Ares) && 
-	 are_exist(v1, v6, Tree_Ares)) {
-        BAD_TETS++;
-        if(!are_exist(v4, v2, Tree_Swaps)) {
-          are_del(v4, v2, Tree_Ares);
-          are_cree(v1, v5, Tree_Ares);
-          are_cree(v1, v5, Tree_Swaps);
-          are_cree(v4, v2, Tree_Swaps);
-        }
-        else if(!are_exist(v5, v3, Tree_Swaps)) {
-          are_del(v5, v3, Tree_Ares);
-          are_cree(v2, v6, Tree_Ares);
-          are_cree(v5, v3, Tree_Swaps);
-          are_cree(v2, v6, Tree_Swaps);
-        }
-        else if(!are_exist(v1, v6, Tree_Swaps)) {
-          are_del(v1, v6, Tree_Ares);
-          are_cree(v4, v3, Tree_Ares);
-          are_cree(v1, v6, Tree_Swaps);
-          are_cree(v4, v3, Tree_Swaps);
-        }
-      }
-      else if(are_exist(v1, v5, Tree_Ares) &&
-              are_exist(v2, v6, Tree_Ares) &&
-	      are_exist(v4, v3, Tree_Ares)) {
-        BAD_TETS++;
-        if(!are_exist(v1, v5, Tree_Swaps)) {
-          are_del(v1, v5, Tree_Ares);
-          are_cree(v4, v2, Tree_Ares);
-          are_cree(v1, v5, Tree_Swaps);
-          are_cree(v4, v2, Tree_Swaps);
-        }
-        else if(!are_exist(v2, v6, Tree_Swaps)) {
-          are_del(v2, v6, Tree_Ares);
-          are_cree(v5, v3, Tree_Ares);
-          are_cree(v5, v3, Tree_Swaps);
-          are_cree(v2, v6, Tree_Swaps);
-        }
-        else if(!are_exist(v4, v3, Tree_Swaps)) {
-          are_del(v4, v3, Tree_Ares);
-          are_cree(v1, v6, Tree_Ares);
-          are_cree(v1, v6, Tree_Swaps);
-          are_cree(v4, v3, Tree_Swaps);
-        }
-      }
-    }
-  }
-}
-
-void Create_HexPri(int iEnt, Vertex * v[8])
-{
-  int dup[4];
-  Hexahedron *newh;
-  Prism *newp;
-
-  if(CTX.mesh.allow_degenerated_extrude) {
-    newh = Create_Hexahedron(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
-    newh->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Hexahedra, &newh);
-    return;
-  }
-
-  int j = 0;
-  for(int i = 0; i < 4; i++)
-    if(v[i]->Num == v[i + 4]->Num)
-      dup[j++] = i;
-
-  if(j == 2) {
-    if(dup[0] == 0 && dup[1] == 1)
-      newp = Create_Prism(v[0], v[3], v[7], v[1], v[2], v[6]);
-    else if(dup[0] == 1 && dup[1] == 2)
-      newp = Create_Prism(v[0], v[1], v[4], v[3], v[2], v[7]);
-    else if(dup[0] == 2 && dup[1] == 3)
-      newp = Create_Prism(v[0], v[3], v[4], v[1], v[2], v[5]);
-    else if(dup[0] == 0 && dup[1] == 3)
-      newp = Create_Prism(v[0], v[1], v[5], v[3], v[2], v[6]);
-    else {
-      Msg(GERROR, "Uncoherent hexahedron (nodes %d %d %d %d %d %d %d %d)",
-          v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
-      return;
-    }
-    newp->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Prisms, &newp);
-  }
-  else {
-    newh = Create_Hexahedron(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
-    newh->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Hexahedra, &newh);
-    if(j)
-      Msg(GERROR, "Degenerated hexahedron %d (nodes %d %d %d %d %d %d %d %d)",
-          newh->Num, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
-  }
-}
-
-void Create_PriPyrTet(int iEnt, Vertex * v[6])
-{
-  int dup[3];
-  Prism *newp;
-  Pyramid *newpyr;
-  Simplex *news;
-
-  if(CTX.mesh.allow_degenerated_extrude) {
-    newp = Create_Prism(v[0], v[1], v[2], v[3], v[4], v[5]);
-    newp->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Prisms, &newp);
-    return;
-  }
-
-  int j = 0;
-  for(int i = 0; i < 3; i++)
-    if(v[i]->Num == v[i + 3]->Num)
-      dup[j++] = i;
-
-  if(j == 2) {
-    if(dup[0] == 0 && dup[1] == 1)
-      news = Create_Simplex(v[0], v[1], v[2], v[5]);
-    else if(dup[0] == 1 && dup[1] == 2)
-      news = Create_Simplex(v[0], v[1], v[2], v[3]);
-    else
-      news = Create_Simplex(v[0], v[1], v[2], v[4]);
-    news->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Simplexes, &news);
-  }
-  else if(j == 1) {
-    if(dup[0] == 0)
-      newpyr = Create_Pyramid(v[1], v[4], v[5], v[2], v[0]);
-    else if(dup[0] == 1)
-      newpyr = Create_Pyramid(v[0], v[2], v[5], v[3], v[1]);
-    else
-      newpyr = Create_Pyramid(v[0], v[1], v[4], v[3], v[2]);
-    newpyr->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Pyramids, &newpyr);
-  }
-  else {
-    newp = Create_Prism(v[0], v[1], v[2], v[3], v[4], v[5]);
-    newp->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Prisms, &newp);
-    if(j)
-      Msg(GERROR, "Degenerated prism %d (nodes %d %d %d %d %d %d)",
-          newp->Num, v[0], v[1], v[2], v[3], v[4], v[5]);
-  }
-
-}
-
-void Create_Sim(int iEnt, Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4)
-{
-  Simplex *news;
-  if(CTX.mesh.allow_degenerated_extrude ||
-     (v1->Num != v2->Num && v1->Num != v3->Num && v1->Num != v4->Num &&
-      v2->Num != v3->Num && v2->Num != v4->Num && v3->Num != v4->Num)) {
-    news = Create_Simplex(v1, v2, v3, v4);
-    news->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THEV->Num;
-    Tree_Add(THEV->Simplexes, &news);
-  }
-}
-
-void Extrude_Simplex_Phase3(void *data, void *dum)
-{
-  Vertex *v[8];
-
-  Simplex *s = *(Simplex **) data;
-
-  List_T *L0 = getnxl(s->V[0], DIM);
-  List_T *L1 = getnxl(s->V[1], DIM);
-  List_T *L2 = getnxl(s->V[2], DIM);
-
-  if(!L0 || !L1 || !L2) return;
-
-  int k = 0;
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      List_Read(L0, k, &v[0]);
-      List_Read(L1, k, &v[1]);
-      List_Read(L2, k, &v[2]);
-      List_Read(L0, k + 1, &v[3]);
-      List_Read(L1, k + 1, &v[4]);
-      List_Read(L2, k + 1, &v[5]);
-      k++;
-      if(ep->mesh.Recombine) {
-	Create_PriPyrTet(ep->mesh.ZonLayer[i], v);
-      }
-      else {
-	if(are_exist(v[3], v[1], Tree_Ares) &&
-	   are_exist(v[4], v[2], Tree_Ares) &&
-	   are_exist(v[3], v[2], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[3]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[2]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[1], v[3], v[4], v[2]);
-	}
-	else if(are_exist(v[3], v[1], Tree_Ares) &&
-		are_exist(v[1], v[5], Tree_Ares) &&
-		are_exist(v[3], v[2], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[3]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[1]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[1], v[5], v[2]);
-	}
-	else if(are_exist(v[3], v[1], Tree_Ares) &&
-		are_exist(v[1], v[5], Tree_Ares) &&
-		are_exist(v[5], v[0], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[5]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[1]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[1], v[3], v[5], v[0]);
-	}
-	else if(are_exist(v[4], v[0], Tree_Ares) &&
-		are_exist(v[4], v[2], Tree_Ares) &&
-		are_exist(v[3], v[2], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[4]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[2]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[3], v[4], v[2]);
-	}
-	else if(are_exist(v[4], v[0], Tree_Ares) &&
-		are_exist(v[4], v[2], Tree_Ares) &&
-		are_exist(v[5], v[0], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[4]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[0]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[2], v[4], v[5]);
-	}
-	else if(are_exist(v[4], v[0], Tree_Ares) &&
-		are_exist(v[1], v[5], Tree_Ares) &&
-		are_exist(v[5], v[0], Tree_Ares)) {
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[2], v[5]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[3], v[4], v[5], v[0]);
-	  Create_Sim(ep->mesh.ZonLayer[i], v[0], v[1], v[4], v[5]);
-	}
-      }
-    }
-  }
-}
-
-void Extrude_Quadrangle_Phase3(void *data, void *dum)
-{
-  Vertex *v[8];
-
-  Quadrangle *q = *(Quadrangle **) data;
-
-  if(!ep->mesh.Recombine) {
-    Msg(GERROR, "You have to use 'Recombine' to extrude quadrangular meshes");
-    return;
-  }
-
-  List_T *L0 = getnxl(q->V[0], DIM);
-  List_T *L1 = getnxl(q->V[1], DIM);
-  List_T *L2 = getnxl(q->V[2], DIM);
-  List_T *L3 = getnxl(q->V[3], DIM);
-
-  if(!L0 || !L1 || !L2 || !L3) return;
-
-  int k = 0;
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      List_Read(L0, k, &v[0]);
-      List_Read(L1, k, &v[1]);
-      List_Read(L2, k, &v[2]);
-      List_Read(L3, k, &v[3]);
-      List_Read(L0, k + 1, &v[4]);
-      List_Read(L1, k + 1, &v[5]);
-      List_Read(L2, k + 1, &v[6]);
-      List_Read(L3, k + 1, &v[7]);
-      k++;
-      Create_HexPri(ep->mesh.ZonLayer[i], v);
-    }
-  }
-}
-
-void Extrude_Vertex(void *data, void *dum)
-{
-  Vertex **vexist, *v, *newv;
-  nxl NXL;
-
-  v = *((Vertex **) data);
-
-  if(!v->Extruded_Points)
-    v->Extruded_Points = List_Create(1, 1, sizeof(nxl));
-
-  NXL.Num = NUM;
-  NXL.Dim = DIM;
-  if(List_Search(v->Extruded_Points, &NXL, compnxl))
-    return;
-  else
-    NXL.List = List_Create(ep->mesh.NbLayer, 1, sizeof(Vertex *));
-
-  List_Add(NXL.List, &v);
-
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      newv = Create_Vertex(++THEM->MaxPointNum, v->Pos.X,
-                           v->Pos.Y, v->Pos.Z, v->lc, v->u);
-      ep->Extrude(i, j + 1, newv->Pos.X, newv->Pos.Y, newv->Pos.Z);
-      if(Vertex_Bound && (vexist = (Vertex **) Tree_PQuery(Vertex_Bound, &newv))) {
-        Free_Vertex(&newv, 0);
-        List_Add(NXL.List, vexist);
-      }
-      else{
-	if(Point_Bound && (vexist = (Vertex **) Tree_PQuery(Point_Bound, &newv))) {
-	  // keep the new one: we cannot have points and vertices
-	  // pointing to the same memory location
-	  newv->Num = (*vexist)->Num;
-	}
-        List_Add(NXL.List, &newv);
-        Tree_Add(THEM->Vertices, &newv);
-        Tree_Insert(Vertex_Bound, &newv);
-      }
-    }
-  }
-
-  List_Add(v->Extruded_Points, &NXL);
-}
-
-void Extrude_Surface1(Surface * s)
-{
-  THES = s;
-  Tree_Action(s->Vertices, Extrude_Vertex);
-  if(!ep->mesh.Recombine)
-    Tree_Action(s->Simplexes, Extrude_Simplex_Phase1);
-}
-
-void Extrude_Surface2(Surface * s)
-{
-  THES = s;
-  Tree_Action(s->Simplexes, Extrude_Simplex_Phase2);
-}
-
-void Extrude_Surface3(Surface * s)
-{
-  THES = s;
-  Tree_Action(s->Simplexes, Extrude_Simplex_Phase3);
-  Tree_Action(s->Quadrangles, Extrude_Quadrangle_Phase3);
-}
-
-
-void Create_Tri(int iEnt, Vertex * v1, Vertex * v2, Vertex * v3)
-{
-  if(CTX.mesh.allow_degenerated_extrude ||
-     (v1->Num != v2->Num && v1->Num != v3->Num && v2->Num != v3->Num)) {
-    Simplex *s = Create_Simplex(v1, v2, v3, NULL);
-    s->iEnt = (iEnt && ep->useZonLayer()) ? iEnt : THES->Num;
-    s->Num = -s->Num;   //Tag triangles to re-extrude
-    Tree_Add(THES->Simplexes, &s);
-  }
-}
-
-void Extrude_Seg(void *data, void *dum)
-{
-  Simplex *ll = *(Simplex**)data;
-  Vertex *V1 = ll->V[0];
-  Vertex *V2 = ll->V[1];
-
-  Vertex *v1, *v2, *v3, *v4;
-
-  List_T *L1 = getnxl(V1, DIM);
-  List_T *L2 = getnxl(V2, DIM);
-
-  if(!L1 || !L2) return;
-
-  int k = 0;
-  for(int i = 0; i < ep->mesh.NbLayer; i++) {
-    for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-      List_Read(L1, k, &v1);
-      List_Read(L2, k, &v2);
-      List_Read(L1, k + 1, &v3);
-      List_Read(L2, k + 1, &v4);
-      if(ep->mesh.Recombine) {
-        if(CTX.mesh.allow_degenerated_extrude){
-          Quadrangle *q = Create_Quadrangle(v1, v2, v4, v3);
-	  q->iEnt = (ep->mesh.ZonLayer[i] && ep->useZonLayer()) ? 
-	    ep->mesh.ZonLayer[i] : THES->Num;
-	  q->Num = -q->Num; // Tag elt to re-extrude
-	  Tree_Add(THES->Quadrangles, &q);
-	}
-        else if(v1->Num == v2->Num || v2->Num == v4->Num){
-          Simplex *s = Create_Simplex(v1, v4, v3, NULL);
-	  s->iEnt = (ep->mesh.ZonLayer[i] && ep->useZonLayer()) ? 
-	    ep->mesh.ZonLayer[i] : THES->Num;
-	  s->Num = -s->Num; // Tag elt to re-extrude
-	  Tree_Add(THES->Simplexes, &s);
-	}
-        else if(v1->Num == v3->Num || v3->Num == v4->Num){
-          Simplex *s = Create_Simplex(v1, v2, v4, NULL);
-	  s->iEnt = (ep->mesh.ZonLayer[i] && ep->useZonLayer()) ? 
-	    ep->mesh.ZonLayer[i] : THES->Num;
-	  s->Num = -s->Num; // Tag elt to re-extrude
-	  Tree_Add(THES->Simplexes, &s);
-	}
-        else if(v1->Num == v4->Num || v2->Num == v3->Num) {
-          Msg(GERROR, "Uncoherent quadrangle  (nodes %d %d %d %d)",
-              v1->Num, v2->Num, v3->Num, v4->Num);
-          return;
-        }
-        else{
-          Quadrangle *q = Create_Quadrangle(v1, v2, v4, v3);
-	  q->iEnt = (ep->mesh.ZonLayer[i] && ep->useZonLayer()) ?
-	    ep->mesh.ZonLayer[i] : THES->Num;
-	  q->Num = -q->Num; // Tag elt to re-extrude
-	  Tree_Add(THES->Quadrangles, &q);
-	}
-      }
-      else {
-        if(are_exist(v3, v2, Tree_Ares)) {
-          Create_Tri(ep->mesh.ZonLayer[i], v3, v2, v1);
-          Create_Tri(ep->mesh.ZonLayer[i], v3, v4, v2);
-        }
-        else {
-          Create_Tri(ep->mesh.ZonLayer[i], v3, v4, v1);
-          Create_Tri(ep->mesh.ZonLayer[i], v1, v4, v2);
-        }
-      }
-      k++;
-    }
-  }
-
-}
-
-void Extrude_Curve(void *data, void *dum)
-{
-  Curve *c = *(Curve **) data;
-
-  //if (c->Num < 0) return;
-
-  Tree_Action(c->Simplexes, Extrude_Seg);
-}
-
-void copy_mesh(Curve * from, Curve * to, int direction)
-{
-  // Warning: this routine relies on the fact that the vertex lists
-  // are ordered...
-
-  List_T *list = from->Vertices;
-  Vertex **vexist, *v, *newv;
-
-  int nb = List_Nbr(to->Vertices);
-  if(nb) {
-    if(nb != List_Nbr(from->Vertices))
-      Msg(GERROR, "Incompatible extrusion of curve %d into curve %d",
-          from->Num, to->Num);
-    return;
-  }
-
-  v = to->beg;
-  if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) {
-    (*vexist)->u = to->ubeg;
-    if((*vexist)->ListCurves)
-      List_Add((*vexist)->ListCurves, &to);
-    List_Add(to->Vertices, vexist);
-  }
-  else {
-    newv = Create_Vertex(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, to->ubeg);
-    Tree_Add(THEM->Vertices, &newv);
-    newv->ListCurves = List_Create(1, 1, sizeof(Curve *));
-    List_Add(newv->ListCurves, &to);
-    List_Add(to->Vertices, &newv);
-  }
-
-  for(int i = 1; i < List_Nbr(list) - 1; i++) {
-    if(direction < 0)
-      List_Read(list, List_Nbr(list) - 1 - i, &v);
-    else
-      List_Read(list, i, &v);
-    newv = Create_Vertex(++THEM->MaxPointNum, v->Pos.X,
-			 v->Pos.Y, v->Pos.Z, v->lc,
-			 (direction > 0) ? v->u : (1. - v->u));
-    ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1],
-		newv->Pos.X, newv->Pos.Y, newv->Pos.Z);
-    if(!comparePosition(&newv, &v)) {
-      Free_Vertex(&newv, 0);
-      newv = v;
-    }
-    else if(Vertex_Bound && (vexist = (Vertex **) Tree_PQuery(Vertex_Bound, &newv))) {
-      Free_Vertex(&newv, 0);
-      newv = *vexist;
-    }
-    else {
-      if(Point_Bound && (vexist = (Vertex **) Tree_PQuery(Point_Bound, &newv))) {
-	// keep the new one: we cannot have points and vertices
-	// pointing to the same memory location
-	newv->Num = (*vexist)->Num;
-      }
-      Tree_Add(THEM->Vertices, &newv);
-      Tree_Insert(Vertex_Bound, &newv);
-    }
-    if(!newv->ListCurves)
-      newv->ListCurves = List_Create(1, 1, sizeof(Curve *));
-    List_Add(newv->ListCurves, &to);
-    List_Add(to->Vertices, &newv);
-  }
-
-  v = to->end;
-  if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) {
-    (*vexist)->u = to->uend;
-    if((*vexist)->ListCurves)
-      List_Add((*vexist)->ListCurves, &to);
-    List_Add(to->Vertices, vexist);
-  }
-  else {
-    newv = Create_Vertex(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, to->uend);
-    Tree_Add(THEM->Vertices, &newv);
-    newv->ListCurves = List_Create(1, 1, sizeof(Curve *));
-    List_Add(newv->ListCurves, &to);
-    List_Add(to->Vertices, &newv);
-  }
-
-  for(int i = 0; i < List_Nbr(to->Vertices) - 1; i++) {
-    Vertex *v1, *v2;
-    List_Read(to->Vertices, i, &v1);
-    List_Read(to->Vertices, i + 1, &v2);
-    Simplex *s = Create_Simplex(v1, v2, NULL, NULL);
-    s->iEnt = to->Num;
-    Tree_Add(to->Simplexes, &s);
-  }
-
-}
-
-int Extrude_Mesh(Curve * c)
-{
-  Vertex **vexist, *v, *newv, *v1, *v2;
-  List_T *L;
-
-  if(!c->Extrude || !c->Extrude->mesh.ExtrudeMesh)
-    return false;
-
-  InitExtrude();
-  THEC = c;
-  DIM = 1;
-  NUM = c->Num;
-  ep = c->Extrude;
-
-  if(ep->geo.Mode == EXTRUDED_ENTITY) {
-    Extrude_Vertex(&c->beg, NULL);
-    L = getnxl(c->beg, DIM);
-    if(!L) return false;
-
-    v = c->beg;
-    if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) {
-      (*vexist)->u = c->ubeg;
-      if((*vexist)->ListCurves)
-        List_Add((*vexist)->ListCurves, &c);
-      List_Add(c->Vertices, vexist);
-    }
-    else {
-      newv = Create_Vertex(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, c->ubeg);
-      newv->ListCurves = List_Create(1, 1, sizeof(Curve *));
-      List_Add(newv->ListCurves, &c);
-      Tree_Add(THEM->Vertices, &newv);
-      List_Add(c->Vertices, &newv);
-    }
-
-    for(int i = 1; i < List_Nbr(L) - 1; i++) {
-      List_Read(L, i, &v);
-      if(!v->ListCurves)
-        v->ListCurves = List_Create(1, 1, sizeof(Curve *));
-      List_Add(v->ListCurves, &c);
-      Tree_Insert(THEM->Vertices, &v);
-      // This is not correct when we have multiple layers with
-      // different spacings. So we fill this in later.
-      //v->u = (double)i / (double)(List_Nbr(L)-1);
-      List_Add(c->Vertices, &v);
-    }
-
-    v = c->end;
-    if((vexist = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) {
-      (*vexist)->u = c->uend;
-      if((*vexist)->ListCurves)
-        List_Add((*vexist)->ListCurves, &c);
-      List_Add(c->Vertices, vexist);
-    }
-    else {
-      newv = Create_Vertex(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, c->uend);
-      newv->ListCurves = List_Create(1, 1, sizeof(Curve *));
-      List_Add(newv->ListCurves, &c);
-      Tree_Add(THEM->Vertices, &newv);
-      List_Add(c->Vertices, &newv);
-    }
-
-    int k = 0;
-    for(int i = 0; i < ep->mesh.NbLayer; i++) {
-      for(int j = 0; j < ep->mesh.NbElmLayer[i]; j++) {
-	if(k >= List_Nbr(c->Vertices) - 1){
-	  Msg(GERROR, "Something wrong in number of elements in extruded curve %d",
-	      c->Num);
-	  return false;
-	}
-	List_Read(c->Vertices, k, &v1);
-	List_Read(c->Vertices, k + 1, &v2);
-	Simplex *s = Create_Simplex(v1, v2, NULL, NULL);
-	s->iEnt = (ep->mesh.ZonLayer[i] && ep->useZonLayer()) ?
-	  ep->mesh.ZonLayer[i] : c->Num;
-	Tree_Add(c->Simplexes, &s);
-	// fill-in the data we didn't have above:
-	v1->u = ep->u(i, j);
-	k++;
-      }
-    }
-
-  }
-  else {
-    Curve *cc = FindCurve(abs(ep->geo.Source));
-    if(!cc)
-      return false;
-    copy_mesh(cc, c, sign(ep->geo.Source));
-  }
-
-  return true;
-}
-
-void copy_mesh(Surface * from, Surface * to)
-{
-  List_T *list;
-  Simplex *s;
-  Quadrangle *q;
-  Vertex **vexist, *newv[4];
-
-  int nbs = Tree_Nbr(to->Simplexes);
-  if(nbs){
-    if(nbs != Tree_Nbr(from->Simplexes))
-      Msg(GERROR, "Incompatible extrusion of surface %d into surface %d",
-	  from->Num, to->Num);
-    return;
-  }
-
-  int nbq = Tree_Nbr(to->Quadrangles);
-  if(nbq){
-    if(nbq != Tree_Nbr(from->Quadrangles))
-      Msg(GERROR, "Incompatible extrusion of surface %d into surface %d",
-	  from->Num, to->Num);
-    return;
-  }
-  
-  // triangles
-  list = Tree2List(from->Simplexes);
-  for(int i = 0; i < List_Nbr(list); i++) {
-    List_Read(list, i, &s);
-    for(int j = 0; j < 3; j++) {
-      newv[j] = Create_Vertex(++THEM->MaxPointNum, s->V[j]->Pos.X, s->V[j]->Pos.Y, 
-			      s->V[j]->Pos.Z, s->V[j]->lc, s->V[j]->u);
-      ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], 
-		  newv[j]->Pos.X, newv[j]->Pos.Y, newv[j]->Pos.Z);
-      if(Vertex_Bound && (vexist = (Vertex **) Tree_PQuery(Vertex_Bound, &newv[j]))) {
-	Free_Vertex(&newv[j], 0);
-	newv[j] = *vexist;
-      }
-      else {
-	if(Point_Bound && (vexist = (Vertex **) Tree_PQuery(Point_Bound, &newv[j]))) {
-	  // keep the new one: we cannot have points and vertices
-	  // pointing to the same memory location
-	  newv[j]->Num = (*vexist)->Num;
-	}
-	Tree_Add(THEM->Vertices, &newv[j]);
-	Tree_Insert(Vertex_Bound, &newv[j]);
-      }
-    }
-    Simplex *news = Create_Simplex(newv[0], newv[1], newv[2], NULL);
-    news->iEnt = to->Num;
-    Tree_Add(to->Simplexes, &news);
-  }
-  List_Delete(list);
-  
-  // quadrangles
-  list = Tree2List(from->Quadrangles);
-  for(int i = 0; i < List_Nbr(list); i++) {
-    List_Read(list, i, &q);
-    for(int j = 0; j < 4; j++) {
-      newv[j] = Create_Vertex(++THEM->MaxPointNum, q->V[j]->Pos.X, q->V[j]->Pos.Y, 
-			      q->V[j]->Pos.Z, q->V[j]->lc, q->V[j]->u);
-      ep->Extrude(ep->mesh.NbLayer - 1, ep->mesh.NbElmLayer[ep->mesh.NbLayer - 1], 
-		  newv[j]->Pos.X, newv[j]->Pos.Y, newv[j]->Pos.Z);
-      if(Vertex_Bound && (vexist = (Vertex **) Tree_PQuery(Vertex_Bound, &newv[j]))) {
-	Free_Vertex(&newv[j], 0);
-	newv[j] = *vexist;
-      }
-      else {
-	if(Point_Bound && (vexist = (Vertex **) Tree_PQuery(Point_Bound, &newv[j]))) {
-	  // keep the new one: we cannot have points and vertices
-	  // pointing to the same memory location
-	  newv[j]->Num = (*vexist)->Num;
-	}
-	Tree_Add(THEM->Vertices, &newv[j]);
-	Tree_Insert(Vertex_Bound, &newv[j]);
-      }
-    }
-    Quadrangle *newq = Create_Quadrangle(newv[0], newv[1], newv[2], newv[3]);
-    newq->iEnt = to->Num;
-    Tree_Add(to->Quadrangles, &newq);
-  }
-  List_Delete(list);
-}
-
-void AddSimVertsInSurf(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  for(int i = 0; i < 3; i++)
-    if(s->V[i])
-      Tree_Insert(THES->Vertices, &s->V[i]);
-}
-
-void AddQuadVertsInSurf(void *a, void *b)
-{
-  Quadrangle *q = *(Quadrangle **) a;
-  for(int i = 0; i < 4; i++)
-    Tree_Insert(THES->Vertices, &q->V[i]);
-}
-
-int Extrude_Mesh(Surface * s)
-{
-  Vertex *v1;
-  Curve *c;
-  extern int FACE_DIMENSION;
-
-  if(!s->Extrude || !s->Extrude->mesh.ExtrudeMesh)
-    return false;
-
-  InitExtrude();
-  THES = s;
-  DIM = 2;
-  NUM = s->Num;
-  ep = s->Extrude;
-  FACE_DIMENSION = 2;
-
-  if(ep->geo.Mode == EXTRUDED_ENTITY) {
-    c = FindCurve(abs(ep->geo.Source));
-    if(!c)
-      return false;
-    for(int i = 0; i < List_Nbr(c->Vertices); i++) {
-      List_Read(c->Vertices, i, &v1);
-      Extrude_Vertex(&v1, NULL);
-    }
-    Extrude_Curve(&c, NULL);
-  }
-  else {
-    Surface *ss = FindSurface(ep->geo.Source);
-    if(!ss)
-      return false;
-    copy_mesh(ss, s);
-  }
-
-  Tree_Action(s->Simplexes, AddSimVertsInSurf);
-  Tree_Action(s->Quadrangles, AddQuadVertsInSurf);
-
-  ReOrientSurfaceMesh(s);
-
-  return true;
-}
-
-static Tree_T *tmp;
-
-void Free_NegativeSimplex(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  if(s) {
-    if(s->Num >= 0) {
-      Tree_Add(tmp, &s);
-    }
-    else {
-      delete s;
-      s = NULL;
-    }
-  }
-}
-
-int Extrude_Mesh(Volume * v)
-{
-  ep = v->Extrude;
-  if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY)
-    return true;
-  else
-    return false;
-}
-
-int Extrude_Mesh(Tree_T * Volumes)
-{
-  int extrude = 0;
-  Surface *s;
-  List_T *list;
-
-  InitExtrude();
-  DIM = 3;
-
-  List_T *vol = Tree2List(Volumes);
-
-  for(int ivol = 0; ivol < List_Nbr(vol); ivol++) {
-    List_Read(vol, ivol, &THEV);
-    ep = THEV->Extrude;
-    if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY)
-      extrude = 1;
-  }
-  if(!extrude)
-    return false;
-
-  Msg(STATUS1, "Mesh 3D... (initial)");
-
-  for(int ivol = 0; ivol < List_Nbr(vol); ivol++) {
-    List_Read(vol, ivol, &THEV);
-    ep = THEV->Extrude;
-    NUM = THEV->Num;
-    if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY) {
-      s = FindSurface(ep->geo.Source);
-      if(s) {
-        Msg(STATUS2, "Meshing volume %d", NUM);
-        Extrude_Surface1(s);
-      }
-    }
-  }
-
-  int j = 0;
-  do {
-    BAD_TETS = 0;
-    for(int ivol = 0; ivol < List_Nbr(vol); ivol++) {
-      List_Read(vol, ivol, &THEV);
-      ep = THEV->Extrude;
-      NUM = THEV->Num;
-      if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY &&
-         !ep->mesh.Recombine) {
-        s = FindSurface(ep->geo.Source);
-        if(s)
-          Extrude_Surface2(s);
-      }
-    }
-    Msg(STATUS2, "Swapping %d", BAD_TETS);
-    if(BAD_TETS == j && j != 0) {
-      Msg(GERROR, "Unable to swap all edges (output mesh will be incorrect): use 'Recombine'");
-      break;
-    }
-    j = BAD_TETS;
-  } while(BAD_TETS);
-
-  Msg(STATUS1, "Mesh 3D... (final)");
-
-  for(int ivol = 0; ivol < List_Nbr(vol); ivol++) {
-    List_Read(vol, ivol, &THEV);
-    ep = THEV->Extrude;
-    NUM = THEV->Num;
-    if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY) {
-      s = FindSurface(ep->geo.Source);
-      if(s) {
-        Msg(STATUS2, "Meshing volume %d", NUM);
-        Extrude_Surface3(s);
-      }
-    }
-  }
-
-  list = List_Create(100, 100, sizeof(Surface *));
-  for(int ivol = 0; ivol < List_Nbr(vol); ivol++) {
-    List_Read(vol, ivol, &THEV);
-    ep = THEV->Extrude;
-    if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY &&
-       !ep->mesh.Recombine) {
-      for(int i = 0; i < List_Nbr(THEV->Surfaces); i++) {
-        List_Read(THEV->Surfaces, i, &s);
-        if(!List_Search(list, &s, compareSurface))
-          List_Add(list, &s);
-      }
-    }
-  }
-  for(int i = 0; i < List_Nbr(list); i++) {
-    List_Read(list, i, &s);
-    tmp = Tree_Create(sizeof(Simplex *), compareQuality);
-    Tree_Action(s->Simplexes, Free_NegativeSimplex);
-    Tree_Delete(s->Simplexes);
-    s->Simplexes = tmp;
-    Msg(STATUS2, "Coherence surface %d", s->Num);
-    Extrude_Mesh(s);
-  }
-
-  List_Delete(list);
-  List_Delete(vol);
-
-  return true;
-}
diff --git a/Mesh/3D_Extrude_Old.cpp b/Mesh/3D_Extrude_Old.cpp
deleted file mode 100644
index 3d15592f909cc18f3726141b60e21d732aef9661..0000000000000000000000000000000000000000
--- a/Mesh/3D_Extrude_Old.cpp
+++ /dev/null
@@ -1,698 +0,0 @@
-// $Id: 3D_Extrude_Old.cpp,v 1.42 2006-07-12 07:24:14 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-// This is the old extrusion mesh generator, only available through
-// the command line option -extrude (w/ or w/o -recombine). This mesh
-// generator pre-supposes a definition of surfaces in the XY plane,
-// and will extrude everything along the Z axis, taking parameters
-// interactively from standard input, e.g.,
-//
-// gmsh test -extrude -recombine < params.ext
-//
-// The progression ratio defines a geometric progression for the
-// definition of the elements heights: a factor of 2 means that the
-// next element will be twice as high as the previous one.
-//
-// All geometrical entities are automatically numbered:
-//
-//         volumes: 3 * K1 + layer * K2 + surf->num
-// New XY surfaces: 2 * K1 + layer * K2 + surf->num
-//  perp. surfaces: 1 * K1 + layer * K2 + curve->num
-//     perp. lines: 4 * K1 + layer * K2 + point->Num
-//    New XY lines: 5 * K1 + layer * K2 + curve->Num
-//
-
-#define MAXLAYERS 100
-#define K1 100.e6
-#define K2 1.e6 // to store MAXLAYERS
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "Context.h"
-#include "Create.h"
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-static Tree_T *Tree_Ares = NULL, *Tree_Swaps = NULL;
-static Volume *THEV;
-static int BAD_TETS, TRY_INVERSE, NbLayer;
-static int NbElmLayer[MAXLAYERS];
-static int ZonLayer[MAXLAYERS];
-static int LineLayer[MAXLAYERS + 1];
-static int SurfLayer[MAXLAYERS + 1];
-static double hLayer[MAXLAYERS];
-static double parLayer[MAXLAYERS];
-
-typedef struct{
-  int a, b;
-} nxn;
-
-static int compnxn(const void *a, const void *b)
-{
-  nxn *q = (nxn *) a;
-  nxn *w = (nxn *) b;
-  if(q->a > w->a)
-    return 1;
-  if(q->a < w->a)
-    return -1;
-  if(q->b > w->b)
-    return 1;
-  if(q->b < w->b)
-    return -1;
-  return 0;
-}
-
-static void InitExtrudeParams(void)
-{
-  char *ret;
-  char str[256];
-
-  printf("Number of layers (default=1): ");
-  ret = fgets(str, sizeof(str), stdin);
-  if(!ret || !strlen(str) || !strcmp(str, "\n"))
-    NbLayer = 1;
-  else
-    NbLayer = atoi(str);
-  
-  if(NbLayer > MAXLAYERS){
-    Msg(GERROR, "Max number of layer (%d) exceeded", MAXLAYERS);
-    NbLayer = MAXLAYERS;
-  }
-
-  FILE *file = fopen(".gmsh-extrude", "w");
-
-  if(file)
-    fprintf(file, "%d\n", NbLayer);
-  for(int i = 0; i < NbLayer; i++) {
-    printf("Number of elements in layer %d (default=1): ", i + 1);
-    ret = fgets(str, sizeof(str), stdin);
-    if(!ret || !strlen(str) || !strcmp(str, "\n"))
-      NbElmLayer[i] = 1;
-    else
-      NbElmLayer[i] = atoi(str);
-    if(file)
-      fprintf(file, "%d\n", NbElmLayer[i]);
-
-    printf("Depth of layer %d (default=1.0): ", i + 1);
-    ret = fgets(str, sizeof(str), stdin);
-    if(!ret || !strlen(str) || !strcmp(str, "\n"))
-      hLayer[i] = 1.0;
-    else
-      hLayer[i] = atof(str);
-    if(file)
-      fprintf(file, "%g\n", hLayer[i]);
-
-    printf("Progression ratio for layer %d (default=1.0): ", i + 1);
-    ret = fgets(str, sizeof(str), stdin);
-    if(!ret || !strlen(str) || !strcmp(str, "\n"))
-      parLayer[i] = 1.0;
-    else
-      parLayer[i] = atof(str);
-    if(file)
-      fprintf(file, "%g\n", parLayer[i]);
-  }
-
-  if(file) {
-    fflush(file);
-    fclose(file);
-  }
-}
-
-static int are_exist(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  return Tree_Search(t, &n);
-}
-
-static void are_cree(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  Tree_Replace(t, &n);
-}
-
-static void are_del(Vertex * v1, Vertex * v2, Tree_T * t)
-{
-  nxn n;
-  n.a = IMAX(v1->Num, v2->Num);
-  n.b = IMIN(v1->Num, v2->Num);
-  Tree_Suppress(t, &n);
-}
-
-static void Extrude_Simplex_Phase1(void *data, void *dum)
-{
-  Vertex *v1, *v2, *v3, *v4, *v5, *v6;
-
-  Simplex *s = *(Simplex **) data;
-
-  int k = 0;
-  for(int i = 0; i < NbLayer; i++) {
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      List_Read(s->V[0]->Extruded_Points, k, &v1);
-      List_Read(s->V[1]->Extruded_Points, k, &v2);
-      List_Read(s->V[2]->Extruded_Points, k, &v3);
-      List_Read(s->V[0]->Extruded_Points, k + 1, &v4);
-      List_Read(s->V[1]->Extruded_Points, k + 1, &v5);
-      List_Read(s->V[2]->Extruded_Points, k + 1, &v6);
-      k++;
-      if(!are_exist(v1, v5, Tree_Ares))
-        are_cree(v2, v4, Tree_Ares);
-      if(!are_exist(v5, v3, Tree_Ares))
-        are_cree(v2, v6, Tree_Ares);
-      if(!are_exist(v4, v3, Tree_Ares))
-        are_cree(v1, v6, Tree_Ares);
-    }
-  }
-}
-
-static void Extrude_Simplex_Phase3(void *data, void *dum)
-{
-  Simplex *news;
-  Prism *newp;
-  Vertex *v1, *v2, *v3, *v4, *v5, *v6;
-
-  Simplex *s = *(Simplex **) data;
-
-  int k = 0;
-  for(int i = 0; i <= NbLayer; i++) {
-    if(SurfLayer[i]) {
-      List_Read(s->V[0]->Extruded_Points, k, &v1);
-      List_Read(s->V[1]->Extruded_Points, k, &v2);
-      List_Read(s->V[2]->Extruded_Points, k, &v3);
-      Simplex *news = Create_Simplex(v1, v2, v3, NULL);
-      news->iEnt = SurfLayer[i];
-      Tree_Add(THEV->Simp_Surf, &news);
-    }
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      k++;
-    }
-  }
-
-  k = 0;
-  for(int i = 0; i < NbLayer; i++) {
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      List_Read(s->V[0]->Extruded_Points, k, &v1);
-      List_Read(s->V[1]->Extruded_Points, k, &v2);
-      List_Read(s->V[2]->Extruded_Points, k, &v3);
-      List_Read(s->V[0]->Extruded_Points, k + 1, &v4);
-      List_Read(s->V[1]->Extruded_Points, k + 1, &v5);
-      List_Read(s->V[2]->Extruded_Points, k + 1, &v6);
-
-      k++;
-      if(ZonLayer[i]) {
-        if(CTX.mesh.oldxtrude_recombine) {
-	  newp = Create_Prism(v1, v2, v3, v4, v5, v6);
-	  newp->iEnt = ZonLayer[i];
-	  Tree_Add(THEV->Prisms, &newp);
-        }
-        else {
-          if(are_exist(v4, v2, Tree_Ares) &&
-             are_exist(v5, v3, Tree_Ares) && 
-	     are_exist(v4, v3, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v4);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v3);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v2, v4, v5, v3);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-          if(are_exist(v4, v2, Tree_Ares) &&
-             are_exist(v2, v6, Tree_Ares) && 
-	     are_exist(v4, v3, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v4);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v2);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v2, v6, v3);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-          if(are_exist(v4, v2, Tree_Ares) &&
-             are_exist(v2, v6, Tree_Ares) && 
-	     are_exist(v6, v1, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v6);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v2);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v2, v4, v6, v1);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-          if(are_exist(v5, v1, Tree_Ares) &&
-             are_exist(v5, v3, Tree_Ares) && 
-	     are_exist(v4, v3, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v5);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v3);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v1, v4, v5, v3);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-          if(are_exist(v5, v1, Tree_Ares) &&
-             are_exist(v5, v3, Tree_Ares) && 
-	     are_exist(v6, v1, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v5);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v1);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v1, v3, v5, v6);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-          if(are_exist(v5, v1, Tree_Ares) &&
-             are_exist(v2, v6, Tree_Ares) && 
-	     are_exist(v6, v1, Tree_Ares)) {
-            news = Create_Simplex(v1, v2, v3, v6);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v4, v5, v6, v1);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-            news = Create_Simplex(v1, v2, v5, v6);
-            news->iEnt = ZonLayer[i];
-            Tree_Add(THEV->Simplexes, &news);
-          }
-        }
-      }
-    }
-  }
-}
-
-static void Extrude_Quadrangle_Phase3(void *data, void *dum)
-{
-
-  Quadrangle *q = *(Quadrangle **) data;
-
-  if(!CTX.mesh.oldxtrude_recombine){
-    Msg(GERROR, "Non recombined extrusion impossible with quadrangles (use -recombine)");
-    return;
-  }
-
-  Vertex *v1, *v2, *v3, *v4, *v5, *v6, *v7, *v8;
-
-  int k = 0;
-  for(int i = 0; i <= NbLayer; i++) {
-    if(SurfLayer[i]) {
-      List_Read(q->V[0]->Extruded_Points, k, &v1);
-      List_Read(q->V[1]->Extruded_Points, k, &v2);
-      List_Read(q->V[2]->Extruded_Points, k, &v3);
-      List_Read(q->V[3]->Extruded_Points, k, &v4);
-      Quadrangle *newq = Create_Quadrangle(v1, v2, v3, v4);
-      newq->iEnt = SurfLayer[i];
-      Tree_Add(THEV->Quad_Surf, &newq);
-    }
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      k++;
-    }
-  }
-
-  k = 0;
-  for(int i = 0; i < NbLayer; i++) {
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      List_Read(q->V[0]->Extruded_Points, k, &v1);
-      List_Read(q->V[1]->Extruded_Points, k, &v2);
-      List_Read(q->V[2]->Extruded_Points, k, &v3);
-      List_Read(q->V[3]->Extruded_Points, k, &v4);
-      List_Read(q->V[0]->Extruded_Points, k + 1, &v5);
-      List_Read(q->V[1]->Extruded_Points, k + 1, &v6);
-      List_Read(q->V[2]->Extruded_Points, k + 1, &v7);
-      List_Read(q->V[3]->Extruded_Points, k + 1, &v8);
-
-      k++;
-      if(ZonLayer[i]) {
-	Hexahedron *newh = Create_Hexahedron(v1, v2, v3, v4, v5, v6, v7, v8);
-	newh->iEnt = ZonLayer[i];
-	Tree_Add(THEV->Hexahedra, &newh);
-      }
-    }
-  }
-}
-
-static void Extrude_Simplex_Phase2(void *data, void *dum)
-{
-  Simplex *s = *(Simplex **) data;
-
-  int k = 0;
-  for(int i = 0; i < NbLayer; i++) {
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      Vertex *v1, *v2, *v3, *v4, *v5, *v6;
-      List_Read(s->V[0]->Extruded_Points, k, &v1);
-      List_Read(s->V[1]->Extruded_Points, k, &v2);
-      List_Read(s->V[2]->Extruded_Points, k, &v3);
-      List_Read(s->V[0]->Extruded_Points, k + 1, &v4);
-      List_Read(s->V[1]->Extruded_Points, k + 1, &v5);
-      List_Read(s->V[2]->Extruded_Points, k + 1, &v6);
-      k++;
-      if(are_exist(v4, v2, Tree_Ares) &&
-         are_exist(v5, v3, Tree_Ares) && 
-	 are_exist(v1, v6, Tree_Ares)) {
-        BAD_TETS++;
-        if(!are_exist(v4, v2, Tree_Swaps)) {
-          are_del(v4, v2, Tree_Ares);
-          are_cree(v1, v5, Tree_Ares);
-          are_cree(v1, v5, Tree_Swaps);
-          are_cree(v4, v2, Tree_Swaps);
-        }
-        else if(!are_exist(v5, v3, Tree_Swaps)) {
-          are_del(v5, v3, Tree_Ares);
-          are_cree(v2, v6, Tree_Ares);
-          are_cree(v5, v3, Tree_Swaps);
-          are_cree(v2, v6, Tree_Swaps);
-        }
-        else if(!are_exist(v1, v6, Tree_Swaps)) {
-          are_del(v1, v6, Tree_Ares);
-          are_cree(v4, v3, Tree_Ares);
-          are_cree(v1, v6, Tree_Swaps);
-          are_cree(v4, v3, Tree_Swaps);
-        }
-      }
-      else if(are_exist(v1, v5, Tree_Ares) &&
-              are_exist(v2, v6, Tree_Ares) && 
-	      are_exist(v4, v3, Tree_Ares)) {
-        BAD_TETS++;
-        if(!are_exist(v1, v5, Tree_Swaps)) {
-          are_del(v1, v5, Tree_Ares);
-          are_cree(v4, v2, Tree_Ares);
-          are_cree(v1, v5, Tree_Swaps);
-          are_cree(v4, v2, Tree_Swaps);
-        }
-        else if(!are_exist(v2, v6, Tree_Swaps)) {
-          are_del(v2, v6, Tree_Ares);
-          are_cree(v5, v3, Tree_Ares);
-          are_cree(v5, v3, Tree_Swaps);
-          are_cree(v2, v6, Tree_Swaps);
-        }
-        else if(!are_exist(v4, v3, Tree_Swaps)) {
-          are_del(v4, v3, Tree_Ares);
-          are_cree(v1, v6, Tree_Ares);
-          are_cree(v1, v6, Tree_Swaps);
-          are_cree(v4, v3, Tree_Swaps);
-        }
-      }
-    }
-  }
-}
-
-static void Extrude_Vertex(void *data, void *dum)
-{
-  Vertex *v = *(Vertex **) data;
-
-  if(v->Extruded_Points)
-    return;
-
-  v->Extruded_Points = List_Create(NbLayer, 1, sizeof(Vertex *));
-  List_Add(v->Extruded_Points, &v);
-
-  //printf("-extruding vertex %d %p\n", v->Num, v);
-
-  double h = 0.0;
-
-  for(int i = 0; i < NbLayer; i++) {
-
-    // Geometric progression ar^i
-    // Sum of n (=NbElmLayer[i]) terms = hLayer[i] = a (r^n-1)/(r-1)
-    
-    double a;
-    if(parLayer[i] == 1.)
-      a = hLayer[i] / (double)NbElmLayer[i];
-    else
-      a = hLayer[i] * (parLayer[i] - 1.) / 
-	(pow(parLayer[i], NbElmLayer[i]) - 1.);
-    
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-     
-      //h += hLayer[i]/(double)NbElmLayer[i];
-
-      h += a * pow(parLayer[i], j);
-
-      Vertex *newv = Create_Vertex(++THEM->MaxPointNum, v->Pos.X, v->Pos.Y, 
-				   v->Pos.Z + h, v->lc, v->u);
-      Tree_Add(THEM->Vertices, &newv);
-      List_Add(v->Extruded_Points, &newv);
-    }
-  }
-}
-
-static void Extrude_Surface1(void *data, void *dum)
-{
-  if(!NbLayer)
-    return;
-  Surface *s = *(Surface **) data;
-
-  Tree_Action(s->Vertices, Extrude_Vertex);
-
-  if(!CTX.mesh.oldxtrude_recombine)
-    Tree_Action(s->Simplexes, Extrude_Simplex_Phase1);
-}
-
-static void Extrude_Surface2(void *data, void *dum)
-{
-  if(!NbLayer)
-    return;
-  Surface *s = *(Surface **) data;
-
-  // we could try a whole bunch of orderings...
-  if(TRY_INVERSE)
-    Tree_Action_Inverse(s->Simplexes, Extrude_Simplex_Phase2);
-  else
-    Tree_Action(s->Simplexes, Extrude_Simplex_Phase2);
-}
-
-static void Extrude_Surface3(void *data, void *dum)
-{
-  if(!NbLayer)
-    return;
-
-  Surface *s = *(Surface **) data;
-
-  Msg(INFO, "Extruding Surface %d", s->Num);
-  for(int i = 0; i < NbLayer; i++) {
-    ZonLayer[i] = (int)(3 * K1) + (int)((i + 1) * K2) + s->Num;
-  }
-  SurfLayer[0] = s->Num;
-  for(int i = 0; i < NbLayer; i++) {
-    SurfLayer[i + 1] = (int)(2 * K1) + (int)((i + 1) * K2) + s->Num;
-  }
-
-  Tree_Action(s->Simplexes, Extrude_Simplex_Phase3);
-  Tree_Action(s->Quadrangles, Extrude_Quadrangle_Phase3);
-}
-
-static void Extrude_Seg(void *data, void *dum)
-{
-  Simplex *ll = *(Simplex**)data;
-  Vertex *V1 = ll->V[0];
-  Vertex *V2 = ll->V[1];
-
-  //printf("-curve vertex %d %p   %d %p\n", V1->Num, V1, V2->Num, V2);
-
-  int k = 0;
-  for(int i = 0; i <= NbLayer; i++) {
-    if(LineLayer[i]) {
-      Vertex *v1, *v2;
-      List_Read(V1->Extruded_Points, k, &v1);
-      List_Read(V2->Extruded_Points, k, &v2);
-      Simplex *s = Create_Simplex(v1, v2, NULL, NULL);
-      s->iEnt = LineLayer[i];
-      Tree_Add(THEV->Lin_Surf, &s);
-    }
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      k++;
-    }
-  }
-
-  k = 0;
-  for(int i = 0; i < NbLayer; i++) {
-    for(int j = 0; j < NbElmLayer[i]; j++) {
-      Vertex *v1, *v2, *v3, *v4;
-      List_Read(V1->Extruded_Points, k, &v1);
-      List_Read(V2->Extruded_Points, k, &v2);
-      List_Read(V1->Extruded_Points, k + 1, &v3);
-      List_Read(V2->Extruded_Points, k + 1, &v4);
-      if(SurfLayer[i]) {
-        if(CTX.mesh.oldxtrude_recombine) {
-          Quadrangle *q = Create_Quadrangle(v1, v2, v4, v3);
-          q->iEnt = SurfLayer[i];
-          Tree_Add(THEV->Quad_Surf, &q);
-        }
-        else {
-          if(are_exist(v3, v2, Tree_Ares)) {
-            Simplex *s = Create_Simplex(v3, v2, v1, NULL);
-            s->iEnt = SurfLayer[i];
-            Tree_Add(THEV->Simp_Surf, &s);
-            s = Create_Simplex(v3, v4, v2, NULL);
-            s->iEnt = SurfLayer[i];
-            Tree_Add(THEV->Simp_Surf, &s);
-          }
-          else {
-            Simplex *s = Create_Simplex(v3, v4, v1, NULL);
-            s->iEnt = SurfLayer[i];
-            Tree_Add(THEV->Simp_Surf, &s);
-            s = Create_Simplex(v1, v4, v2, NULL);
-            s->iEnt = SurfLayer[i];
-            Tree_Add(THEV->Simp_Surf, &s);
-          }
-        }
-      }
-      k++;
-    }
-  }
-
-}
-
-static void Extrude_Curve(void *data, void *dum)
-{
-  if(!NbLayer)
-    return;
-
-  Curve *c = *(Curve **) data;
-
-  if(c->Num < 0)
-    return;
-
-  Msg(INFO, "Extruding Curve %d", c->Num);
-
-  LineLayer[0] = c->Num;
-  for(int i = 0; i < NbLayer; i++) {
-    SurfLayer[i] = (int)(1 * K1) + (int)((i + 1) * K2) + c->Num;
-    LineLayer[i + 1] = (int)(5 * K1) + (int)((i + 1) * K2) + c->Num;
-  }
-
-  List_Action(c->Vertices, Extrude_Vertex);
-  Tree_Action(c->Simplexes, Extrude_Seg);
-}
-
-static void Extrude_Point(void *data, void *dum)
-{
-  if(!NbLayer)
-    return;
-
-  Vertex *v = *(Vertex **) data;
-
-  Msg(INFO, "Extruding Vertex %d", v->Num);
-
-  for(int i = 0; i < NbLayer; i++) {
-    LineLayer[i] = (int)(4 * K1) + (int)((i + 1) * K2) + v->Num;
-  }
-
-  // only extrude points for which a mesh vertex exists with the same
-  // number (i.e., start & end points of curves)
-  Vertex **pV;
-  if((pV = (Vertex **) Tree_PQuery(THEM->Vertices, &v))) {
-    Extrude_Vertex(pV, NULL);
-    int k = 0;
-    for(int i = 0; i < NbLayer; i++) {
-      for(int j = 0; j < NbElmLayer[i]; j++) {
-	Vertex *v1, *v2;
-	List_Read((*pV)->Extruded_Points, k, &v1);
-	List_Read((*pV)->Extruded_Points, k + 1, &v2);
-	if(LineLayer[i]) {
-	  Simplex *s = Create_Simplex(v1, v2, NULL, NULL);
-	  s->iEnt = LineLayer[i];
-	  Tree_Add(THEV->Lin_Surf, &s);
-	}
-	k++;
-      }
-    }
-  }
-  
-}
-
-void FreeEP(void *a, void *b)
-{
-  Vertex *v = *(Vertex **) a;
-  if(v->Extruded_Points){
-    Free_ExtrudedPoints(v->Extruded_Points);
-    v->Extruded_Points = NULL;
-  }
-}
-
-void Extrude_Mesh_Old()
-{
-  InitExtrudeParams();
-
-  // clean up Extruded_Points stuff (in case another extrusion was
-  // performed before)
-  Tree_Action(THEM->Vertices, FreeEP);
-
-  THEV = Create_Volume(1, MSH_VOLUME);
-  Tree_Add(THEM->Volumes, &THEV);
-
-  TRY_INVERSE = 0;
-
- try_again:
-
-  if(Tree_Ares)
-    Tree_Delete(Tree_Ares);
-  if(Tree_Swaps)
-    Tree_Delete(Tree_Swaps);
-  Tree_Ares = Tree_Create(sizeof(nxn), compnxn);
-  Tree_Swaps = Tree_Create(sizeof(nxn), compnxn);
-
-  Tree_Action(THEM->Surfaces, Extrude_Surface1);
-
-  if(!CTX.mesh.oldxtrude_recombine) {
-    int j = 0;
-    do {
-      BAD_TETS = 0;
-      Tree_Action(THEM->Surfaces, Extrude_Surface2);
-      Msg(INFO, "%d swaps", BAD_TETS);
-      if(BAD_TETS == j && j != 0) {
-	if(!TRY_INVERSE){
-	  Msg(WARNING, "Unable to swap all edges: trying again...");
-	  TRY_INVERSE = 1;
-	  goto try_again;
-	}
-	else{
-	  Msg(GERROR, "Unable to swap all edges (output mesh will be incorrect): use -recombine");
-	  break;
-	}
-      }
-      j = BAD_TETS;
-    } while(BAD_TETS);
-  }
-  
-  Tree_Action(THEM->Surfaces, Extrude_Surface3);
-  Tree_Action(THEM->Curves, Extrude_Curve);
-  Tree_Action(THEM->Points, Extrude_Point);
-
-  Tree_Delete(Tree_Ares);
-  Tree_Delete(Tree_Swaps);
-}
diff --git a/Mesh/3D_Mesh.cpp b/Mesh/3D_Mesh.cpp
deleted file mode 100644
index 47fb13de2a5ed7f538258aa861aa8db5887e78f0..0000000000000000000000000000000000000000
--- a/Mesh/3D_Mesh.cpp
+++ /dev/null
@@ -1,947 +0,0 @@
-// $Id: 3D_Mesh.cpp,v 1.74 2006-08-05 10:05:45 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-// Isotropic Delaunay 3D:
-// while the tree of bad quality tets is not empty {
-//   take the worst tet
-//   create a new point
-//   remove the test whose circumscribed sphere contains the point
-//   reconstruct the convex volume
-// } 
-
-#include <vector>
-#include <algorithm>
-#include <time.h>
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "3D_Mesh.h"
-#include "Create.h"
-#include "Context.h"
-
-extern Mesh *THEM;
-extern Context_T CTX;
-extern int FACE_DIMENSION;
-
-static Tree_T *Tsd, *Sim_Sur_Le_Bord, *POINTS_TREE;
-static List_T *Simplexes_Destroyed, *Simplexes_New, *Suppress;
-static List_T *POINTS_LIST;
-static Simplex *THES;
-static Vertex *THEV;
-static Tree_T *SimXFac;
-static double volume, LC3D;
-static int ZONEELIMINEE, Methode = 0;
-
-Simplex MyNewBoundary;
-int Alerte_Point_Scabreux;
-
-inline void cgsmpl(Simplex * s, double &x, double &y, double &z)
-{
-  // this inlining crashes with gcc -O2...
-
-  x = 0.25 * (s->V[0]->Pos.X +
-              s->V[1]->Pos.X + s->V[2]->Pos.X + s->V[3]->Pos.X);
-  y = 0.25 * (s->V[0]->Pos.Y +
-              s->V[1]->Pos.Y + s->V[2]->Pos.Y + s->V[3]->Pos.Y);
-  z = 0.25 * (s->V[0]->Pos.Z +
-              s->V[1]->Pos.Z + s->V[2]->Pos.Z + s->V[3]->Pos.Z);
-}
-
-struct closestSimplex {
-  double X, Y, Z;
-  closestSimplex(double x, double y, double z) : X(x), Y(y), Z(z)
-  {
-    ;
-  }
-  bool operator () (Simplex * a, Simplex * b)
-  {
-    double x1, y1, z1, x2, y2, z2;
-    cgsmpl(a, x1, y1, z1);
-    cgsmpl(b, x2, y2, z2);
-    double d1 =
-      (x1 - X) * (x1 - X) + (y1 - Y) * (y1 - Y) + (z1 - Z) * (z1 - Z);
-    double d2 =
-      (x2 - X) * (x2 - X) + (y2 - Y) * (y2 - Y) + (z2 - Z) * (z2 - Z);
-    return d1 < d2;
-  }
-};
-
-void DebugSimplexe(Simplex * s)
-{
-  int i;
-
-  fprintf(stderr, "Simplexe %p = %d %d %d %d \n",
-          s, s->V[0]->Num, s->V[1]->Num, s->V[2]->Num, s->V[3]->Num);
-
-  for(i = 0; i < 4; i++) {
-    if(s->S[i] != &MyNewBoundary)
-      printf(" face : %d %d %d -> Simplexe %p\n",
-             s->F[i].V[0]->Num, s->F[i].V[1]->Num, s->F[i].V[2]->Num,
-             s->S[i]);
-    else
-      printf(" face : %d %d %d -> Simplexe Boundary\n",
-             s->F[i].V[0]->Num, s->F[i].V[1]->Num, s->F[i].V[2]->Num);
-  }
-}
-
-void VSIM(void *a, void *b)
-{
-  Simplex *S;
-
-  S = *(Simplex **) a;
-  if(S->V[3])
-    volume += fabs(S->Volume_Simplexe());
-}
-
-void add_points(void *a, void *b)
-{
-  Tree_Insert(POINTS_TREE, a);
-}
-
-void add_points_2(void *a, void *b)
-{
-  List_Add(POINTS_LIST, a);
-}
-
-
-double Interpole_lcTetraedre(Simplex * s, Vertex * v)
-{
-  double mat[3][3], rhs[3], sol[3], det;
-
-  s->matsimpl(mat);
-  rhs[0] = v->Pos.X - s->V[0]->Pos.X;
-  rhs[1] = v->Pos.Y - s->V[0]->Pos.Y;
-  rhs[2] = v->Pos.Z - s->V[0]->Pos.Z;
-
-  sys3x3(mat, rhs, sol, &det);
-  if(det == 0.0 ||
-     (1. - sol[0] - sol[1] - sol[2]) > 1. ||
-     (1. - sol[0] - sol[1] - sol[2]) < 0. ||
-     sol[0] > 1. ||
-     sol[1] > 1. ||
-     sol[2] > 1. || sol[0] < 0. || sol[1] < 0. || sol[2] < 0.) {
-    return DMAX(s->V[0]->lc,
-                DMAX(s->V[1]->lc, DMAX(s->V[2]->lc, s->V[3]->lc)));
-    //sol[0] = sol[1] = sol[2] = 0.25;
-  }
-
-  return (s->V[0]->lc * (1. - sol[0] - sol[1] - sol[2]) +
-          sol[0] * s->V[1]->lc + sol[1] * s->V[2]->lc + sol[2] * s->V[3]->lc);
-}
-
-Vertex *NewVertex(Simplex * s)
-{
-  Vertex *v;
-
-  v =
-    Create_Vertex(++THEM->MaxPointNum, s->Center.X, s->Center.Y, s->Center.Z,
-                  1., 0.0);
-  v->lc = Interpole_lcTetraedre(s, v);
-
-  return (v);
-}
-
-inline int Pt_In_Circum(Simplex * s, Vertex * v)
-{
-  // Determines of a point is inside the simplexe's circumscribed sphere
-  double d1 = s->Radius;
-  double d2 = sqrt(DSQR(v->Pos.X - s->Center.X) +
-		   DSQR(v->Pos.Y - s->Center.Y) + 
-		   DSQR(v->Pos.Z - s->Center.Z));
-  double eps = fabs(d1 - d2) / (d1 + d2);
-
-  if(eps < 1.e-12) return 0; // return 1? 0?
-  if(d2 < d1) return 1;
-  return 0;
-}
-
-struct SimplexInteriorCheck {
-  bool operator() (Simplex * s, double x[3], double u[3])
-  {
-    Vertex v(x[0], x[1], x[2]);
-      return Pt_In_Circum(s, &v);
-  }
-};
-
-struct SimplexInBox {
-  double sizeBox;
-  SimplexInBox(double sb) : sizeBox(sb)
-  {
-    ;
-  }
-  void operator() (Simplex * s, double min[3], double max[3])
-  {
-    double ss;
-    if(sizeBox > s->Radius)
-      ss = s->Radius;
-    else
-      ss = sizeBox;
-    min[0] = s->Center.X - ss;
-    max[0] = s->Center.X + ss;
-    min[1] = s->Center.Y - ss;
-    max[1] = s->Center.Y + ss;
-    min[2] = s->Center.Z - ss;
-    max[2] = s->Center.Z + ss;
-  }
-};
-
-// Recursive search
-
-Simplex *SearchPointByNeighbor(Vertex * v, Simplex * s, Tree_T * visited,
-                               int depth)
-{
-  if(depth > 150)
-    return 0;
-  if(Tree_Search(visited, &s))
-    return 0;
-  Tree_Add(visited, &s);
-  if(Pt_In_Circum(s, v))
-    return s;
-  Simplex *S[4];
-  int k = 0;
-  for(int i = 0; i < 4; i++) {
-    if(s->S[i] != &MyNewBoundary) {
-      S[k++] = s->S[i];
-    }
-  }
-  std::sort(S, S + k, closestSimplex(v->Pos.X, v->Pos.Y, v->Pos.Z));
-  for(int i = 0; i < k; i++) {
-    Simplex *q = SearchPointByNeighbor(v, S[i], visited, depth + 1);
-    if(q)
-      return q;
-  }
-  return 0;
-}
-
-void Action_First_Simplexes(void *a, void *b)
-{
-  Simplex **q;
-
-  if(!THES) {
-    q = (Simplex **) a;
-    if(Pt_In_Circum(*q, THEV)) {
-      THES = *q;
-    }
-  }
-}
-
-void LiS(void *a, void *b)
-{
-  int j, N;
-  SxF SXF, *pSXF;
-  Simplex **pS, *S;
-
-  pS = (Simplex **) a;
-  S = *pS;
-  N = (S->V[3]) ? 4 : 3;
-
-  for(j = 0; j < N; j++) {
-    SXF.F = S->F[j];
-    if((pSXF = (SxF *) Tree_PQuery(SimXFac, &SXF))) {
-      // Create link
-      S->S[j] = pSXF->S;
-      pSXF->S->S[pSXF->NumFaceSimpl] = S;
-    }
-    else {
-      SXF.S = S;
-      SXF.NumFaceSimpl = j;
-      Tree_Add(SimXFac, &SXF);
-    }
-  }
-}
-
-void RzS(void *a, void *b)
-{
-  int j, N;
-  Simplex **pS, *S;
-  pS = (Simplex **) a;
-  S = *pS;
-
-  N = (S->V[3]) ? 4 : 3;
-
-  for(j = 0; j < N; j++) {
-    if((S->S[j]) == NULL) {
-      S->S[j] = &MyNewBoundary;
-    }
-  }
-}
-
-// create the links between the simplices, i.e., search for neighbors
-
-void Link_Simplexes(List_T * Sim, Tree_T * Tim)
-{
-  Simplex *S;
-  int i;
-
-  SimXFac = Tree_Create(sizeof(SxF), compareSxF);
-  if(Sim) {
-    for(i = 0; i < List_Nbr(Sim); i++) {
-      List_Read(Sim, i, &S);
-      LiS(&S, NULL);
-    }
-    for(i = 0; i < List_Nbr(Sim); i++) {
-      List_Read(Sim, i, &S);
-      RzS(&S, NULL);
-    }
-  }
-  else {
-    Tree_Action(Tim, LiS);
-    Tree_Action(Tim, RzS);
-  }
-  Tree_Delete(SimXFac);
-}
-
-void Box_6_Tetraedron(List_T * P, Mesh * m)
-{
-#define FACT 1.1
-#define LOIN 0.2
-
-  int i, j;
-  static int pts[8][3] = { 
-    {0, 0, 0},
-    {1, 0, 0},
-    {1, 1, 0},
-    {0, 1, 0},
-    {0, 0, 1},
-    {1, 0, 1},
-    {1, 1, 1},
-    {0, 1, 1}
-  };
-  static int tet[6][4] = { 
-    {1, 5, 2, 4},
-    {2, 5, 6, 4},
-    {4, 5, 6, 8},
-    {6, 4, 8, 7},
-    {6, 4, 7, 3},
-    {2, 3, 4, 6}
-  };
-  double Xm = 0., Ym = 0., Zm = 0., XM = 0., YM = 0., ZM = 0., Xc, Yc, Zc;
-  Simplex *S, *ps;
-  Vertex *V, *v, *pv;
-  List_T *smp;
-
-  smp = List_Create(8, 1, sizeof(Simplex *));
-
-  V = (Vertex *) Malloc(8 * sizeof(Vertex));
-
-  for(i = 0; i < List_Nbr(P); i++) {
-    List_Read(P, i, &v);
-    if(!i) {
-      Xm = XM = v->Pos.X;
-      Ym = YM = v->Pos.Y;
-      Zm = ZM = v->Pos.Z;
-    }
-    else {
-      Xm = DMIN(Xm, v->Pos.X);
-      XM = DMAX(XM, v->Pos.X);
-      Ym = DMIN(Ym, v->Pos.Y);
-      YM = DMAX(YM, v->Pos.Y);
-      Zm = DMIN(Zm, v->Pos.Z);
-      ZM = DMAX(ZM, v->Pos.Z);
-    }
-  }
-  if(Xm == XM)
-    XM = Xm + 1.;
-  if(Ym == YM)
-    YM = Ym + 1.;
-  if(Zm == ZM)
-    ZM = Zm + 1.;
-
-  Xc = XM - Xm;
-  Yc = YM - Ym;
-  Zc = ZM - Zm;
-
-  LC3D = sqrt(Xc * Xc + Yc * Yc + Zc * Zc);
-
-  /* 8 box points
-
-     Z    8____________7
-     |   /|           /|
-     |  / |          / |
-     | /  |         /  |
-    5|/___|________/6  |
-     |   4|________|___|3
-     |   /         |   /
-     |  / Y        |  /
-     | /           | /
-     |/____________|/___ X
-     1             2
-
-   */
-
-  for(i = 0; i < 8; i++) {
-    if(pts[i][0])
-      V[i].Pos.X = Xm - LOIN * Xc;
-    else
-      V[i].Pos.X = XM + LOIN * Xc;
-
-    if(pts[i][1])
-      V[i].Pos.Y = Ym - LOIN * Yc;
-    else
-      V[i].Pos.Y = YM + LOIN * Yc;
-
-    if(pts[i][2])
-      V[i].Pos.Z = Zm - LOIN * Zc;
-    else
-      V[i].Pos.Z = ZM + LOIN * Zc;
-
-    V[i].Num = -(++THEM->MaxPointNum);
-    pv = &V[i];
-    pv->lc = 1.0;
-    pv->Mov = NULL;
-    Tree_Replace(m->Vertices, &pv);
-  }
-
-  // 6-tet mesh of the box
-
-  for(i = 0; i < 6; i++) {
-    S = Create_Simplex(&V[tet[i][0] - 1], &V[tet[i][1] - 1],
-                       &V[tet[i][2] - 1], &V[tet[i][3] - 1]);
-    List_Add(smp, &S);
-  }
-
-  Link_Simplexes(smp, NULL);
-  for(i = 0; i < List_Nbr(smp); i++) {
-    List_Read(smp, i, &ps);
-    for(j = 0; j < 4; j++)
-      if(ps->S[j] == NULL)
-        ps->S[j] = &MyNewBoundary;
-    Tree_Replace(m->Simplexes, &ps);
-  }
-
-}
-
-
-void Fill_Sim_Des(void *a, void *b)
-{
-  Simplex **S;
-  S = (Simplex **) a;
-  if(Pt_In_Circum(*S, THEV))
-    List_Add(Simplexes_Destroyed, a);
-}
-
-void TStoLS(void *a, void *b)
-{
-  List_Add(Simplexes_Destroyed, a);
-}
-
-void TAtoLA(void *a, void *b)
-{
-  List_Add(Simplexes_New, a);
-}
-
-void CrSi(void *a, void *b)
-{
-  SxF *S;
-  Simplex *s;
-  S = (SxF *) a;
-  if(S->NumFaceSimpl == 1) {
-    s = Create_Simplex(THEV, S->F.V[0], S->F.V[1], S->F.V[2]);
-    s->iEnt = ZONEELIMINEE;
-    THEM->Metric->setSimplexQuality(s);
-    List_Add(Simplexes_New, &s);
-  }
-  else if(S->NumFaceSimpl != 2) {
-    Msg(WARNING, "Huh! Panic in CrSi");
-  }
-}
-
-
-void NewSimplexes(Mesh * m, List_T * Sim, List_T * news)
-{
-  int i, j;
-  Tree_T *SimXFac;
-  Simplex *S;
-  SxF SXF, *pSXF;
-
-  SimXFac = Tree_Create(sizeof(SxF), compareSxF);
-
-  for(i = 0; i < List_Nbr(Sim); i++) {
-    List_Read(Sim, i, &S);
-    if(!i)
-      ZONEELIMINEE = S->iEnt;
-    else {
-      if(S->iEnt != ZONEELIMINEE) {
-        Msg(WARNING, "Huh! The elimination failed %d %d",
-            S->iEnt, ZONEELIMINEE);
-      }
-    }
-    for(j = 0; j < 4; j++) {
-      SXF.F = S->F[j];
-      if((pSXF = (SxF *) Tree_PQuery(SimXFac, &SXF))) {
-        (pSXF->NumFaceSimpl)++;
-      }
-      else {
-        SXF.NumFaceSimpl = 1;
-        Tree_Add(SimXFac, &SXF);
-      }
-    }
-  }
-
-  // The non-common faces are on the boundary -> create new simplices
-  Tree_Action(SimXFac, CrSi);
-  Tree_Delete(SimXFac);
-}
-
-
-/* Methode recursive : Rempli Tsd les simplexes detruits 
-   Invariant : Le simplexe est a eliminer
-   Le simplexe n'est pas encore considere */
-
-int recur_bowyer(Simplex * s)
-{
-  int i;
-
-  Tree_Insert(Tsd, &s);
-  for(i = 0; i < 4; i++) {
-    if(s->S[i] && s->S[i] != &MyNewBoundary && !Tree_Query(Tsd, &s->S[i])) {
-      if(Pt_In_Circum(s->S[i], THEV) && (s->iEnt == s->S[i]->iEnt)) {
-        recur_bowyer(s->S[i]);
-      }
-      else {
-        if(s->iEnt != s->S[i]->iEnt) {
-          //Msg(WARNING, "Point scabreux %d", s->S[i]->Num);
-          Alerte_Point_Scabreux = 1;
-        }
-        Tree_Insert(Sim_Sur_Le_Bord, &s->S[i]);
-      }
-    }
-  }
-  return 1;
-}
-
-
-
-bool Bowyer_Watson(Mesh * m, Vertex * v, Simplex * S, int force)
-{
-  int i;
-  Simplex *s;
-  double volumeold, volumenew;
-
-  THEV = v;
-
-  double x =
-    (S->V[0]->Pos.X + S->V[1]->Pos.X + S->V[2]->Pos.X + S->V[3]->Pos.X) / 4.;
-  double y =
-    (S->V[0]->Pos.Y + S->V[1]->Pos.Y + S->V[2]->Pos.Y + S->V[3]->Pos.Y) / 4.;
-  double z =
-    (S->V[0]->Pos.Z + S->V[1]->Pos.Z + S->V[2]->Pos.Z + S->V[3]->Pos.Z) / 4.;
-
-  if(force)
-    THEM->Metric->Identity();
-  else
-    THEM->Metric->setMetric(x, y, z);
-
-  Tsd = Tree_Create(sizeof(Simplex *), compareSimplex);
-  Sim_Sur_Le_Bord = Tree_Create(sizeof(Simplex *), compareSimplex);
-  List_Reset(Simplexes_Destroyed);
-  List_Reset(Simplexes_New);
-
-  if(Methode) {
-    Tree_Action(m->Simplexes, Fill_Sim_Des);
-  }
-  else {
-    recur_bowyer(S);
-  }
-
-  Tree_Action(Tsd, TStoLS);
-  NewSimplexes(m, Simplexes_Destroyed, Simplexes_New);
-
-  // compute volume
-
-  if(Alerte_Point_Scabreux || !CTX.mesh.speed_max) {
-    volume = 0.0;
-    for(i = 0; i < List_Nbr(Simplexes_Destroyed); i++) {
-      VSIM(List_Pointer(Simplexes_Destroyed, i), NULL);
-    }
-    volumeold = volume;
-    volume = 0.0;
-    for(i = 0; i < List_Nbr(Simplexes_New); i++) {
-      VSIM(List_Pointer(Simplexes_New, i), NULL);
-    }
-    volumenew = volume;
-  }
-  else {
-    volumeold = 1.0;
-    volumenew = 1.0;
-  }
-
-  // volume criterion
-
-  if((fabs(volumeold - volumenew) / (volumeold + volumenew)) > 1.e-8) {
-    if(Tree_Suppress(m->Simplexes, &S)) {
-      S->Quality = 0.0;
-      Tree_Add(m->Simplexes, &S);
-    }
-    if(force) {
-      List_Reset(Simplexes_Destroyed);
-      List_Reset(Simplexes_New);
-      Tree_Delete(Sim_Sur_Le_Bord);
-      Tree_Delete(Tsd);
-      //printf(" Aie Aie Aie volume changed %g -> %g\n",volumeold,volumenew);
-      return false;
-    }
-  }
-  else {
-    Tree_Add(m->Vertices, &THEV);
-    for(i = 0; i < List_Nbr(Simplexes_New); i++) {
-      Simplex *theNewS;
-      List_Read(Simplexes_New, i, &theNewS);
-#if 0
-      if(force) {
-	double xc = theNewS->Center.X;
-	double yc = theNewS->Center.Y;
-	double zc = theNewS->Center.Z;
-	double rd = theNewS->Radius;   
-	cgsmpl (theNewS,x,y,z);
-	THEM->Metric->setMetric (x, y, z);
-	THEM->Metric->setSimplexQuality (theNewS);
-	theNewS->Center.X = xc;
-	theNewS->Center.Y = yc;
-	theNewS->Center.Z = zc;
-	theNewS->Radius = rd;  
-      }
-#endif
-      Tree_Add(m->Simplexes, &theNewS);
-    }
-
-    // remove deleted tets
-
-    for(i = 0; i < List_Nbr(Simplexes_Destroyed); i++) {
-      List_Read(Simplexes_Destroyed, i, &s);
-      if(!Tree_Suppress(m->Simplexes, &s))
-        Msg(GERROR, "Impossible to delete simplex");
-      Free_Simplex(&s, 0);
-    }
-
-    // create links between new tets
-
-    Tree_Action(Sim_Sur_Le_Bord, TAtoLA);
-    Link_Simplexes(Simplexes_New, m->Simplexes);
-  }
-
-  Tree_Delete(Sim_Sur_Le_Bord);
-  Tree_Delete(Tsd);
-  return true;
-}
-
-void Convex_Hull_Mesh(List_T * Points, Mesh * m)
-{
-  int i, j, N, n;
-
-  N = List_Nbr(Points);
-  n = IMAX(N / 20, 1);
-
-  Box_6_Tetraedron(Points, m);
-  List_Sort(Points, comparePosition);
-
-  int Nb1 = 0, Nb2 = 0, Nb3 = 0;
-
-  for(i = 0; i < N; i++) {
-    THES = NULL;
-    List_Read(Points, i, &THEV);
-    if(Simplexes_New)
-      for(j = 0; j < List_Nbr(Simplexes_New); j++) {
-        Simplex *simp;
-        List_Read(Simplexes_New, j, &simp);
-        if(Pt_In_Circum(simp, THEV)) {
-          THES = simp;
-          break;
-        }
-      }
-
-    if(THES)
-      Nb1++;
-
-    if(!THES) {
-      if(Simplexes_New && List_Nbr(Simplexes_New)) {
-        Tree_T *visited = Tree_Create(sizeof(Simplex *), compareSimplex);
-        Simplex *simp;
-        List_Read(Simplexes_New, 0, &simp);
-        THES = SearchPointByNeighbor(THEV, simp, visited, 0);
-        Tree_Delete(visited);
-      }
-      if(THES)
-        Nb2++;
-    }
-
-
-    if(!THES) {
-      Tree_Action(m->Simplexes, Action_First_Simplexes);
-      if(THES)
-        Nb3++;
-    }
-
-    if(i % n == n - 1) {
-      volume = 0.0;
-      Tree_Action(m->Simplexes, VSIM);
-      Msg(STATUS2, "Nod=%d/%d Elm=%d Vol=%g (%d %d %d)", i + 1, N, 
-	  Tree_Nbr(m->Simplexes), volume, Nb1, Nb2, Nb3);
-    }
-    if(!THES) {
-      Msg(WARNING, "Vertex (%g,%g,%g) in no simplex", THEV->Pos.X,
-          THEV->Pos.Y, THEV->Pos.Z);
-      THEV->Pos.X +=
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.Y +=
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.Z +=
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      Tree_Action(m->Simplexes, Action_First_Simplexes);
-    }
-    bool ca_marche = Bowyer_Watson(m, THEV, THES, 1);
-    int count = 0;
-    while(!ca_marche) {
-      count++;
-      double dx =
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      double dy =
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      double dz =
-        CTX.mesh.rand_factor * LC3D * (1. -
-                                       (double)rand() / (double)RAND_MAX);
-      THEV->Pos.X += dx;
-      THEV->Pos.Y += dy;
-      THEV->Pos.Z += dz;
-      THES = NULL;
-      Tree_Action(m->Simplexes, Action_First_Simplexes);
-      ca_marche = Bowyer_Watson(m, THEV, THES, 1);
-      THEV->Pos.X -= dx;
-      THEV->Pos.Y -= dy;
-      THEV->Pos.Z -= dz;
-      if(count > 5) {
-        N++;
-        List_Add(POINTS_LIST, &THEV);
-        Msg(WARNING, "Unable to add point %d (will try it later)", THEV->Num);
-        break;
-      }
-    }
-  }
-}
-
-void suppress_vertex(void *data, void *dum)
-{
-  Vertex **pv;
-
-  pv = (Vertex **) data;
-  if((*pv)->Num < 0)
-    List_Add(Suppress, pv);
-}
-
-void suppress_simplex(void *data, void *dum)
-{
-  Simplex **pv;
-
-  pv = (Simplex **) data;
-  if((*pv)->iEnt == 0)
-    List_Add(Suppress, pv);
-}
-
-void Maillage_Volume(void *data, void *dum)
-{
-  Volume *v, **pv;
-  Mesh M;
-  Surface S, *s;
-  Simplex *simp;
-  Vertex *newv;
-  int n, N;
-  double uvw[3];
-  int i;
-
-  FACE_DIMENSION = 2;
-
-  pv = (Volume **) data;
-  v = *pv;
-
-  /*  if(v->Typ == MSH_VOLUME_DISCRETE) 
-    {
-      printf("coucou1\n");
-      int temp = CTX.mesh.algo3d;
-      CTX.mesh.algo3d = FRONTAL_NETGEN;
-      CTX.mesh.algo3d =DELAUNAY_TETGEN;
-      Mesh_Tetgen(v);
-      CTX.mesh.algo3d = temp;
-    }
-    else*/ if(Extrude_Mesh(v)) {
-  }
-  else if(MeshTransfiniteVolume(v)) {
-  }
-  else if((v->Typ != 99999) && Mesh_Netgen(v)) {
-  }
-  else if((v->Typ != 99999) && Mesh_Tetgen(v)) {
-  }
-  else if((v->Typ == 99999) && (CTX.mesh.algo3d != FRONTAL_NETGEN)
-                            && (CTX.mesh.algo3d != DELAUNAY_TETGEN)) {
-    
-    Simplexes_New = List_Create(10, 10, sizeof(Simplex *));
-    Simplexes_Destroyed = List_Create(10, 10, sizeof(Simplex *));
-
-    Mesh *LOCAL = &M;
-    s = &S;
-
-    POINTS_TREE = Tree_Create(sizeof(Vertex *), comparePosition);
-    POINTS_LIST = List_Create(100, 100, sizeof(Vertex *));
-    LOCAL->Simplexes = v->Simplexes;
-    LOCAL->Vertices = v->Vertices;
-    
-
-    for(i = 0; i < List_Nbr(v->Surfaces); i++) {
-      List_Read(v->Surfaces, i, &s);
-      Tree_Action(s->Vertices, add_points);
-    }
-    Tree_Action(POINTS_TREE, add_points_2);
-    Tree_Delete(POINTS_TREE);
-
-    N = List_Nbr(POINTS_LIST);
-    n = N / 30 + 1;
-
-    if(!N)
-      return;
-
-    // Create initial mesh respecting the boundary
-
-    Msg(STATUS1, "Mesh 3D... (initial)");
-
-    Convex_Hull_Mesh(POINTS_LIST, LOCAL);
-
-    if(!Coherence(v, LOCAL))
-      Msg(GERROR,
-          "Surface recovery failed (send a bug report with the geo file to <gmsh@geuz.org>!)");
-
-    Link_Simplexes(NULL, LOCAL->Simplexes);
-
-    if(CTX.mesh.initial_only == 3) {
-      POINTS_TREE = THEM->Vertices;
-      Tree_Action(v->Vertices, add_points);
-      POINTS_TREE = THEM->Simplexes;
-      Tree_Action(v->Simplexes, add_points);
-      return;
-    }
-
-    // remove nodes with nums < 0
-
-    Suppress = List_Create(10, 10, sizeof(Vertex *));
-    Tree_Action(v->Vertices, suppress_vertex);
-    for(i = 0; i < List_Nbr(Suppress); i++) {
-      Tree_Suppress(v->Vertices, List_Pointer(Suppress, i));
-    }
-    List_Delete(Suppress);
-
-    // remove elements whose volume num==0 (i.e., that don't belong to
-    // any volume)
-
-    Suppress = List_Create(10, 10, sizeof(Simplex *));
-    Tree_Action(v->Simplexes, suppress_simplex);
-    for(i = 0; i < List_Nbr(Suppress); i++) {
-      Tree_Suppress(v->Simplexes, List_Pointer(Suppress, i));
-    }
-
-    List_Delete(Suppress);
-
-    if(Tree_Nbr(LOCAL->Simplexes) == 0)
-      return;
-
-    // If there is something left to mesh:
-
-    Msg(STATUS1, "Mesh 3D... (final)");
-
-    v->Simplexes = LOCAL->Simplexes;
-
-    POINTS_TREE = THEM->Simplexes;
-
-    Tree_Right(LOCAL->Simplexes, &simp);
-    i = 0;
-
-    while(simp->Quality > CONV_VALUE) {
-      newv = NewVertex(simp);
-      while(!simp->Pt_In_Simplexe(newv, uvw, 1.e-5) &&
-            (simp->S[0] == &MyNewBoundary ||
-             !simp->S[0]->Pt_In_Simplexe(newv, uvw, 1.e-5)) &&
-            (simp->S[1] == &MyNewBoundary ||
-             !simp->S[1]->Pt_In_Simplexe(newv, uvw, 1.e-5)) &&
-            (simp->S[2] == &MyNewBoundary ||
-             !simp->S[2]->Pt_In_Simplexe(newv, uvw, 1.e-5)) &&
-            (simp->S[3] == &MyNewBoundary ||
-             !simp->S[3]->Pt_In_Simplexe(newv, uvw, 1.e-5))) {
-        Tree_Suppress(LOCAL->Simplexes, &simp);
-        simp->Quality = 0.1;
-        Tree_Insert(LOCAL->Simplexes, &simp);
-        Tree_Right(LOCAL->Simplexes, &simp);
-        if(simp->Quality < CONV_VALUE)
-          break;
-        newv = NewVertex(simp);
-      }
-      if(simp->Quality < CONV_VALUE)
-        break;
-      i++;
-      if(i % n == n - 1) {
-        volume = 0.0;
-        Tree_Action(LOCAL->Simplexes, VSIM);
-        Msg(STATUS2, "Nod=%d Elm=%d Vol=%g Conv=%g->%g",
-            Tree_Nbr(LOCAL->Vertices), Tree_Nbr(LOCAL->Simplexes),
-	    volume, simp->Quality, CONV_VALUE);
-      }
-      Bowyer_Watson(LOCAL, newv, simp, 0);
-      Tree_Right(LOCAL->Simplexes, &simp);
-    }
-
-    POINTS_TREE = THEM->Vertices;
-    Tree_Action(v->Vertices, add_points);
-    POINTS_TREE = THEM->Simplexes;
-    Tree_Action(v->Simplexes, add_points);
-
-#if 0 // this is full of bugs :-)
-    if(CTX.mesh.quality) {
-      extern void SwapEdges3D(Mesh * M, Volume * v, double GammaPrescribed,
-                              bool order);
-      Msg(STATUS2, "Swapping edges (1st pass)");
-      SwapEdges3D(THEM, v, CTX.mesh.quality, true);
-      Msg(STATUS2, "Swapping edges (2nd pass)");
-      SwapEdges3D(THEM, v, CTX.mesh.quality, false);
-      Msg(STATUS2, "Swapping edges (last pass)");
-      SwapEdges3D(THEM, v, CTX.mesh.quality, true);
-    }
-#endif
-
-#if 0 // this is full of bugs, too :-)
-    if(CTX.mesh.nb_smoothing) {
-      Msg(STATUS2, "Smoothing volume %d", v->Num);
-      tnxe = Tree_Create (sizeof (NXE), compareNXE);
-      create_NXE (v->Vertices, v->Simplexes, tnxe);
-      for (int i = 0; i < CTX.mesh.nb_smoothing; i++)
-	Tree_Action (tnxe, ActionLiss);
-      delete_NXE (tnxe);
-      Msg(STATUS2, "Swapping edges (last pass)");
-      SwapEdges3D (THEM, v, 0.5, true);
-    }
-#endif
-
-    List_Delete(Simplexes_New);
-    List_Delete(Simplexes_Destroyed);
-  }
-
-}
diff --git a/Mesh/3D_Mesh.h b/Mesh/3D_Mesh.h
deleted file mode 100644
index 2382443a4900a4d450967af6c03119c1d7e51f60..0000000000000000000000000000000000000000
--- a/Mesh/3D_Mesh.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef _3D_MESH_H_
-#define _3D_MESH_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Tree.h"
-#include "Mesh.h"
-
-void AddSimplexInGrid (Mesh * m, Simplex * s, int boule_boite);
-int Coherence (Volume * v, Mesh * m);
-void cut_tetraedre (Intersection * pI, Tree_T * AddedTet, Tree_T * TetDel,
-                    Tree_T * newpoints);
-void Impression_Resultats (void);
-void Restore_Volume (Volume * v);
-void Remise_A_Zero (void);
-
-#endif
diff --git a/Mesh/3D_Mesh_Netgen.cpp b/Mesh/3D_Mesh_Netgen.cpp
deleted file mode 100644
index faa8717169613f17de496c331675b39df2aa211a..0000000000000000000000000000000000000000
--- a/Mesh/3D_Mesh_Netgen.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-// $Id: 3D_Mesh_Netgen.cpp,v 1.26 2006-08-22 01:58:34 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-//
-// Contributor(s):
-//   Nicolas Tardieu
-//
-
-#include "Gmsh.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "Create.h"
-#include "Numeric.h"
-#include "Context.h"
-#include "OS.h"
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-#if !defined(HAVE_NETGEN)
-
-int Mesh_Netgen(Volume * v)
-{
-  if(CTX.mesh.algo3d == FRONTAL_NETGEN)
-    Msg(GERROR, "Netgen is not compiled in this version of Gmsh");
-  return 0;
-}
-
-void Optimize_Netgen(Volume * v)
-{
-  Msg(GERROR, "Netgen is not compiled in this version of Gmsh");
-}
-
-void Optimize_Netgen()
-{
-  Msg(GERROR, "Netgen is not compiled in this version of Gmsh");
-}
-
-#else
-
-namespace nglib {
-#include "nglib.h"
-#include "nglib_addon.h"
-}
-
-using namespace nglib;
-
-class Netgen{
- private:
-  List_T *_surverts, *_volverts;
-  Volume *_vol;
-  Ng_Mesh *_ngmesh;
- public:
-  Netgen(Volume *vol, int importVolumeMesh = 0);
-  Netgen(Surface *sur, int importSurfaceMesh = 0);
-  ~Netgen();
-  void MeshVolume();
-  void TransferVolumeMesh();
-  void OptimizeVolume();
-};
-
-Netgen::Netgen(Volume *vol, int importVolumeMesh)
-  : _volverts(0), _vol(vol)
-{
-  // creates Netgen mesh structure
-  //Ng_Init();
-  NgAddOn_Init();
-  _ngmesh = Ng_NewMesh();
-  
-  // Get all surface vertices (the same vertex can belong to several
-  // surfaces...)
-  Tree_T *tree = Tree_Create(sizeof(Vertex*), compareVertex);
-  for(int i = 0; i < List_Nbr(_vol->Surfaces); i++) {
-    Surface *s;
-    List_Read(_vol->Surfaces, i, &s);
-    Tree_Unit(tree, s->Vertices);
-  }
-  _surverts = Tree2List(tree);
-  List_Sort(_surverts, compareVertex);
-
-  if(importVolumeMesh){
-    Tree_T *tree2 = Tree_Soustraction(_vol->Vertices, tree);
-    _volverts = Tree2List(tree2);
-    List_Sort(_volverts, compareVertex);
-    Tree_Delete(tree2);
-  }
-
-  Tree_Delete(tree);
-  
-  // Transfer the vertices
-  for(int i = 0; i < List_Nbr(_surverts); i++){
-    Vertex *v;
-    List_Read(_surverts, i, &v);
-    double tmp[3];
-    tmp[0] = v->Pos.X;
-    tmp[1] = v->Pos.Y;
-    tmp[2] = v->Pos.Z;
-    Ng_AddPoint(_ngmesh, tmp);
-  }
-  for(int i = 0; i < List_Nbr(_volverts); i++){
-    Vertex *v;
-    List_Read(_volverts, i, &v);
-    double tmp[3];
-    tmp[0] = v->Pos.X;
-    tmp[1] = v->Pos.Y;
-    tmp[2] = v->Pos.Z;
-    Ng_AddPoint(_ngmesh, tmp);
-  }
-
-  // Transfert all surface simplices
-  for(int i = 0; i < List_Nbr(_vol->Surfaces); i++) {
-    Surface *s;
-    List_Read(_vol->Surfaces, i, &s);
-    int sign;
-    List_Read(_vol->SurfacesOrientations, i, &sign);
-    List_T *simplist = Tree2List(s->Simplexes);
-    for(int j = 0; j < List_Nbr(simplist); j++) {
-      Simplex *simp;
-      List_Read(simplist, j, &simp);
-      int tmp[3], index[3];
-      if(sign > 0){
-	index[0] = 0;
-	index[1] = 1;
-	index[2] = 2;
-      }
-      else{
-	index[0] = 0;
-	index[1] = 2;
-	index[2] = 1;
-      }
-      tmp[0] = 1 + List_ISearch(_surverts, &simp->V[index[0]], compareVertex);
-      tmp[1] = 1 + List_ISearch(_surverts, &simp->V[index[1]], compareVertex);
-      tmp[2] = 1 + List_ISearch(_surverts, &simp->V[index[2]], compareVertex);
-      Ng_AddSurfaceElement(_ngmesh, NG_TRIG, tmp);
-    }
-    List_Delete(simplist);
-  }
-  
-  // Transfer the volume elements
-  if(importVolumeMesh){
-    List_T *simplist = Tree2List(_vol->Simplexes);
-    for(int i = 0; i < List_Nbr(simplist); i++) {
-      Simplex *simp;
-      List_Read(simplist, i, &simp);
-      if(simp->Volume_Simplexe() > 0) { // FIXME: check this!
-	Vertex *temp = simp->V[0];
-	simp->V[0] = simp->V[1];
-	simp->V[1] = temp;
-      }
-      int tmp[4];
-      tmp[0] = 1 + List_ISearch(_surverts, &simp->V[0], compareVertex);
-      tmp[1] = 1 + List_ISearch(_surverts, &simp->V[1], compareVertex);
-      tmp[2] = 1 + List_ISearch(_surverts, &simp->V[2], compareVertex);
-      tmp[3] = 1 + List_ISearch(_surverts, &simp->V[3], compareVertex);
-      int n = List_Nbr(_surverts) + 1;
-      if(!tmp[0]) tmp[0] = n + List_ISearch(_volverts, &simp->V[0], compareVertex);
-      if(!tmp[1]) tmp[1] = n + List_ISearch(_volverts, &simp->V[1], compareVertex);
-      if(!tmp[2]) tmp[2] = n + List_ISearch(_volverts, &simp->V[2], compareVertex);
-      if(!tmp[3]) tmp[3] = n + List_ISearch(_volverts, &simp->V[3], compareVertex);
-      Ng_AddVolumeElement(_ngmesh, NG_TET, tmp);
-    }
-    List_Delete(simplist);    
-  }
-}
-
-Netgen::Netgen(Surface *sur, int importSurfaceMesh)
-{
-  // todo
-}
-
-Netgen::~Netgen()
-{
-  List_Delete(_surverts);
-  List_Delete(_volverts);
-  Ng_DeleteMesh(_ngmesh);
-  Ng_Exit();
-}
-
-void Netgen::MeshVolume()
-{
-  Ng_Meshing_Parameters mp;
-  mp.maxh = 1;
-  mp.fineness = 1;
-  mp.secondorder = 0;
-  //Ng_GenerateVolumeMesh(_ngmesh, &mp);
-  NgAddOn_GenerateVolumeMesh(_ngmesh, &mp); // does not optimize
-}
-
-void Netgen::TransferVolumeMesh()
-{
-  // Gets total number of vertices of Netgen's mesh
-  int nbv = Ng_GetNP(_ngmesh);
-  
-  if(!nbv) return;
-
-  Vertex **vtable = (Vertex **)Malloc(nbv * sizeof(Vertex*));
-  
-  // Get existing unmodified surface vertices
-  for(int i = 0; i < List_Nbr(_surverts); i++){
-    List_Read(_surverts, i, &vtable[i]);
-    Tree_Insert(_vol->Vertices, &vtable[i]);
-    Tree_Insert(THEM->Vertices, &vtable[i]);
-  }
-
-  // Create new volume vertices
-  for(int i = List_Nbr(_surverts); i < nbv; i++) {
-    double tmp[3];
-    Ng_GetPoint(_ngmesh, i+1, tmp);
-    vtable[i] = Create_Vertex(++(THEM->MaxPointNum), tmp[0], tmp[1], tmp[2], 1., 0);
-    Tree_Add(_vol->Vertices, &vtable[i]);
-    Tree_Add(THEM->Vertices, &vtable[i]);
-  }
-
-  // Get total number of simplices of Netgen's mesh
-  int nbe = Ng_GetNE(_ngmesh);
-
-  // Create new volume simplices
-  for(int i = 0; i < nbe; i++) {
-    int tmp[4];
-    Ng_GetVolumeElement(_ngmesh, i+1, tmp);
-    Simplex *simp = Create_Simplex(vtable[tmp[0]-1], vtable[tmp[1]-1],
-				   vtable[tmp[2]-1], vtable[tmp[3]-1]);
-    simp->iEnt = _vol->Num;
-    Tree_Add(_vol->Simplexes, &simp);
-    // also add a copy in the global simplex tree
-    Tree_Add(THEM->Simplexes, &simp);
-  }
-  
-  Free(vtable);
-}
-
-static void suppressSimplex(void *a, void *b)
-{
-  Tree_Suppress(THEM->Simplexes, a);
-}
-
-void Netgen::OptimizeVolume()
-{
-  Ng_Meshing_Parameters mp;
-  mp.maxh = 1;
-  mp.fineness = 1;
-  mp.secondorder = 0;
-
-  // remove the pure volume vertices from the mesh
-  for(int i = 0; i < List_Nbr(_volverts); i++){
-    Vertex *v;
-    List_Read(_volverts, i, &v);
-    Tree_Suppress(_vol->Vertices, &v);
-    Tree_Suppress(THEM->Vertices, &v);
-    Free_Vertex(&v, NULL);
-  }
-  // remove the tets
-  Tree_Action(_vol->Simplexes, suppressSimplex);
-  Tree_Action(_vol->Simplexes, Free_Simplex);
-  Tree_Delete(_vol->Simplexes);
-  _vol->Simplexes = Tree_Create(sizeof(Simplex*), compareQuality);
-
-  NgAddOn_OptimizeVolumeMesh(_ngmesh, &mp);
-}
-
-int Mesh_Netgen(Volume * v)
-{
-  if(CTX.mesh.algo3d != FRONTAL_NETGEN)
-    return 0;
-
-  if(CTX.mesh.bgmesh_type == ONFILE){
-    Msg(GERROR, "Netgen is not ready to be used with a background mesh");
-    return 0;
-  }
-
-  Msg(INFO, "Meshing volume %d", v->Num);
-  Netgen ng(v);
-  ng.MeshVolume();
-  ng.TransferVolumeMesh();
-  
-  return 1;
-}
-
-void Optimize_Netgen(Volume * v)
-{
-  // abort of we don't have real volumes (volume has no CAD, or has no
-  // surface loop w/ oriented surfaces) or if there are no simplices
-  // to optimize
-  if(v->Typ == MSH_VOLUME_DISCRETE || v->Method == TRANSFINI ||
-     Extrude_Mesh(v) || !Tree_Nbr(v->Simplexes))
-    return;
-
-  Msg(INFO, "Optimizing volume %d", v->Num);
-  Netgen ng(v, 1);
-  ng.OptimizeVolume();
-  ng.TransferVolumeMesh();
-}
-
-void Optimize_Netgen()
-{
-  Msg(STATUS1, "Mesh optimize...");
-  double t1 = Cpu();
-
-  // cleanup 2nd order vertices, if any
-  Degre1(); 
-
-  // make sure we don't have ONFILE (so that when we create simplices
-  // we don't try to compute the quality from the bgmesh)
-  CTX.mesh.bgmesh_type = WITHPOINTS; 
-
-  List_T *list = Tree2List(THEM->Volumes);
-  for(int i = 0; i < List_Nbr(list); i++){
-    Volume *v;
-    List_Read(list, i, &v);
-    Optimize_Netgen(v);
-  }
-  List_Delete(list);
-
-  double t2 = Cpu();
-  Msg(INFO, "Mesh optimize complete (%g s)", t2 - t1);
-}
-
-#endif // !HAVE_NETGEN
diff --git a/Mesh/3D_Mesh_Tetgen.cpp b/Mesh/3D_Mesh_Tetgen.cpp
deleted file mode 100644
index 81d0d75ea967c2e951fce5e6f064a6b49e927702..0000000000000000000000000000000000000000
--- a/Mesh/3D_Mesh_Tetgen.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-// $Id: 3D_Mesh_Tetgen.cpp,v 1.9 2006-08-05 13:31:28 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-//
-// Contributor(s):
-//   Jozef Vesely
-//
-
-#include "Gmsh.h"
-#include "Mesh.h"
-#include "Create.h"
-#include "Numeric.h"
-#include "Context.h"
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-#if !defined(HAVE_TETGEN)
-
-int Mesh_Tetgen(Volume * v)
-{
-  if(CTX.mesh.algo3d == DELAUNAY_TETGEN)
-    Msg(GERROR, "Tetgen is not compiled in this version of Gmsh");
-  return 0;
-}
-#else
-
-#include "tetgen.h"
-
-int Mesh_Tetgen(Volume * vol) {
-  tetgenio in, out;
-  char opts[128];
-
-  if(CTX.mesh.algo3d != DELAUNAY_TETGEN)
-    return 0;
-
-  if(CTX.mesh.bgmesh_type == ONFILE){
-    Msg(GERROR, "Tetgen is not ready to be used with a background mesh");
-    return 0;
-  }
-
-  Msg(STATUS2, "Meshing volume %d with experimental tetgen", vol->Num);
-  
-  // Get all surface vertices (from all surfaces)
-  Tree_T *treeVrtx = Tree_Create(sizeof(Vertex*), compareVertex);
-  Tree_T *treeSimp = Tree_Create(sizeof(Simplex*), compareSimplex);
-  
-  for(int i = 0; i < List_Nbr(vol->Surfaces); i++) {
-    Surface *sur;
-    List_Read(vol->Surfaces, i, &sur);
-    
-    Tree_Unit(treeVrtx, sur->Vertices);
-    Tree_Unit(treeSimp, sur->Simplexes);
-    
-    // DELETE all triangles and vertices,
-    // tetgen will refine also surface mesh
-    Tree_Delete(sur->Simplexes);
-    Tree_Delete(sur->Vertices);
-    sur->Simplexes = Tree_Create(sizeof(Simplex *), compareQuality);
-    sur->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
-  }
-
-  List_T *listVrtx = Tree2List(treeVrtx);
-  List_T *listSimp = Tree2List(treeSimp);
-  
-  Tree_Delete(treeVrtx);
-  Tree_Delete(treeSimp);
-
-  // Set input parameters  
-  in.mesh_dim = 3;
-  in.firstnumber = 1;
-  
-  in.numberofpoints = List_Nbr(listVrtx);
-  in.pointlist = new REAL[in.numberofpoints * 3];
-  in.pointmarkerlist = NULL;
-  
-  in.numberoffacets = List_Nbr(listSimp);
-  in.facetlist = new tetgenio::facet[in.numberoffacets];
-  in.facetmarkerlist = new int[in.numberoffacets];
-
-  double lc_max = -1.0;
-  for(int i = 0; i < List_Nbr(listVrtx); i++){
-    Vertex *v;
-    List_Read(listVrtx, i, &v);
-    in.pointlist[i*3 + 0] = v->Pos.X;
-    in.pointlist[i*3 + 1] = v->Pos.Y;
-    in.pointlist[i*3 + 2] = v->Pos.Z;
-    if(v->lc > lc_max) lc_max = v->lc;
-    
-    // DELETE the vertices from global mesh
-    Tree_Suppress(THEM->Vertices, &v);
-  }
- 
-  for(int i = 0; i < List_Nbr(listSimp); i++) {
-    Simplex *s;
-    List_Read(listSimp, i, &s);
-    
-    tetgenio::facet *f = &in.facetlist[i];
-    tetgenio::init(f);
-    
-    f->numberofholes = 0;
-    f->numberofpolygons = 1;
-    tetgenio::polygon *p = f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
-    tetgenio::init(p);
-    
-    p->numberofvertices = 3;
-    p->vertexlist = new int[p->numberofvertices];
-    p->vertexlist[0] = List_ISearch(listVrtx, &s->V[0], compareVertex) +1; 
-    p->vertexlist[1] = List_ISearch(listVrtx, &s->V[1], compareVertex) +1;
-    p->vertexlist[2] = List_ISearch(listVrtx, &s->V[2], compareVertex) +1;
-    
-    in.facetmarkerlist[i] = s->iEnt;
-  }
- 
-  sprintf(opts, "pq1.4Ya%f%c", (float)CTX.mesh.quality, 
-	  (CTX.verbosity < 3)? 'Q': (CTX.verbosity > 6)? 'V': '\0');
-  Msg(STATUS2, "Meshing with volume constraint %f", (float)CTX.mesh.quality);
-  
-  tetrahedralize(opts, &in, &out);
- 
-  // CHECK
-  // out.trifacemarkerlist != NULL
-  // out.numberofcorners == 4
-  // out.mesh_dim == 3 
-  
-  Vertex **vtable = new Vertex*[out.numberofpoints]; 
-  for (int i = 0; i < out.numberofpoints; i++) {
-    vtable[i] = Create_Vertex(++(THEM->MaxPointNum), 
-			      out.pointlist[i * 3 + 0], 
-			      out.pointlist[i * 3 + 1],
-			      out.pointlist[i * 3 + 2],
-			      1., 0);
-    Tree_Add(vol->Vertices, &vtable[i]);
-    Tree_Add(THEM->Vertices, &vtable[i]);
-  }
-  
-  for(int j = 0; j < List_Nbr(vol->Surfaces); j++){
-    Surface *sur;
-    List_Read(vol->Surfaces, j, &sur);
-    for (int i = 0; i<out.numberoftrifaces; i++){
-      if (out.trifacemarkerlist[i] == sur->Num) {
-	Simplex *s = Create_Simplex(vtable[ out.trifacelist[i * 3 + 0]-1 ],
-				    vtable[ out.trifacelist[i * 3 + 1]-1 ],
-				    vtable[ out.trifacelist[i * 3 + 2]-1 ],
-				    NULL);
-	s->iEnt = sur->Num;
-	Tree_Add(sur->Simplexes, &s);
-      }
-    } 
-  }
-  
-  for (int i = 0; i < out.numberoftetrahedra; i++) {
-    Simplex *s = Create_Simplex(vtable[ out.tetrahedronlist[i * 4 + 0] -1],
-				vtable[ out.tetrahedronlist[i * 4 + 1] -1],
-				vtable[ out.tetrahedronlist[i * 4 + 2] -1],
-				vtable[ out.tetrahedronlist[i * 4 + 3] -1]);
-    s->iEnt = vol->Num;
-    Tree_Add(vol->Simplexes, &s);
-    Tree_Add(THEM->Simplexes, &s);
-  }
-  
-  List_Delete(listVrtx);
-  List_Delete(listSimp);
-  return 1;
-}
-
-#endif // !HAVE_TETGEN
diff --git a/Mesh/3D_Transfinite.cpp b/Mesh/3D_Transfinite.cpp
deleted file mode 100644
index 28220cc13909ee8a43f9f73c530f9b25c703bfab..0000000000000000000000000000000000000000
--- a/Mesh/3D_Transfinite.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-// $Id: 3D_Transfinite.cpp,v 1.6 2006-08-05 10:05:45 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-//
-// Contributor(s):
-//   Patrick Dular
-//
-
-/*  
-  Volume transfinite meshes
-
-                     a0   s0 s1  f0  s0 s1 s5 s4              s6      
-   s7        s6      a1   s1 s2  f1  s1 s2 s6 s4              *       
-     *-------*       a2   s3 s2  f2  s3 s2 s6 s7             /|\      
-     |\s4    |\      a3   s0 s3  f3  s0 s3 s7 s4            / | \     
-     | *-------* s5  a4   s4 s5  f4  s0 s1 s2 s3      s7/s4/  |s2\    
-     | |   s2| |     a5   s5 s6  f5  s4 s5 s6 s7          *---*---* s5
-  s3 *-|-----* |     a6   s7 s6                           |  / \  |   
-      \|      \|     a7   s4 s7                           | /   \ |   
-       *-------*     a8   s0 s4                           |/     \|   
- v w  s0       s1    a9   s1 s5                           *-------*     
-  \|                 a10  s2 s6                  v w    s3/s0     s1    
-   *--u              a11  s3 s7                   \|                 
-                                                   *--u              
-
-
-  Warning: 
-
-  1) the definition of a prismatic volume has to follow the ordering
-  given in the fig (degenerescence has to be in s0/s4)
-  
-  2) meshing a hex volume with prisms assumes that the surface mesh
-     has been oriented in a certain way ('left' and 'alternate'
-     transf. surfaces are not supported)
-*/
-
-#include "Gmsh.h"
-#include "Mesh.h"
-#include "Interpolation.h"
-#include "Create.h"
-
-extern Mesh *THEM;
-
-int index2d(int flag, int M, int N, int m, int n)
-{
-  switch (flag) {
-  case 0:
-    return (n + N * m);
-  case 1:
-    return (M * N - M * (n + 1) + m);
-  case 2:
-    return (M * N - (n + N * m) - 1);
-  case 3:
-    return (M + n * M - m - 1);
-  case 4:
-    return (N + m * N - n - 1);
-  case 5:
-    return (M * N - (m + M * n) - 1);
-  case 6:
-    return (M * N - N * (m + 1) + n);
-  case 7:
-    return (m + M * n);
-  default:
-    return 0;
-  }
-}
-
-void index_uv(int flag, Vertex * ver, double *u, double *v)
-{
-  switch (flag) {
-  case 0:
-    *u = ver->us[0];
-    *v = ver->us[1];
-    break;
-  case 1:
-    *u = ver->us[1];
-    *v = 1. - ver->us[0];
-    break;
-  case 2:
-    *u = 1. - ver->us[0];
-    *v = 1. - ver->us[1];
-    break;
-  case 3:
-    *u = 1. - ver->us[1];
-    *v = ver->us[0];
-    break;
-  case 4:
-    *u = ver->us[0];
-    *v = 1. - ver->us[1];
-    break;
-  case 5:
-    *u = 1. - ver->us[1];
-    *v = 1. - ver->us[0];
-    break;
-  case 6:
-    *u = 1. - ver->us[0];
-    *v = ver->us[1];
-    break;
-  case 7:
-    *u = ver->us[1];
-    *v = ver->us[0];
-    break;
-  }
-}
-
-#define CREATE_HEX Create_Hexahedron(list[(i)   + N1*(j)   + N1*N2*(k)],   \
-                                     list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                     list[(i+1) + N1*(j+1) + N1*N2*(k)],   \
-                                     list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                     list[(i)   + N1*(j)   + N1*N2*(k+1)], \
-                                     list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                     list[(i+1) + N1*(j+1) + N1*N2*(k+1)], \
-                                     list[(i)   + N1*(j+1) + N1*N2*(k+1)])
-
-#define CREATE_PRISM_1 Create_Prism(list[(i)   + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k+1)])
-
-#define CREATE_PRISM_2 Create_Prism(list[(i+1) + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i+1) + N1*(j+1) + N1*N2*(k+1)], \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)])
-
-#define CREATE_SIM_1 Create_Simplex(list[(i)   + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j)   + N1*N2*(k+1)])
-
-#define CREATE_SIM_2 Create_Simplex(list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)])
-
-#define CREATE_SIM_3 Create_Simplex(list[(i)   + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k+1)])
-
-#define CREATE_SIM_4 Create_Simplex(list[(i+1) + N1*(j)   + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j+1) + N1*N2*(k)])
-
-#define CREATE_SIM_5 Create_Simplex(list[(i)   + N1*(j+1) + N1*N2*(k)],   \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j+1) + N1*N2*(k)])
-
-#define CREATE_SIM_6 Create_Simplex(list[(i+1) + N1*(j)   + N1*N2*(k+1)], \
-                                    list[(i)   + N1*(j+1) + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j+1) + N1*N2*(k+1)], \
-                                    list[(i+1) + N1*(j+1) + N1*N2*(k)])
-
-int MeshTransfiniteVolume(Volume * vol)
-{
-  int i, j, k, flag, nbs, nbp, nbg;
-  int nbtet = 0, nbpri = 0, nbhex = 0;
-  Surface *G[6], *GG[6];
-  Vertex V, *CP[4], **list;
-  double u, v, w, dum;
-  int F_flag[6];
-  int N1, N2, N3;
-  Vertex *F[6], *C[12], *Stmp[8], *S[8];
-  Hexahedron *hexa;
-  Prism *prism;
-  Simplex *simp;
-  int NbFacesFound = 0;
-
-  static int tab1hex[] = { 0, 1, 5, 4, 
-			   1, 2, 6, 5,
-			   3, 2, 6, 7, 
-			   0, 3, 7, 4, 
-			   0, 1, 2, 3, 
-			   4, 5, 6, 7 };
-
-  static int tab2[] = { 0, 1, 2, 3,
-			1, 2, 3, 0,
-			2, 3, 0, 1,
-			3, 0, 1, 2,
-			3, 2, 1, 0,
-			2, 1, 0, 3, 
-			1, 0, 3, 2,
-			0, 3, 2, 1 };
-
-  if(vol->Method != TRANSFINI)
-    return 0;
-
-  nbs = List_Nbr(vol->Surfaces);
-
-  if(nbs == 5)
-    nbp = 6;
-  else if(nbs == 6)
-    nbp = 8;
-  else
-    return 0;
-
-  if(List_Nbr(vol->TrsfPoints) != nbp)
-    return 0;
-
-  Msg(STATUS2, "Meshing volume %d", vol->Num);
-
-  for(i = 0; i < 6; i++)
-    G[i] = NULL;
-
-  for(i = 0; i < nbp; i++)
-    List_Read(vol->TrsfPoints, i, &Stmp[i]);
-
-  if(nbp == 8) {
-    for(i = 0; i < 8; i++)
-      S[i] = Stmp[i];
-  }
-  else if(nbp == 6) {
-    S[0] = S[3] = Stmp[0];
-    S[1] = Stmp[1];
-    S[2] = Stmp[2];
-    S[4] = S[7] = Stmp[3];
-    S[5] = Stmp[4];
-    S[6] = Stmp[5];
-  }
-
-  for(i = 0; i < nbs; i++)
-    List_Read(vol->Surfaces, i, &GG[i]);
-
-  for(i = 0; i < nbs; i++) {
-    nbg = List_Nbr(GG[i]->Generatrices);
-
-    if(List_Nbr(GG[i]->TrsfPoints) != nbg)
-      return 0;
-
-    for(j = 0; j < nbg; j++)
-      List_Read(GG[i]->TrsfPoints, j, &CP[j]);
-
-    if(nbg == 3)
-      CP[3] = CP[0];
-
-    for(flag = 0; flag < 8; flag++) {
-      for(k = 0; k < 6; k++) {
-        if(S[tab1hex[4 * k]]->Num == CP[tab2[4 * flag]]->Num &&
-           S[tab1hex[4 * k + 1]]->Num == CP[tab2[4 * flag + 1]]->Num &&
-           S[tab1hex[4 * k + 2]]->Num == CP[tab2[4 * flag + 2]]->Num &&
-           S[tab1hex[4 * k + 3]]->Num == CP[tab2[4 * flag + 3]]->Num) {
-          G[k] = GG[i];
-          F_flag[k] = flag;
-          NbFacesFound++;
-
-	  if(GG[i]->Recombine_Dir != 1){
-	    Msg(GERROR, "Transfinite Volume not available yet with left- or alternate-"
-		"oriented transfinite surfaces");
-	    return 0;
-	  }
-	  
-        }
-      }
-    }
-  }
-
-  if(nbs == 6 && NbFacesFound != 6) {
-    Msg(WARNING, "Wrong definition of hexahedric Transfinite Volume %d",
-        vol->Num);
-    return 0;
-  }
-
-  if(nbs == 5 && NbFacesFound != 5) {
-    Msg(WARNING1, "Wrong definition of prismatic Transfinite Volume %d",
-        vol->Num);
-    Msg(WARNING2, "Possibly because the first and fourth points are not the");
-    Msg(WARNING3, "degenerated ones");
-    return 0;
-  }
-
-  if(nbs == 6) {
-    for(i = 0; i < 6; i++) {
-      if(G[i] == NULL) {
-        Msg(WARNING, "Wrong definition of hexahedric Transfinite Volume %d",
-            vol->Num);
-        return 0;
-      }
-    }
-  }
-  else if(nbs == 5) {
-    for(i = 0; i < 6; i++) {
-      if(i != 3) {
-        if(G[i] == NULL) {
-          Msg(WARNING1, "Wrong definition of prismatic Transfinite Volume %d", vol->Num);
-          Msg(WARNING2, "Possibly because the first and fourth points are not the");
-          Msg(WARNING3, "degenerated ones");
-          return 0;
-        }
-      }
-    }
-  }
-
-  N1 = (F_flag[4] % 2 == 0) ? G[4]->Nu : G[4]->Nv;
-  N2 = (F_flag[4] % 2 == 0) ? G[4]->Nv : G[4]->Nu;
-  N3 = (F_flag[0] % 2 == 0) ? G[0]->Nv : G[0]->Nu;
-
-  list = (Vertex **) Malloc(N1 * N2 * N3 * sizeof(Vertex *));
-
-  for(i = 0; i < N1; i++) {
-
-    for(j = 0; j < N2; j++) {
-
-      List_Read(G[4]->TrsfVertices, index2d(F_flag[4], N1, N2, i, 0), &C[0]);
-      List_Read(G[4]->TrsfVertices, index2d(F_flag[4], N1, N2, N1 - 1, j), &C[1]);
-      List_Read(G[4]->TrsfVertices, index2d(F_flag[4], N1, N2, i, N2 - 1), &C[2]);
-      List_Read(G[4]->TrsfVertices, index2d(F_flag[4], N1, N2, 0, j), &C[3]);
-      List_Read(G[5]->TrsfVertices, index2d(F_flag[5], N1, N2, i, 0), &C[4]);
-      List_Read(G[5]->TrsfVertices, index2d(F_flag[5], N1, N2, N1 - 1, j), &C[5]);
-      List_Read(G[5]->TrsfVertices, index2d(F_flag[5], N1, N2, i, N2 - 1), &C[6]);
-      List_Read(G[5]->TrsfVertices, index2d(F_flag[5], N1, N2, 0, j), &C[7]);
-
-      List_Read(G[4]->TrsfVertices, index2d(F_flag[4], N1, N2, i, j), &F[4]);
-      List_Read(G[5]->TrsfVertices, index2d(F_flag[5], N1, N2, i, j), &F[5]);
-
-      index_uv(F_flag[4], F[4], &u, &v);
-
-      for(k = 0; k < N3; k++) {
-
-        List_Read(G[0]->TrsfVertices, index2d(F_flag[0], N1, N3, 0, k), &C[8]);
-        List_Read(G[0]->TrsfVertices, index2d(F_flag[0], N1, N3, N1 - 1, k), &C[9]);
-        List_Read(G[2]->TrsfVertices, index2d(F_flag[2], N1, N3, N1 - 1, k), &C[10]);
-        List_Read(G[2]->TrsfVertices, index2d(F_flag[2], N1, N3, 0, k), &C[11]);
-
-        List_Read(G[0]->TrsfVertices, index2d(F_flag[0], N1, N3, i, k), &F[0]);
-        List_Read(G[1]->TrsfVertices, index2d(F_flag[1], N2, N3, j, k), &F[1]);
-        List_Read(G[2]->TrsfVertices, index2d(F_flag[2], N1, N3, i, k), &F[2]);
-        if(nbs == 6)
-          List_Read(G[3]->TrsfVertices, index2d(F_flag[3], N2, N3, j, k), &F[3]);
-        else if(nbs == 5)
-          F[3] = C[8];
-
-        index_uv(F_flag[0], F[0], &dum, &w);
-
-        if(i && j && k && i != N1 - 1 && j != N2 - 1 && k != N3 - 1) {
-          V = TransfiniteHex(*F[0], *F[1], *F[2], *F[3], *F[4], *F[5],
-                             *C[0], *C[1], *C[2], *C[3], *C[4], *C[5],
-                             *C[6], *C[7], *C[8], *C[9], *C[10], *C[11],
-                             *S[0], *S[1], *S[2], *S[3], *S[4], *S[5], *S[6],
-                             *S[7], u, v, w);
-          list[i + N1 * j + N1 * N2 * k] =
-            Create_Vertex(++THEM->MaxPointNum, V.Pos.X, V.Pos.Y, V.Pos.Z,
-			  V.lc, 0.0);
-        }
-        else if(!i) {
-          list[i + N1 * j + N1 * N2 * k] = F[3];
-        }
-        else if(!j) {
-          list[i + N1 * j + N1 * N2 * k] = F[0];
-        }
-        else if(!k) {
-          list[i + N1 * j + N1 * N2 * k] = F[4];
-        }
-        else if(i == N1 - 1) {
-          list[i + N1 * j + N1 * N2 * k] = F[1];
-        }
-        else if(j == N2 - 1) {
-          list[i + N1 * j + N1 * N2 * k] = F[2];
-        }
-        else if(k == N3 - 1) {
-          list[i + N1 * j + N1 * N2 * k] = F[5];
-        }
-
-      }
-    }
-  }
-
-  for(i = 0; i < N1; i++) {
-    for(j = 0; j < N2; j++) {
-      for(k = 0; k < N3; k++) {
-        Tree_Insert(THEM->Vertices, &list[i + N1 * j + N1 * N2 * k]);
-        Tree_Insert(vol->Vertices, &list[i + N1 * j + N1 * N2 * k]);
-      }
-    }
-  }
-
-  if(nbs == 6) {
-    for(i = 0; i < N1 - 1; i++) {
-      for(j = 0; j < N2 - 1; j++) {
-        for(k = 0; k < N3 - 1; k++) {
-          if(G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-             G[3]->Recombine && G[4]->Recombine && G[5]->Recombine) {
-            hexa = CREATE_HEX;
-            hexa->iEnt = vol->Num;
-            Tree_Add(vol->Hexahedra, &hexa);
-
-            nbhex++;
-          }
-          else if(!G[0]->Recombine && G[1]->Recombine && !G[2]->Recombine &&
-                  G[3]->Recombine && G[4]->Recombine && G[5]->Recombine) {
-            prism = Create_Prism(list[(i) + N1 * (j) + N1 * N2 * (k)],
-                                 list[(i + 1) + N1 * (j) + N1 * N2 * (k)],
-                                 list[(i) + N1 * (j) + N1 * N2 * (k + 1)],
-                                 list[(i) + N1 * (j + 1) + N1 * N2 * (k)],
-                                 list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k)],
-                                 list[(i) + N1 * (j + 1) + N1 * N2 * (k + 1)]);
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            prism = Create_Prism(list[(i + 1) + N1 * (j) + N1 * N2 * (k + 1)],
-                                 list[(i) + N1 * (j) + N1 * N2 * (k + 1)],
-                                 list[(i + 1) + N1 * (j) + N1 * N2 * (k)],
-                                 list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k + 1)],
-                                 list[(i) + N1 * (j + 1) + N1 * N2 * (k + 1)],
-                                 list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k)]);
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            nbpri += 2;
-          }
-          else if(G[0]->Recombine && !G[1]->Recombine && G[2]->Recombine &&
-                  !G[3]->Recombine && G[4]->Recombine && G[5]->Recombine) {
-            prism = Create_Prism(list[(i + 1) + N1 * (j) + N1 * N2 * (k)],
-                                 list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k)],
-                                 list[(i + 1) + N1 * (j) + N1 * N2 * (k + 1)],
-                                 list[(i) + N1 * (j) + N1 * N2 * (k)],
-                                 list[(i) + N1 * (j + 1) + N1 * N2 * (k)],
-                                 list[(i) + N1 * (j) + N1 * N2 * (k + 1)]);
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            prism = Create_Prism(list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k + 1)],
-				 list[(i + 1) + N1 * (j) + N1 * N2 * (k + 1)],
-				 list[(i + 1) + N1 * (j + 1) + N1 * N2 * (k)],
-				 list[(i) + N1 * (j + 1) + N1 * N2 * (k + 1)],
-				 list[(i) + N1 * (j) + N1 * N2 * (k + 1)],
-				 list[(i) + N1 * (j + 1) + N1 * N2 * (k)]);
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            nbpri += 2;
-          }
-          else if(G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-                  G[3]->Recombine && !G[4]->Recombine && !G[5]->Recombine) {
-            prism = CREATE_PRISM_1;
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-            prism = CREATE_PRISM_2;
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            nbpri += 2;
-          }
-          else if(!G[0]->Recombine && !G[1]->Recombine && !G[2]->Recombine &&
-                  !G[3]->Recombine && !G[4]->Recombine && !G[5]->Recombine) {
-            simp = CREATE_SIM_1;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_2;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_3;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_4;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_5;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_6;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-
-            nbtet += 6;
-          }
-          else {
-            Msg(WARNING, "Wrong surface recombining in Transfinite Volume %d",
-                vol->Num);
-            return 0;
-          }
-        }
-      }
-    }
-  }
-  else if(nbs == 5) {
-    for(j = 0; j < N2 - 1; j++) {
-      for(k = 0; k < N3 - 1; k++) {
-        if((G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-            G[4]->Recombine && G[5]->Recombine) ||
-           (G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-            !G[4]->Recombine && !G[5]->Recombine)) {
-          prism = Create_Prism(list[N1 * (j) + N1 * N2 * (k)],
-                               list[1 + N1 * (j) + N1 * N2 * (k)],
-                               list[1 + N1 * (j + 1) + N1 * N2 * (k)],
-                               list[N1 * (j) + N1 * N2 * (k + 1)],
-                               list[1 + N1 * (j) + N1 * N2 * (k + 1)],
-                               list[1 + N1 * (j + 1) + N1 * N2 * (k + 1)]);
-          prism->iEnt = vol->Num;
-          Tree_Add(vol->Prisms, &prism);
-
-          nbpri++;
-        }
-        else if(!G[0]->Recombine && !G[1]->Recombine && !G[2]->Recombine &&
-                !G[4]->Recombine && !G[5]->Recombine) {
-          simp = Create_Simplex(list[+N1 * (j) + N1 * N2 * (k)],
-                                list[1 + N1 * (j) + N1 * N2 * (k)],
-                                list[1 + N1 * (j + 1) + N1 * N2 * (k)],
-                                list[+N1 * (j) + N1 * N2 * (k + 1)]);
-          simp->iEnt = vol->Num;
-          Tree_Add(vol->Simplexes, &simp);
-
-          simp = Create_Simplex(list[1 + N1 * (j) + N1 * N2 * (k)],
-                                list[1 + N1 * (j + 1) + N1 * N2 * (k)],
-                                list[+N1 * (j) + N1 * N2 * (k + 1)],
-                                list[1 + N1 * (j) + N1 * N2 * (k + 1)]);
-          simp->iEnt = vol->Num;
-          Tree_Add(vol->Simplexes, &simp);
-
-          simp = Create_Simplex(list[+N1 * (j) + N1 * N2 * (k + 1)],
-                                list[1 + N1 * (j + 1) + N1 * N2 * (k + 1)],
-                                list[1 + N1 * (j) + N1 * N2 * (k + 1)],
-                                list[1 + N1 * (j + 1) + N1 * N2 * (k)]);
-          simp->iEnt = vol->Num;
-          Tree_Add(vol->Simplexes, &simp);
-
-          nbtet += 2;
-        }
-        else {
-          Msg(WARNING, "Wrong surface recombining in Transfinite Volume %d",
-              vol->Num);
-          return 0;
-        }
-      }
-    }
-    for(i = 1; i < N1 - 1; i++) {
-      for(j = 0; j < N2 - 1; j++) {
-        for(k = 0; k < N3 - 1; k++) {
-          if(G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-             G[4]->Recombine && G[5]->Recombine) {
-            hexa = CREATE_HEX;
-            hexa->iEnt = vol->Num;
-            Tree_Add(vol->Hexahedra, &hexa);
-
-            nbhex++;
-          }
-          else if(G[0]->Recombine && G[1]->Recombine && G[2]->Recombine &&
-                  !G[4]->Recombine && !G[5]->Recombine) {
-            prism = CREATE_PRISM_1;
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-            prism = CREATE_PRISM_2;
-            prism->iEnt = vol->Num;
-            Tree_Add(vol->Prisms, &prism);
-
-            nbpri += 2;
-          }
-          else if(!G[0]->Recombine && !G[1]->Recombine && !G[2]->Recombine &&
-                  !G[4]->Recombine && !G[5]->Recombine) {
-            simp = CREATE_SIM_1;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_2;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_3;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_4;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_5;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-            simp = CREATE_SIM_6;
-            simp->iEnt = vol->Num;
-            Tree_Add(vol->Simplexes, &simp);
-
-            nbtet += 6;
-          }
-          else {
-            Msg(WARNING, "Wrong surface recombining in Transfinite Volume %d",
-                vol->Num);
-            return 0;
-          }
-        }
-      }
-    }
-  }
-
-  return 1;
-}
diff --git a/Mesh/3D_BGMesh.cpp b/Mesh/BackgroundMesh.cpp
similarity index 97%
rename from Mesh/3D_BGMesh.cpp
rename to Mesh/BackgroundMesh.cpp
index 52ee8b1a308acb5521dc9912d070961ea6628d67..9f280613e2a4fb1e2081023a1a02faf082bf15e2 100644
--- a/Mesh/3D_BGMesh.cpp
+++ b/Mesh/BackgroundMesh.cpp
@@ -1,4 +1,4 @@
-// $Id: 3D_BGMesh.cpp,v 1.49 2006-08-19 08:26:47 remacle Exp $
+// $Id: BackgroundMesh.cpp,v 1.1 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
diff --git a/Mesh/Create.cpp b/Mesh/Create.cpp
index 54c78d865153696060a6daee7153d22ad6d8f175..4f8c90826ad859d95535a79630dfb9de198ff8d9 100644
--- a/Mesh/Create.cpp
+++ b/Mesh/Create.cpp
@@ -1,4 +1,4 @@
-// $Id: Create.cpp,v 1.86 2006-11-25 00:44:25 geuzaine Exp $
+// $Id: Create.cpp,v 1.87 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -35,24 +35,6 @@
 extern Mesh *THEM;
 extern Context_T CTX;
 
-int compareNXE(const void *a, const void *b)
-{
-  NXE *q, *w;
-
-  q = (NXE *) a;
-  w = (NXE *) b;
-  return compareVertex(&q->v, &w->v);
-}
-
-int compareFxE(const void *a, const void *b)
-{
-  FxE *q, *w;
-
-  q = (FxE *) a;
-  w = (FxE *) b;
-  return compareFace(&q->Sorted, &w->Sorted);
-}
-
 int compareSurfaceLoop(const void *a, const void *b)
 {
   SurfaceLoop **q, **w;
@@ -71,22 +53,6 @@ int compareEdgeLoop(const void *a, const void *b)
   return ((*q)->Num - (*w)->Num);
 }
 
-int compareQuality(const void *a, const void *b)
-{
-  double d;
-  Simplex **q, **w;
-
-  q = (Simplex **) a;
-  w = (Simplex **) b;
-  d = (*q)->Quality - (*w)->Quality;
-
-  if(d > 0)
-    return (1);
-  if(d < 0)
-    return (-1);
-  return ((*q)->Num - (*w)->Num);
-}
-
 int compareCurve(const void *a, const void *b)
 {
   Curve **q, **w;
@@ -96,15 +62,6 @@ int compareCurve(const void *a, const void *b)
   return ((*q)->Num - (*w)->Num);
 }
 
-int compareAttractor(const void *a, const void *b)
-{
-  Attractor **q, **w;
-
-  q = (Attractor **) a;
-  w = (Attractor **) b;
-  return ((*q)->Num - (*w)->Num);
-}
-
 int compareSurface(const void *a, const void *b)
 {
   Surface **q, **w;
@@ -123,15 +80,6 @@ int compareVolume(const void *a, const void *b)
   return ((*q)->Num - (*w)->Num);
 }
 
-int compareSxF(const void *a, const void *b)
-{
-  SxF *q, *w;
-
-  q = (SxF *) a;
-  w = (SxF *) b;
-  return compareFace(&q->F, &w->F);
-}
-
 int comparePhysicalGroup(const void *a, const void *b)
 {
   PhysicalGroup *q, *w;
@@ -163,21 +111,6 @@ int compareMeshPartitionIndex(const void *a, const void *b)
   return (q->Index - w->Index);
 }
 
-Attractor *Create_Attractor(int Num, double lc1, double lc2, double Radius,
-                            Vertex * v, Curve * c, Surface * s)
-{
-  Attractor *pA;
-
-  pA = (Attractor *) Malloc(sizeof(Attractor));
-  pA->v = v;
-  pA->c = c;
-  pA->s = s;
-  pA->lc1 = lc1;
-  pA->lc2 = lc2;
-  pA->Radius = Radius;
-  return pA;
-}
-
 PhysicalGroup *Create_PhysicalGroup(int Num, int typ, List_T * intlist)
 {
   PhysicalGroup *p = (PhysicalGroup *) Malloc(sizeof(PhysicalGroup));
@@ -524,7 +457,6 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste,
 			  {1, 0, 0, 0.0} };
 
   Curve *pC = (Curve *) Malloc(sizeof(Curve));
-  //  pC->bds = 0;
   pC->Color.type = 0;
   pC->Visible = 1;
   pC->cp = NULL;
@@ -533,8 +465,6 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T * Liste,
   pC->Typ = Typ;
   pC->Num = Num;
   THEM->MaxLineNum = IMAX(THEM->MaxLineNum, Num);
-  pC->Simplexes = Tree_Create(sizeof(Simplex *), compareSimplex);
-  pC->SimplexesBase = Tree_Create(sizeof(SimplexBase *), compareSimplexBase);
   pC->Method = LIBRE;
   pC->degre = Order;
   pC->Circle.n[0] = 0.0;
@@ -632,10 +562,6 @@ void Free_Curve(void *a, void *b)
   Curve *pC = *(Curve **) a;
   if(pC) {
     List_Delete(pC->Vertices);
-    Tree_Action(pC->Simplexes, Free_Simplex);
-    Tree_Delete(pC->Simplexes);
-    Tree_Action(pC->SimplexesBase, Free_SimplexBase);
-    Tree_Delete(pC->SimplexesBase);
     Free(pC->k);
     List_Delete(pC->Control_Points);
     Free(pC->cp);
@@ -647,7 +573,6 @@ void Free_Curve(void *a, void *b)
 Surface *Create_Surface(int Num, int Typ)
 {
   Surface *pS = (Surface *) Malloc(sizeof(Surface));
-  //  pS->bds = 0;
   pS->Color.type = 0;
   pS->Visible = 1;
   pS->Num = Num;
@@ -660,9 +585,6 @@ Surface *Create_Surface(int Num, int Typ)
   pS->Recombine_Dir = 1;
   pS->RecombineAngle = 75;
   pS->TrsfPoints = List_Create(4, 4, sizeof(Vertex *));
-  pS->Simplexes = Tree_Create(sizeof(Simplex *), compareQuality);
-  pS->SimplexesBase = Tree_Create(sizeof(SimplexBase *), compareSimplexBase);
-  pS->Quadrangles = Tree_Create(sizeof(Quadrangle *), compareQuadrangle);
   pS->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
   pS->TrsfVertices = List_Create(1, 10, sizeof(Vertex *));
   pS->Contours = List_Create(1, 1, sizeof(List_T *));
@@ -672,7 +594,6 @@ Surface *Create_Surface(int Num, int Typ)
   pS->Generatrices = NULL;
   pS->EmbeddedPoints = NULL;
   pS->EmbeddedCurves = NULL;
-  pS->Edges = NULL;
   pS->Extrude = NULL;
   return (pS);
 }
@@ -682,12 +603,6 @@ void Free_Surface(void *a, void *b)
   Surface *pS = *(Surface **) a;
   if(pS) {
     List_Delete(pS->TrsfPoints);
-    Tree_Action(pS->Simplexes, Free_Simplex);
-    Tree_Delete(pS->Simplexes);
-    Tree_Action(pS->SimplexesBase, Free_SimplexBase);
-    Tree_Delete(pS->SimplexesBase);
-    Tree_Action(pS->Quadrangles, Free_Quadrangle);
-    Tree_Delete(pS->Quadrangles);
     Tree_Delete(pS->Vertices);
     List_Delete(pS->TrsfVertices);
     List_Delete(pS->Contours);
@@ -696,10 +611,6 @@ void Free_Surface(void *a, void *b)
     List_Delete(pS->Generatrices);
     List_Delete(pS->EmbeddedCurves);
     List_Delete(pS->EmbeddedPoints);
-    if(pS->Edges) {
-      Tree_Action(pS->Edges, Free_Edge);
-      Tree_Delete(pS->Edges);
-    }
     Free(pS);
     pS = NULL;
   }
@@ -719,33 +630,14 @@ Volume *Create_Volume(int Num, int Typ)
   pV->TrsfPoints = List_Create(6, 6, sizeof(Vertex *));
   pV->Surfaces = List_Create(1, 2, sizeof(Surface *));
   pV->SurfacesOrientations = List_Create(1, 2, sizeof(int));
-  pV->Simplexes = Tree_Create(sizeof(Simplex *), compareQuality);
-  pV->SimplexesBase = Tree_Create(sizeof(Simplex *), compareSimplexBase);
   pV->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
-  pV->Hexahedra = Tree_Create(sizeof(Hexahedron *), compareHexahedron);
-  pV->Prisms = Tree_Create(sizeof(Prism *), comparePrism);
-  pV->Pyramids = Tree_Create(sizeof(Pyramid *), comparePyramid);
   pV->Extrude = NULL;
-  pV->Edges = NULL;
-  pV->Faces = NULL;
-  // for old extrusion mesh generator
-  pV->Lin_Surf = Tree_Create(sizeof(Simplex *), compareSimplex);
-  pV->Simp_Surf = Tree_Create(sizeof(Simplex *), compareSimplex);
-  pV->Quad_Surf = Tree_Create(sizeof(Simplex *), compareQuadrangle);
   return pV;
 }
 
 void Free_Volume(void *a, void *b)
 {
   Volume *pV = *(Volume **) a;
-  if(pV) {
-    Tree_Action(pV->Simplexes, Free_Simplex);
-    Tree_Action(pV->SimplexesBase, Free_SimplexBase);
-    Tree_Action(pV->Hexahedra, Free_Hexahedron);
-    Tree_Action(pV->Prisms, Free_Prism);
-    Tree_Action(pV->Pyramids, Free_Pyramid);
-    Tree_Action(pV->Edges, Free_Edge);
-  }
   Free_Volume_But_Not_Elements(a, b);
 }
 
@@ -756,17 +648,7 @@ void Free_Volume_But_Not_Elements(void *a, void *b)
     List_Delete(pV->TrsfPoints);
     List_Delete(pV->Surfaces);  // surfaces freed elsewhere
     List_Delete(pV->SurfacesOrientations);
-    Tree_Delete(pV->Simplexes);
-    Tree_Delete(pV->SimplexesBase);
-    Tree_Delete(pV->Lin_Surf); // for old extrusion mesh generator
-    Tree_Delete(pV->Simp_Surf); // for old extrusion mesh generator
-    Tree_Delete(pV->Quad_Surf); // for old extrusion mesh generator
     Tree_Delete(pV->Vertices);  // vertices freed elsewhere
-    Tree_Delete(pV->Hexahedra);
-    Tree_Delete(pV->Prisms);
-    Tree_Delete(pV->Pyramids);
-    Tree_Delete(pV->Edges);
-    Tree_Delete(pV->Faces);
     Free(pV);
     pV = NULL;
   }
diff --git a/Mesh/Create.h b/Mesh/Create.h
index 25e2e755b85e741fab4b9daafd23fc7557946f5d..292f6320e21621b9a8e57432eba3e480f9976ca9 100644
--- a/Mesh/Create.h
+++ b/Mesh/Create.h
@@ -30,7 +30,6 @@ int compareSurfaceLoop(const void *a, const void *b);
 int compareEdgeLoop(const void *a, const void *b);
 int compareQuality(const void *a, const void *b);
 int compareCurve(const void *a, const void *b);
-int compareAttractor(const void *a, const void *b);
 int compareSurface(const void *a, const void *b);
 int compareVolume(const void *a, const void *b);
 int compareSxF(const void *a, const void *b);
@@ -38,8 +37,6 @@ int compareMeshPartitionNum(const void *a, const void *b);
 int compareMeshPartitionIndex(const void *a, const void *b);
 int comparePhysicalGroup(const void *a, const void *b);
 
-Attractor     *Create_Attractor(int Num, double lc1, double lc2, double Radius,
-				Vertex * v, Curve * c, Surface * s);
 PhysicalGroup *Create_PhysicalGroup(int Num, int typ, List_T * intlist);
 Curve         *Create_Curve(int Num, int Typ, int Order, List_T * Liste,
 			    List_T * Knots, int p1, int p2, double u1, double u2);
diff --git a/Mesh/CrossData.cpp b/Mesh/CrossData.cpp
deleted file mode 100644
index 1dc581bd5b6a94bf7847a92b1b450d912101fb37..0000000000000000000000000000000000000000
--- a/Mesh/CrossData.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-// $Id: CrossData.cpp,v 1.14 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Mesh.h"
-
-Tree_T *TreeTemp;
-
-NXE::NXE()
-{
-  v = NULL;
-  Liste = NULL;
-}
-
-NXE::~NXE()
-{
-  //  if(Liste)List_Delete(Liste);
-}
-
-void Delete_NXE(void *data, void *dummy)
-{
-  NXE *pnxe = (NXE *) data;
-  if(pnxe->Liste)
-    List_Delete(pnxe->Liste);
-}
-
-void AddTable(void *data, void *dummy)
-{
-  Simplex *s;
-  NXE nxe, *pnxe;
-  int i;
-
-  s = *(Simplex **) data;
-
-  for(i = 0; i < 4; i++) {
-    if(s->V[i]) {
-      nxe.v = s->V[i];
-      if((pnxe = (NXE *) Tree_PQuery(TreeTemp, &nxe))) {
-        List_Add(pnxe->Liste, &s);
-      }
-      else {
-        nxe.Liste = List_Create(1, 1, sizeof(Simplex *));
-        List_Add(nxe.Liste, &s);
-        Tree_Add(TreeTemp, &nxe);
-      }
-    }
-  }
-}
-
-void create_NXE(Tree_T * TreeAllNod, Tree_T * TreeAllElg, Tree_T * TreeAllNXE)
-{
-  TreeTemp = TreeAllNXE;
-  Tree_Action(TreeAllElg, AddTable);
-}
-
-void delete_NXE(Tree_T * TreeAllNXE)
-{
-  Tree_Action(TreeAllNXE, Delete_NXE);
-  Tree_Delete(TreeAllNXE);
-}
diff --git a/Mesh/DiscreteSurface.cpp b/Mesh/DiscreteSurface.cpp
deleted file mode 100644
index 81205b446365e23dc5a8661e742639d5051104a0..0000000000000000000000000000000000000000
--- a/Mesh/DiscreteSurface.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-// $Id: DiscreteSurface.cpp,v 1.46 2006-08-29 10:39:48 remacle Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems to "gmsh@geuz.org".
-
-// Public interface for discrete surface/curve mesh algo
-
-#include "Mesh.h"
-
-int MeshDiscreteSurface(Surface * s)
-{
-  throw;
-}
-
-int MeshDiscreteCurve(Curve * c)
-{
-  throw;
-}
diff --git a/Mesh/2D_DivAndConq.cpp b/Mesh/DivideAndConquer.cpp
similarity index 70%
rename from Mesh/2D_DivAndConq.cpp
rename to Mesh/DivideAndConquer.cpp
index fc0b4a5b1fb844fa091462fa9a310c7a34df891f..b1829d80900dd7b7228153f4e65f36894ff56a59 100644
--- a/Mesh/2D_DivAndConq.cpp
+++ b/Mesh/DivideAndConquer.cpp
@@ -1,4 +1,4 @@
-// $Id: 2D_DivAndConq.cpp,v 1.25 2006-09-14 15:23:29 remacle Exp $
+// $Id: DivideAndConquer.cpp,v 1.1 2006-11-25 02:47:39 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -40,9 +40,9 @@
 #include "Gmsh.h"
 #include "Numeric.h"
 #include "Mesh.h"
-#include "2D_Mesh.h"
+#include "Context.h"
 
-extern double LC2D;
+extern Context_T CTX;
 
 static PointRecord *pPointArray;
 
@@ -56,55 +56,47 @@ void PushgPointArray(PointRecord * ptr)
 
 PointRecord *PopgPointArray(void)
 {
-  return (pPointArray);
+  return pPointArray;
 }
 
 PointNumero Predecessor(PointNumero a, PointNumero b)
 {
-  DListPeek p;
-
-  p = pPointArray[a].adjacent;
+  DListPeek p = pPointArray[a].adjacent;
   if(p == NULL)
     return -1;
 
   do {
     if(p->point_num == b)
-      return (Pred(p)->point_num);
+      return Pred(p)->point_num;
     p = Pred(p);
   } while(p != pPointArray[a].adjacent);
 
   return -1;
-
 }
 
-
 PointNumero Successor(PointNumero a, PointNumero b)
 {
-  DListPeek p;
-
-  p = pPointArray[a].adjacent;
+  DListPeek p = pPointArray[a].adjacent;
   if(p == NULL)
     return -1;
 
   do {
     if(p->point_num == b)
-      return (Succ(p)->point_num);
+      return Succ(p)->point_num;
     p = Succ(p);
   } while(p != pPointArray[a].adjacent);
 
   return -1;
-
 }
 
 int FixFirst(PointNumero x, PointNumero f)
 {
-  DListPeek p, copy;
-  int out = 0;
-
-  p = pPointArray[x].adjacent;
+  DListPeek p = pPointArray[x].adjacent;
   if(p == NULL)
-    return (0);
-  copy = p;
+    return 0;
+
+  int out = 0;
+  DListPeek copy = p;
   do {
     if(p->point_num == f) {
       pPointArray[x].adjacent = p;
@@ -121,6 +113,22 @@ PointNumero First(PointNumero x)
   return (pPointArray[x].adjacent)->point_num;
 }
 
+// we use robust predicates here
+
+int Is_left_of(PointNumero x, PointNumero y, PointNumero check)
+{
+  double pa[2] = {(double)pPointArray[x].where.h, (double)pPointArray[x].where.v};
+  double pb[2] = {(double)pPointArray[y].where.h, (double)pPointArray[y].where.v};
+  double pc[2] = {(double)pPointArray[check].where.h, (double)pPointArray[check].where.v};
+  double result = gmsh::orient2d(pa, pb, pc);
+  return result > 0;
+}
+
+int Is_right_of(PointNumero x, PointNumero y, PointNumero check)
+{
+  return Is_left_of(y, x, check);
+}
+
 Segment LowerCommonTangent(DT vl, DT vr)
 {
   PointNumero x, y, z, z1, z2, temp;
@@ -150,7 +158,6 @@ Segment LowerCommonTangent(DT vl, DT vr)
   }
 }
 
-
 Segment UpperCommonTangent(DT vl, DT vr)
 {
   PointNumero x, y, z, z1, z2, temp;
@@ -180,14 +187,13 @@ Segment UpperCommonTangent(DT vl, DT vr)
   }
 }
 
-
-/* return 1 if the point k is NOT in the circumcircle of
-   triangle hij */
+/* return 1 if the point k is NOT in the circumcircle of triangle
+   hij */
 int Qtest(PointNumero h, PointNumero i, PointNumero j, PointNumero k)
 {
   if((h == i) && (h == j) && (h == k)) {
     Msg(GERROR, "3 identical points in Qtest");
-    return (0); /* returning 1 will cause looping for ever */
+    return 0; /* returning 1 will cause looping for ever */
   }
   
   double pa[2] = {(double)pPointArray[h].where.h, (double)pPointArray[h].where.v};
@@ -200,7 +206,6 @@ int Qtest(PointNumero h, PointNumero i, PointNumero j, PointNumero k)
   return (result < 0) ? 1 : 0;
 }
 
-
 int merge(DT vl, DT vr)
 {
   Segment bt, ut;
@@ -215,11 +220,11 @@ int merge(DT vl, DT vr)
   while((l != ut.from) || (r != ut.to)) {
     a = b = 0;
     if(!Insert(l, r))
-      return (0);
+      return 0;
 
     r1 = Predecessor(r, l);
     if(r1 == -1)
-      return (0);
+      return 0;
     if(Is_right_of(l, r, r1))
       a = 1;
     else {
@@ -227,14 +232,14 @@ int merge(DT vl, DT vr)
       while(!out) {
         r2 = Predecessor(r, r1);
         if(r2 == -1)
-          return (0);
+          return 0;
         if(r2 < vr.begin)
           out = 1;
         else if(Qtest(l, r, r1, r2))
           out = 1;
         else {
           if(!Delete(r, r1))
-            return (0);
+            return 0;
           r1 = r2;
           if(Is_right_of(l, r, r1))
             out = a = 1;
@@ -244,7 +249,7 @@ int merge(DT vl, DT vr)
 
     l1 = Successor(l, r);
     if(l1 == -1)
-      return (0);
+      return 0;
     if(Is_left_of(r, l, l1))
       b = 1;
     else {
@@ -252,14 +257,14 @@ int merge(DT vl, DT vr)
       while(!out) {
         l2 = Successor(l, l1);
         if(l2 == -1)
-          return (0);
+          return 0;
         if(l2 > vl.end)
           out = 1;
         else if(Qtest(r, l, l1, l2))
           out = 1;
         else {
           if(!Delete(l, l1))
-            return (0);
+            return 0;
           l1 = l2;
           if(Is_left_of(r, l, l1))
             out = b = 1;
@@ -279,16 +284,15 @@ int merge(DT vl, DT vr)
     }
   }
   if(!Insert(l, r))
-    return (0);
+    return 0;
 
   if(!FixFirst(ut.to, ut.from))
-    return (0);
+    return 0;
   if(!FixFirst(bt.from, bt.to))
-    return (0);
-  return (1);
+    return 0;
+  return 1;
 }
 
-
 DT recur_trig(PointNumero left, PointNumero right)
 {
   int n, m;
@@ -341,22 +345,20 @@ int comparePoints(const void *i, const void *j)
   x = ((PointRecord *) i)->where.h - ((PointRecord *) j)->where.h;
   if(x == 0.) {
     y = ((PointRecord *) i)->where.v - ((PointRecord *) j)->where.v;
-    return ((y < 0.) ? -1 : 1);
+    return (y < 0.) ? -1 : 1;
   }
   else
-    return ((x < 0.) ? -1 : 1);
+    return (x < 0.) ? -1 : 1;
 }
 
-
-/*  this fonction builds the delaunay triangulation and the voronoi for a
-    window. All error handling is done here. */
-
+/*  this fonction builds the delaunay triangulation and the voronoi
+    for a window. All error handling is done here. */
 int DelaunayAndVoronoi(DocPeek doc)
 {
   PushgPointArray(doc->points);
 
   if(doc->numPoints < 2)
-    return (1);
+    return 1;
 
   qsort(doc->points, doc->numPoints, sizeof(PointRecord), comparePoints);
   recur_trig(0, doc->numPoints - 1);
@@ -364,21 +366,18 @@ int DelaunayAndVoronoi(DocPeek doc)
   return 1;
 }
 
-
 /* this routine puts in xc and yc the coord of the center
    of the circumcircle of triangle (x1,y1),(x2,y2),(x3,y3)  */
-
 int CircumCircle(double x1, double y1, double x2, double y2, double x3,
                  double y3, double *xc, double *yc)
 {
   double d, a1, a2, a3;
 
-
   d = 2. * (double)(y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2));
   if(d == 0.0) {
     Msg(WARNING, "Colinear points in circum circle computation");
     *xc = *yc = -99999.;
-    return (0);
+    return 0;
   }
 
   a1 = x1 * x1 + y1 * y1;
@@ -387,33 +386,15 @@ int CircumCircle(double x1, double y1, double x2, double y2, double x3,
   *xc = (double)((a1 * (y3 - y2) + a2 * (y1 - y3) + a3 * (y2 - y1)) / d);
   *yc = (double)((a1 * (x2 - x3) + a2 * (x3 - x1) + a3 * (x1 - x2)) / d);
 
-  if(fabs(d) < 1.e-12 * DSQR(LC2D))
+  if(fabs(d) < 1.e-12 * DSQR(CTX.lc))
     Msg(WARNING,
         "Almost colinear points in circum circle computation (d = %g)", d);
 
-  return (1);
-}
-
-// Again, we use robust predicates here
-
-
-int Is_right_of(PointNumero x, PointNumero y, PointNumero check)
-{
-  return Is_left_of(y, x, check);
-}
-
-int Is_left_of(PointNumero x, PointNumero y, PointNumero check)
-{
-  double pa[2] = {(double)pPointArray[x].where.h, (double)pPointArray[x].where.v};
-  double pb[2] = {(double)pPointArray[y].where.h, (double)pPointArray[y].where.v};
-  double pc[2] = {(double)pPointArray[check].where.h, (double)pPointArray[check].where.v};
-  double result = gmsh::orient2d(pa, pb, pc);
-  return result > 0;
+  return 1;
 }
 
 /* This routine insert the point 'newPoint' in the list dlist,
-   respecting the clock-wise orientation.                              */
-
+   respecting the clock-wise orientation. */
 int DListInsert(DListRecord ** dlist, MPoint center, PointNumero newPoint)
 {
   DListRecord *p, *newp;
@@ -427,22 +408,22 @@ int DListInsert(DListRecord ** dlist, MPoint center, PointNumero newPoint)
     *dlist = newp;
     Pred(*dlist) = newp;
     Succ(*dlist) = newp;
-    return (1);
+    return 1;
   }
   if(Succ(*dlist) == *dlist) {
     Pred(*dlist) = newp;
     Succ(*dlist) = newp;
     Pred(newp) = *dlist;
     Succ(newp) = *dlist;
-    return (1);
+    return 1;
   }
   /*  If we are here, the double-linked circular list has 2 or more
-     elements, so we have to calculate where to put the new one.          */
+     elements, so we have to calculate where to put the new one. */
 
   p = *dlist;
   first = p->point_num;
 
-  /* first, compute polar coord. of the first point.     */
+  /* first, compute polar coord. of the first point. */
   yy = (double)(pPointArray[first].where.v - center.v);
   xx = (double)(pPointArray[first].where.h - center.h);
   alpha1 = atan2(yy, xx);
@@ -465,13 +446,13 @@ int DListInsert(DListRecord ** dlist, MPoint center, PointNumero newPoint)
       Succ(p) = newp;
       Pred(newp) = p;
       Pred(Succ(newp)) = newp;
-      return (1);
+      return 1;
     }
     p = Succ(p);
   } while(p != *dlist);
 
-  /*** ON NE DOIT JAMAIS ARRIVER ICI ***/
-  return (0);
+  /* never here! */
+  return 0;
 }
 
 int Insert(PointNumero a, PointNumero b)
@@ -494,15 +475,15 @@ int DListDelete(DListPeek * dlist, PointNumero oldPoint)
   DListPeek p;
 
   if(*dlist == NULL)
-    return (0);
+    return 0;
   if(Succ(*dlist) == *dlist) {
     if((*dlist)->point_num == oldPoint) {
       Free(*dlist);
       *dlist = NULL;
-      return (1);
+      return 1;
     }
     else
-      return (0);
+      return 0;
   }
   p = *dlist;
   do {
@@ -513,12 +494,12 @@ int DListDelete(DListPeek * dlist, PointNumero oldPoint)
         *dlist = Succ(p);
       }
       Free(p);
-      return (1);
+      return 1;
     }
     p = Succ(p);
   } while(p != *dlist);
 
-  return (0);
+  return 0;
 }
 
 
@@ -535,6 +516,145 @@ int Delete(PointNumero a, PointNumero b)
   return rslt;
 }
 
+/* compte les points sur le polygone convexe */
+
+int CountPointsOnHull(int n, PointRecord * pPointArray)
+{
+  PointNumero p, p2, temp;
+  int i;
+
+  if(pPointArray[0].adjacent == NULL)
+    return 0;
+  i = 1;
+  p = 0;
+  p2 = First(0);
+  while((p2 != 0) && (i < n)) {
+    i++;
+    temp = p2;
+    p2 = Successor(p2, p);
+    p = temp;
+  }
+  return (i <= n) ? i : -1;
+}
+
+PointNumero *ConvertDlistToArray(DListPeek * dlist, int *n)
+{
+  DListPeek p, temp;
+  int i, max = 0;
+  PointNumero *ptr;
+
+  p = *dlist;
+  do {
+    max++;
+    p = Pred(p);
+  } while(p != *dlist);
+  ptr = (PointNumero *) Malloc((max + 1) * sizeof(PointNumero));
+  if(ptr == NULL)
+    return NULL;
+  p = *dlist;
+  for(i = 0; i < max; i++) {
+    ptr[i] = p->point_num;
+    temp = p;
+    p = Pred(p);
+    Free(temp);
+  }
+  ptr[max] = ptr[0];
+  *dlist = NULL;
+  *n = max;
+  return ptr;
+}
+
+void filldel(Delaunay * deladd, int aa, int bb, int cc,
+             PointRecord * points)
+{
+  double qual, newqual;
+  MPoint pt2;
+  Vertex *v, *dum;
+
+  deladd->t.a = aa;
+  deladd->t.b = bb;
+  deladd->t.c = cc;
+  deladd->t.info = TOLINK;
+  deladd->t.info2 = 0;
+  deladd->v.voisin1 = NULL;
+  deladd->v.voisin2 = NULL;
+  deladd->v.voisin3 = NULL;
+
+  CircumCircle(points[aa].where.h, points[aa].where.v,
+               points[bb].where.h, points[bb].where.v,
+               points[cc].where.h, points[cc].where.v, 
+	       &deladd->t.xc, &deladd->t.yc);
+
+  pt2.h = deladd->t.xc;
+  pt2.v = deladd->t.yc;
+
+  newqual = (points[aa].quality + points[bb].quality + points[cc].quality) / 3.;
+
+  deladd->t.quality_value =
+    sqrt((deladd->t.xc - points[cc].where.h) * (deladd->t.xc -
+						points[cc].where.h) +
+	 (deladd->t.yc - points[cc].where.v) * (deladd->t.yc -
+						points[cc].where.v)
+	 ) / newqual;
+  deladd->t.position = INTERN;
+}
+
+/* Convertir les listes d'adjacence en triangles */
+
+int Conversion(DocPeek doc)
+{
+  /* on suppose que n >= 3      gPointArray est suppose OK. */
+
+  Striangle *striangle;
+  int n, i, j;
+  int count = 0, count2 = 0;
+  PointNumero aa, bb, cc;
+  PointRecord *ptemp;
+
+  PointRecord *gPointArray = doc->points;
+
+  n = doc->numPoints;
+  striangle = (Striangle *) Malloc(n * sizeof(Striangle));
+  count2 = (int)CountPointsOnHull(n, doc->points);
+
+  /* nombre de triangles que l'on doit obtenir */
+  count2 = 2 * (n - 1) - count2;
+
+  if(doc->delaunay)
+    Free(doc->delaunay);
+
+  doc->delaunay = (Delaunay *) Malloc(2 * count2 * sizeof(Delaunay));
+
+  for(i = 0; i < n; i++) {
+    /* on cree une liste de points connectes au point i (t) + nombre de points (t_length) */
+    striangle[i].t =
+      ConvertDlistToArray(&gPointArray[i].adjacent, &striangle[i].t_length);
+    striangle[i].info = NULL;
+    striangle[i].info_length = 0;
+  }
+
+  /* on balaye les noeuds de gauche a droite -> on cree les triangles  */
+  count = 0;
+  for(i = 0; i < n; i++) {
+    for(j = 0; j < striangle[i].t_length; j++) {
+      if((striangle[i].t[j] > i) && (striangle[i].t[j + 1] > i) &&
+         (Is_right_of(i, striangle[i].t[j], striangle[i].t[j + 1]))) {
+        aa = i;
+        bb = striangle[i].t[j];
+        cc = striangle[i].t[j + 1];
+        filldel(&doc->delaunay[count], aa, bb, cc, gPointArray);
+        count++;
+      }
+    }
+  }
+  for(i = 0; i < n; i++)
+    Free(striangle[i].t);
+  Free(striangle);
+  doc->numTriangles = count2;
+
+  return 1;
+}
+
 /*  Cette routine efface toutes les listes d'adjacence du pPointArray. */
 
 void remove_all_dlist(int n, PointRecord * pPointArray)
@@ -553,3 +673,15 @@ void remove_all_dlist(int n, PointRecord * pPointArray)
       pPointArray[i].adjacent = NULL;
     }
 }
+
+void Make_Mesh_With_Points(DocRecord * ptr, PointRecord * Liste,
+                           int Numpoints)
+{
+  ptr->numTriangles = 0;
+  ptr->points = Liste;
+  ptr->numPoints = Numpoints;
+  ptr->delaunay = 0;
+  DelaunayAndVoronoi(ptr);
+  Conversion(ptr);
+  remove_all_dlist(ptr->numPoints, ptr->points);
+}
diff --git a/Mesh/Edge.cpp b/Mesh/Edge.cpp
deleted file mode 100644
index 756768e63e869848847f1670de4b5cc7aa73750f..0000000000000000000000000000000000000000
--- a/Mesh/Edge.cpp
+++ /dev/null
@@ -1,441 +0,0 @@
-// $Id: Edge.cpp,v 1.20 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "Edge.h"
-#include "Tools.h"
-
-int edges_tetra[6][2] = {
-  {0, 1},
-  {1, 2},
-  {2, 0},
-  {3, 0},
-  {3, 2},
-  {3, 1}
-};
-
-int edges_quad[4][2] = {
-  {0, 1},
-  {1, 2},
-  {2, 3},
-  {3, 0}
-};
-
-int edges_hexa[12][2] = {
-  {0, 1},
-  {0, 3},
-  {0, 4},
-  {1, 2},
-  {1, 5},
-  {2, 3},
-  {2, 6},
-  {3, 7},
-  {4, 5},
-  {4, 7},
-  {5, 6},
-  {6, 7}
-};
-
-int edges_prism[9][2] = {
-  {0, 1},
-  {0, 2},
-  {0, 3},
-  {1, 2},
-  {1, 4},
-  {2, 5},
-  {3, 4},
-  {3, 5},
-  {4, 5}
-};
-
-int edges_pyramid[8][2] = {
-  {0, 1},
-  {0, 3},
-  {0, 4},
-  {1, 2},
-  {1, 4},
-  {2, 3},
-  {2, 4},
-  {3, 4}
-};
-
-int edges_non[3] = { 2, 0, 1 };
-
-int compareEdge(const void *a, const void *b)
-{
-  Edge *q = (Edge *) a;
-  Edge *w = (Edge *) b;
-  int i1 = IMAX(q->V[0]->Num, q->V[1]->Num);
-  int i2 = IMAX(w->V[0]->Num, w->V[1]->Num);
-  int j1 = IMIN(q->V[0]->Num, q->V[1]->Num);
-  int j2 = IMIN(w->V[0]->Num, w->V[1]->Num);
-
-  if(i1 < i2)
-    return (1);
-  if(i1 > i2)
-    return (-1);
-  if(j1 < j2)
-    return (1);
-  if(j1 > j2)
-    return (-1);
-  return 0;
-}
-
-int compareEdgePtr(const void *a, const void *b)
-{
-  Edge *q = *(Edge **) a;
-  Edge *w = *(Edge **) b;
-
-  return compareEdge(q, w);
-}
-
-int compareEdgeAngle(const void *a, const void *b)
-{
-  Edge *q = (Edge *) a;
-  Edge *w = (Edge *) b;
-  if(q->a >= w->a)
-    return (1);
-  return (-1);
-}
-
-void EdgesContainer::AddEdges(Simplex * s)
-{
-  int N, i;
-  Edge E, *pE;
-
-  if(s->V[3])
-    N = 6;
-  else if(s->V[2])
-    N = 3;
-  else
-    N = 1;
-
-  for(i = 0; i < N; i++) {
-    E.V[0] = s->V[edges_tetra[i][0]];
-    E.V[1] = s->V[edges_tetra[i][1]];
-    if((pE = (Edge *) Tree_PQuery(AllEdges, &E))) {
-      if(!pE->Simplexes) // the edge could belong to a non-simplex
-	pE->Simplexes = List_Create(2, 1, sizeof(Simplex *));
-      List_Add(pE->Simplexes, &s);
-      if(N == 3)
-        pE->O[1] = s->V[edges_non[i]];
-    }
-    else {
-      E.Simplexes = List_Create(2, 1, sizeof(Simplex *));
-      if(N == 3){
-        E.O[0] = s->V[edges_non[i]];
-        E.O[1] = NULL;
-      }
-      List_Add(E.Simplexes, &s);
-      E.newv = NULL;
-      Tree_Add(AllEdges, &E);
-    }
-  }
-}
-
-void EdgesContainer::AddEdges(Quadrangle * q)
-{
-  Edge E, *pE;
-
-  for(int i = 0; i < 4; i++) {
-    E.V[0] = q->V[edges_quad[i][0]];
-    E.V[1] = q->V[edges_quad[i][1]];
-    if((pE = (Edge *) Tree_PQuery(AllEdges, &E))) {
-      if(!pE->Quadrangles) // the edge could belong to a non-quad
-	pE->Quadrangles = List_Create(2, 1, sizeof(Quadrangle *));
-      List_Add(pE->Quadrangles, &q);
-    }
-    else {
-      E.Quadrangles = List_Create(2, 1, sizeof(Quadrangle *));
-      List_Add(E.Quadrangles, &q);
-      E.newv = NULL;
-      Tree_Add(AllEdges, &E);
-    }
-  }
-}
-
-void EdgesContainer::AddEdges(Hexahedron * h)
-{
-  Edge E, *pE;
-
-  for(int i = 0; i < 12; i++) {
-    E.V[0] = h->V[edges_hexa[i][0]];
-    E.V[1] = h->V[edges_hexa[i][1]];
-    if((pE = (Edge *) Tree_PQuery(AllEdges, &E))) {
-      if(!pE->Hexahedra) // the edge could belong to a non-hexa
-	pE->Hexahedra = List_Create(2, 1, sizeof(Hexahedron *));
-      List_Add(pE->Hexahedra, &h);
-    }
-    else {
-      E.Hexahedra = List_Create(2, 1, sizeof(Hexahedron *));
-      List_Add(E.Hexahedra, &h);
-      E.newv = NULL;
-      Tree_Add(AllEdges, &E);
-    }
-  }
-}
-
-void EdgesContainer::AddEdges(Prism * p)
-{
-  Edge E, *pE;
-
-  for(int i = 0; i < 9; i++) {
-    E.V[0] = p->V[edges_prism[i][0]];
-    E.V[1] = p->V[edges_prism[i][1]];
-    if((pE = (Edge *) Tree_PQuery(AllEdges, &E))) {
-      if(!pE->Prisms) // the edge could belong to a non-prism
-	pE->Prisms = List_Create(2, 1, sizeof(Prism *));
-      List_Add(pE->Prisms, &p);
-    }
-    else {
-      E.Prisms = List_Create(2, 1, sizeof(Prism *));
-      List_Add(E.Prisms, &p);
-      E.newv = NULL;
-      Tree_Add(AllEdges, &E);
-    }
-  }
-}
-
-void EdgesContainer::AddEdges(Pyramid * p)
-{
-  Edge E, *pE;
-
-  for(int i = 0; i < 8; i++) {
-    E.V[0] = p->V[edges_pyramid[i][0]];
-    E.V[1] = p->V[edges_pyramid[i][1]];
-    if((pE = (Edge *) Tree_PQuery(AllEdges, &E))) {
-      if(!pE->Pyramids) // the edge could belong to a non-pyramid
-	pE->Pyramids = List_Create(2, 1, sizeof(Pyramid *));
-      List_Add(pE->Pyramids, &p);
-    }
-    else {
-      E.Pyramids = List_Create(2, 1, sizeof(Pyramid *));
-      List_Add(E.Pyramids, &p);
-      E.newv = NULL;
-      Tree_Add(AllEdges, &E);
-    }
-  }
-}
-
-EdgesContainer::EdgesContainer(Tree_T * Simplexes)
-{
-  AllEdges = Tree_Create(sizeof(Edge), compareEdge);
-  AddSimplexTree(Simplexes);
-}
-
-EdgesContainer::EdgesContainer(List_T * Surfaces)
-{
-  AllEdges = Tree_Create(sizeof(Edge), compareEdge);
-  Surface *s;
-  for(int i = 0; i < List_Nbr(Surfaces); i++) {
-    List_Read(Surfaces, i, &s);
-    AddSimplexTree(s->Simplexes);
-  }
-}
-
-EdgesContainer::EdgesContainer()
-{
-  AllEdges = Tree_Create(sizeof(Edge), compareEdge);
-}
-
-void EdgesContainer::AddSimplexTree(Tree_T * Simplexes)
-{
-  Simplex *s;
-  List_T *temp = Tree2List(Simplexes);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &s);
-    AddEdges(s);
-  }
-  List_Delete(temp);
-}
-
-void EdgesContainer::AddQuadrangleTree(Tree_T * Quadrangles)
-{
-  Quadrangle *q;
-  List_T *temp = Tree2List(Quadrangles);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &q);
-    AddEdges(q);
-  }
-  List_Delete(temp);
-}
-
-void EdgesContainer::AddHexahedronTree(Tree_T * Hexahedra)
-{
-  Hexahedron *h;
-  List_T *temp = Tree2List(Hexahedra);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &h);
-    AddEdges(h);
-  }
-  List_Delete(temp);
-}
-
-void EdgesContainer::AddPrismTree(Tree_T * Prisms)
-{
-  Prism *p;
-  List_T *temp = Tree2List(Prisms);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &p);
-    AddEdges(p);
-  }
-  List_Delete(temp);
-}
-
-void EdgesContainer::AddPyramidTree(Tree_T * Pyramids)
-{
-  Pyramid *p;
-  List_T *temp = Tree2List(Pyramids);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &p);
-    AddEdges(p);
-  }
-  List_Delete(temp);
-}
-
-void Free_Edge(void *a, void *b)
-{
-  Edge *e = (Edge *) a;
-  List_Delete(e->Liste);
-  List_Delete(e->Simplexes);
-  List_Delete(e->Quadrangles);
-  List_Delete(e->Hexahedra);
-  List_Delete(e->Prisms);
-  List_Delete(e->Pyramids);
-  List_Delete(e->Points);
-}
-
-EdgesContainer::~EdgesContainer()
-{
-  Tree_Action(AllEdges, Free_Edge);
-  Tree_Delete(AllEdges);
-}
-
-bool EdgesContainer::Search(Vertex * v1, Vertex * v2)
-{
-  Edge E;
-  E.V[0] = v1;
-  E.V[1] = v2;
-  if(!Tree_Search(AllEdges, &E))
-    return false;
-  return true;
-}
-
-void EdgesContainer::Print()
-{
-  List_T *temp = Tree2List(AllEdges);
-  printf("Print Edges START\n");
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    Edge *e = (Edge*)List_Pointer(temp, i);
-    printf("edge %d -> %d", e->V[0]->Num, e->V[1]->Num);
-    if(List_Nbr(e->Simplexes)){
-      printf(", in simplex");
-      for(int j = 0; j < List_Nbr(e->Simplexes); j++){
-	Simplex *s = *(Simplex**)List_Pointer(e->Simplexes, j);
-	printf(" %d", s->Num);
-      }
-    }
-    if(List_Nbr(e->Quadrangles)){
-      printf(", in quad");
-      for(int j = 0; j < List_Nbr(e->Quadrangles); j++){
-	Quadrangle *q = *(Quadrangle**)List_Pointer(e->Quadrangles, j);
-	printf(" %d", q->Num);
-      }
-    }
-    if(List_Nbr(e->Hexahedra)){
-      printf(", in hexa");
-      for(int j = 0; j < List_Nbr(e->Hexahedra); j++){
-	Hexahedron *h = *(Hexahedron**)List_Pointer(e->Hexahedra, j);
-	printf(" %d", h->Num);
-      }
-    }
-    if(List_Nbr(e->Prisms)){
-      printf(", in prism");
-      for(int j = 0; j < List_Nbr(e->Prisms); j++){
-	Prism *p = *(Prism**)List_Pointer(e->Prisms, j);
-	printf(" %d", p->Num);
-      }
-    }
-    if(List_Nbr(e->Pyramids)){
-      printf(", in pyramid");
-      for(int j = 0; j < List_Nbr(e->Pyramids); j++){
-	Pyramid *p = *(Pyramid**)List_Pointer(e->Pyramids, j);
-	printf(" %d", p->Num);
-      }
-    }
-    printf("\n");
-  }
-  printf("Print Edges STOP\n");
-  List_Delete(temp);
-}
-
-void EdgesContainer::SwapEdge(Vertex * V[2])
-{
-  Edge *e, E;
-  Simplex *s, *s1, *s2;
-  int i, j;
-  Vertex *p[2], *q[2];
-
-  E.V[0] = V[0];
-  E.V[1] = V[1];
-  e = (Edge *) Tree_PQuery(AllEdges, &E);
-  E = *e;
-  if(!e)
-    return;
-  if(!e->Simplexes)
-    return;
-  List_Read(e->Simplexes, 0, &s1);
-  List_Read(e->Simplexes, 1, &s2);
-
-  for(i = 0; i < 3; i++) {
-    if(s1->S[i] == s2) {
-      s1->ExtractOppositeEdges(i, p, q);
-      if(!s1->SwapEdge(i))
-        return;
-      Tree_Suppress(AllEdges, &E);
-      E.V[0] = q[0];
-      E.V[1] = q[1];
-      Tree_Add(AllEdges, &E);
-
-      E.V[0] = q[0];
-      E.V[1] = p[0];
-      e = (Edge *) Tree_PQuery(AllEdges, &E);
-      for(j = 0; j < 2; j++) {
-        List_Read(e->Simplexes, j, &s);
-        if(s == s2)
-          List_Write(e->Simplexes, j, &s1);
-      }
-
-      E.V[0] = q[1];
-      E.V[1] = p[1];
-      e = (Edge *) Tree_PQuery(AllEdges, &E);
-      for(j = 0; j < 2; j++) {
-        List_Read(e->Simplexes, j, &s);
-        if(s == s1)
-          List_Write(e->Simplexes, j, &s2);
-      }
-      V[0] = q[0];
-      V[1] = q[1];
-    }
-  }
-}
diff --git a/Mesh/Edge.h b/Mesh/Edge.h
deleted file mode 100644
index 94175f7a9646efe41554d18c0db6e237a431cf5b..0000000000000000000000000000000000000000
--- a/Mesh/Edge.h
+++ /dev/null
@@ -1,85 +0,0 @@
-#ifndef _EDGE_H_
-#define _EDGE_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "List.h"
-#include "Tree.h"
-#include "Vertex.h"
-#include "Simplex.h"
-
-class Edge {
-public :
-  int Num;
-  Vertex *V[2];
-  List_T *Simplexes;
-  List_T *Quadrangles;
-  List_T *Hexahedra;
-  List_T *Prisms;
-  List_T *Pyramids;
-  Vertex *newv;
-  Vertex *O[2];
-  double a;
-  List_T *Liste;
-  List_T *Points;
-  Edge(){
-    Num = 0;
-    Simplexes = NULL;
-    Quadrangles = NULL;
-    Hexahedra = NULL;
-    Prisms = NULL;
-    Pyramids = NULL;
-    Liste = NULL;
-    Points = NULL;
-  }
-  ~Edge(){ ; }
-};
-
-class EdgesContainer
-{
-  public :
-    Tree_T * AllEdges;
-    EdgesContainer(Tree_T *Simplexes);
-    EdgesContainer(List_T *Surfaces);
-    EdgesContainer();
-    ~EdgesContainer();
-    void AddSimplexTree(Tree_T *Simplexes);
-    void AddQuadrangleTree(Tree_T *Quadrangles);
-    void AddHexahedronTree(Tree_T *Hexahedra);
-    void AddPrismTree(Tree_T *Prisms);    
-    void AddPyramidTree(Tree_T *Pyramids);
-    void AddEdges(Simplex *s);
-    void AddEdges(Quadrangle *q);
-    void AddEdges(Hexahedron *h);
-    void AddEdges(Prism *p);
-    void AddEdges(Pyramid *p);
-    void RemoveEdge(Edge *e);
-    void SwapEdge(Vertex *v[2]);
-    bool Search(Vertex *v1, Vertex *v2);
-    void Print();
-};
-
-void Free_Edge(void *a, void *b);
-
-int compareEdge(const void *a, const void *b);
-int compareEdgePtr(const void *a, const void *b);
-int compareEdgeAngle(const void *a, const void *b);
-
-#endif
diff --git a/Mesh/Element.cpp b/Mesh/Element.cpp
deleted file mode 100644
index 3319a2af01e1b3a1bd5e33f5cb0e2842f35d323a..0000000000000000000000000000000000000000
--- a/Mesh/Element.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-// $Id: Element.cpp,v 1.13 2006-08-12 16:16:30 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Mesh.h"
-#include "Numeric.h"
-#include "Element.h"
-
-extern int edges_quad[4][2];
-extern int edges_hexa[12][2];
-extern int edges_prism[9][2];
-extern int edges_pyramid[8][2];
-
-int Element::TotalNumber = 0;
-
-Element::Element()
-  : iEnt(-1), iPart(-1), Visible(1), VSUP(NULL)
-{
-  Num = ++TotalNumber; 
-}
-
-Element::~Element()
-{
-  if(VSUP) Free(VSUP);
-}
-
-double Element::lij(Vertex *Vi, Vertex *Vj)
-{
-  return sqrt(DSQR(Vi->Pos.X - Vj->Pos.X) +
-              DSQR(Vi->Pos.Y - Vj->Pos.Y) +
-              DSQR(Vi->Pos.Z - Vj->Pos.Z));
-}
-
-double Element::RhoShapeMeasure()
-{
-  double min = minEdge();
-  double max = maxEdge();
-  if(max)
-    return min/max;
-  else
-    return 0.;
-}
-
-// Quads
-
-Quadrangle::Quadrangle()
-  : Element()
-{
-  for(int i = 0; i < 4; i++) V[i] = NULL;
-}
-
-Quadrangle::Quadrangle(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4)
-  : Element()
-{
-  V[0] = v1; V[1] = v2; V[2] = v3; V[3] = v4;
-}
-
-double Quadrangle::maxEdge()
-{
-  double maxlij = 0.;
-  for(int i = 0; i < 4; i++)
-      maxlij = DMAX(maxlij, lij(V[edges_quad[i][0]], V[edges_quad[i][1]]));
-  return maxlij;
-}
-
-double Quadrangle::minEdge()
-{
-  double minlij = 1.e25;
-  for(int i = 0; i < 4; i++)
-      minlij = DMIN(minlij, lij(V[edges_quad[i][0]], V[edges_quad[i][1]]));
-  return minlij;
-}
-
-Quadrangle *Create_Quadrangle(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4)
-{
-  return new Quadrangle(v1, v2, v3, v4);
-}
-
-void Free_Quadrangle(void *a, void *b)
-{
-  Quadrangle *q = *(Quadrangle **) a;
-  if(q) {
-    delete q;
-    q = NULL;
-  }
-}
-
-int compareQuadrangle(const void *a, const void *b)
-{
-  Quadrangle *q = *(Quadrangle **) a;
-  Quadrangle *w = *(Quadrangle **) b;
-  return (q->Num - w->Num);
-}
-
-// Hexas
-
-Hexahedron::Hexahedron()
-  : Element()
-{
-  for(int i = 0; i < 8; i++) V[i] = NULL;
-}
-
-Hexahedron::Hexahedron(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4,
-		       Vertex *v5, Vertex *v6, Vertex *v7, Vertex *v8)
-  : Element()
-{
-  V[0] = v1; V[1] = v2; V[2] = v3; V[3] = v4;
-  V[4] = v5; V[5] = v6; V[6] = v7; V[7] = v8;
-}
-
-double Hexahedron::Orientation()
-{
-  double mat[3][3];
-  mat[0][0] = V[1]->Pos.X - V[0]->Pos.X;
-  mat[0][1] = V[3]->Pos.X - V[0]->Pos.X;
-  mat[0][2] = V[4]->Pos.X - V[0]->Pos.X;
-  mat[1][0] = V[1]->Pos.Y - V[0]->Pos.Y;
-  mat[1][1] = V[3]->Pos.Y - V[0]->Pos.Y;
-  mat[1][2] = V[4]->Pos.Y - V[0]->Pos.Y;
-  mat[2][0] = V[1]->Pos.Z - V[0]->Pos.Z;
-  mat[2][1] = V[3]->Pos.Z - V[0]->Pos.Z;
-  mat[2][2] = V[4]->Pos.Z - V[0]->Pos.Z;
-  return det3x3(mat);
-}
-
-double Hexahedron::maxEdge()
-{
-  double maxlij = 0.;
-  for(int i = 0; i < 12; i++)
-      maxlij = DMAX(maxlij, lij(V[edges_hexa[i][0]], V[edges_hexa[i][1]]));
-  return maxlij;
-}
-
-double Hexahedron::minEdge()
-{
-  double minlij = 1.e25;
-  for(int i = 0; i < 12; i++)
-      minlij = DMIN(minlij, lij(V[edges_hexa[i][0]], V[edges_hexa[i][1]]));
-  return minlij;
-}
-
-Hexahedron *Create_Hexahedron(Vertex * v1, Vertex * v2, Vertex * v3,
-                              Vertex * v4, Vertex * v5, Vertex * v6,
-                              Vertex * v7, Vertex * v8)
-{
-  return new Hexahedron(v1, v2, v3, v4, v5, v6, v7, v8);
-}
-
-void Free_Hexahedron(void *a, void *b)
-{
-  Hexahedron *h = *(Hexahedron **) a;
-  if(h) {
-    delete h;
-    h = NULL;
-  }
-}
-
-int compareHexahedron(const void *a, const void *b)
-{
-  Hexahedron *q = *(Hexahedron **) a;
-  Hexahedron *w = *(Hexahedron **) b;
-  return (q->Num - w->Num);
-}
-
-// Prisms
-
-Prism::Prism()
-  : Element()
-{
-  for(int i = 0; i < 6; i++) V[i] = NULL;
-}
-
-Prism::Prism(Vertex *v1, Vertex *v2, Vertex *v3, 
-	     Vertex *v4, Vertex *v5, Vertex *v6)
-  : Element()
-{
-  V[0] = v1; V[1] = v2; V[2] = v3; 
-  V[3] = v4; V[4] = v5; V[5] = v6;
-}
-
-double Prism::Orientation()
-{
-  double mat[3][3];
-  mat[0][0] = V[1]->Pos.X - V[0]->Pos.X;
-  mat[0][1] = V[2]->Pos.X - V[0]->Pos.X;
-  mat[0][2] = V[3]->Pos.X - V[0]->Pos.X;
-  mat[1][0] = V[1]->Pos.Y - V[0]->Pos.Y;
-  mat[1][1] = V[2]->Pos.Y - V[0]->Pos.Y;
-  mat[1][2] = V[3]->Pos.Y - V[0]->Pos.Y;
-  mat[2][0] = V[1]->Pos.Z - V[0]->Pos.Z;
-  mat[2][1] = V[2]->Pos.Z - V[0]->Pos.Z;
-  mat[2][2] = V[3]->Pos.Z - V[0]->Pos.Z;
-  return det3x3(mat);
-}
-
-double Prism::maxEdge()
-{
-  double maxlij = 0.;
-  for(int i = 0; i < 9; i++)
-      maxlij = DMAX(maxlij, lij(V[edges_prism[i][0]], V[edges_prism[i][1]]));
-  return maxlij;
-}
-
-double Prism::minEdge()
-{
-  double minlij = 1.e25;
-  for(int i = 0; i < 9; i++)
-      minlij = DMIN(minlij, lij(V[edges_prism[i][0]], V[edges_prism[i][1]]));
-  return minlij;
-}
-
-Prism *Create_Prism(Vertex * v1, Vertex * v2, Vertex * v3,
-                    Vertex * v4, Vertex * v5, Vertex * v6)
-{
-  return new Prism(v1, v2, v3, v4, v5, v6);
-}
-
-void Free_Prism(void *a, void *b)
-{
-  Prism *p = *(Prism **) a;
-  if(p) {
-    delete p;
-    p = NULL;
-  }
-}
-
-int comparePrism(const void *a, const void *b)
-{
-  Prism *q = *(Prism **) a;
-  Prism *w = *(Prism **) b;
-  return (q->Num - w->Num);
-}
-
-// Pyramids
-
-Pyramid::Pyramid()
-  : Element()
-{
-  for(int i = 0; i < 5; i++) V[i] = NULL;
-}
-
-Pyramid::Pyramid(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4, Vertex *v5)
-  : Element()
-{
-  V[0] = v1; V[1] = v2; V[2] = v3; V[3] = v4; V[4] = v5; 
-}
-
-double Pyramid::Orientation()
-{
-  double mat[3][3];
-  mat[0][0] = V[1]->Pos.X - V[0]->Pos.X;
-  mat[0][1] = V[3]->Pos.X - V[0]->Pos.X;
-  mat[0][2] = V[4]->Pos.X - V[0]->Pos.X;
-  mat[1][0] = V[1]->Pos.Y - V[0]->Pos.Y;
-  mat[1][1] = V[3]->Pos.Y - V[0]->Pos.Y;
-  mat[1][2] = V[4]->Pos.Y - V[0]->Pos.Y;
-  mat[2][0] = V[1]->Pos.Z - V[0]->Pos.Z;
-  mat[2][1] = V[3]->Pos.Z - V[0]->Pos.Z;
-  mat[2][2] = V[4]->Pos.Z - V[0]->Pos.Z;
-  return det3x3(mat);
-}
-
-double Pyramid::maxEdge()
-{
-  double maxlij = 0.;
-  for(int i = 0; i < 8; i++)
-      maxlij = DMAX(maxlij, lij(V[edges_pyramid[i][0]], V[edges_pyramid[i][1]]));
-  return maxlij;
-}
-
-double Pyramid::minEdge()
-{
-  double minlij = 1.e25;
-  for(int i = 0; i < 8; i++)
-      minlij = DMIN(minlij, lij(V[edges_pyramid[i][0]], V[edges_pyramid[i][1]]));
-  return minlij;
-}
-
-Pyramid *Create_Pyramid(Vertex * v1, Vertex * v2, Vertex * v3,
-                        Vertex * v4, Vertex * v5)
-{
-  return new Pyramid(v1, v2, v3, v4, v5);
-}
-
-void Free_Pyramid(void *a, void *b)
-{
-  Pyramid *p = *(Pyramid **) a;
-  if(p) {
-    delete p;
-    p = NULL;
-  }
-}
-
-int comparePyramid(const void *a, const void *b)
-{
-  Pyramid *q = *(Pyramid **) a;
-  Pyramid *w = *(Pyramid **) b;
-  return (q->Num - w->Num);
-}
-
diff --git a/Mesh/Element.h b/Mesh/Element.h
deleted file mode 100644
index ccb60f80bf63cc990451d76ec5dced87549ffb2a..0000000000000000000000000000000000000000
--- a/Mesh/Element.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef _ELEMENT_H_
-#define _ELEMENT_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Vertex.h"
-
-class Element {
- public:
-  int     Num;           // Number
-  int     iEnt;          // Elementary geometrical entity
-  int     iPart;         // Mesh partition index
-  char    Visible;       // Visualization flag
-  Vertex  **VSUP;        // suppl. nodes for higher order elts
-  static  int TotalNumber;
-  Element();
-  virtual ~Element();
-  double lij(Vertex *Vi, Vertex *Vj);
-  virtual double maxEdge() = 0;
-  virtual double minEdge() = 0;
-  double RhoShapeMeasure();
-};
-
-class Quadrangle : public Element{
- public:
-  Vertex *V[4];
-  Quadrangle();
-  Quadrangle(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-  ~Quadrangle() {}
-  double maxEdge();
-  double minEdge();
-};
-
-class Hexahedron : public Element{
- public:
-  Vertex *V[8];
-  Hexahedron();
-  Hexahedron(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4,
-	     Vertex *v5, Vertex *v6, Vertex *v7, Vertex *v8);
-  ~Hexahedron() {}
-  double Orientation();
-  double maxEdge();
-  double minEdge();
-};
-
-class Prism : public Element{
- public:
-  Vertex *V[6];
-  Prism();
-  Prism(Vertex *v1, Vertex *v2, Vertex *v3, 
-	Vertex *v4, Vertex *v5, Vertex *v6);
-  ~Prism() {}
-  double Orientation();
-  double maxEdge();
-  double minEdge();
-};
-
-class Pyramid : public Element{
- public:
-  Vertex *V[5];
-  Pyramid();
-  Pyramid(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4, Vertex *v5);
-  ~Pyramid() {}
-  double Orientation();
-  double maxEdge();
-  double minEdge();
-};
-
-// C interface
-
-Quadrangle *Create_Quadrangle (Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-Hexahedron *Create_Hexahedron(Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4,
-			      Vertex * v5, Vertex * v6, Vertex * v7, Vertex * v8);
-Prism *Create_Prism(Vertex * v1, Vertex * v2, Vertex * v3,
-		    Vertex * v4, Vertex * v5, Vertex * v6);
-Pyramid *Create_Pyramid(Vertex * v1, Vertex * v2, Vertex * v3,
-			Vertex * v4, Vertex * v5);
-
-void Free_Quadrangle(void *a, void *b);
-void Free_Hexahedron(void *a, void *b);
-void Free_Prism(void *a, void *b);
-void Free_Pyramid(void *a, void *b);
-
-int compareQuadrangle(const void *a, const void *b);
-int compareHexahedron(const void *a, const void *b);
-int comparePrism(const void *a, const void *b);
-int comparePyramid(const void *a, const void *b);
-
-#endif
diff --git a/Mesh/Face.cpp b/Mesh/Face.cpp
deleted file mode 100644
index c2db9dc190bf5d1e9d39434fab626d4c889ba4ad..0000000000000000000000000000000000000000
--- a/Mesh/Face.cpp
+++ /dev/null
@@ -1,332 +0,0 @@
-// $Id: Face.cpp,v 1.4 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-
-// Simplex faces
-
-int trifaces_tetra[4][3] = {
-  {0, 2, 1},
-  {0, 1, 3},
-  {0, 3, 2},
-  {3, 1, 2}
-};
-
-int trifaces_prism[2][3] = {
-  {0, 2, 1},
-  {3, 4, 5}
-};
-
-int trifaces_pyramid[4][3] = {
-  {0, 1, 4},
-  {3, 0, 4},
-  {1, 2, 4},
-  {2, 3, 4}
-};
-
-extern int FACE_DIMENSION;
-
-int compareFace(const void *a, const void *b)
-{
-  Face *q = (Face *) a;
-  Face *w = (Face *) b;
-
-  if(!q->V[0] || !w->V[0])
-    Msg(FATAL, "Bad face (are you trying to generate hexahedra with a Delaunay?!)");
-
-  if(q->V[0]->Num > w->V[0]->Num)
-    return (1);
-  if(q->V[0]->Num < w->V[0]->Num)
-    return (-1);
-
-  if(q->V[1]->Num > w->V[1]->Num)
-    return (1);
-  if(q->V[1]->Num < w->V[1]->Num)
-    return (-1);
-
-  if(FACE_DIMENSION == 1 || !q->V[2] || !w->V[2])
-    return 0;
-
-  if(q->V[2]->Num > w->V[2]->Num)
-    return (1);
-  if(q->V[2]->Num < w->V[2]->Num)
-    return (-1);
-  return (0);
-}
-
-// Quad faces
-
-// define the faces to have exterior normals, so that we can use these
-// structures directly in the drawing routines
-
-// int quadfaces_hexa[6][4] = {
-//   {0, 1, 2, 3},
-//   {0, 1, 4, 5},
-//   {0, 3, 4, 7},
-//   {1, 2, 5, 6},
-//   {2, 3, 6, 7},
-//   {4, 5, 6, 7}
-// };
-
-// int quadfaces_prism[3][4] = {
-//   {0, 1, 3, 4},
-//   {0, 2, 3, 5},
-//   {1, 2, 4, 5}
-// };
-
-// int quadfaces_pyramid[1][4] = {
-//   {0, 1, 2, 3}
-// };
-
-int quadfaces_hexa[6][4] = {
-  {0, 3, 2, 1},
-  {0, 1, 5, 4},
-  {0, 4, 7, 3},
-  {1, 2, 6, 5},
-  {2, 3, 7, 6},
-  {4, 5, 6, 7}
-};
-
-int quadfaces_prism[3][4] = {
-  {0, 1, 4, 3},
-  {0, 3, 5, 2},
-  {1, 2, 5, 4}
-};
-
-int quadfaces_pyramid[1][4] = {
-  {0, 3, 2, 1}
-};
-
-QuadFace::QuadFace()
-{
-  V[0] = V[1] = V[2] = V[3] = NULL;
-  newv = NULL;
-  quad = NULL;
-  hexa[0] = hexa[1] = NULL;
-  prism[0] = prism[1] = NULL;
-  pyramid[0] = pyramid[1] = NULL;
-}
-
-QuadFacesContainer::QuadFacesContainer()
-{
-  AllFaces = Tree_Create(sizeof(QuadFace), compareQuadFace);
-}
-
-QuadFacesContainer::~QuadFacesContainer()
-{
-  Tree_Delete(AllFaces);
-}
-
-void QuadFacesContainer::AddQuadrangleTree(Tree_T *Quadrangles)
-{
-  Quadrangle *q;
-  List_T *temp = Tree2List(Quadrangles);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &q);
-    AddQuadFaces(q);
-  }
-  List_Delete(temp);
-}
-
-void QuadFacesContainer::AddHexahedronTree(Tree_T *Hexahedra)
-{
-  Hexahedron *h;
-  List_T *temp = Tree2List(Hexahedra);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &h);
-    AddQuadFaces(h);
-  }
-  List_Delete(temp);
-}
-
-void QuadFacesContainer::AddPrismTree(Tree_T *Prisms)
-{
-  Prism *p;
-  List_T *temp = Tree2List(Prisms);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &p);
-    AddQuadFaces(p);
-  }
-  List_Delete(temp);
-}
-
-void QuadFacesContainer::AddPyramidTree(Tree_T *Pyramids)
-{
-  Pyramid *p;
-  List_T *temp = Tree2List(Pyramids);
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    List_Read(temp, i, &p);
-    AddQuadFaces(p);
-  }
-  List_Delete(temp);
-}
-
-void QuadFacesContainer::AddQuadFaces(Quadrangle *q)
-{
-  QuadFace F, *pF;
-
-  F.V[0] = q->V[0];
-  F.V[1] = q->V[1];
-  F.V[2] = q->V[2];
-  F.V[3] = q->V[3];
-  qsort(F.V, 4, sizeof(Vertex *), compareVertex);
-
-  if((pF = (QuadFace *) Tree_PQuery(AllFaces, &F))) {
-    if(!pF->quad)
-      pF->quad = q;
-  }
-  else {
-    F.quad = q;
-    F.newv = NULL;
-    Tree_Add(AllFaces, &F);
-  }
-}
-
-void QuadFacesContainer::AddQuadFaces(Hexahedron *h)
-{
-  QuadFace F, *pF;
-
-  for(int i = 0; i < 6; i++) {
-    F.V[0] = h->V[quadfaces_hexa[i][0]];
-    F.V[1] = h->V[quadfaces_hexa[i][1]];
-    F.V[2] = h->V[quadfaces_hexa[i][2]];
-    F.V[3] = h->V[quadfaces_hexa[i][3]];
-    qsort(F.V, 4, sizeof(Vertex *), compareVertex);
-
-    if((pF = (QuadFace *) Tree_PQuery(AllFaces, &F))) {
-      if(!pF->hexa[0])
-	pF->hexa[0] = h;
-      else if(!pF->hexa[1])
-	pF->hexa[1] = h;
-    }
-    else {
-      F.hexa[0] = h;
-      F.newv = NULL;
-      Tree_Add(AllFaces, &F);
-    }
-  }
-}
-
-void QuadFacesContainer::AddQuadFaces(Prism *p)
-{
-  QuadFace F, *pF;
-
-  for(int i = 0; i < 3; i++) {
-    F.V[0] = p->V[quadfaces_prism[i][0]];
-    F.V[1] = p->V[quadfaces_prism[i][1]];
-    F.V[2] = p->V[quadfaces_prism[i][2]];
-    F.V[3] = p->V[quadfaces_prism[i][3]];
-    qsort(F.V, 4, sizeof(Vertex *), compareVertex);
-
-    if((pF = (QuadFace *) Tree_PQuery(AllFaces, &F))) {
-      if(!pF->prism[0])
-	pF->prism[0] = p;
-      else if(!pF->prism[1])
-	pF->prism[1] = p;
-    }
-    else {
-      F.prism[0] = p;
-      F.newv = NULL;
-      Tree_Add(AllFaces, &F);
-    }
-  }
-}
-
-void QuadFacesContainer::AddQuadFaces(Pyramid *p)
-{
-  QuadFace F, *pF;
-
-  F.V[0] = p->V[quadfaces_pyramid[0][0]];
-  F.V[1] = p->V[quadfaces_pyramid[0][1]];
-  F.V[2] = p->V[quadfaces_pyramid[0][2]];
-  F.V[3] = p->V[quadfaces_pyramid[0][3]];
-  qsort(F.V, 4, sizeof(Vertex *), compareVertex);
-
-  if((pF = (QuadFace *) Tree_PQuery(AllFaces, &F))) {
-    if(!pF->pyramid[0])
-      pF->pyramid[0] = p;
-    else if(!pF->pyramid[1])
-      pF->pyramid[1] = p;
-  }
-  else {
-    F.pyramid[0] = p;
-    F.newv = NULL;
-    Tree_Add(AllFaces, &F);
-  }
-}
-
-void QuadFacesContainer::Print()
-{
-  List_T *temp = Tree2List(AllFaces);
-  printf("Print QuadFaces START\n");
-  for(int i = 0; i < List_Nbr(temp); i++) {
-    QuadFace *f = (QuadFace*)List_Pointer(temp, i);
-    printf("quadface %d %d %d %d", 
-	   f->V[0]->Num, f->V[1]->Num, f->V[2]->Num, f->V[3]->Num);
-    if(f->quad)
-      printf(", in quad %d", f->quad->Num);
-    if(f->hexa[0])
-      printf(", in hexa %d", f->hexa[0]->Num);
-    if(f->hexa[1])
-      printf(" %d", f->hexa[1]->Num);
-    if(f->prism[0])
-      printf(", in prism %d", f->prism[0]->Num);
-    if(f->prism[1])
-      printf(" %d", f->prism[1]->Num);
-    if(f->pyramid[0])
-      printf(", in pyramid %d", f->pyramid[0]->Num);
-    if(f->pyramid[1])
-      printf(" %d", f->pyramid[1]->Num);
-    printf("\n");
-  }
-  printf("Print QuadFacess STOP\n");
-  List_Delete(temp);
-}
-
-int compareQuadFace(const void *a, const void *b)
-{
-  QuadFace *q = (QuadFace *) a;
-  QuadFace *w = (QuadFace *) b;
-
-  if(q->V[0]->Num > w->V[0]->Num)
-    return 1;
-  if(q->V[0]->Num < w->V[0]->Num)
-    return -1;
-
-  if(q->V[1]->Num > w->V[1]->Num)
-    return 1;
-  if(q->V[1]->Num < w->V[1]->Num)
-    return -1;
-
-  if(q->V[2]->Num > w->V[2]->Num)
-    return 1;
-  if(q->V[2]->Num < w->V[2]->Num)
-    return -1;
-
-  if(q->V[3]->Num > w->V[3]->Num)
-    return 1;
-  if(q->V[3]->Num < w->V[3]->Num)
-    return -1;
-
-  return 0;
-}
diff --git a/Mesh/Face.h b/Mesh/Face.h
deleted file mode 100644
index 0557a6105df715cc5ba062ef4499694bbba0d240..0000000000000000000000000000000000000000
--- a/Mesh/Face.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef _FACE_H_
-#define _FACE_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "List.h"
-#include "Tree.h"
-#include "Vertex.h"
-#include "Element.h"
-
-typedef struct {
-  Vertex *V[3];
-} Face;
-
-class QuadFace
-{
- public:
-  Vertex *V[4];
-  Vertex *newv;
-  Quadrangle *quad;
-  Hexahedron *hexa[2];
-  Prism *prism[2];
-  Pyramid *pyramid[2];
-  QuadFace();
-  ~QuadFace(){;}
-};
-
-class QuadFacesContainer
-{
- public :
-  Tree_T *AllFaces;
-  QuadFacesContainer();
-  ~QuadFacesContainer();
-  void AddQuadrangleTree(Tree_T *Quadrangles);
-  void AddHexahedronTree(Tree_T *Hexahedra);
-  void AddPrismTree(Tree_T *Prisms);    
-  void AddPyramidTree(Tree_T *Pyramids);
-  void AddQuadFaces(Quadrangle *q);
-  void AddQuadFaces(Hexahedron *h);
-  void AddQuadFaces(Prism *p);
-  void AddQuadFaces(Pyramid *p);
-  void Print();
-};
-
-int compareFace(const void *a, const void *b);
-int compareQuadFace(const void *a, const void *b);
-
-#endif
diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp
index fff0dfc1de1a30b88031367dc7429ff56c24e5e2..db04474e1ebe34a726026b17b2f6af2adacb567c 100644
--- a/Mesh/Generator.cpp
+++ b/Mesh/Generator.cpp
@@ -1,4 +1,4 @@
-// $Id: Generator.cpp,v 1.98 2006-09-15 00:55:40 geuzaine Exp $
+// $Id: Generator.cpp,v 1.99 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -22,12 +22,10 @@
 #include "Gmsh.h"
 #include "Numeric.h"
 #include "Mesh.h"
-#include "BDS.h"
 #include "Create.h"
 #include "Context.h"
 #include "OpenFile.h"
 #include "Views.h"
-#include "PartitionMesh.h"
 #include "OS.h"
 #include "meshGEdge.h"
 #include "meshGFace.h"
@@ -194,50 +192,9 @@ void ApplyLcFactor_Point(void *a, void *b)
   v->lc *= CTX.mesh.lc_factor;
 }
 
-void ApplyLcFactor_Attractor(void *a, void *b)
-{
-  Attractor *v = *(Attractor **) a;
-  v->lc1 *= CTX.mesh.lc_factor;
-  v->lc2 *= CTX.mesh.lc_factor;
-}
-
 void ApplyLcFactor()
 {
   Tree_Action(THEM->Points, ApplyLcFactor_Point);
-  List_Action(THEM->Metric->Attractors, ApplyLcFactor_Attractor);
-}
-
-void Move_SimplexBaseToSimplex(int dimension)
-{
-  if(dimension >= 1){
-    List_T *Curves = Tree2List(THEM->Curves);
-    for(int i = 0; i < List_Nbr(Curves); i++) {
-      Curve *c;
-      List_Read(Curves, i, &c);
-      Move_SimplexBaseToSimplex(&c->SimplexesBase, c->Simplexes);
-    }
-    List_Delete(Curves);
-  }
-
-  if(dimension >= 2){
-    List_T *Surfaces = Tree2List(THEM->Surfaces);
-    for(int i = 0; i < List_Nbr(Surfaces); i++){
-      Surface *s;
-      List_Read(Surfaces, i, &s);
-      Move_SimplexBaseToSimplex(&s->SimplexesBase, s->Simplexes);
-    }
-    List_Delete(Surfaces);
-  }
-  
-  if(dimension >= 3){
-    List_T *Volumes = Tree2List(THEM->Volumes);
-    for(int i = 0; i < List_Nbr(Volumes); i++){
-      Volume *v;
-      List_Read(Volumes, i, &v);
-      Move_SimplexBaseToSimplex(&v->SimplexesBase, v->Simplexes);
-    }
-    List_Delete(Volumes);
-  }
 }
 
 bool TooManyElements(int dim){
@@ -297,10 +254,7 @@ void Maillage_Dimension_3()
 
 void Init_Mesh0()
 {
-  THEM->bds = 0;
-  THEM->bds_mesh = 0;
   THEM->Vertices = NULL;
-  THEM->Simplexes = NULL;
   THEM->Points = NULL;
   THEM->Curves = NULL;
   THEM->SurfaceLoops = NULL;
@@ -309,7 +263,6 @@ void Init_Mesh0()
   THEM->Volumes = NULL;
   THEM->PhysicalGroups = NULL;
   THEM->Partitions = NULL;
-  THEM->Metric = NULL;
 }
 
 void Init_Mesh()
@@ -322,24 +275,12 @@ void Init_Mesh()
   THEM->MaxVolumeNum = 0;
   THEM->MaxPhysicalNum = 0;
 
-  Element::TotalNumber = 0;
-
-  ExitExtrude();
-
-  if(THEM->bds) delete THEM->bds;
-  THEM->bds = 0;
-
   Tree_Action(THEM->Vertices, Free_Vertex);  
   Tree_Delete(THEM->Vertices);
 
   Tree_Action(THEM->Points, Free_Vertex);  
   Tree_Delete(THEM->Points);
 
-  // Note: don't free the simplices here (with Tree_Action
-  // (THEM->Simplexes, Free_Simplex)): we free them in each curve,
-  // surface, volume
-  Tree_Delete(THEM->Simplexes);
-
   Tree_Action(THEM->Curves, Free_Curve);
   Tree_Delete(THEM->Curves);
 
@@ -361,11 +302,7 @@ void Init_Mesh()
   List_Action(THEM->Partitions, Free_MeshPartition);
   List_Delete(THEM->Partitions);
 
-  if(THEM->Metric)
-    delete THEM->Metric;
-
   THEM->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
-  THEM->Simplexes = Tree_Create(sizeof(Simplex *), compareSimplex);
   THEM->Points = Tree_Create(sizeof(Vertex *), compareVertex);
   THEM->Curves = Tree_Create(sizeof(Curve *), compareCurve);
   THEM->SurfaceLoops = Tree_Create(sizeof(SurfaceLoop *), compareSurfaceLoop);
@@ -374,7 +311,6 @@ void Init_Mesh()
   THEM->Volumes = Tree_Create(sizeof(Volume *), compareVolume);
   THEM->PhysicalGroups = List_Create(5, 5, sizeof(PhysicalGroup *));
   THEM->Partitions = List_Create(5, 5, sizeof(MeshPartition *));
-  THEM->Metric = new GMSHMetric;
   THEM->status = 0;
 
   CTX.mesh.bgmesh_type = WITHPOINTS;
@@ -433,16 +369,13 @@ void mai3d(int ask)
 
   // Optimize quality
   if(GMODEL->getMeshStatus() == 3 && CTX.mesh.optimize)
-    Optimize_Netgen();
+    Msg(GERROR, "Mesh optimize has yet to be reinterfaced");
+  //Optimize_Netgen();
 
   // Create second order elements
   if(GMODEL->getMeshStatus() && CTX.mesh.order == 2) 
     Degre2(CTX.mesh.second_order_linear, CTX.mesh.second_order_incomplete);
 
-  // Partition
-  if(GMODEL->getMeshStatus() > 1 && CTX.mesh.nbPartitions != 1)
-    PartitionMesh(THEM, CTX.mesh.nbPartitions);
-
   Msg(STATUS1, "Mesh");
   CTX.threads_lock = 0;
   CTX.mesh.changed = ENT_ALL;
diff --git a/Mesh/Interpolation.cpp b/Mesh/Interpolation.cpp
index 9b901ed89e154c25e7e93d15af1662db6f34b59e..685a9ac52edc02da8782ab17b78ebfb421a4fcd4 100644
--- a/Mesh/Interpolation.cpp
+++ b/Mesh/Interpolation.cpp
@@ -1,4 +1,4 @@
-// $Id: Interpolation.cpp,v 1.29 2006-11-25 00:44:25 geuzaine Exp $
+// $Id: Interpolation.cpp,v 1.30 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -324,6 +324,27 @@ void TransfiniteSph(Vertex S, Vertex center, Vertex * T)
   T->Pos.Z = center.Pos.Z + r * dirz;
 }
 
+void Calcule_Z_Plan(void *data, Surface *THESURFACE)
+{
+  Vertex **pv, *v;
+  Vertex V;
+
+  V.Pos.X = THESURFACE->a;
+  V.Pos.Y = THESURFACE->b;
+  V.Pos.Z = THESURFACE->c;
+
+  Projette(&V, THESURFACE->plan);
+
+  pv = (Vertex **) data;
+  v = *pv;
+  if(V.Pos.Z != 0.0)
+    v->Pos.Z = (THESURFACE->d - V.Pos.X * v->Pos.X - V.Pos.Y * v->Pos.Y)
+      / V.Pos.Z;
+  else
+    v->Pos.Z = 0.0;
+}
+
+
 Vertex InterpolateSurface(Surface * s, double u, double v,
                           int derivee, int u_v)
 {
@@ -397,7 +418,7 @@ Vertex InterpolateSurface(Surface * s, double u, double v,
 
   case MSH_SURF_PLAN:
 
-    Calcule_Z_Plan(&xx, &dum);
+    Calcule_Z_Plan(&xx, s);
     //Projette_Inverse(&xx, &dum);
     return x;
 
diff --git a/Mesh/Makefile b/Mesh/Makefile
index 5634f9c59a32e7453a541431dcd0b8f19167c416..8a1547e89669ee1ef00cd6c717ceb960464ad199 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.137 2006-11-16 18:48:01 geuzaine Exp $
+# $Id: Makefile,v 1.138 2006-11-25 02:47:40 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -30,39 +30,12 @@ INCLUDE = -I../Numeric -I../Common -I../DataStr -I../Geo -I../Mesh\
           -I../contrib/Metis
 CFLAGS  =  ${OPTIM} ${FLAGS} ${INCLUDE} 
 
-SRC = 1D_Mesh.cpp \
-      2D_Mesh.cpp \
-        2D_Transfinite.cpp \
-        2D_Elliptic.cpp \
-        2D_BGMesh.cpp \
-        2D_Recombine.cpp \
-        2D_InitMesh.cpp \
-        2D_Bowyer.cpp \
-        2D_Bricks.cpp \
-        2D_DivAndConq.cpp \
-        2D_Util.cpp \
-        2D_Links.cpp \
-        2D_Tree.cpp \
-        2D_Cylindrical.cpp \
-        2D_Parametric.cpp \
-        2D_Mesh_Aniso.cpp \
-        2D_Mesh_Triangle.cpp \
-        3D_Mesh.cpp \
-        3D_Transfinite.cpp \
-        3D_BGMesh.cpp \
-        3D_Extrude.cpp \
-        3D_Extrude_Old.cpp \
-        3D_Coherence.cpp \
-        3D_Divide.cpp \
-        3D_Mesh_Netgen.cpp \
-        3D_Mesh_Tetgen.cpp \
+SRC = DivideAndConquer.cpp \
+      BackgroundMesh.cpp \
       BDS.cpp \
       Create.cpp \
       Generator.cpp \
-      DiscreteSurface.cpp \
-      SwapEdge.cpp \
       Utils.cpp \
-      Metric.cpp \
       meshGEdge.cpp \
       meshGFace.cpp \
       meshGFaceTransfinite.cpp \
@@ -71,14 +44,7 @@ SRC = 1D_Mesh.cpp \
       Nurbs.cpp \
       Interpolation.cpp \
       SecondOrder.cpp \
-      PartitionMesh.cpp\
-      Smoothing.cpp \
-      CrossData.cpp \
-      Vertex.cpp \
-      Edge.cpp \
-      Face.cpp \
-      Element.cpp \
-      Simplex.cpp 
+      Vertex.cpp
 
 OBJ = ${SRC:.cpp=.o}
 
@@ -110,227 +76,49 @@ depend:
 	rm -f Makefile.new
 
 # DO NOT DELETE THIS LINE
-1D_Mesh.o: 1D_Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h \
-  Vertex.h Element.h Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h \
-  Metric.h Matrix.h Utils.h ../Common/Context.h Interpolation.h
-2D_Mesh.o: 2D_Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h Utils.h Vertex.h \
-  Create.h 2D_Mesh.h ../Common/Context.h Interpolation.h
-2D_Transfinite.o: 2D_Transfinite.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  ../Numeric/Numeric.h Interpolation.h
-2D_Elliptic.o: 2D_Elliptic.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h
-2D_BGMesh.o: 2D_BGMesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h
-2D_Recombine.o: 2D_Recombine.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h \
-  Vertex.h Element.h Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h \
-  Metric.h Matrix.h Interpolation.h Utils.h 2D_Mesh.h Create.h \
-  ../Common/Context.h
-2D_InitMesh.o: 2D_InitMesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h
-2D_Bowyer.o: 2D_Bowyer.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h
-2D_Bricks.o: 2D_Bricks.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h
-2D_DivAndConq.o: 2D_DivAndConq.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h
-2D_Util.o: 2D_Util.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h ../Common/Context.h
-2D_Links.o: 2D_Links.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  2D_Mesh.h ../Common/Context.h
-2D_Tree.o: 2D_Tree.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h 2D_Mesh.h
-2D_Cylindrical.o: 2D_Cylindrical.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  ../Common/Context.h
-2D_Parametric.o: 2D_Parametric.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Interpolation.h Vertex.h Mesh.h \
-  2D_Mesh.h Create.h ../Common/Context.h
-2D_Mesh_Aniso.o: 2D_Mesh_Aniso.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h Interpolation.h Vertex.h \
-  Create.h ../Common/Context.h
-2D_Mesh_Triangle.o: 2D_Mesh_Triangle.cpp ../Common/Gmsh.h \
+DivideAndConquer.o: DivideAndConquer.cpp ../Common/Gmsh.h \
   ../Common/Message.h ../DataStr/Malloc.h ../DataStr/List.h \
   ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h \
-  ../DataStr/Tree.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  ../Numeric/Numeric.h ../Common/Context.h
-3D_Mesh.o: 3D_Mesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h \
-  Vertex.h Element.h Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h \
-  Metric.h Matrix.h 3D_Mesh.h Create.h ../Common/Context.h
-3D_Transfinite.o: 3D_Transfinite.cpp ../Common/Gmsh.h ../Common/Message.h \
+  ../DataStr/Tree.h ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h \
+  Vertex.h ../Geo/ExtrudeParams.h ../Common/Context.h
+BackgroundMesh.o: BackgroundMesh.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h Interpolation.h \
-  Create.h
-3D_BGMesh.o: 3D_BGMesh.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h ../Common/Views.h \
-  ../Common/ColorTable.h ../Common/VertexArray.h \
+  Mesh.h ../Common/GmshDefines.h Vertex.h ../Geo/ExtrudeParams.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
   ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Context.h \
   ../Common/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h
-3D_Extrude.o: 3D_Extrude.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h ../Common/Context.h \
-  Create.h Vertex.h
-3D_Extrude_Old.o: 3D_Extrude_Old.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h ../Common/Context.h \
-  Create.h Vertex.h
-3D_Coherence.o: 3D_Coherence.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h \
-  Vertex.h Element.h Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h \
-  Metric.h Matrix.h 3D_Mesh.h Create.h
-3D_Divide.o: 3D_Divide.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h
-3D_Mesh_Netgen.o: 3D_Mesh_Netgen.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  Create.h ../Numeric/Numeric.h ../Common/Context.h ../Common/OS.h
-3D_Mesh_Tetgen.o: 3D_Mesh_Tetgen.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h Create.h \
-  ../Numeric/Numeric.h ../Common/Context.h
 BDS.o: BDS.cpp ../Numeric/Numeric.h ../Common/GmshMatrix.h BDS.h \
   ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/GmshDefines.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/MVertex.h \
-  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Context.h \
-  ../DataStr/List.h ../Geo/ExtrudeParams.h ../Geo/MElement.h \
-  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h \
-  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
-  ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
-  ../Common/GmshMatrix.h ../Common/Message.h
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
+  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/ExtrudeParams.h ../Common/Views.h ../Common/ColorTable.h \
+  ../Common/VertexArray.h ../Common/SmoothNormals.h \
+  ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Common/Message.h
 Create.o: Create.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h Utils.h Vertex.h \
-  ../Common/Context.h Create.h
+  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
+  ../Geo/ExtrudeParams.h Mesh.h Utils.h Vertex.h ../Common/Context.h \
+  Create.h
 Generator.o: Generator.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h BDS.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h \
+  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h \
+  ../Geo/ExtrudeParams.h BDS.h ../Geo/GFace.h ../Geo/GPoint.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
   ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
   ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
@@ -339,85 +127,61 @@ Generator.o: Generator.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Geo/ExtrudeParams.h ../Common/Views.h ../Common/ColorTable.h \
   ../Common/VertexArray.h ../Common/SmoothNormals.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h Create.h \
-  ../Parser/OpenFile.h PartitionMesh.h ../Common/OS.h meshGEdge.h \
-  meshGFace.h meshGRegion.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h
-DiscreteSurface.o: DiscreteSurface.cpp Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h
-SwapEdge.o: SwapEdge.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  SwapPatterns.h
+  ../Parser/OpenFile.h ../Common/OS.h meshGEdge.h meshGFace.h \
+  meshGRegion.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h \
+  ../Geo/GFace.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/MElement.h \
+  ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h
 Utils.o: Utils.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h Interpolation.h Vertex.h \
+  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
+  ../Geo/ExtrudeParams.h Mesh.h Interpolation.h Vertex.h \
   ../Common/Context.h
-Metric.o: Metric.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Mesh.h Matrix.h Interpolation.h \
-  Vertex.h
 meshGEdge.o: meshGEdge.cpp meshGEdge.h ../Geo/GEdge.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/GmshDefines.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Common/Context.h \
-  ../DataStr/List.h ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h \
-  ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h \
-  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h \
-  ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h \
-  ../DataStr/Tree.h Utils.h Vertex.h Mesh.h Element.h Simplex.h Face.h \
-  Edge.h Metric.h Matrix.h
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
+  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
+  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Common/Gmsh.h \
+  ../Common/Message.h ../DataStr/Malloc.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
+  Utils.h Vertex.h Mesh.h
 meshGFace.o: meshGFace.cpp meshGFace.h ../Geo/GVertex.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/GmshDefines.h ../Geo/MVertex.h \
-  ../Geo/SPoint3.h ../Geo/GPoint.h 2D_Mesh.h ../DataStr/List.h \
-  ../DataStr/Tree.h ../DataStr/avl.h Mesh.h Vertex.h Element.h Simplex.h \
-  Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h ../Geo/GEdge.h \
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
   ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
   ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
   ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../Geo/ExtrudeParams.h ../Geo/GFace.h \
-  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
-  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/ExtrudeParams.h Utils.h ../Common/Message.h BDS.h \
+  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
+  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
+  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/Pair.h ../Geo/ExtrudeParams.h Utils.h Vertex.h Mesh.h \
+  ../DataStr/Tree.h ../DataStr/avl.h ../Common/Message.h BDS.h \
   ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
   ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
   ../Common/GmshMatrix.h
 meshGFaceTransfinite.o: meshGFaceTransfinite.cpp meshGFace.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Common/Message.h
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h \
+  ../Common/Message.h
 meshGRegionDelaunayInsertion.o: meshGRegionDelaunayInsertion.cpp \
   meshGRegionDelaunayInsertion.h ../Geo/MElement.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
@@ -430,88 +194,52 @@ meshGRegionDelaunayInsertion.o: meshGRegionDelaunayInsertion.cpp \
 meshGRegion.o: meshGRegion.cpp meshGRegion.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
-  ../Common/SmoothNormals.h BDS.h ../Common/Views.h \
-  ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h BDS.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
   ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
   ../Common/GmshMatrix.h ../Common/Message.h
 Nurbs.o: Nurbs.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Nurbs.h Vertex.h Mesh.h ../Common/GmshDefines.h Element.h Simplex.h \
-  Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h ../Geo/Geo.h \
-  ../Geo/GeoUtils.h ../Mesh/Mesh.h Create.h ../Geo/CAD.h ../Mesh/Vertex.h \
-  ../Geo/ExtrudeParams.h
+  Nurbs.h Vertex.h Mesh.h ../Common/GmshDefines.h ../Geo/ExtrudeParams.h \
+  ../Geo/Geo.h ../Geo/GeoUtils.h ../Mesh/Mesh.h Create.h ../Geo/CAD.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h
 Interpolation.o: Interpolation.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Numeric/Numeric.h ../Geo/Geo.h Nurbs.h Vertex.h Mesh.h \
-  ../Common/GmshDefines.h Element.h Simplex.h Face.h Edge.h \
-  ../Geo/ExtrudeParams.h Metric.h Matrix.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h Utils.h Interpolation.h
+  ../Common/GmshDefines.h ../Geo/ExtrudeParams.h ../Geo/CAD.h \
+  ../Mesh/Mesh.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h Utils.h \
+  Interpolation.h
 SecondOrder.o: SecondOrder.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/GEdge.h \
-  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
-  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Common/Context.h ../DataStr/List.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
-  ../Common/SmoothNormals.h ../Geo/MRep.h ../Geo/GEdge.h ../Geo/GFace.h \
-  ../Geo/GRegion.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MElement.h \
-  ../Common/VertexArray.h ../Common/Message.h ../Common/OS.h
-PartitionMesh.o: PartitionMesh.cpp Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  PartitionMesh.h
-Smoothing.o: Smoothing.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Mesh.h ../Common/GmshDefines.h Vertex.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h
-CrossData.o: CrossData.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h \
+  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h \
+  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Numeric/Numeric.h ../Common/Context.h ../DataStr/List.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h ../Geo/MRep.h \
+  ../Geo/GEdge.h ../Geo/GFace.h ../Geo/GRegion.h ../Geo/MVertex.h \
+  ../Geo/MEdge.h ../Geo/MElement.h ../Common/VertexArray.h \
+  ../Common/Message.h ../Common/OS.h
 Vertex.o: Vertex.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h Vertex.h Mesh.h ../Common/GmshDefines.h Element.h \
-  Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h \
-  ../Common/Context.h
-Edge.o: Edge.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Numeric/Numeric.h Mesh.h \
-  ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h Edge.h \
-  ../Geo/ExtrudeParams.h Metric.h Matrix.h
-Face.o: Face.cpp ../Common/Gmsh.h ../Common/Message.h ../DataStr/Malloc.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Numeric/Numeric.h Mesh.h \
-  ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h Edge.h \
-  ../Geo/ExtrudeParams.h Metric.h Matrix.h
-Element.o: Element.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  Mesh.h ../Common/GmshDefines.h Vertex.h Element.h Simplex.h Face.h \
-  Edge.h ../Geo/ExtrudeParams.h Metric.h Matrix.h ../Numeric/Numeric.h
-Simplex.o: Simplex.cpp ../Common/Gmsh.h ../Common/Message.h \
-  ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
-  ../Numeric/Numeric.h ../Geo/Geo.h Mesh.h ../Common/GmshDefines.h \
-  Vertex.h Element.h Simplex.h Face.h Edge.h ../Geo/ExtrudeParams.h \
-  Metric.h Matrix.h ../Common/Context.h
+  ../Numeric/Numeric.h Vertex.h Mesh.h ../Common/GmshDefines.h \
+  ../Geo/ExtrudeParams.h ../Common/Context.h
diff --git a/Mesh/Mesh.h b/Mesh/Mesh.h
index 6a42091f517a6ee45a767fb8d594639e4650f016..049ce33bc4836805a62bf17816dfdda0041b0e2e 100644
--- a/Mesh/Mesh.h
+++ b/Mesh/Mesh.h
@@ -24,9 +24,6 @@
 #include "List.h"
 #include "Tree.h"
 #include "Vertex.h"
-#include "Element.h"
-#include "Simplex.h"
-#include "Edge.h"
 #include "ExtrudeParams.h"
 
 class BDS_Mesh;
@@ -127,14 +124,6 @@ struct _MAILLAGE{
   int zone;
 };
 
-class NXE{
- public :
-  Vertex *v;
-  List_T *Liste;
-  ~NXE();
-  NXE();
-};
-
 typedef struct{
   double zaxis[3];
   double radius1;
@@ -169,11 +158,8 @@ struct _Surf{
   double a, b, c, d;
   List_T *Orientations;
   List_T *Contours;
-  Tree_T *Simplexes, *SimplexesBase;
-  Tree_T *Quadrangles;
   Tree_T *Vertices;
   List_T *TrsfVertices;
-  Tree_T *Edges;
   int OrderU, OrderV;
   float *ku, *kv, *cp;
   struct _Surf *Support;
@@ -207,13 +193,6 @@ typedef struct{
   char Visible;
 }MeshPartition;
 
-typedef struct{
-  Face F;
-  Face Sorted;
-  Simplex *S[2];
-  int N;
-}FxE;
-
 typedef struct {
   int Num;
   int Typ;
@@ -225,42 +204,9 @@ typedef struct {
   List_T *Surfaces;
   List_T *SurfacesOrientations;
   Tree_T *Vertices;
-  Tree_T *Edges;
-  Tree_T *Faces;
-  Tree_T *Simplexes, *SimplexesBase;
-  Tree_T *Lin_Surf; // for old extrusion mesh generator
-  Tree_T *Simp_Surf; // for old extrusion mesh generator
-  Tree_T *Quad_Surf; // for old extrusion mesh generator
-  Tree_T *Hexahedra;
-  Tree_T *Prisms;
-  Tree_T *Pyramids;
   DrawingColor Color;
 }Volume;
 
-typedef struct {
-  Edge e1, e2;
-  int iFac;
-}exf_T;
-
-// Edge-Simplex intersections
-
-typedef struct{
-  int NbIntersect;      // nombre total d'intersections
-  Edge *e;              // arete
-  Simplex *s;           // simplexe
-  Face *f;              // face
-  int NbVertex;         // nombre de noeuds du simplexe que coupe l'arete
-  Vertex *V[12];        // noeuds du simplexe que coupe l'arete
-  int iV[12];           // noeuds du simplexe que coupe l'arete
-  int NbEdge;           // nombre d'intersections arete-arete
-  int E[12];            // aretes
-  Vertex *VE[12];       // noeuds d'intersection
-  int NbFace;           // nombre d'intersections face-arete
-  Face *F[12];          // faces
-  int iF[12];           // faces
-  Vertex *VF[12];       // position des points d'intersections face-arete
-}Intersection;
-
 typedef struct _Mesh Mesh;
 
 typedef struct{
@@ -283,7 +229,6 @@ typedef struct{
   double ubeg, uend;
   List_T *Control_Points;
   List_T *Vertices;
-  Tree_T *Simplexes, *SimplexesBase;
   ExtrudeParams *Extrude;
   float *k, *cp;
   int degre;
@@ -292,24 +237,11 @@ typedef struct{
   DrawingColor Color;
 }Curve;
 
-typedef struct{
-  int Num;
-  int Typ;
-  Vertex *v;
-  Curve *c;
-  Surface *s;
-  double lc1, lc2;
-  double Radius;
-}Attractor;
-
-#include "Metric.h"
-
 struct _Mesh{
   char name[256];
   int status; // current state of the mesh
   Tree_T *Points;
   Tree_T *Vertices;
-  Tree_T *Simplexes;
   Tree_T *Curves;
   Tree_T *Surfaces;
   Tree_T *Volumes;
@@ -317,85 +249,24 @@ struct _Mesh{
   Tree_T *EdgeLoops;
   List_T *PhysicalGroups;
   List_T *Partitions;
-  GMSHMetric *Metric;
   BDS_Mesh *bds;
   BDS_Mesh *bds_mesh;
   int MaxPointNum, MaxLineNum, MaxLineLoopNum, MaxSurfaceNum;
   int MaxSurfaceLoopNum, MaxVolumeNum, MaxPhysicalNum;
 };
 
-typedef struct {
-  Simplex *S;
-  Face F;
-  int NumFaceSimpl;
-}SxF;
-
-struct Map{
-  int Num;
-  List_T *List;
-};
-
-
 // public functions
 
 void mai3d(int Asked);
-
 void Init_Mesh0();
 void Init_Mesh();
-
 void Maillage_Dimension_1();
 void Maillage_Dimension_2();
 void Maillage_Dimension_3();
-
-void Maillage_Curve(void *data, void *dummy);
-void Maillage_Surface(void *data, void *dum);
-void Maillage_Volume(void *data, void *dum);
-
-int Extrude_Mesh(Curve *c);
-int Extrude_Mesh(Surface *s);
-int Extrude_Mesh(Volume *v);
-int Extrude_Mesh(Tree_T *Volumes);
-void ExitExtrude();
-void Extrude_Mesh_Old();
-
-int MeshTransfiniteSurface(Surface *sur);
-int MeshTransfiniteVolume(Volume *vol);
-int MeshCylindricalSurface(Surface *s);
-int MeshParametricSurface(Surface *s);
-int MeshEllipticSurface(Surface *sur);
-int MeshDiscreteSurface(Surface *sur);
-int MeshDiscreteCurve(Curve *c);
-int ReMesh();
-
-int AlgorithmeMaillage2DAnisotropeModeJF(Surface *s);
-void Maillage_Automatique_VieuxCode(Surface *pS, int ori);
-int Mesh_Triangle(Surface *s);
-int Mesh_Netgen(Volume *v);
-int Mesh_Tetgen(Volume *v);
-void Optimize_Netgen(Volume *v);
-void Optimize_Netgen();
-
-int Calcule_Contours(Surface *s);
-void Link_Simplexes(List_T *Sim, Tree_T *Tim);
-void Calcule_Z(void *data, void *dum);
-void Calcule_Z_Plan(void *data, void *dum);
-void Projette_Plan_Moyen(void *a, void *b);
-void Projette_Inverse(void *a, void *b);
-void Freeze_Vertex(void *a, void *b);
-void deFreeze_Vertex(void *a, void *b);
-void ReOrientSurfaceMesh(Surface *s);
-
-void Move_SimplexBaseToSimplex(int dimension);
-
+void Make_Mesh_With_Points(DocRecord * ptr, PointRecord * Liste, int Numpoints);
 double BGMXYZ(double X, double Y, double Z);
 int BGMExists();
-void ActionLiss(void *data, void *dummy);
-void ActionLissSurf(void *data, void *dummy);
-int Recombine(Tree_T *TreeAllVert, Tree_T *TreeAllSimp, Tree_T *TreeAllQuad,
-		double a);
-int Recombine_All(Mesh *M);
 void ApplyLcFactor();
-
 void Degre1();
 void Degre2(bool linear=true, bool incomplete=false);
 
diff --git a/Mesh/Metric.cpp b/Mesh/Metric.cpp
deleted file mode 100644
index 2fc659ea82919095308dc37e988e58fef9c817b0..0000000000000000000000000000000000000000
--- a/Mesh/Metric.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-// $Id: Metric.cpp,v 1.21 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include <time.h>
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "CAD.h"
-#include "Mesh.h"
-#include "Matrix.h"
-#include "Interpolation.h"
-
-Matrix3x3 Matrix3x3::operator *(const Matrix3x3 & autre)
-{
-  Matrix3x3 m(0.);
-  for(int i = 0; i < 3; i++) {
-    for(int j = 0; j < 3; j++) {
-      for(int k = 0; k < 3; k++)
-        m.mat[i][j] += mat[i][k] * autre.mat[k][j];
-      if(fabs(m.mat[i][j]) < 1.e-15)
-        m.mat[i][j] = 0.0;
-    }
-  }
-  return m;
-}
-
-void Matrix3x3::setMetric()
-{
-  Matrix3x3 rot(eVec[0], eVec[1], eVec[2]);
-  Matrix3x3 rotT(eVec[0], eVec[1], eVec[2]);
-  Matrix3x3 Id(0.0);
-  rotT.transpose();
-  Id.Identity(1.0);
-  for(int i = 0; i < 3; i++)
-    Id.mat[i][i] = eVal[i];
-  Matrix3x3 kk = (Id * rot);
-  Matrix3x3 m = rotT * kk;
-  /*
-     Msg(INFO,"rot: %g %g %g %g %g %g %g %g %g \n  ", 
-     rot[0][0], rot[0][1], rot[0][2],
-     rot[1][0], rot[1][1], rot[1][2],
-     rot[2][0], rot[2][1], rot[2][2]);                
-     Msg(INFO,"rotT: %g %g %g %g %g %g %g %g %g \n  ", 
-     rotT[0][0], rotT[0][1], rotT[0][2],
-     rotT[1][0], rotT[1][1], rotT[1][2],
-     rotT[2][0], rotT[2][1], rotT[2][2]);                     
-     Msg(INFO,"id: %g %g %g %g %g %g %g %g %g \n  ", 
-     Id[0][0], Id[0][1], Id[0][2],
-     Id[1][0], Id[1][1], Id[1][2],
-     Id[2][0], Id[2][1], Id[2][2]);                   
-
-     Msg(INFO,"kk: %g %g %g %g %g %g %g %g %g \n  ", 
-     kk[0][0], kk[0][1], kk[0][2],
-     kk[1][0], kk[1][1], kk[1][2],
-     kk[2][0], kk[2][1], kk[2][2]);                   
-
-     Msg(INFO,"m: %g %g %g %g %g %g %g %g %g \n  ", 
-     m[0][0], m[0][1], m[0][2],
-     m[1][0], m[1][1], m[1][2],
-     m[2][0], m[2][1], m[2][2]);                      
-   */
-  for(int i = 0; i < 3; i++)
-    for(int j = 0; j < 3; j++)
-      mat[i][j] = m.mat[i][j];
-}
-
-
-GMSHMetric::GMSHMetric()
-{
-  Identity();
-  Attractors = List_Create(2, 2, sizeof(Attractor *));
-  limite_aniso = 3000.;
-  min_cos = 0.0095;
-  quality_measure = QUALITY_SIMPLEX_BASED;
-}
-
-
-Matrix3x3 GMSHMetric::Intersect2Metrics(Matrix3x3 * m1[2])
-{
-  double lmax = 0.;
-  int im = 0, ic = 0, io = 0;
-  Vector3 cmax(0., 0, 0, 0);
-  Matrix3x3 res(0.0);
-
-  for(int i = 0; i < 3; i++) {
-    for(int j = 0; j < 2; j++) {
-      Vector3 v(0.0);
-      double l;
-      m1[j]->getEigen(i, v, l);
-      // cout << i << " " << j << " " << l << endl; 
-      if(l > lmax) {
-        ic = i;
-        lmax = l;
-        cmax = v;
-        im = j;
-        io = (j == 0) ? 1 : 0;
-      }
-    }
-  }
-
-  // cout << "lmax " << lmax  << endl;
-  res.setEigen(ic, cmax[0], cmax[1], cmax[2], lmax);
-
-  for(int i = 0; i < 3; i++) {
-    if(i != ic) {
-      Vector3 v(0.0);
-      double l;
-      m1[im]->getEigen(i, v, l);
-      double l2 = m1[io]->quadraticFormEval(v);
-      // cout << l << " " << l2 << endl;
-      res.setEigen(i, v[0], v[1], v[2], (l2 > l) ? l2 : l);
-    }
-  }
-  // cout << "gives " << endl;
-  // res.print();
-  // cout<<endl;
-  res.setMetric();
-  return res;
-
-}
-
-double GMSHMetric::
-Local_Metric_Of_Attractors(double X, double Y, double Z, double metric[3][3])
-{
-  int i;
-  Attractor *a;
-  double u, x1, x2, d = 0.;
-  Vertex v1(X, Y, Z), v2, metr;
-
-  Matrix3x3 myOldMetric(0., m);
-
-  for(i = 0; i < List_Nbr(Attractors); i++) {
-    Matrix3x3 myMetric(0.);
-    List_Read(Attractors, i, &a);
-    if(a->v) {
-      d = sqrt((X - a->v->Pos.X) * (X - a->v->Pos.X) +
-               (Y - a->v->Pos.Y) * (Y - a->v->Pos.Y) +
-               (Z - a->v->Pos.Z) * (Z - a->v->Pos.Z));
-      metr = Vertex(1., 0., 0.);
-    }
-    if(a->c) {
-      ProjectPointOnCurve(a->c, &v1, &v2, &metr);
-      d = sqrt((X - v2.Pos.X) * (X - v2.Pos.X) +
-               (Y - v2.Pos.Y) * (Y - v2.Pos.Y) +
-               (Z - v2.Pos.Z) * (Z - v2.Pos.Z));
-
-    }
-    double d1 = d * a->Radius;
-    if(fabs(d1) < a->Radius * 1.e-6)
-      d1 = 0.0;
-    u = exp(-(d1 * d1));
-    x1 = (1. - u) + u * a->lc1;
-    x2 = (1. - u) + u * a->lc2;
-    // cout << " dist from "<<  X  << " " << Y << " = " << d << endl;
-    if(u > 1.e-2) {
-      if(a->v) {
-        double q11 = 1. / (x1 * x1);
-        double q22 = 1. / (x2 * x2);
-        //double q12 = 1. / (x1 * x2);
-
-        myMetric.setEigen(0, 1., 0., 0., q11);
-        myMetric.setEigen(1, 0., 1., 0., q22);
-        myMetric.setEigen(2, 0., 0., 1., q11);
-        myMetric.setMetric();
-      }
-      else if(a->c) {
-        double xx = 0.0, yy = 0.0, zz = 0.0;
-        if(metr.Pos.X != 0.0 || metr.Pos.Y != 0.0)
-          zz = 1.0;
-        else if(metr.Pos.Y == 0.0)
-          yy = 1.0;
-        else
-          xx = 1.0;
-
-        Vertex z(xx, yy, zz);
-        Vertex d2 = metr % z;
-        metr.norme();
-        d2.norme();
-        Vertex d3 = metr % d2;
-        d3.norme();
-
-        myMetric.setEigen(0, metr.Pos.X, metr.Pos.Y, metr.Pos.Z,
-                          1. / (x1 * x1));
-        myMetric.setEigen(1, d2.Pos.X, d2.Pos.Y, d2.Pos.Z, 1. / (x2 * x2));
-        myMetric.setEigen(2, d3.Pos.X, d3.Pos.Y, d3.Pos.Z, 1. / (x1 * x1));
-        myMetric.setMetric();
-        /*
-           Msg(INFO,"%d %12.5E heigens : %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E %12.5E \n  ", a->c->Num,d,
-           metr.Pos.X, metr.Pos.Y, metr.Pos.Z,
-           d2.Pos.X,d2.Pos.Y,d2.Pos.Z,
-           d3.Pos.X,d3.Pos.Y,d3.Pos.Z);
-
-           Msg(INFO,"heigenv : %12.5E %12.5E \n",x1,x2);
-
-           Msg(INFO,"curve Metric: %g %g %g %g %g %g %g %g %g \n  ", 
-           myMetric[0][0], myMetric[0][1], myMetric[0][2],
-           myMetric[1][0], myMetric[1][1], myMetric[1][2],
-           myMetric[2][0], myMetric[2][1], myMetric[2][2]);                     
-         */
-      }
-      Matrix3x3 *M[2];
-      M[0] = &myMetric;
-      M[1] = &myOldMetric;
-      myOldMetric = Intersect2Metrics(M);
-      // myOldMetric = myMetric;
-    }
-  }
-  myOldMetric.copy(m);
-  return 1.0;
-}
-
-
-void GMSHMetric:: setMetric(double u, double v, Surface * s)
-{
-  double a, b, c;               // ellipse axx+byy+cxy=1
-  double l1, l2;                // 2 eigenvalues
-
-  Identity();
-  Vertex p = InterpolateSurface(s, u, v, 0, 0);
-  if(s->Typ != MSH_SURF_PLAN && s->Typ != MSH_SURF_REGL
-     && s->Typ != MSH_SURF_TRIC) {
-    Vertex du = InterpolateSurface(s, u, v, 1, 1);
-    Vertex dv = InterpolateSurface(s, u, v, 1, 2);
-
-    a = du * du;
-    b = dv * dv;
-    c = du * dv;
-
-    m[0][0] = a;
-    m[1][1] = b;
-    m[0][1] = c;
-    m[1][0] = c;
-
-    l1 = 0.5 * ((a + b) + sqrt((a - b) * (a - b) + 4. * c * c));
-    l2 = 0.5 * ((a + b) - sqrt((a - b) * (a - b) + 4. * c * c));
-
-    if(l1 == 0.0 && l2 == 0.0)
-      Identity();
-
-    else if(sqrt(l1 / l2) > limite_aniso) {
-      // on limite les rapports de metrique a limite_ansio
-      double r = limite_aniso * limite_aniso * (l2 / l1);
-      m[0][0] = a / r;
-      m[1][1] = b * r;
-      m[0][1] = c;
-      m[1][0] = c;
-    }
-  }
-  Local_Metric_Of_Attractors(p.Pos.X, p.Pos.Y, p.Pos.Z, NULL);
-  return;
-}
-
-void GMSHMetric:: setMetric(double x, double y, double z)
-{
-  Identity();
-  Local_Metric_Of_Attractors(x, y, z, NULL);
-  return;
-}
-
-
-void GMSHMetric:: setMetricMin(double u, double v, Surface * s)
-{
-  /*setMetric(u,v,s);
-     return;
-   */
-  Identity();
-  if(s->Typ != MSH_SURF_PLAN && s->Typ != MSH_SURF_REGL
-     && s->Typ != MSH_SURF_TRIC) {
-    Vertex du = InterpolateSurface(s, u, v, 1, 1);
-    Vertex dv = InterpolateSurface(s, u, v, 1, 2);
-    double d = (du * du > dv * dv) ? du * du : dv * dv;
-    m[0][0] = d;
-    m[1][1] = d;
-  }
-  return;
-}
-
-double GMSHMetric:: getWorstEdge(Simplex * s, Surface * surf, Vertex * v[2])
-{
-  double l1, l2, l3, q1, q2, q3;
-  v[0] = s->V[0];
-  v[1] = s->V[1];
-  l1 = EdgeLengthOnSurface(surf, v, 1);
-  v[0] = s->V[0];
-  v[1] = s->V[2];
-  l2 = EdgeLengthOnSurface(surf, v, 1);
-  v[0] = s->V[1];
-  v[1] = s->V[2];
-  l3 = EdgeLengthOnSurface(surf, v, 1);
-
-  q1 = 2. * l1 / (s->V[0]->lc + s->V[1]->lc);
-  q2 = 2. * l2 / (s->V[0]->lc + s->V[2]->lc);
-  q3 = 2. * l3 / (s->V[1]->lc + s->V[2]->lc);
-
-  if(q1 >= q2 && q1 >= q3) {
-    v[0] = s->V[0];
-    v[1] = s->V[1];
-    return l1;
-  }
-  else if(q2 >= q3) {
-    v[0] = s->V[0];
-    v[1] = s->V[2];
-    return l2;
-  }
-  return l3;
-}
-
-void GMSHMetric:: setSimplexQuality(Simplex * s, Surface * surf)
-{
-  if(quality_measure == QUALITY_EDGES_BASED) {
-    Vertex *v[2], vv;
-    double l1, l2, l3, q1, q2, q3;
-    v[0] = s->V[0];
-    v[1] = s->V[1];
-    vv = (*v[1]) - (*v[0]);
-    l1 = LengthVector(&vv);
-    v[0] = s->V[0];
-    v[1] = s->V[2];
-    vv = (*v[1]) - (*v[0]);
-    l2 = LengthVector(&vv);
-    v[0] = s->V[1];
-    v[1] = s->V[2];
-    vv = (*v[1]) - (*v[0]);
-    l3 = LengthVector(&vv);
-
-    q1 = 2. * l1 / (s->V[0]->lc + s->V[1]->lc);
-    q2 = 2. * l2 / (s->V[0]->lc + s->V[2]->lc);
-    q3 = 2. * l3 / (s->V[1]->lc + s->V[2]->lc);
-
-    s->Quality = DMAX(DMAX(q1, q2), q3) / (RacineDeTrois);
-  }
-  else {
-    /*
-       Matrix3x3 myOldMetric (0.,m);
-       Identity();
-       Local_Metric_Of_Attractors (s->V[0]->Pos.X,s->V[0]->Pos.Y,s->V[0]->Pos.Z,0);
-       Local_Metric_Of_Attractors (s->V[1]->Pos.X,s->V[1]->Pos.Y,s->V[1]->Pos.Z,0);
-       Local_Metric_Of_Attractors (s->V[2]->Pos.X,s->V[2]->Pos.Y,s->V[2]->Pos.Z,0);
-     */
-    s->Center_Ellipsum_2D(m);
-    s->Quality = 3. * s->Radius / (s->V[0]->lc + s->V[1]->lc + s->V[2]->lc);
-  }
-}
-
-void GMSHMetric:: setSimplexQuality(Simplex * s)
-{
-  if(quality_measure == QUALITY_EDGES_BASED) {
-    Vertex *v[2], vv;
-    double l1, l2, l3, l4, l5, l6, q1, q2, q3, q4, q5, q6;
-    v[0] = s->V[0];
-    v[1] = s->V[1];
-    vv = (*v[1]) - (*v[0]);
-    l1 = LengthVector(&vv);
-    v[0] = s->V[0];
-    v[1] = s->V[2];
-    vv = (*v[1]) - (*v[0]);
-    l2 = LengthVector(&vv);
-    v[0] = s->V[1];
-    v[1] = s->V[2];
-    vv = (*v[1]) - (*v[0]);
-    l3 = LengthVector(&vv);
-    v[0] = s->V[0];
-    v[1] = s->V[3];
-    vv = (*v[1]) - (*v[0]);
-    l4 = LengthVector(&vv);
-    v[0] = s->V[1];
-    v[1] = s->V[3];
-    vv = (*v[1]) - (*v[0]);
-    l5 = LengthVector(&vv);
-    v[0] = s->V[2];
-    v[1] = s->V[3];
-    vv = (*v[1]) - (*v[0]);
-    l6 = LengthVector(&vv);
-
-    q1 = 2. * l1 / (s->V[0]->lc + s->V[1]->lc);
-    q2 = 2. * l2 / (s->V[0]->lc + s->V[2]->lc);
-    q3 = 2. * l3 / (s->V[1]->lc + s->V[2]->lc);
-    q4 = 2. * l4 / (s->V[0]->lc + s->V[3]->lc);
-    q5 = 2. * l5 / (s->V[1]->lc + s->V[3]->lc);
-    q6 = 2. * l6 / (s->V[2]->lc + s->V[3]->lc);
-
-    //s->Quality = (0.5/6.)*(q1+q2+q3+q4+q5+q6);
-
-    //double qmax = (DMAX (q1, DMAX (q2, DMAX (q3, DMAX (q4, DMAX (q5, q6))))));
-
-    s->Quality = (q1 + q2 + q3 + q4 + q5 + q6) / (6. * RacineDeDeux);
-  }
-  else {
-    //double x = (s->V[0]->Pos.X + s->V[1]->Pos.X + s->V[2]->Pos.X + s->V[3]->Pos.X) / 4.;
-    //double y = (s->V[0]->Pos.Y + s->V[1]->Pos.Y + s->V[2]->Pos.Y + s->V[3]->Pos.Y) / 4.;
-    //      double z = (s->V[0]->Pos.Z + s->V[1]->Pos.Z + s->V[2]->Pos.Z + s->V[3]->Pos.Z) / 4.;
-    //      setMetric(x,y,z);
-    s->Center_Ellipsum_3D(m);
-    s->Quality =
-      4. * s->Radius / (s->V[0]->lc + s->V[1]->lc + s->V[2]->lc +
-                        s->V[3]->lc);
-  }
-}
-
-double GMSHMetric::operator () (int i, int j)
-{
-  return m[i][j];
-}
-
-
-double *GMSHMetric::operator[] (int i)
-{
-  if(i < 0 || i > 3)
-    return m[0];
-  return m[i];
-}
-
-void GMSHMetric:: Identity()
-{
-  m[0][0] = m[1][1] = m[2][2] = 1.0;
-  m[1][0] = m[1][2] = m[0][1] = 0.0;
-  m[2][0] = m[2][1] = m[0][2] = 0.0;
-}
-
-void GMSHMetric:: setMetric(double u, Curve * c)
-{
-  ;
-}
-
-
-double GMSHMetric:: getLc(double u, Curve * c)
-{
-  double l;
-  Identity();
-  Vertex v = InterpolateCurve(c, u, 0);
-  Vertex du = InterpolateCurve(c, u, 1);
-  Local_Metric_Of_Attractors(v.Pos.X, v.Pos.Y, v.Pos.Z, NULL);
-  l = LengthVector(&du);
-  /*   
-     Msg(INFO,"GetLC : u = %g l=%g  lc=%g  return=%g\n", u, l, v.lc, l/v.lc);
-     Msg(INFO,"Metric: %g %g %g %g %g %g %g %g %g \n  ", 
-     m[0][0], m[0][1], m[0][2],
-     m[1][0], m[1][1], m[1][2],
-     m[2][0], m[2][1], m[2][2]);
-     Msg(INFO,"du = %g %g %g\n",du.Pos.X,du.Pos.Y,du.Pos.Z);
-   */
-  return l / v.lc;
-}
-
-double GMSHMetric:: LengthVector(Vertex * v)
-{
-  double qqq =
-    v->Pos.X * (v->Pos.X * m[0][0] + v->Pos.Y * m[0][1] +
-                v->Pos.Z * m[0][2]) + v->Pos.Y * (v->Pos.X * m[1][0] +
-                                                  v->Pos.Y * m[1][1] +
-                                                  v->Pos.Z * m[1][2]) +
-    v->Pos.Z * (v->Pos.X * m[2][0] + v->Pos.Y * m[2][1] + v->Pos.Z * m[2][2]);
-  //  Msg(INFO,"qqq = %g\n",qqq);
-  return sqrt(qqq);
-}
-
-double GMSHMetric:: EdgeLengthOnSurface(Surface * s, Vertex * v[2], int cuts)
-{
-  Vertex dv;
-
-  if(!s) {
-    dv = (*v[1]) - (*v[0]);
-    return LengthVector(&dv);
-  }
-
-  dv.Pos.X = (v[1]->Pos.X - v[0]->Pos.X) / (double)cuts;
-  dv.Pos.Y = (v[1]->Pos.Y - v[0]->Pos.Y) / (double)cuts;
-
-  double l = 0.0, posu, posv;
-
-  for(int i = 0; i < cuts; i++) {
-    posu = v[0]->Pos.X + dv.Pos.X * ((double)(i) + 0.5);
-    posv = v[0]->Pos.Y + dv.Pos.Y * ((double)(i) + 0.5);
-    setMetric(posu, posv, s);
-    l += LengthVector(&dv);
-  }
-  return l;
-}
diff --git a/Mesh/Metric.h b/Mesh/Metric.h
deleted file mode 100644
index 896e1427a301195d381ba5660ad7d76012b0941f..0000000000000000000000000000000000000000
--- a/Mesh/Metric.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef _METRIC_H_
-#define _METRIC_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "List.h"
-#include "Vertex.h"
-#include "Simplex.h"
-#include "Mesh.h"
-#include "Matrix.h"
-
-class GMSHMetric{
- public:
-  double m[3][3];
-  double limite_aniso;
-  double min_cos;
-  int quality_measure;
-  List_T  *Attractors;
-  GMSHMetric();
-  void Identity ();
-  Matrix3x3 Intersect2Metrics (Matrix3x3 *M[2]);
-  double EdgeLengthOnSurface (Surface *s , Vertex *v[2], int cuts);
-  double LengthVector (Vertex *v);
-  void setMetric (double u,double v ,Surface *s);
-  void setMetric (double x,double y ,double z);
-  void setMetricMin (double u,double v ,Surface *s);
-  void setSimplexQuality (Simplex *s,  Surface *surf);
-  void  setSimplexQuality (Simplex *s);
-  void setMetric (double u,Curve *c);
-  double getLc ( double u , Curve *c );
-  double operator () (int i,int j);
-  double * operator [] (int i);
-  double Local_Metric_Of_Attractors (double X, double Y, double Z,
-				     double metric[3][3]);
-  double getWorstEdge (Simplex *s, Surface *surf, Vertex *v[2]);
-} ;
-
-#endif
diff --git a/Mesh/PartitionMesh.cpp b/Mesh/PartitionMesh.cpp
deleted file mode 100644
index 25e4c0ee6fd2ebc385cee16c266bdddcc16739f5..0000000000000000000000000000000000000000
--- a/Mesh/PartitionMesh.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-// $Id: PartitionMesh.cpp,v 1.9 2006-08-29 10:39:49 remacle Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-//
-// Please report all bugs and problems to "gmsh@geuz.org".
-
-#include "Mesh.h"
-#include "PartitionMesh.h"
-
-void PartitionMesh(Mesh * M, int NP)
-{
-  throw;
-}
-
-void PartitionMesh(BDS_Mesh * m, int NP)
-{
-  throw;
-}
diff --git a/Mesh/PartitionMesh.h b/Mesh/PartitionMesh.h
deleted file mode 100644
index a0929a189bb950b69ca95ba0b20957cc7e5f1d5d..0000000000000000000000000000000000000000
--- a/Mesh/PartitionMesh.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PARTITION_MESH_GMSH__
-#define _PARTITION_MESH_GMSH__
-void PartitionMesh ( BDS_Mesh *M , int NP);
-void PartitionMesh ( Mesh *M , int NP);
-void DeleteMesh(Mesh * M);
-#endif
diff --git a/Mesh/Simplex.cpp b/Mesh/Simplex.cpp
deleted file mode 100644
index def18accd9caaa9058b0ceaa4a9a904318f453c8..0000000000000000000000000000000000000000
--- a/Mesh/Simplex.cpp
+++ /dev/null
@@ -1,856 +0,0 @@
-// $Id: Simplex.cpp,v 1.49 2006-08-05 13:31:28 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Geo.h"
-#include "Mesh.h"
-#include "Simplex.h"
-#include "Context.h"
-
-extern Context_T CTX;
-extern Mesh *THEM;
-
-extern Simplex MyNewBoundary;
-extern int edges_tetra[6][2];
-
-int FACE_DIMENSION = 2;
-
-// Basic simplex (contains only pointers to the nodes)
-
-SimplexBase::SimplexBase()
-  : Element()
-{
-  V[0] = V[1] = V[2] = V[3] = NULL;
-}
-
-SimplexBase::SimplexBase(Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4)
-  : Element()
-{
-  V[0] = v1; V[1] = v2; V[2] = v3; V[3] = v4;
-}
-
-double SimplexBase::Volume_Simplexe()
-{
-  double mat[3][3];
-
-  if(V[3])
-    return (matsimpl(mat) / 6.);
-  else
-    return (surfsimpl());
-}
-
-double SimplexBase::Volume_Simplexe2D()
-{
-  return ((V[1]->Pos.X - V[0]->Pos.X) *
-          (V[2]->Pos.Y - V[1]->Pos.Y) -
-          (V[2]->Pos.X - V[1]->Pos.X) * 
-	  (V[1]->Pos.Y - V[0]->Pos.Y));
-}
-
-void SimplexBase::center_tet(double X[4], double Y[4], double Z[4], double res[3])
-{
-  double mat[3][3], b[3], dum;
-  int i;
-  b[0] = X[1] * X[1] - X[0] * X[0] +
-    Y[1] * Y[1] - Y[0] * Y[0] + Z[1] * Z[1] - Z[0] * Z[0];
-  b[1] = X[2] * X[2] - X[1] * X[1] +
-    Y[2] * Y[2] - Y[1] * Y[1] + Z[2] * Z[2] - Z[1] * Z[1];
-  b[2] = X[3] * X[3] - X[2] * X[2] +
-    Y[3] * Y[3] - Y[2] * Y[2] + Z[3] * Z[3] - Z[2] * Z[2];
-
-  for(i = 0; i < 3; i++)
-    b[i] *= 0.5;
-
-  mat[0][0] = X[1] - X[0];
-  mat[0][1] = Y[1] - Y[0];
-  mat[0][2] = Z[1] - Z[0];
-  mat[1][0] = X[2] - X[1];
-  mat[1][1] = Y[2] - Y[1];
-  mat[1][2] = Z[2] - Z[1];
-  mat[2][0] = X[3] - X[2];
-  mat[2][1] = Y[3] - Y[2];
-  mat[2][2] = Z[3] - Z[2];
-
-  if(!sys3x3(mat, b, res, &dum)) {
-    Msg(WARNING, "Coplanar points in circum sphere computation");
-    Msg(WARNING, "(%g,%g,%g) (%g,%g,%g) (%g,%g,%g) (%g,%g,%g)",
-        X[0], Y[0], Z[0], X[1], Y[1], Z[1], X[2], Y[2], Z[2], X[3], Y[3],
-        Z[3]);
-    res[0] = res[1] = res[2] = 10.0e10;
-  }
-
-}
-
-double SimplexBase::matsimpl(double mat[3][3])
-{
-  mat[0][0] = V[1]->Pos.X - V[0]->Pos.X;
-  mat[0][1] = V[2]->Pos.X - V[0]->Pos.X;
-  mat[0][2] = V[3]->Pos.X - V[0]->Pos.X;
-  mat[1][0] = V[1]->Pos.Y - V[0]->Pos.Y;
-  mat[1][1] = V[2]->Pos.Y - V[0]->Pos.Y;
-  mat[1][2] = V[3]->Pos.Y - V[0]->Pos.Y;
-  mat[2][0] = V[1]->Pos.Z - V[0]->Pos.Z;
-  mat[2][1] = V[2]->Pos.Z - V[0]->Pos.Z;
-  mat[2][2] = V[3]->Pos.Z - V[0]->Pos.Z;
-  return det3x3(mat);
-}
-
-double SimplexBase::AireFace(Vertex * V[3])
-{
-  double a[3], b[3], c[3];
-
-  a[0] = V[2]->Pos.X - V[1]->Pos.X;
-  a[1] = V[2]->Pos.Y - V[1]->Pos.Y;
-  a[2] = V[2]->Pos.Z - V[1]->Pos.Z;
-
-  b[0] = V[0]->Pos.X - V[1]->Pos.X;
-  b[1] = V[0]->Pos.Y - V[1]->Pos.Y;
-  b[2] = V[0]->Pos.Z - V[1]->Pos.Z;
-
-  prodve(a, b, c);
-  return (0.5 * sqrt(c[0] * c[0] + c[1] * c[1] + c[2] * c[2]));
-}
-
-double SimplexBase::surfsimpl()
-{
-  return AireFace(V);
-}
-
-double SimplexBase::rhoin()
-{
-  double s1, s2, s3, s4;
-
-  if(V[3]) {
-    Vertex *F[3];
-    F[0] = V[0]; F[1] = V[1]; F[2] = V[2]; s1 = fabs(AireFace(F));
-    F[0] = V[0]; F[1] = V[2]; F[2] = V[3]; s2 = fabs(AireFace(F));
-    if(FACE_DIMENSION == 1) {
-      V[0] = V[1]; V[1] = V[2]; V[2] = V[3]; s3 = fabs(AireFace(F));
-      V[0] = V[0]; V[1] = V[1]; V[2] = V[3]; s4 = fabs(AireFace(F));
-    }
-    else {
-      F[0] = V[0]; F[1] = V[1]; F[2] = V[3]; s3 = fabs(AireFace(F));
-      F[0] = V[1]; F[1] = V[2]; F[2] = V[3]; s4 = fabs(AireFace(F));
-    }
-    return 3. * fabs(Volume_Simplexe()) / (s1 + s2 + s3 + s4);
-  }
-  else {
-    return 1.0;
-  }
-}
-
-double SimplexBase::maxEdge()
-{
-  double maxlij = 0.;
-  int N = V[3] ? 6 : 3;
-
-  if(V[3] || V[2])
-    for(int i = 0; i < N; i++)
-      maxlij = DMAX(maxlij, lij(V[edges_tetra[i][0]], V[edges_tetra[i][1]]));
-  else if(V[1])
-    maxlij = lij(V[0], V[1]);
-
-  return maxlij;
-}
-
-double SimplexBase::minEdge()
-{
-  double minlij = 1.e25;
-  int N = V[3] ? 6 : 3;
-
-  if(V[3] || V[2])
-    for(int i = 0; i < N; i++)
-      minlij = DMIN(minlij, lij(V[edges_tetra[i][0]], V[edges_tetra[i][1]]));
-  else if(V[1])
-    minlij = lij(V[0], V[1]);
-
-  return minlij;
-}
-
-double SimplexBase::EtaShapeMeasure()
-{
-  if(!V[3]) return 0.;
-
-  double lij2 = 0.0;
-  for(int i = 0; i <= 3; i++) {
-    for(int j = i + 1; j <= 3; j++) {
-      lij2 += DSQR(lij(V[i], V[j]));
-    }
-  }
-  return 12. * pow(9. / 10. * DSQR(fabs(Volume_Simplexe())), 1./3.) / (lij2);
-}
-
-double SimplexBase::GammaShapeMeasure()
-{
-  if(!V[3]) return 0.;
-
-  double maxlij = 0.0;
-  for(int i = 0; i <= 3; i++) {
-    for(int j = i + 1; j <= 3; j++) {
-      if(i != j)
-        maxlij = DMAX(maxlij, lij(V[i], V[j]));
-    }
-  }
-  return 12. * rhoin() / (sqrt(6.) * maxlij);
-}
-
-SimplexBase *Create_SimplexBase(Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4)
-{
-  return new SimplexBase(v1, v2, v3, v4);
-}
-
-void Free_SimplexBase(void *a, void *b)
-{
-  SimplexBase *s = *(SimplexBase **) a;
-  if(s) {
-    delete s;
-    s = NULL;
-  }
-}
-
-int compareSimplexBase(const void *a, const void *b)
-{
-  SimplexBase *q = *(SimplexBase **) a;
-  SimplexBase *w = *(SimplexBase **) b;
-  return (q->Num - w->Num);
-}
-
-// Mesh simplex (contains all the data necessary for mesh generation)
-
-Simplex::Simplex()
-  : SimplexBase()
-{
-  S[0] = S[1] = S[2] = S[3] = NULL;
-  Quality = 0.;
-}
-
-Simplex::Simplex(Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4)
-  : SimplexBase(v1, v2, v3, v4)
-{
-  S[0] = S[1] = S[2] = S[3] = NULL;
-  Quality = 0.;
-  Fourre_Simplexe(v1, v2, v3, v4);
-}
-
-int Simplex::CircumCircle(double x1, double y1, double x2, double y2,
-                          double x3, double y3, double *xc, double *yc)
-{
-  double d, a1, a2, a3;
-
-  d = 2. * (double)(y1 * (x2 - x3) + y2 * (x3 - x1) + y3 * (x1 - x2));
-  if(d == 0.0) {
-    *xc = *yc = -99999.;
-    Msg(WARNING, "Degenerated simplex");
-    return 0;
-  }
-
-  a1 = x1 * x1 + y1 * y1;
-  a2 = x2 * x2 + y2 * y2;
-  a3 = x3 * x3 + y3 * y3;
-  *xc = (double)((a1 * (y3 - y2) + a2 * (y1 - y3) + a3 * (y2 - y1)) / d);
-  *yc = (double)((a1 * (x2 - x3) + a2 * (x3 - x1) + a3 * (x1 - x2)) / d);
-
-  return 1;
-}
-
-void Simplex::Center_Circum()
-{
-  /* Calcul du centre de la boule circonscrite */
-  int i, N;
-  double X[4], Y[4], Z[4];
-  double res[3];
-
-  if(!V[3])
-    N = 3;
-  else
-    N = 4;
-
-  for(i = 0; i < N; i++) {
-    X[i] = V[i]->Pos.X;
-    Y[i] = V[i]->Pos.Y;
-    Z[i] = V[i]->Pos.Z;
-  }
-
-  if(N == 3) {
-    CircumCircle(V[0]->Pos.X, V[0]->Pos.Y,
-                 V[1]->Pos.X, V[1]->Pos.Y,
-                 V[2]->Pos.X, V[2]->Pos.Y, &Center.X, &Center.Y);
-    Center.Z = 0.0;
-    if(fabs(Center.X) > 1.e10)
-      Center.X = 1.e10;
-    if(fabs(Center.Y) > 1.e10)
-      Center.Y = 1.e10;
-    Radius = sqrt((X[0] - Center.X) * (X[0] - Center.X) +
-                  (Y[0] - Center.Y) * (Y[0] - Center.Y));
-  }
-  else {
-    center_tet(X, Y, Z, res);
-
-    Center.X = res[0];
-    Center.Y = res[1];
-    Center.Z = res[2];
-    Radius = sqrt((X[0] - Center.X) * (X[0] - Center.X) +
-                  (Y[0] - Center.Y) * (Y[0] - Center.Y) +
-                  (Z[0] - Center.Z) * (Z[0] - Center.Z));
-  }
-}
-
-int Simplex::Pt_In_Ellipse(Vertex * v, double Metric[3][3])
-{
-  double eps, d1, d2, x[2];
-
-  Center_Ellipsum_2D(Metric);
-
-  x[0] = Center.X - v->Pos.X;
-  x[1] = Center.Y - v->Pos.Y;
-
-  d1 = Radius;
-  d2 = sqrt(x[0] * x[0] * Metric[0][0]
-            + x[1] * x[1] * Metric[1][1]
-            + 2. * x[0] * x[1] * Metric[0][1]);
-
-  eps = fabs(d1 - d2) / (d1 + d2);
-  if(eps < 1.e-12) {
-    return (1); // Ou Zero ???
-  }
-  if(d2 < d1)
-    return 1;
-  return 0;
-
-}
-
-void Simplex::Fourre_Simplexe(Vertex * v1, Vertex * v2, Vertex * v3,
-                              Vertex * v4)
-{
-  int i, N;
-  V[0] = v1;
-  V[1] = v2;
-  V[2] = v3;
-  V[3] = v4;
-  VSUP = NULL;
-
-  if(!v3) {
-    F[0].V[0] = (v1->Num > v2->Num) ? v2 : v1;
-    F[0].V[1] = (v1->Num > v2->Num) ? v1 : v2;
-    F[0].V[2] = NULL;
-    return;
-  }
-
-  F[0].V[0] = v1;
-  F[0].V[1] = v2;
-  F[0].V[2] = v3;
-
-  F[1].V[0] = v1;
-  F[1].V[1] = v3;
-  F[1].V[2] = v4;
-  if(FACE_DIMENSION == 1) {
-    F[2].V[0] = v2;
-    F[2].V[1] = v3;
-    F[2].V[2] = v4;
-
-    F[3].V[0] = v1;
-    F[3].V[1] = v2;
-    F[3].V[2] = v4;
-  }
-  else {
-    F[2].V[0] = v1;
-    F[2].V[1] = v2;
-    F[2].V[2] = v4;
-
-    F[3].V[0] = v2;
-    F[3].V[1] = v3;
-    F[3].V[2] = v4;
-  }
-
-  if(!v4) {
-    N = 3;
-    if(FACE_DIMENSION != 1) {
-      qsort(F[0].V, 3, sizeof(Vertex *), compareVertex);
-      return;
-    }
-  }
-  else {
-    N = 4;
-  }
-
-  Center_Circum();
-
-  if(N == 4 && CTX.mesh.bgmesh_type == ONFILE){
-    Quality = fabs(4. * Radius / BGMXYZ(Center.X, Center.Y, Center.Z));
-  }
-  else{
-    Quality = (double)N * Radius / (V[0]->lc + V[1]->lc + V[2]->lc + 
-				    ((V[3]) ? V[3]->lc : 0.0));
-  }
-
-  for(i = 0; i < N; i++)
-    qsort(F[i].V, N - 1, sizeof(Vertex *), compareVertex);
-
-  //qsort(F,N,sizeof(Face),compareFace);
-}
-
-Simplex *Create_Simplex(Vertex * v1, Vertex * v2, Vertex * v3, Vertex * v4)
-{
-  return new Simplex(v1, v2, v3, v4);
-}
-
-void Free_Simplex(void *a, void *b)
-{
-  Simplex *s = *(Simplex **) a;
-  if(s) {
-    delete s;
-    s = NULL;
-  }
-}
-
-int compareSimplex(const void *a, const void *b)
-{
-  Simplex *q = *(Simplex **) a;
-  Simplex *w = *(Simplex **) b;
-  return (q->Num - w->Num);
-}
-
-int compareSimplexBarycenter(const void *a, const void *b)
-{
-  Simplex *q = *(Simplex **) a;
-  Simplex *w = *(Simplex **) b;
-  int nq = q->V[3] ? 4 : q->V[2] ? 3 : q->V[1] ? 2 : 1;
-  int nw = w->V[3] ? 4 : w->V[2] ? 3 : w->V[1] ? 2 : 1;
-  double bq, bw, TOL = CTX.lc * 1.e-6;
-
-  bq = bw = 0.;
-  for(int i = 0; i < nq; i++) bq += q->V[i]->Pos.X;
-  for(int i = 0; i < nw; i++) bw += w->V[i]->Pos.X;
-  if(bq-bw > TOL) return 1; else if(bq-bw < -TOL) return -1;
-
-  bq = bw = 0.;
-  for(int i = 0; i < nq; i++) bq += q->V[i]->Pos.Y;
-  for(int i = 0; i < nw; i++) bw += w->V[i]->Pos.Y;
-  if(bq-bw > TOL) return 1; else if(bq-bw < -TOL) return -1;
-
-  bq = bw = 0.;
-  for(int i = 0; i < nq; i++) bq += q->V[i]->Pos.Z;
-  for(int i = 0; i < nw; i++) bw += w->V[i]->Pos.Z;
-  if(bq-bw > TOL) return 1; else if(bq-bw < -TOL) return -1;
-
-  return 0;
-}
-
-int Simplex::Pt_In_Simplexe(Vertex * v, double uvw[3], double tol)
-{
-  double mat[3][3];
-  double b[3], dum;
-
-  matsimpl(mat);
-  b[0] = v->Pos.X - V[0]->Pos.X;
-  b[1] = v->Pos.Y - V[0]->Pos.Y;
-  b[2] = v->Pos.Z - V[0]->Pos.Z;
-
-  sys3x3(mat, b, uvw, &dum);
-  if(uvw[0] >= -tol && uvw[1] >= -tol && uvw[2] >= -tol &&
-     uvw[0] <= 1. + tol && uvw[1] <= 1. + tol && uvw[2] <= 1. + tol &&
-     1. - uvw[0] - uvw[1] - uvw[2] > -tol) {
-    return (1);
-  }
-  return (0);
-}
-
-void Simplex::Center_Ellipsum_2D(double m[3][3])
-{
-  double sys[2][2], x[2];
-  double rhs[2], a, b, d;
-  double x1, y1, x2, y2, x3, y3;
-
-  x1 = V[0]->Pos.X;
-  y1 = V[0]->Pos.Y;
-  x2 = V[1]->Pos.X;
-  y2 = V[1]->Pos.Y;
-  x3 = V[2]->Pos.X;
-  y3 = V[2]->Pos.Y;
-
-  a = m[0][0];
-  b = 0.5 * (m[0][1] + m[1][0]);
-  d = m[1][1];
-
-  sys[0][0] = 2. * a * (x1 - x2) + 2. * b * (y1 - y2);
-  sys[0][1] = 2. * d * (y1 - y2) + 2. * b * (x1 - x2);
-  sys[1][0] = 2. * a * (x1 - x3) + 2. * b * (y1 - y3);
-  sys[1][1] = 2. * d * (y1 - y3) + 2. * b * (x1 - x3);
-
-  rhs[0] =
-    a * (x1 * x1 - x2 * x2) + d * (y1 * y1 - y2 * y2) + 2. * b * (x1 * y1 -
-                                                                  x2 * y2);
-  rhs[1] =
-    a * (x1 * x1 - x3 * x3) + d * (y1 * y1 - y3 * y3) + 2. * b * (x1 * y1 -
-                                                                  x3 * y3);
-
-  sys2x2(sys, rhs, x);
-
-  Center.X = x[0];
-  Center.Y = x[1];
-
-  Radius = sqrt((x[0] - x1) * (x[0] - x1) * a
-                + (x[1] - y1) * (x[1] - y1) * d
-                + 2. * (x[0] - x1) * (x[1] - y1) * b);
-}
-
-void Simplex::Center_Ellipsum_3D(double m[3][3])
-{
-  double sys[3][3], x[3];
-  double rhs[3], det;
-  double x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4;
-
-  x1 = V[0]->Pos.X;
-  y1 = V[0]->Pos.Y;
-  z1 = V[0]->Pos.Z;
-  x2 = V[1]->Pos.X;
-  y2 = V[1]->Pos.Y;
-  z2 = V[1]->Pos.Z;
-  x3 = V[2]->Pos.X;
-  y3 = V[2]->Pos.Y;
-  z3 = V[2]->Pos.Z;
-  x4 = V[3]->Pos.X;
-  y4 = V[3]->Pos.Y;
-  z4 = V[3]->Pos.Z;
-
-  sys[0][0] =
-    2. * m[0][0] * (x1 - x2) + 2. * m[1][0] * (y1 - y2) + 2. * m[2][0] * (z1 -
-                                                                          z2);
-  sys[0][1] =
-    2. * m[0][1] * (x1 - x2) + 2. * m[1][1] * (y1 - y2) + 2. * m[2][1] * (z1 -
-                                                                          z2);
-  sys[0][2] =
-    2. * m[0][2] * (x1 - x2) + 2. * m[1][2] * (y1 - y2) + 2. * m[2][2] * (z1 -
-                                                                          z2);
-
-  sys[1][0] =
-    2. * m[0][0] * (x1 - x3) + 2. * m[1][0] * (y1 - y3) + 2. * m[2][0] * (z1 -
-                                                                          z3);
-  sys[1][1] =
-    2. * m[0][1] * (x1 - x3) + 2. * m[1][1] * (y1 - y3) + 2. * m[2][1] * (z1 -
-                                                                          z3);
-  sys[1][2] =
-    2. * m[0][2] * (x1 - x3) + 2. * m[1][2] * (y1 - y3) + 2. * m[2][2] * (z1 -
-                                                                          z3);
-
-  sys[2][0] =
-    2. * m[0][0] * (x1 - x4) + 2. * m[1][0] * (y1 - y4) + 2. * m[2][0] * (z1 -
-                                                                          z4);
-  sys[2][1] =
-    2. * m[0][1] * (x1 - x4) + 2. * m[1][1] * (y1 - y4) + 2. * m[2][1] * (z1 -
-                                                                          z4);
-  sys[2][2] =
-    2. * m[0][2] * (x1 - x4) + 2. * m[1][2] * (y1 - y4) + 2. * m[2][2] * (z1 -
-                                                                          z4);
-
-  rhs[0] = m[0][0] * (x1 * x1 - x2 * x2)
-    + m[1][1] * (y1 * y1 - y2 * y2)
-    + m[2][2] * (z1 * z1 - z2 * z2)
-    + 2. * m[1][0] * (x1 * y1 - x2 * y2)
-    + 2. * m[2][0] * (x1 * z1 - x2 * z2)
-    + 2. * m[2][1] * (z1 * y1 - z2 * y2);
-  rhs[1] = m[0][0] * (x1 * x1 - x3 * x3)
-    + m[1][1] * (y1 * y1 - y3 * y3)
-    + m[2][2] * (z1 * z1 - z3 * z3)
-    + 2. * m[1][0] * (x1 * y1 - x3 * y3)
-    + 2. * m[2][0] * (x1 * z1 - x3 * z3)
-    + 2. * m[2][1] * (z1 * y1 - z3 * y3);
-  rhs[2] = m[0][0] * (x1 * x1 - x4 * x4)
-    + m[1][1] * (y1 * y1 - y4 * y4)
-    + m[2][2] * (z1 * z1 - z4 * z4)
-    + 2. * m[1][0] * (x1 * y1 - x4 * y4)
-    + 2. * m[2][0] * (x1 * z1 - x4 * z4)
-    + 2. * m[2][1] * (z1 * y1 - z4 * y4);
-
-  sys3x3(sys, rhs, x, &det);
-
-  Center.X = x[0];
-  Center.Y = x[1];
-  Center.Z = x[2];
-
-  Radius = sqrt((x[0] - x1) * (x[0] - x1) * m[0][0]
-                + (x[1] - y1) * (x[1] - y1) * m[1][1]
-                + (x[2] - z1) * (x[2] - z1) * m[2][2]
-                + 2. * (x[0] - x1) * (x[1] - y1) * m[0][1]
-                + 2. * (x[0] - x1) * (x[2] - z1) * m[0][2]
-                + 2. * (x[1] - y1) * (x[2] - z1) * m[1][2]);
-}
-
-int Simplex::Pt_In_Simplex_2D(Vertex * v)
-{
-  double Xmin, Xmax, Ymin, Ymax, Xtr[4], Ytr[4], A[2], B[2], X, Y, Signus[3];
-  int i;
-
-  X = v->Pos.X;
-  Y = v->Pos.Y;
-  Xtr[0] = Xmax = Xmin = V[0]->Pos.X;
-  Xtr[3] = V[0]->Pos.X;
-  Xtr[1] = V[1]->Pos.X;
-  Xtr[2] = V[2]->Pos.X;
-  Ytr[0] = Ymax = Ymin = V[0]->Pos.Y;
-  Ytr[3] = V[0]->Pos.Y;
-  Ytr[1] = V[1]->Pos.Y;
-  Ytr[2] = V[2]->Pos.Y;
-
-  for(i = 1; i < 3; i++) {
-    Xmin = (Xtr[i] < Xmin) ? Xtr[i] : Xmin;
-    Xmax = (Xtr[i] > Xmax) ? Xtr[i] : Xmax;
-    Ymin = (Ytr[i] < Ymin) ? Ytr[i] : Ymin;
-    Ymax = (Ytr[i] > Ymax) ? Ytr[i] : Ymax;
-  }
-
-  if(X > Xmax || X < Xmin || Y > Ymax || Y < Ymin)
-    return (0);
-
-  for(i = 0; i < 3; i++) {
-    A[0] = Xtr[i + 1] - Xtr[i];
-    A[1] = Ytr[i + 1] - Ytr[i];
-    B[0] = X - Xtr[i];
-    B[1] = Y - Ytr[i];
-    Signus[i] = A[0] * B[1] - A[1] * B[0];
-  }
-  for(i = 0; i < 2; i++) {
-    if((Signus[i] * Signus[i + 1]) < 0)
-      return 0;
-  }
-  return 1;
-}
-
-bool Simplex::VertexIn(Vertex * v)
-{
-  if(!this || this == &MyNewBoundary)
-    return false;
-  int N = 4;
-  if(!V[3])
-    N = 3;
-  for(int i = 0; i < N; i++)
-    if(!compareVertex(&V[i], &v))
-      return true;
-  return false;
-}
-
-bool Simplex::EdgeIn(Vertex * v1, Vertex * v2, Vertex * v[2])
-{
-  if(!this || this == &MyNewBoundary)
-    return false;
-  int N = 4;
-  if(!V[3])
-    N = 3;
-  int n = 0;
-  for(int i = 0; i < N; i++) {
-    if(compareVertex(&V[i], &v1) && compareVertex(&V[i], &v2)) {
-      v[n++] = V[i];
-      if(n > 2)
-        return false;
-    }
-  }
-  return true;
-}
-
-bool Simplex::ExtractOppositeEdges(int iFac, Vertex * p[2], Vertex * q[2])
-{
-  Simplex *s1 = this;
-  if(!s1 || s1 == &MyNewBoundary || !s1->iEnt)
-    return false;
-  Simplex *s2 = s1->S[iFac];
-  if(!s2 || s2 == &MyNewBoundary || !s2->iEnt)
-    return false;
-  int i, ip = 0, iq = 0;
-
-  for(i = 0; i < 3; i++)
-    if(s1->VertexIn(s2->V[i]))
-      p[ip++] = s2->V[i];
-    else
-      q[iq++] = s2->V[i];
-
-  for(i = 0; i < 3; i++)
-    if(!s2->VertexIn(s1->V[i]))
-      q[iq++] = s1->V[i];
-
-  if(ip != 2 || iq != 2) {
-    return false;
-  }
-  return true;
-}
-
-bool Simplex::SwapEdge(int iFac)
-{
-  Simplex *s1 = NULL, *s2 = NULL, *s11 = NULL, *s21 = NULL;
-  Vertex *p[4] = { NULL, NULL, NULL, NULL };
-  Vertex *q[4] = { NULL, NULL, NULL, NULL };
-  int i, ip, iq;
-
-  s1 = this;
-  if(!s1 || s1 == &MyNewBoundary || !s1->iEnt)
-    return false;
-  s2 = s1->S[iFac];
-  if(!s2 || s2 == &MyNewBoundary || !s2->iEnt)
-    return false;
-  ip = iq = 0;
-
-  for(i = 0; i < 3; i++)
-    if(s1->VertexIn(s2->V[i]))
-      p[ip++] = s2->V[i];
-    else
-      q[iq++] = s2->V[i];
-
-  for(i = 0; i < 3; i++)
-    if(!s2->VertexIn(s1->V[i]))
-      q[iq++] = s1->V[i];
-
-  if(ip != 2 || iq != 2) {
-    return false;
-  }
-
-  for(i = 0; i < 3; i++)
-    if(s1->S[i]->VertexIn(p[1]) && s1->S[i]->VertexIn(q[1]))
-      s11 = s1->S[i];
-
-  for(i = 0; i < 3; i++)
-    if(s2->S[i]->VertexIn(p[0]) && s2->S[i]->VertexIn(q[0]))
-      s21 = s2->S[i];
-
-  if(!s11 || !s21)
-    return false;
-
-  double vol1 = s1->Volume_Simplexe() + s2->Volume_Simplexe();
-
-  s1->V[0] = p[0];
-  s1->V[1] = q[0];
-  s1->V[2] = q[1];
-  s2->V[0] = p[1];
-  s2->V[1] = q[0];
-  s2->V[2] = q[1];
-
-  double vol2 = s1->Volume_Simplexe() + s2->Volume_Simplexe();
-
-  if(s1->Volume_Simplexe() == 0.0 || s2->Volume_Simplexe() == 0.0 ||
-     fabs(fabs(vol1) - fabs(vol2)) > 1.e-5 * (fabs(vol1) + fabs(vol2))) {
-    s1->V[0] = p[0];
-    s1->V[1] = p[1];
-    s1->V[2] = q[1];
-    s2->V[0] = p[0];
-    s2->V[1] = p[1];
-    s2->V[2] = q[0];
-    return false;
-  }
-
-  for(i = 0; i < 3; i++)
-    if(s1->S[i] == s11)
-      s1->S[i] = s21;
-  for(i = 0; i < 3; i++)
-    if(s2->S[i] == s21)
-      s2->S[i] = s11;
-
-  if(s21 != &MyNewBoundary && s21 && s21->iEnt)
-    for(i = 0; i < 3; i++)
-      if(s21->S[i] == s2)
-        s21->S[i] = s1;
-  if(s11 != &MyNewBoundary && s11 && s11->iEnt)
-    for(i = 0; i < 3; i++)
-      if(s11->S[i] == s1)
-        s11->S[i] = s2;
-  return true;
-}
-
-bool Simplex::SwapFace(int iFac, List_T * newsimp, List_T * delsimp)
-{
-  Simplex *s = S[iFac], *s1, *s2, *s3;
-  Vertex *o[2] = {NULL, NULL};
-  int i;
-
-  if(!s || s == &MyNewBoundary || !s->iEnt)
-    return false;
-  if(!this || this == &MyNewBoundary || !this->iEnt)
-    return false;
-
-  for(i = 0; i < 4; i++)
-    if(!VertexIn(s->V[i]))
-      o[0] = s->V[i];
-  for(i = 0; i < 4; i++)
-    if(!s->VertexIn(V[i]))
-      o[1] = V[i];
-
-  s1 = Create_Simplex(s->F[iFac].V[0], s->F[iFac].V[1], o[0], o[1]);
-  s2 = Create_Simplex(s->F[iFac].V[1], s->F[iFac].V[2], o[0], o[1]);
-  s3 = Create_Simplex(s->F[iFac].V[2], s->F[iFac].V[0], o[0], o[1]);
-
-  double vol1 = s->Volume_Simplexe() + Volume_Simplexe();
-  double vol2 = s1->Volume_Simplexe() + s2->Volume_Simplexe() + s3->Volume_Simplexe();
-
-  if(fabs(fabs(vol1) - fabs(vol2)) > 1.e-5 * (fabs(vol1) + fabs(vol2))) {
-    delete s1;
-    delete s2;
-    delete s3;
-    return false;
-  }
-
-  double gamma1 = GammaShapeMeasure();
-
-  if(s1->GammaShapeMeasure() < gamma1 ||
-     s2->GammaShapeMeasure() < gamma1 || 
-     s3->GammaShapeMeasure() < gamma1)
-    return false;
-
-  return true;
-}
-
-// Transfer SimplexBase to Simplex
-
-static Tree_T *simptree = NULL;
-
-void Copy_SimplexBaseToSimplex(void *a, void *b)
-{
-  SimplexBase *base = *(SimplexBase**)a;
-  Simplex *s = Create_Simplex(base->V[0], base->V[1], base->V[2], base->V[3]);
-  s->iEnt = base->iEnt;
-  s->Num = base->Num;
-  s->iPart = base->iPart;
-  s->Visible = base->Visible;
-  if(base->VSUP){
-    int ns;
-    if(base->V[3])
-      ns = 6;
-    else if(base->V[2])
-      ns = 3;
-    else if(base->V[1])
-      ns = 1;
-    else
-      ns = 0;
-    if(ns){
-      s->VSUP = (Vertex **) Malloc(ns * sizeof(Vertex *));
-      memcpy(s->VSUP, base->VSUP, ns * sizeof(Vertex *));
-    }
-  }
-  Tree_Insert(simptree, &s);
-}
-
-void Move_SimplexBaseToSimplex(Tree_T **base, Tree_T *simp)
-{
-  if(!Tree_Nbr(*base)) return;
-  simptree = simp;
-  Tree_Action(*base, Copy_SimplexBaseToSimplex);
-  Tree_Action(*base, Free_SimplexBase);
-  Tree_Delete(*base);
-  *base = Tree_Create(sizeof(SimplexBase *), compareSimplexBase);
-}
-
diff --git a/Mesh/Simplex.h b/Mesh/Simplex.h
deleted file mode 100644
index 4f3043dda1374d6ef3b30a82cca84b6e2ce83cc5..0000000000000000000000000000000000000000
--- a/Mesh/Simplex.h
+++ /dev/null
@@ -1,87 +0,0 @@
-#ifndef _SIMPLEX_H_
-#define _SIMPLEX_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "List.h"
-#include "Tree.h"
-#include "Vertex.h"
-#include "Element.h"
-#include "Face.h"
-
-class SimplexBase : public Element {
- public:
-  Vertex  *V[4];         // 4 nodes
-  SimplexBase();
-  ~SimplexBase() {}
-  SimplexBase(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-  double Volume_Simplexe();
-  double Volume_Simplexe2D();
-  double matsimpl(double mat[3][3]);
-  void center_tet(double X[4],double Y[4], double Z[4], double res[3]);
-  double AireFace(Vertex *V[3]);
-  double surfsimpl();
-  double GammaShapeMeasure();
-  double EtaShapeMeasure();
-  double rhoin();
-  double maxEdge();
-  double minEdge();
-};
-
-SimplexBase *Create_SimplexBase(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-void Free_SimplexBase(void *a, void *b);
-int compareSimplexBase(const void *a, const void *b);
-
-class Simplex : public SimplexBase {
- public:
-  Face    F[4];          // 4 faces
-  double  Quality;       // simplex quality
-  Coord   Center;        // CC center
-  double  Radius;        // CC radius
-  Simplex *S[4];         // 4 neighbours
-  Simplex();
-  ~Simplex() {}
-  Simplex(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-  void Fourre_Simplexe(Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-  int Pt_In_Simplexe(Vertex *v, double uvw[3], double tol);
-  int Pt_In_Simplex_2D(Vertex *v);
-  void Center_Circum();
-  int CircumCircle(double x1,double y1,double x2,double y2,double x3,double y3,
-                   double *xc,double *yc);
-  void Center_Ellipsum_2D(double m[3][3]);
-  int Pt_In_Ellipse(Vertex *v,double m[3][3]);
-  bool VertexIn(Vertex *v);
-  bool EdgeIn(Vertex *v1, Vertex *v2, Vertex *v[2]);
-  bool SwapEdge(int iFac);
-  bool SwapFace(int iFac, List_T *newsimp, List_T *delsimp);
-  bool ExtractOppositeEdges( int iFac, Vertex *p[2], Vertex *q[2]);
-  void Center_Ellipsum_3D(double m[3][3]);
-};
-
-int compareSimplex(const void *a, const void *b);
-int compareSimplexBarycenter(const void *a, const void *b);
-int compareFace(const void *a, const void *b);
-
-Simplex *Create_Simplex (Vertex *v1, Vertex *v2, Vertex *v3, Vertex *v4);
-void Free_Simplex(void *a, void *b);
-
-void Move_SimplexBaseToSimplex(Tree_T **base, Tree_T *simp);
-
-#endif
diff --git a/Mesh/Smoothing.cpp b/Mesh/Smoothing.cpp
deleted file mode 100644
index df0a826bed75e0e53001475c797acfa87b1ccfeb..0000000000000000000000000000000000000000
--- a/Mesh/Smoothing.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-// $Id: Smoothing.cpp,v 1.16 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-
-void AmelioreSurface_EliminationTripet(Surface * surf, Mesh * m,
-                                       Tree_T * tnxe)
-{
-  int i, j, k;
-  List_T *lnxe = Tree2List(tnxe);
-  Vertex *v1, *v2, *v3;
-  List_T *ListNoeuds = List_Create(2, 1, sizeof(Vertex *));
-  Simplex *s[3], *news;
-  NXE nxe;
-  bool ok;
-
-  for(i = 0; i < List_Nbr(lnxe); i++) {
-    List_Read(lnxe, i, &nxe);
-    if(List_Nbr(nxe.Liste) == 3) {
-      ok = true;
-      if(nxe.v->ListCurves)
-        ok = false;
-      else {
-        for(j = 0; j < 3; j++) {
-          List_Read(nxe.Liste, j, &s[j]);
-          if(!Tree_Search(surf->Simplexes, &s[j]))
-            ok = false;
-          for(k = 0; k < 3; k++)
-            if(compareVertex(&nxe.v, &s[j]->V[k]))
-              List_Insert(ListNoeuds, &s[j]->V[k], compareVertex);
-        }
-      }
-      if(ok) {
-        List_Read(ListNoeuds, 0, &v1);
-        List_Read(ListNoeuds, 1, &v2);
-        List_Read(ListNoeuds, 2, &v3);
-        news = Create_Simplex(v1, v2, v3, 0);
-        Tree_Suppress(surf->Simplexes, &s[0]);
-        Tree_Suppress(surf->Simplexes, &s[1]);
-        Tree_Suppress(surf->Simplexes, &s[2]);
-        Tree_Suppress(m->Vertices, &nxe.v);
-        Tree_Add(surf->Simplexes, &news);
-      }
-      List_Reset(ListNoeuds);
-    }
-  }
-  List_Delete(ListNoeuds);
-  List_Delete(lnxe);
-}
-
-
-void ActionLiss(void *data, void *dummy)
-{
-  List_T *nodes;
-
-  NXE *pnxe;
-  Simplex *s;
-  double X, Y, Z, Sum;
-  int i, j;
-
-
-  pnxe = (NXE *) data;
-
-  // On Ne Lisse Point Les Points sur les courbes (quelle horreur)
-  if(pnxe->v->ListCurves)
-    return;
-  nodes = List_Create(2, 2, sizeof(Vertex *));
-
-  X = Y = Z = Sum = 0.0;
-  double volume_before = 0.0;
-  double min_quality_old = 1.0;
-  for(i = 0; i < List_Nbr(pnxe->Liste); i++) {
-    List_Read(pnxe->Liste, i, &s);
-    min_quality_old = DMIN(min_quality_old, s->GammaShapeMeasure());
-    volume_before += fabs(s->Volume_Simplexe());
-    // On Ne Lisse Point Les Points sur les surfaces quand les volumes
-    // sont mailles
-    if(s->V[3] && pnxe->v->ListSurf)
-      return;
-    for(j = 0; j < 4; j++) {
-      if(s->V[j] && compareVertex(&pnxe->v, &s->V[j])) {
-        Sum += 0.5;
-        X += s->V[j]->Pos.X * 0.5;
-        Y += s->V[j]->Pos.Y * 0.5;
-        Z += s->V[j]->Pos.Z * 0.5;
-      }
-    }
-  }
-
-  double xold = pnxe->v->Pos.X;
-  double yold = pnxe->v->Pos.Y;
-  double zold = pnxe->v->Pos.Z;
-  double a = 0.5;
-
-  if(Sum != 0.0) {
-    pnxe->v->Pos.X = a * (X / Sum) + (1. - a) * pnxe->v->Pos.X;
-    pnxe->v->Pos.Y = a * (Y / Sum) + (1. - a) * pnxe->v->Pos.Y;
-    pnxe->v->Pos.Z = a * (Z / Sum) + (1. - a) * pnxe->v->Pos.Z;
-  }
-
-  double min_quality_new = 1.0;
-  for(i = 0; i < List_Nbr(pnxe->Liste); i++) {
-    List_Read(pnxe->Liste, i, &s);
-    min_quality_new = DMIN(min_quality_new, s->GammaShapeMeasure());
-  }
-
-  double volume_after = 0.0;
-  for(i = 0; i < List_Nbr(pnxe->Liste); i++) {
-    List_Read(pnxe->Liste, i, &s);
-    volume_after += fabs(s->Volume_Simplexe());
-  }
-  if(fabs(volume_after - volume_before) > 1.e-8 * 
-     fabs(volume_after + volume_before) || 
-     min_quality_old > min_quality_new) {
-    pnxe->v->Pos.X = xold;
-    pnxe->v->Pos.Y = yold;
-    pnxe->v->Pos.Z = zold;
-  }
-  List_Delete(nodes);
-}
-
-
-void ActionLissSurf(void *data, void *dummy)
-{
-  NXE *pnxe;
-  Simplex *s;
-  double X, Y, Z, Sum;
-  int i, j;
-
-  pnxe = (NXE *) data;
-
-  // On Ne Lisse Point Les Points sur les courbes
-  if(pnxe->v->ListCurves)
-    return;
-
-  X = Y = Z = Sum = 0.0;
-  for(i = 0; i < List_Nbr(pnxe->Liste); i++) {
-    List_Read(pnxe->Liste, i, &s);
-    // On Ne Lisse Point Les Points sur les surfaces quand les volumes
-    // sont mailles
-    for(j = 0; j < 4; j++) {
-      if(s->V[j] && compareVertex(&pnxe->v, &s->V[j])) {
-        Sum += 0.5;
-        X += s->V[j]->Pos.X * 0.5;
-        Y += s->V[j]->Pos.Y * 0.5;
-        Z += s->V[j]->Pos.Z * 0.5;
-      }
-    }
-  }
-  if(Sum != 0.0) {
-    pnxe->v->Pos.X = X / Sum;
-    pnxe->v->Pos.Y = Y / Sum;
-    pnxe->v->Pos.Z = Z / Sum;
-  }
-}
-
-void RandomSwapEdges(Surface * s)
-{
-  int i;
-  List_T *AllTrg = Tree2List(s->Simplexes);
-  Simplex *t;
-  for(i = 0; i < List_Nbr(AllTrg); i++) {
-    List_Read(AllTrg, i, &t);
-    t->SwapEdge(1);
-  }
-}
diff --git a/Mesh/SwapEdge.cpp b/Mesh/SwapEdge.cpp
deleted file mode 100644
index 283badcc43f24875de8f01589a829f23bfe96747..0000000000000000000000000000000000000000
--- a/Mesh/SwapEdge.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-// $Id: SwapEdge.cpp,v 1.18 2006-01-06 00:34:26 geuzaine Exp $
-//
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include "Gmsh.h"
-#include "Numeric.h"
-#include "Mesh.h"
-#include "SwapPatterns.h"
-
-extern Simplex MyNewBoundary;
-extern int edges_tetra[6][2];
-
-
-int TrouveCoquille(Simplex * s, Vertex * Ed[2],
-                   List_T * Coquille, Tree_T * TreeSimpl,
-                   Vertex * Contour[100])
-{
-  Simplex *stack[256], *actual;
-  Vertex *other[2];
-  int K, i, N = 0;
-  List_T *Edges = List_Create(12, 2, sizeof(Edge));
-  Edge E;
-
-  stack[N++] = s;
-
-  while(N > 0) {
-    actual = stack[--N];
-    if(!Tree_Search(TreeSimpl, &actual)) {
-      Tree_Add(TreeSimpl, &actual);
-      if(actual->EdgeIn(Ed[0], Ed[1], other)) {
-        List_Add(Coquille, &actual);
-        if(actual != s)
-          actual->Radius = -1.;
-        E.V[0] = other[0];
-        E.V[1] = other[1];
-        List_Add(Edges, &E);
-        for(i = 0; i < 4; i++) {
-          if(actual->S[i] && actual->S[i] != &MyNewBoundary)
-            stack[N++] = actual->S[i];
-          else
-            return 0;
-        }
-      }
-    }
-  }
-
-  List_Read(Edges, 0, &E);
-  N = 0;
-  Contour[N++] = E.V[0];
-  Contour[N++] = E.V[1];
-  List_Suppress(Edges, &E, compareEdge);
-  K = 0;
-
-  while(List_Nbr(Edges)) {
-    if(K++ > Tree_Nbr(TreeSimpl))
-      return 0;
-    for(i = 0; i < List_Nbr(Edges); i++) {
-      List_Read(Edges, i, &E);
-      if(!compareVertex(&Contour[N - 1], &E.V[0]) &&
-         compareVertex(&Contour[N - 2], &E.V[1])) {
-        Contour[N++] = E.V[1];
-        List_Suppress(Edges, &E, compareEdge);
-        break;
-      }
-      if(!compareVertex(&Contour[N - 1], &E.V[1]) &&
-         compareVertex(&Contour[N - 2], &E.V[0])) {
-        Contour[N++] = E.V[0];
-        List_Suppress(Edges, &E, compareEdge);
-        break;
-      }
-    }
-
-  }
-  if(!compareVertex(&Contour[0], &Contour[N - 1]))
-    return N - 1;
-  return 0;
-}
-
-bool FindBestPattern(int N, Vertex * Contour[100], Vertex * Ed[2],
-                     List_T * Coquille, List_T * Pattern)
-{
-  int i, j, k, kk, tri[3];
-  Simplex *s, *Pat[100];
-  double old_volume, new_volume;
-  double worst_tet_old, worst_tet_new;
-  bool stop = false;
-  SwapPattern *sp = NULL;
-  SwapPattern3 *x3;
-  SwapPattern4 *x4;
-  SwapPattern5 *x5;
-  SwapPattern6 *x6;
-  SwapPattern7 *x7;
-  SwapPatternN *xN;
-  switch (N) {
-  case 3:
-    x3 = new SwapPattern3;
-    sp = x3;
-    break;
-  case 4:
-    x4 = new SwapPattern4;
-    sp = x4;
-    break;
-  case 5:
-    if(stop)
-      return false;
-    x5 = new SwapPattern5;
-    sp = x5;
-    break;
-  case 6:
-    if(stop)
-      return false;
-    x6 = new SwapPattern6;
-    sp = x6;
-    break;
-  case 7:
-    if(stop)
-      return false;
-    x7 = new SwapPattern7;
-    sp = x7;
-    break;
-  default:
-    if(stop)
-      return false;
-    xN = new SwapPatternN(N);
-    sp = xN;
-    break;
-  }
-
-  old_volume = 0.0;
-  worst_tet_old = 1.;
-  int IENT = 0;
-  for(k = 0; k < List_Nbr(Coquille); k++) {
-    List_Read(Coquille, k, &s);
-    IENT = s->iEnt;
-    old_volume += fabs(s->Volume_Simplexe());
-    worst_tet_old = DMIN(worst_tet_old, s->GammaShapeMeasure());
-  }
-
-  for(i = 0; i < sp->GetNbPatterns(); i++) {
-    for(j = 0; j < sp->GetNbRotations(i); j++) {
-      new_volume = 0.;
-      worst_tet_new = 1.;
-      kk = 0;
-      for(k = 0; k < sp->GetNbTriangles(); k++) {
-        sp->GetTriangle(i, k, tri);
-        s = Create_Simplex(Contour[tri[0]],
-                           Contour[tri[1]], Contour[tri[2]], Ed[0]);
-        s->iEnt = IENT;
-        Pat[kk++] = s;
-        new_volume += fabs(s->Volume_Simplexe());
-        worst_tet_new = DMIN(worst_tet_new, s->GammaShapeMeasure());
-        s = Create_Simplex(Contour[tri[0]],
-                           Contour[tri[1]], Contour[tri[2]], Ed[1]);
-        s->iEnt = IENT;
-        Pat[kk++] = s;
-        new_volume += fabs(s->Volume_Simplexe());
-        worst_tet_new = DMIN(worst_tet_new, s->GammaShapeMeasure());
-      }
-      if(fabs(new_volume - old_volume) >
-         1.e-5 * fabs(new_volume + old_volume))
-        Msg(WARNING, "Edge swapping failed");
-      if(fabs(new_volume - old_volume) > 1.e-5 * fabs(new_volume + old_volume)
-         || worst_tet_new < worst_tet_old) {
-        for(k = 0; k < 2 * sp->GetNbTriangles(); k++) {
-          delete Pat[k];
-        }
-      }
-      else {
-        for(k = 0; k < List_Nbr(Pattern); k++) {
-          List_Read(Pattern, k, &s);
-          delete s;
-        }
-        List_Reset(Pattern);
-        for(k = 0; k < 2 * sp->GetNbTriangles(); k++) {
-          List_Add(Pattern, &Pat[k]);
-        }
-        worst_tet_old = worst_tet_new;
-      }
-    }
-  }
-
-  delete sp;
-  return true;
-}
-
-
-bool SwapEdge(Mesh * M, Volume * v, Simplex * s, int iEdge)
-{
-  int i;
-  Vertex *Contour[100];
-  Vertex *Ed[2];
-  Simplex *simp;
-  Tree_T *TreeSimpl = Tree_Create(sizeof(Simplex *), compareSimplex);
-  List_T *Coquille = List_Create(10, 10, sizeof(Simplex *));
-  Ed[0] = s->V[edges_tetra[iEdge][0]];
-  Ed[1] = s->V[edges_tetra[iEdge][1]];
-  int N = TrouveCoquille(s, Ed, Coquille, TreeSimpl, Contour);
-
-  List_T *Pattern = List_Create(2 * N - 4, 1, sizeof(Simplex *));
-
-  FindBestPattern(N, Contour, Ed, Coquille, Pattern);
-
-  if(List_Nbr(Pattern)) {
-    for(i = 0; i < List_Nbr(Coquille); i++) {
-      List_Read(Coquille, i, &simp);
-      Tree_Suppress(v->Simplexes, &simp);
-      Tree_Suppress(TreeSimpl, &simp);
-    }
-    for(i = 0; i < List_Nbr(Pattern); i++) {
-      List_Read(Pattern, i, &simp);
-      Tree_Add(v->Simplexes, &simp);
-      Tree_Add(TreeSimpl, &simp);
-    }
-    Link_Simplexes(NULL, TreeSimpl /*v->Simplexes */ );
-  }
-  Tree_Delete(TreeSimpl);
-  List_Delete(Coquille);
-  List_Delete(Pattern);
-  return true;
-}
-
-int GetWorstEdge(Simplex * s, EdgesContainer & ec, bool order)
-{
-  Vertex *v11, *v12;
-  Vertex *v21, *v22;
-  v11 = s->V[edges_tetra[0][0]];
-  v12 = s->V[edges_tetra[0][1]];
-  v21 = s->V[edges_tetra[4][0]];
-  v22 = s->V[edges_tetra[4][1]];
-  Vertex d11 = *(v12) - *(v11);
-  Vertex d12 = *(v22) - *(v21);
-  d12.norme();
-  d11.norme();
-  double prosc1 = fabs(d11 * d12);
-
-  v11 = s->V[edges_tetra[1][0]];
-  v12 = s->V[edges_tetra[1][1]];
-  v21 = s->V[edges_tetra[3][0]];
-  v22 = s->V[edges_tetra[3][1]];
-  Vertex d21 = *(v12) - *(v11);
-  Vertex d22 = *(v22) - *(v21);
-  d22.norme();
-  d21.norme();
-  double prosc2 = fabs(d21 * d22);
-
-  v11 = s->V[edges_tetra[2][0]];
-  v12 = s->V[edges_tetra[2][1]];
-  v21 = s->V[edges_tetra[5][0]];
-  v22 = s->V[edges_tetra[5][1]];
-  Vertex d31 = *(v12) - *(v11);
-  Vertex d32 = *(v22) - *(v21);
-  d32.norme();
-  d31.norme();
-  double prosc3 = fabs(d31 * d32);
-
-  if(prosc1 < prosc2 && prosc1 < prosc3) {
-    if(!order && !ec.Search(s->V[edges_tetra[0][0]], s->V[edges_tetra[0][1]]))
-      return 0;
-    if(!ec.Search(s->V[edges_tetra[4][0]], s->V[edges_tetra[4][1]]))
-      return 4;
-    if(!ec.Search(s->V[edges_tetra[0][0]], s->V[edges_tetra[0][1]]))
-      return 0;
-    return -1;
-  }
-  if(prosc2 < prosc1 && prosc2 < prosc3) {
-    if(!order && !ec.Search(s->V[edges_tetra[1][0]], s->V[edges_tetra[1][1]]))
-      return 1;
-    if(!ec.Search(s->V[edges_tetra[3][0]], s->V[edges_tetra[3][1]]))
-      return 3;
-    if(!ec.Search(s->V[edges_tetra[1][0]], s->V[edges_tetra[1][1]]))
-      return 1;
-    return -1;
-  }
-  if(prosc3 < prosc2 && prosc3 < prosc1) {
-    if(!order && !ec.Search(s->V[edges_tetra[2][0]], s->V[edges_tetra[2][1]]))
-      return 2;
-    if(!ec.Search(s->V[edges_tetra[5][0]], s->V[edges_tetra[5][1]]))
-      return 5;
-    if(!ec.Search(s->V[edges_tetra[2][0]], s->V[edges_tetra[2][1]]))
-      return 2;
-    return -1;
-  }
-  return -1;
-}
-
-void SwapEdges3D(Mesh * M, Volume * v, double GammaPrescribed, bool order)
-{
-  List_T *list = Tree2List(v->Simplexes);
-  List_T *srfs = Tree2List(M->Surfaces);
-  if(!List_Nbr(srfs))
-    return;
-  EdgesContainer ec(srfs);
-  Simplex *s;
-
-  for(int i = 0; i < List_Nbr(list); i++) {
-    List_Read(list, i, &s);
-    if(s->GammaShapeMeasure() < GammaPrescribed) {
-      int iEdge = GetWorstEdge(s, ec, order);
-      if(iEdge >= 0)
-        SwapEdge(M, v, s, iEdge);
-    }
-  }
-  List_Delete(srfs);
-  List_Delete(list);
-}
diff --git a/Mesh/SwapPatterns.h b/Mesh/SwapPatterns.h
deleted file mode 100644
index 5a9e93aa7e37301166d24661bc0a4ec2bb752dcd..0000000000000000000000000000000000000000
--- a/Mesh/SwapPatterns.h
+++ /dev/null
@@ -1,223 +0,0 @@
-#ifndef _SWAP_PATTERNS_H_
-#define _SWAP_PATTERNS_H_
-
-// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-int swap_patterns_3 [1][1][3] = {
-  {
-    {0,1,2}
-  }
-};
-
-int swap_patterns_4 [1][2][3] = {
-  {
-    {0,1,3},
-    {1,2,3}
-  }
-};
-
-int swap_patterns_5 [1][3][3] = {
-  {
-    {0,1,2},
-    {0,2,4},
-    {2,3,4}
-  }
-};
-
-int swap_patterns_6 [4][4][3] = {
-  {
-    {0,1,2},
-    {0,2,5},
-    {5,2,4},
-    {4,2,3}
-  },
-  {
-    {0,1,2},
-    {0,2,3},
-    {5,2,3},
-    {5,3,4}
-  },
-  {
-    {0,1,5},
-    {5,1,2},
-    {5,2,4},
-    {4,2,3}
-  },
-  {
-    {0,1,2},
-    {4,0,2},
-    {4,2,3},
-    {0,4,5}
-  }
-};
-
-int swap_patterns_7 [6][5][3] = {
-  {
-    {0,1,3},
-    {1,2,3},
-    {0,3,6},
-    {6,3,5},
-    {5,3,4}
-  },
-  {
-    {0,1,3},
-    {1,2,3},
-    {0,3,4},
-    {0,4,6},
-    {6,4,5}
-  },
-  {
-    {0,1,3},
-    {1,2,3},
-    {0,3,6},
-    {6,3,4},
-    {6,4,5}
-  },
-  {
-    {0,1,2},
-    {0,2,3},
-    {0,3,6},
-    {6,3,5},
-    {5,3,4}
-  },
-  {
-    {0,1,6},
-    {1,2,3},
-    {6,1,3},
-    {6,3,5},
-    {5,3,4}
-  },
-  {
-    {0,1,3},
-    {1,2,3},
-    {0,3,5},
-    {5,3,4},
-    {0,5,6}
-  }
-};
-
-
-class SwapPattern{
-protected :
-  int NbPatterns;
-  int NbNod;
-  int Rot;
-  virtual void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3])=0;
-public :
-  SwapPattern(){Rot = 0;}
-  virtual ~SwapPattern(){}
-  int GetNbPatterns() {return NbPatterns;}
-  virtual int GetNbRotations(int iPattern) = 0;
-  int GetNbTriangles(){return NbNod-2;}
-  void GetTriangle(int iPattern, int iTriangle,int tri[3]){
-    GetTriangleWithoutRot(iPattern,iTriangle,tri);
-    for(int i=0;i<3;i++){
-      tri[i] = (tri[i]+Rot)%NbNod;
-    }
-  }
-  void Rotate (){Rot++;};
-};
-
-class SwapPattern3 : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = swap_patterns_3[iPattern][iTriangle][0];
-    tri[1] = swap_patterns_3[iPattern][iTriangle][1];
-    tri[2] = swap_patterns_3[iPattern][iTriangle][2];
-  }
-public :
-  SwapPattern3(){NbPatterns = 1;NbNod = 3;}
-  int GetNbRotations (int iPattern){
-    return 1;
-  };
-};
-
-class SwapPattern4 : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = swap_patterns_4[iPattern][iTriangle][0];
-    tri[1] = swap_patterns_4[iPattern][iTriangle][1];
-    tri[2] = swap_patterns_4[iPattern][iTriangle][2];
-  }
-public :
-  SwapPattern4(){NbPatterns = 1;NbNod = 4;}
-  int GetNbRotations (int iPattern){
-    return 2;
-  };
-};
-
-class SwapPattern5 : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = swap_patterns_5[iPattern][iTriangle][0];
-    tri[1] = swap_patterns_5[iPattern][iTriangle][1];
-    tri[2] = swap_patterns_5[iPattern][iTriangle][2];
-  }
-public :
-  SwapPattern5(){NbPatterns = 1;NbNod = 5;}
-  int GetNbRotations (int iPattern){
-    return 5;
-  };
-};
-
-class SwapPattern6 : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = swap_patterns_6[iPattern][iTriangle][0];
-    tri[1] = swap_patterns_6[iPattern][iTriangle][1];
-    tri[2] = swap_patterns_6[iPattern][iTriangle][2];
-  }
-public :
-  SwapPattern6(){NbPatterns = 4;NbNod = 6;}
-  int GetNbRotations (int iPattern){
-    switch(iPattern){
-    case 0:return 6;
-    case 1:return 3;
-    case 2:return 3;
-    case 3:return 2;
-    default: return 0;
-    }
-  }
-};
-
-class SwapPattern7 : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = swap_patterns_7[iPattern][iTriangle][0];
-    tri[1] = swap_patterns_7[iPattern][iTriangle][1];
-    tri[2] = swap_patterns_7[iPattern][iTriangle][2];
-  }
-public :
-  SwapPattern7(){NbPatterns = 6;NbNod = 7;}
-  int GetNbRotations (int iPattern){
-    return 7;
-  }
-};
-
-class SwapPatternN : public SwapPattern{
-  void GetTriangleWithoutRot(int iPattern, int iTriangle,int tri[3]){
-    tri[0] = 0;
-    tri[1] = iTriangle+1;
-    tri[2] = iTriangle+2;
-  }
-public :
-  SwapPatternN(int N){NbPatterns = 1;NbNod = N;}
-  int GetNbRotations (int iPattern){
-    return 8;
-  }
-};
-
-
-#endif
diff --git a/Mesh/Vertex.cpp b/Mesh/Vertex.cpp
index a5503af868cd0b1ec4cd1c770e7cbe4410366f3a..50e1129becea1022af622925a575a2b72dc32c5b 100644
--- a/Mesh/Vertex.cpp
+++ b/Mesh/Vertex.cpp
@@ -1,4 +1,4 @@
-// $Id: Vertex.cpp,v 1.30 2006-08-12 16:16:30 geuzaine Exp $
+// $Id: Vertex.cpp,v 1.31 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -41,7 +41,6 @@ Vertex::Vertex()
   Mov = NULL;
   ListSurf = NULL;
   ListCurves = NULL;
-  Extruded_Points = NULL;
 }
 
 Vertex::Vertex(double X, double Y, double Z, double l, double W)
@@ -57,7 +56,6 @@ Vertex::Vertex(double X, double Y, double Z, double l, double W)
   Mov = NULL;
   ListSurf = NULL;
   ListCurves = NULL;
-  Extruded_Points = NULL;
 }
 
 void Vertex::norme()
@@ -123,12 +121,6 @@ void Delete_Vertex(Vertex * pV)
   if(pV) {
     List_Delete(pV->ListSurf);
     List_Delete(pV->ListCurves);
-    if(CTX.mesh.oldxtrude) {    //old automatic extrusion algorithm
-      List_Delete(pV->Extruded_Points);
-    }
-    else {
-      Free_ExtrudedPoints(pV->Extruded_Points);
-    }
     delete pV;
   }
 }
diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp
index 798f5759cfb09a4bdbd45f02bdf855d013e0c536..82deee90255c0daef09803bd1a48489976c87976 100644
--- a/Mesh/meshGFace.cpp
+++ b/Mesh/meshGFace.cpp
@@ -1,4 +1,4 @@
-// $Id: meshGFace.cpp,v 1.24 2006-11-24 20:07:48 geuzaine Exp $
+// $Id: meshGFace.cpp,v 1.25 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -21,7 +21,6 @@
 
 #include "meshGFace.h"
 #include "GVertex.h"
-#include "2D_Mesh.h"
 #include "GEdge.h"
 #include "GFace.h"
 #include "MVertex.h"
@@ -523,127 +522,6 @@ void RefineMesh ( GFace *gf, BDS_Mesh &m , const int NIT)
     }  
 }
 
-void OldMeshGenerator ( GFace *gf,
-			std::vector<MVertex*> &points,
-			std::vector<int> &indices, int initialOnly)
-{
-
-
-  // put the loops on the right sense, cause this stupid cannot
-  // handle non oriented loops
-  int nbEdgeLoops = indices.size()-1;
-
-  for(int i = 0; i < nbEdgeLoops; i++) {
-    int nbPtsOnEdgeLoop = indices[i+1] -indices[i];
-    std::vector<MVertex*> loop;
-    for(int j = indices[i]; j < indices[i+1]; j++)loop.push_back(points[j]);
-    //    Msg(INFO, " %d %d %d %d",i,indices[i],indices[i+1],Orientation(loop));
-    int k = 0;
-    int ori = Orientation(loop);
-    if (i == 0 && !ori)
-      for(int j = indices[i]; j < indices[i+1]; j++)points[j] = loop [nbPtsOnEdgeLoop-k++-1];
-    else if (i != 0 && ori)
-      for(int j = indices[i]; j < indices[i+1]; j++)points[j] = loop [nbPtsOnEdgeLoop-k++-1];
-  }
-
-  extern PointRecord *gPointArray;
-
-  // FIX THAT !!
-  double LC2D = 1;
-  if (gf->geomType () == GEntity::Plane)
-    {
-      SBoundingBox3d bb = gf->bounds();
-      SPoint3 _min = bb.min();
-      SPoint3 _max = bb.max();
-      
-      SVector3 diam (_min,_max);
-      LC2D = norm(diam);
-    }
-
-  //  Msg(INFO, "LC = %g",LC2D);
-
-  maillage M;
-  ContourRecord *cp, **liste;
-  liste = (ContourPeek *) malloc(nbEdgeLoops * sizeof(ContourPeek));
-  for(int i = 0; i < nbEdgeLoops; i++) {
-    cp = (ContourRecord *) malloc(sizeof(ContourRecord));
-    int nbPtsOnEdgeLoop = indices[i+1] -indices[i];
-    cp->oriented_points =
-      (PointRecord *) malloc(nbPtsOnEdgeLoop * sizeof(PointRecord));
-    cp->perturbations = (MPoint *) malloc( nbPtsOnEdgeLoop * sizeof(MPoint));
-    cp->numerocontour = i;
-    int k=0;
-    //    Msg(INFO, " %d %d %d ",i,indices[i],indices[i+1]);
-    for(int j = indices[i]; j < indices[i+1]; j++) {
-      MVertex *here     = points[j];
-      cp->oriented_points[k].where.h = here->x();
-      cp->oriented_points[k].where.v = here->y();
-      cp->perturbations[k].h = CTX.mesh.rand_factor * LC2D *
-        (double)rand() / (double)RAND_MAX;
-      cp->perturbations[k].v = CTX.mesh.rand_factor * LC2D *
-        (double)rand() / (double)RAND_MAX;      
-      cp->oriented_points[k].numcontour = i;
-
-      MVertex *previous = (j == indices[i])?points[indices[i+1]-1] : points[j-1]; 
-      MVertex *next     = (j == indices[i+1]-1)?points[indices[i]] : points[j+1];
-
-      double lc = 0.5 * ( sqrt ( (here->x() - previous->x())*(here->x() - previous->x()) +
-				 (here->y() - previous->y())*(here->y() - previous->y()) ) +
-			  sqrt ( (here->x() - next->x())*(here->x() - next->x()) +
-				 (here->y() - next->y())*(here->y() - next->y()) ) );		   
-      
-      //            Msg(INFO, " %g %g %g ",here->x(),here->y(),lc);
-      cp->oriented_points[k].quality = lc;
-      cp->oriented_points[k].permu = j;
-      cp->oriented_points[k].initial = j;
-      k++;
-    }
-    cp->numpoints = nbPtsOnEdgeLoop;
-    liste[i] = cp;
-  }
-
-  int N;
-  int res_mesh_domain = mesh_domain(liste, nbEdgeLoops, &M, &N,initialOnly);
-
-  //  Msg(INFO, "result is %d",res_mesh_domain);
-    
-  MVertex ** verts_ = new MVertex* [M.numpoints];
-  for(int i = 0; i < M.numpoints; i++) {
-    //    Msg(INFO, "gpa[%d] = %g %g",i,gPointArray[i].where.h,gPointArray[i].where.v);
-    if(gPointArray[i].initial < 0) {
-   
-      verts_[i]  = new MFaceVertex ( gPointArray[i].where.h,
-				     gPointArray[i].where.v, 0.0, gf, 
-				     0,0);           
-      gf->mesh_vertices.push_back(verts_[i]);
-    }
-    else
-      {
-	verts_[i]  = points[gPointArray[i].initial];
-      }
-  }  
-  
-  for(int i = 0; i < M.numtriangles; i++) 
-    {
-      int a = M.listdel[i]->t.a;
-      int b = M.listdel[i]->t.b;
-      int c = M.listdel[i]->t.c;
-      //      Msg(INFO, "tri[%d] = %d %d %d",i,a,b,c);
-      gf->triangles.push_back(new MTriangle(verts_[a], verts_[b], verts_[c]));
-    }
-  
-  delete [] verts_;
-  if(res_mesh_domain >= 0)
-    free(M.listdel);
-  free(gPointArray);
-  
-  for(int i = 0; i < nbEdgeLoops; i++) {
-    free(liste[i]->perturbations);
-    free(liste[i]->oriented_points);
-    free(liste[i]);
-  }
-  free(liste);
-}
 
 
 bool recover_medge ( BDS_Mesh *m, GEdge *ge)
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index e862056358e1c2c66ee8951d404e2cdb452c068e..08ab5734f0f1bf7914e178f1c0fade9e3c4149d2 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -126,7 +126,7 @@
 
 #line 1 "Gmsh.y"
 
-// $Id: Gmsh.tab.cpp,v 1.276 2006-11-25 00:44:25 geuzaine Exp $
+// $Id: Gmsh.tab.cpp,v 1.277 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -527,32 +527,32 @@ static const short yyrline[] = { 0,
    579,   584,   588,   597,   599,   600,   601,   602,   605,   607,
    610,   645,   684,   738,   755,   773,   784,   803,   817,   834,
    860,   887,   901,   918,   932,   949,   969,   992,  1002,  1017,
-  1037,  1053,  1072,  1091,  1109,  1127,  1145,  1171,  1189,  1215,
-  1235,  1259,  1283,  1309,  1326,  1344,  1363,  1382,  1421,  1446,
-  1465,  1484,  1500,  1520,  1537,  1554,  1574,  1580,  1585,  1590,
-  1597,  1599,  1600,  1603,  1608,  1612,  1628,  1644,  1660,  1680,
-  1695,  1701,  1707,  1718,  1728,  1738,  1752,  1770,  1784,  1791,
-  1797,  1806,  1819,  1865,  1880,  1891,  1911,  1921,  1943,  1947,
-  1952,  1957,  1967,  1984,  2000,  2026,  2053,  2085,  2092,  2097,
-  2103,  2107,  2115,  2124,  2132,  2140,  2145,  2153,  2158,  2166,
-  2171,  2181,  2188,  2195,  2202,  2209,  2216,  2223,  2230,  2237,
-  2244,  2249,  2256,  2261,  2268,  2273,  2280,  2285,  2292,  2297,
-  2304,  2309,  2316,  2321,  2328,  2333,  2340,  2345,  2355,  2359,
-  2364,  2391,  2415,  2423,  2442,  2460,  2478,  2507,  2542,  2569,
-  2596,  2610,  2628,  2635,  2641,  2644,  2650,  2655,  2664,  2666,
-  2667,  2668,  2669,  2670,  2671,  2672,  2673,  2680,  2681,  2682,
-  2683,  2684,  2685,  2686,  2687,  2688,  2689,  2690,  2691,  2692,
-  2693,  2694,  2695,  2696,  2697,  2698,  2699,  2700,  2701,  2702,
-  2703,  2704,  2705,  2706,  2707,  2708,  2709,  2710,  2711,  2713,
-  2714,  2715,  2716,  2717,  2718,  2719,  2720,  2721,  2722,  2723,
-  2724,  2725,  2726,  2727,  2728,  2729,  2730,  2731,  2732,  2733,
-  2738,  2743,  2744,  2745,  2746,  2747,  2748,  2752,  2768,  2783,
-  2803,  2817,  2830,  2853,  2871,  2889,  2907,  2925,  2932,  2937,
-  2941,  2945,  2949,  2955,  2960,  2964,  2968,  2974,  2978,  2982,
-  2988,  2994,  3001,  3007,  3011,  3016,  3020,  3031,  3038,  3049,
-  3069,  3079,  3089,  3099,  3116,  3135,  3159,  3187,  3193,  3197,
-  3201,  3213,  3218,  3230,  3237,  3258,  3263,  3277,  3283,  3289,
-  3294,  3302,  3310,  3324,  3338,  3342,  3361,  3383
+  1037,  1053,  1060,  1079,  1097,  1115,  1133,  1159,  1177,  1203,
+  1223,  1247,  1271,  1297,  1314,  1321,  1340,  1359,  1398,  1423,
+  1442,  1461,  1477,  1497,  1514,  1531,  1551,  1557,  1562,  1567,
+  1574,  1576,  1577,  1580,  1585,  1589,  1605,  1621,  1637,  1657,
+  1672,  1678,  1684,  1695,  1705,  1715,  1729,  1747,  1761,  1768,
+  1774,  1783,  1796,  1842,  1857,  1868,  1888,  1898,  1920,  1924,
+  1929,  1934,  1944,  1961,  1977,  2003,  2030,  2062,  2069,  2074,
+  2080,  2084,  2092,  2101,  2109,  2117,  2122,  2130,  2135,  2143,
+  2148,  2158,  2165,  2172,  2179,  2186,  2193,  2200,  2207,  2214,
+  2221,  2226,  2233,  2238,  2245,  2250,  2257,  2262,  2269,  2274,
+  2281,  2286,  2293,  2298,  2305,  2310,  2317,  2322,  2332,  2336,
+  2341,  2368,  2392,  2400,  2419,  2437,  2455,  2484,  2519,  2546,
+  2573,  2587,  2605,  2612,  2618,  2621,  2627,  2632,  2641,  2643,
+  2644,  2645,  2646,  2647,  2648,  2649,  2650,  2657,  2658,  2659,
+  2660,  2661,  2662,  2663,  2664,  2665,  2666,  2667,  2668,  2669,
+  2670,  2671,  2672,  2673,  2674,  2675,  2676,  2677,  2678,  2679,
+  2680,  2681,  2682,  2683,  2684,  2685,  2686,  2687,  2688,  2690,
+  2691,  2692,  2693,  2694,  2695,  2696,  2697,  2698,  2699,  2700,
+  2701,  2702,  2703,  2704,  2705,  2706,  2707,  2708,  2709,  2710,
+  2715,  2720,  2721,  2722,  2723,  2724,  2725,  2729,  2745,  2760,
+  2780,  2794,  2807,  2830,  2848,  2866,  2884,  2902,  2909,  2914,
+  2918,  2922,  2926,  2932,  2937,  2941,  2945,  2951,  2955,  2959,
+  2965,  2971,  2978,  2984,  2988,  2993,  2997,  3008,  3015,  3026,
+  3046,  3056,  3066,  3076,  3093,  3112,  3136,  3164,  3170,  3174,
+  3178,  3190,  3195,  3207,  3214,  3235,  3240,  3254,  3260,  3266,
+  3271,  3279,  3287,  3301,  3315,  3319,  3338,  3360
 };
 #endif
 
@@ -3775,26 +3775,14 @@ case 81:
 case 82:
 #line 1054 "Gmsh.y"
 {
-      for(int i = 0; i < List_Nbr(yyvsp[-9].l); i++){
-	double p;
-      	List_Read(yyvsp[-9].l, i, &p);
-        Vertex *v = FindPoint((int)p);
-        if(!v)
-	  yymsg(WARNING, "Unknown point %d", (int)p);
-	else{
-	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
-					  yyvsp[-6].d, yyvsp[-4].d, yyvsp[-2].d, v, NULL, NULL);
-	  List_Add(THEM->Metric->Attractors, &a);
-        }
-      }
+      yymsg(GERROR, "Attractors are deprecated");
       List_Delete(yyvsp[-9].l);
-      // dummy values
       yyval.s.Type = 0;
       yyval.s.Num = 0;
     ;
     break;}
 case 83:
-#line 1073 "Gmsh.y"
+#line 1061 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-3].l); i++){
 	double d;
@@ -3812,7 +3800,7 @@ case 83:
     ;
     break;}
 case 84:
-#line 1092 "Gmsh.y"
+#line 1080 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -3832,7 +3820,7 @@ case 84:
     ;
     break;}
 case 85:
-#line 1110 "Gmsh.y"
+#line 1098 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -3852,7 +3840,7 @@ case 85:
     ;
     break;}
 case 86:
-#line 1128 "Gmsh.y"
+#line 1116 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -3872,7 +3860,7 @@ case 86:
     ;
     break;}
 case 87:
-#line 1146 "Gmsh.y"
+#line 1134 "Gmsh.y"
 {
       int num = (int)yyvsp[-6].d;
       if(FindCurve(num)){
@@ -3900,7 +3888,7 @@ case 87:
     ;
     break;}
 case 88:
-#line 1172 "Gmsh.y"
+#line 1160 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -3920,7 +3908,7 @@ case 88:
     ;
     break;}
 case 89:
-#line 1190 "Gmsh.y"
+#line 1178 "Gmsh.y"
 {
       int num = (int)yyvsp[-6].d;
       if(FindCurve(num)){
@@ -3948,7 +3936,7 @@ case 89:
     ;
     break;}
 case 90:
-#line 1217 "Gmsh.y"
+#line 1205 "Gmsh.y"
 {
       int num = (int)yyvsp[-14].d;
       if(FindCurve(num)){
@@ -3969,7 +3957,7 @@ case 90:
     ;
     break;}
 case 91:
-#line 1236 "Gmsh.y"
+#line 1224 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(List_Nbr(yyvsp[-1].l) < 4){
@@ -3995,7 +3983,7 @@ case 91:
     ;
     break;}
 case 92:
-#line 1260 "Gmsh.y"
+#line 1248 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(List_Nbr(yyvsp[-1].l) < 4){
@@ -4021,7 +4009,7 @@ case 92:
     ;
     break;}
 case 93:
-#line 1284 "Gmsh.y"
+#line 1272 "Gmsh.y"
 {
       int num = (int)yyvsp[-8].d;
       if(List_Nbr(yyvsp[-5].l) + (int)yyvsp[-1].d + 1 != List_Nbr(yyvsp[-3].l)){
@@ -4049,7 +4037,7 @@ case 93:
     ;
     break;}
 case 94:
-#line 1310 "Gmsh.y"
+#line 1298 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindEdgeLoop(num)){
@@ -4068,27 +4056,16 @@ case 94:
     ;
     break;}
 case 95:
-#line 1327 "Gmsh.y"
-{
-      for(int i = 0; i < List_Nbr(yyvsp[-9].l); i++){
-	double p;
-      	List_Read(yyvsp[-9].l, i, &p);
-	Curve *c = FindCurve((int)p);
-        if(!c)
-	  yymsg(WARNING, "Unknown curve %d", (int)p);
-	else{
-	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
-					  yyvsp[-6].d, yyvsp[-4].d, yyvsp[-2].d, NULL, c, NULL);
-	  List_Add(THEM->Metric->Attractors, &a);
-        }
-      }
-      // dummy values
+#line 1315 "Gmsh.y"
+{
+      yymsg(GERROR, "Attractors are deprecated");
+      List_Delete(yyvsp[-9].l);
       yyval.s.Type = 0;
       yyval.s.Num = 0;
     ;
     break;}
 case 96:
-#line 1345 "Gmsh.y"
+#line 1322 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_LINE)){
@@ -4106,7 +4083,7 @@ case 96:
     ;
     break;}
 case 97:
-#line 1364 "Gmsh.y"
+#line 1341 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindSurface(num)){
@@ -4127,7 +4104,7 @@ case 97:
     ;
     break;}
 case 98:
-#line 1383 "Gmsh.y"
+#line 1360 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d, type = 0;
       if(FindSurface(num)){
@@ -4168,7 +4145,7 @@ case 98:
     ;
     break;}
 case 99:
-#line 1422 "Gmsh.y"
+#line 1399 "Gmsh.y"
 {
       int num = (int)yyvsp[-8].d;
       Surface *support = FindSurface((int)yyvsp[-4].d);
@@ -4195,7 +4172,7 @@ case 99:
     ;
     break;}
 case 100:
-#line 1449 "Gmsh.y"
+#line 1426 "Gmsh.y"
 {
       int num = (int)yyvsp[-16].d;
       if(FindSurface(num)){
@@ -4214,7 +4191,7 @@ case 100:
     ;
     break;}
 case 101:
-#line 1468 "Gmsh.y"
+#line 1445 "Gmsh.y"
 {
       int num = (int)yyvsp[-16].d;
       if(FindSurface(num)){
@@ -4233,7 +4210,7 @@ case 101:
     ;
     break;}
 case 102:
-#line 1485 "Gmsh.y"
+#line 1462 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindSurfaceLoop(num)){
@@ -4251,7 +4228,7 @@ case 102:
     ;
     break;}
 case 103:
-#line 1501 "Gmsh.y"
+#line 1478 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_SURFACE)){
@@ -4269,7 +4246,7 @@ case 103:
     ;
     break;}
 case 104:
-#line 1521 "Gmsh.y"
+#line 1498 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindVolume(num)){
@@ -4288,7 +4265,7 @@ case 104:
     ;
     break;}
 case 105:
-#line 1538 "Gmsh.y"
+#line 1515 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindVolume(num)){
@@ -4307,7 +4284,7 @@ case 105:
     ;
     break;}
 case 106:
-#line 1555 "Gmsh.y"
+#line 1532 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_VOLUME)){
@@ -4325,59 +4302,59 @@ case 106:
     ;
     break;}
 case 107:
-#line 1576 "Gmsh.y"
+#line 1553 "Gmsh.y"
 {
       TranslateShapes(yyvsp[-3].v[0], yyvsp[-3].v[1], yyvsp[-3].v[2], yyvsp[-1].l, 1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 108:
-#line 1581 "Gmsh.y"
+#line 1558 "Gmsh.y"
 {
       RotateShapes(yyvsp[-8].v[0], yyvsp[-8].v[1], yyvsp[-8].v[2], yyvsp[-6].v[0], yyvsp[-6].v[1], yyvsp[-6].v[2], yyvsp[-4].d, yyvsp[-1].l, 1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 109:
-#line 1586 "Gmsh.y"
+#line 1563 "Gmsh.y"
 {
       SymmetryShapes(yyvsp[-3].v[0], yyvsp[-3].v[1], yyvsp[-3].v[2], yyvsp[-3].v[3], yyvsp[-1].l, 1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 110:
-#line 1591 "Gmsh.y"
+#line 1568 "Gmsh.y"
 {
       DilatShapes(yyvsp[-6].v[0], yyvsp[-6].v[1], yyvsp[-6].v[2], yyvsp[-4].d, yyvsp[-1].l, 1);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 111:
-#line 1598 "Gmsh.y"
+#line 1575 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 112:
-#line 1599 "Gmsh.y"
+#line 1576 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 113:
-#line 1600 "Gmsh.y"
+#line 1577 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 114:
-#line 1605 "Gmsh.y"
+#line 1582 "Gmsh.y"
 {
       yyval.l = List_Create(3, 3, sizeof(Shape));
     ;
     break;}
 case 115:
-#line 1609 "Gmsh.y"
+#line 1586 "Gmsh.y"
 {
       List_Add(yyval.l, &yyvsp[0].s);
     ;
     break;}
 case 116:
-#line 1613 "Gmsh.y"
+#line 1590 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4395,7 +4372,7 @@ case 116:
     ;
     break;}
 case 117:
-#line 1629 "Gmsh.y"
+#line 1606 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4413,7 +4390,7 @@ case 117:
     ;
     break;}
 case 118:
-#line 1645 "Gmsh.y"
+#line 1622 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4431,7 +4408,7 @@ case 118:
     ;
     break;}
 case 119:
-#line 1661 "Gmsh.y"
+#line 1638 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4449,7 +4426,7 @@ case 119:
     ;
     break;}
 case 120:
-#line 1682 "Gmsh.y"
+#line 1659 "Gmsh.y"
 {
       yyval.l = List_Create(3, 3, sizeof(Shape));
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -4464,7 +4441,7 @@ case 120:
     ;
     break;}
 case 121:
-#line 1696 "Gmsh.y"
+#line 1673 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")) AliasView((int)yyvsp[-2].d, 0);
       Free(yyvsp[-4].c);
@@ -4472,7 +4449,7 @@ case 121:
     ;
     break;}
 case 122:
-#line 1702 "Gmsh.y"
+#line 1679 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")) AliasView((int)yyvsp[-2].d, 0);
       Free(yyvsp[-4].c);
@@ -4480,7 +4457,7 @@ case 122:
     ;
     break;}
 case 123:
-#line 1708 "Gmsh.y"
+#line 1685 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")) AliasView((int)yyvsp[-2].d, 1);
       Free(yyvsp[-4].c);
@@ -4488,7 +4465,7 @@ case 123:
     ;
     break;}
 case 124:
-#line 1720 "Gmsh.y"
+#line 1697 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	Shape TheShape;
@@ -4499,7 +4476,7 @@ case 124:
     ;
     break;}
 case 125:
-#line 1729 "Gmsh.y"
+#line 1706 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")){
 	RemoveViewByIndex((int)yyvsp[-2].d);
@@ -4511,7 +4488,7 @@ case 125:
     ;
     break;}
 case 126:
-#line 1739 "Gmsh.y"
+#line 1716 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-1].c, "Meshes") || !strcmp(yyvsp[-1].c, "All")){
 	Init_Mesh();
@@ -4527,7 +4504,7 @@ case 126:
     ;
     break;}
 case 127:
-#line 1753 "Gmsh.y"
+#line 1730 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-2].c, "Empty") && !strcmp(yyvsp[-1].c, "Views")){
 	for(int i = List_Nbr(CTX.post.list) - 1; i >= 0; i--){
@@ -4543,7 +4520,7 @@ case 127:
     ;
     break;}
 case 128:
-#line 1772 "Gmsh.y"
+#line 1749 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	Shape TheShape;
@@ -4554,7 +4531,7 @@ case 128:
     ;
     break;}
 case 129:
-#line 1786 "Gmsh.y"
+#line 1763 "Gmsh.y"
 {
       for(int i = 0; i < 4; i++)
 	VisibilityShape(yyvsp[-1].c, i, 1);
@@ -4562,7 +4539,7 @@ case 129:
     ;
     break;}
 case 130:
-#line 1792 "Gmsh.y"
+#line 1769 "Gmsh.y"
 {
       for(int i = 0; i < 4; i++)
 	VisibilityShape(yyvsp[-1].c, i, 0);
@@ -4570,7 +4547,7 @@ case 130:
     ;
     break;}
 case 131:
-#line 1798 "Gmsh.y"
+#line 1775 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	Shape TheShape;
@@ -4581,7 +4558,7 @@ case 131:
     ;
     break;}
 case 132:
-#line 1807 "Gmsh.y"
+#line 1784 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	Shape TheShape;
@@ -4592,7 +4569,7 @@ case 132:
     ;
     break;}
 case 133:
-#line 1821 "Gmsh.y"
+#line 1798 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-2].c, "Include")){
 	char tmpstring[1024];
@@ -4639,7 +4616,7 @@ case 133:
     ;
     break;}
 case 134:
-#line 1866 "Gmsh.y"
+#line 1843 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-6].c, "Save") && !strcmp(yyvsp[-5].c, "View")){
 	Post_View **vv = (Post_View **)List_Pointer_Test(CTX.post.list, (int)yyvsp[-3].d);
@@ -4656,7 +4633,7 @@ case 134:
     ;
     break;}
 case 135:
-#line 1881 "Gmsh.y"
+#line 1858 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-6].c, "Background") && !strcmp(yyvsp[-5].c, "Mesh")  && !strcmp(yyvsp[-4].c, "View")){
 	Post_View **vv = (Post_View **)List_Pointer_Test(CTX.post.list, (int)yyvsp[-2].d);
@@ -4669,7 +4646,7 @@ case 135:
     ;
     break;}
 case 136:
-#line 1892 "Gmsh.y"
+#line 1869 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-2].c, "Sleep")){
 	SleepInSeconds(yyvsp[-1].d);
@@ -4691,7 +4668,7 @@ case 136:
     ;
     break;}
 case 137:
-#line 1912 "Gmsh.y"
+#line 1889 "Gmsh.y"
 {
        try {
 	 GMSH_PluginManager::instance()->action(yyvsp[-4].c, yyvsp[-1].c, 0);
@@ -4703,7 +4680,7 @@ case 137:
      ;
     break;}
 case 138:
-#line 1922 "Gmsh.y"
+#line 1899 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-1].c, "ElementsFromAllViews"))
 	CombineViews(0, 1, CTX.post.combine_remove_orig);
@@ -4727,27 +4704,27 @@ case 138:
     ;
     break;}
 case 139:
-#line 1944 "Gmsh.y"
+#line 1921 "Gmsh.y"
 {
       exit(0);
     ;
     break;}
 case 140:
-#line 1948 "Gmsh.y"
+#line 1925 "Gmsh.y"
 {
       CTX.forced_bbox = 0;
       SetBoundingBox();
     ;
     break;}
 case 141:
-#line 1953 "Gmsh.y"
+#line 1930 "Gmsh.y"
 {
       CTX.forced_bbox = 1;
       SetBoundingBox(yyvsp[-12].d, yyvsp[-10].d, yyvsp[-8].d, yyvsp[-6].d, yyvsp[-4].d, yyvsp[-2].d);
     ;
     break;}
 case 142:
-#line 1958 "Gmsh.y"
+#line 1935 "Gmsh.y"
 {
 #if defined(HAVE_FLTK)
       Draw();
@@ -4755,7 +4732,7 @@ case 142:
     ;
     break;}
 case 143:
-#line 1970 "Gmsh.y"
+#line 1947 "Gmsh.y"
 {
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-3].d;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-1].d;
@@ -4772,7 +4749,7 @@ case 143:
     ;
     break;}
 case 144:
-#line 1985 "Gmsh.y"
+#line 1962 "Gmsh.y"
 {
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-5].d;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-3].d;
@@ -4790,7 +4767,7 @@ case 144:
     ;
     break;}
 case 145:
-#line 2001 "Gmsh.y"
+#line 1978 "Gmsh.y"
 {
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-3].d;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-1].d;
@@ -4818,7 +4795,7 @@ case 145:
     ;
     break;}
 case 146:
-#line 2027 "Gmsh.y"
+#line 2004 "Gmsh.y"
 {
       LoopControlVariablesTab[ImbricatedLoop][0] = yyvsp[-5].d;
       LoopControlVariablesTab[ImbricatedLoop][1] = yyvsp[-3].d;
@@ -4847,7 +4824,7 @@ case 146:
     ;
     break;}
 case 147:
-#line 2054 "Gmsh.y"
+#line 2031 "Gmsh.y"
 {
       if(ImbricatedLoop <= 0){
 	yymsg(GERROR, "Invalid For/EndFor loop");
@@ -4881,7 +4858,7 @@ case 147:
     ;
     break;}
 case 148:
-#line 2086 "Gmsh.y"
+#line 2063 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->createFunction(yyvsp[0].c, yyin, yyname, yylineno))
 	yymsg(GERROR, "Redefinition of function %s", yyvsp[0].c);
@@ -4890,14 +4867,14 @@ case 148:
     ;
     break;}
 case 149:
-#line 2093 "Gmsh.y"
+#line 2070 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->leaveFunction(&yyin, yyname, yylineno))
 	yymsg(GERROR, "Error while exiting function");
     ;
     break;}
 case 150:
-#line 2098 "Gmsh.y"
+#line 2075 "Gmsh.y"
 {
       if(!FunctionManager::Instance()->enterFunction(yyvsp[-1].c, &yyin, yyname, yylineno))
 	yymsg(GERROR, "Unknown function %s", yyvsp[-1].c);
@@ -4905,18 +4882,18 @@ case 150:
     ;
     break;}
 case 151:
-#line 2104 "Gmsh.y"
+#line 2081 "Gmsh.y"
 {
       if(!yyvsp[-1].d) skip_until("If", "EndIf");
     ;
     break;}
 case 152:
-#line 2108 "Gmsh.y"
+#line 2085 "Gmsh.y"
 {
     ;
     break;}
 case 153:
-#line 2117 "Gmsh.y"
+#line 2094 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE, yyvsp[-1].l, 
@@ -4926,7 +4903,7 @@ case 153:
     ;
     break;}
 case 154:
-#line 2125 "Gmsh.y"
+#line 2102 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(ROTATE, yyvsp[-1].l, 
@@ -4936,7 +4913,7 @@ case 154:
     ;
     break;}
 case 155:
-#line 2133 "Gmsh.y"
+#line 2110 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE_ROTATE, yyvsp[-1].l, 
@@ -4946,14 +4923,14 @@ case 155:
     ;
     break;}
 case 156:
-#line 2141 "Gmsh.y"
+#line 2118 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 157:
-#line 2146 "Gmsh.y"
+#line 2123 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE, yyvsp[-3].l, 
@@ -4963,14 +4940,14 @@ case 157:
     ;
     break;}
 case 158:
-#line 2154 "Gmsh.y"
+#line 2131 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 159:
-#line 2159 "Gmsh.y"
+#line 2136 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(ROTATE, yyvsp[-3].l, 
@@ -4980,14 +4957,14 @@ case 159:
     ;
     break;}
 case 160:
-#line 2167 "Gmsh.y"
+#line 2144 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 161:
-#line 2172 "Gmsh.y"
+#line 2149 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE_ROTATE, yyvsp[-3].l, 
@@ -4997,7 +4974,7 @@ case 161:
     ;
     break;}
 case 162:
-#line 2182 "Gmsh.y"
+#line 2159 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_POINT, (int)yyvsp[-4].d, 
@@ -5006,7 +4983,7 @@ case 162:
     ;
     break;}
 case 163:
-#line 2189 "Gmsh.y"
+#line 2166 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SEGM_LINE, (int)yyvsp[-4].d, 
@@ -5015,7 +4992,7 @@ case 163:
     ;
     break;}
 case 164:
-#line 2196 "Gmsh.y"
+#line 2173 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SURF_PLAN, (int)yyvsp[-4].d, 
@@ -5024,7 +5001,7 @@ case 164:
     ;
     break;}
 case 165:
-#line 2203 "Gmsh.y"
+#line 2180 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_POINT, (int)yyvsp[-8].d, 
@@ -5033,7 +5010,7 @@ case 165:
     ;
     break;}
 case 166:
-#line 2210 "Gmsh.y"
+#line 2187 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SEGM_LINE, (int)yyvsp[-8].d, 
@@ -5042,7 +5019,7 @@ case 166:
     ;
     break;}
 case 167:
-#line 2217 "Gmsh.y"
+#line 2194 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SURF_PLAN, (int)yyvsp[-8].d, 
@@ -5051,7 +5028,7 @@ case 167:
     ;
     break;}
 case 168:
-#line 2224 "Gmsh.y"
+#line 2201 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_POINT, (int)yyvsp[-10].d, 
@@ -5060,7 +5037,7 @@ case 168:
     ;
     break;}
 case 169:
-#line 2231 "Gmsh.y"
+#line 2208 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SEGM_LINE, (int)yyvsp[-10].d, 
@@ -5069,7 +5046,7 @@ case 169:
     ;
     break;}
 case 170:
-#line 2238 "Gmsh.y"
+#line 2215 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SURF_PLAN, (int)yyvsp[-10].d, 
@@ -5078,14 +5055,14 @@ case 170:
     ;
     break;}
 case 171:
-#line 2245 "Gmsh.y"
+#line 2222 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 172:
-#line 2250 "Gmsh.y"
+#line 2227 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_POINT, (int)yyvsp[-8].d, 
@@ -5094,14 +5071,14 @@ case 172:
     ;
     break;}
 case 173:
-#line 2257 "Gmsh.y"
+#line 2234 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 174:
-#line 2262 "Gmsh.y"
+#line 2239 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SEGM_LINE, (int)yyvsp[-8].d, 
@@ -5110,14 +5087,14 @@ case 174:
     ;
     break;}
 case 175:
-#line 2269 "Gmsh.y"
+#line 2246 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 176:
-#line 2274 "Gmsh.y"
+#line 2251 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SURF_PLAN, (int)yyvsp[-8].d, 
@@ -5126,14 +5103,14 @@ case 176:
     ;
     break;}
 case 177:
-#line 2281 "Gmsh.y"
+#line 2258 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 178:
-#line 2286 "Gmsh.y"
+#line 2263 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_POINT, (int)yyvsp[-12].d, 
@@ -5142,14 +5119,14 @@ case 178:
     ;
     break;}
 case 179:
-#line 2293 "Gmsh.y"
+#line 2270 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 180:
-#line 2298 "Gmsh.y"
+#line 2275 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SEGM_LINE, (int)yyvsp[-12].d, 
@@ -5158,14 +5135,14 @@ case 180:
     ;
     break;}
 case 181:
-#line 2305 "Gmsh.y"
+#line 2282 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 182:
-#line 2310 "Gmsh.y"
+#line 2287 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SURF_PLAN, (int)yyvsp[-12].d, 
@@ -5174,14 +5151,14 @@ case 182:
     ;
     break;}
 case 183:
-#line 2317 "Gmsh.y"
+#line 2294 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 184:
-#line 2322 "Gmsh.y"
+#line 2299 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_POINT, (int)yyvsp[-14].d, 
@@ -5190,14 +5167,14 @@ case 184:
     ;
     break;}
 case 185:
-#line 2329 "Gmsh.y"
+#line 2306 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 186:
-#line 2334 "Gmsh.y"
+#line 2311 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SEGM_LINE, (int)yyvsp[-14].d, 
@@ -5206,14 +5183,14 @@ case 186:
     ;
     break;}
 case 187:
-#line 2341 "Gmsh.y"
+#line 2318 "Gmsh.y"
 {
       extr.mesh.ExtrudeMesh = false;
       extr.mesh.Recombine = false;
     ;
     break;}
 case 188:
-#line 2346 "Gmsh.y"
+#line 2323 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SURF_PLAN, (int)yyvsp[-14].d, 
@@ -5222,17 +5199,17 @@ case 188:
     ;
     break;}
 case 189:
-#line 2357 "Gmsh.y"
+#line 2334 "Gmsh.y"
 {
     ;
     break;}
 case 190:
-#line 2360 "Gmsh.y"
+#line 2337 "Gmsh.y"
 {
     ;
     break;}
 case 191:
-#line 2366 "Gmsh.y"
+#line 2343 "Gmsh.y"
 {
       double d;
       extr.mesh.ExtrudeMesh = true;
@@ -5260,7 +5237,7 @@ case 191:
     ;
     break;}
 case 192:
-#line 2392 "Gmsh.y"
+#line 2369 "Gmsh.y"
 {
       double d;
       extr.mesh.ExtrudeMesh = true;
@@ -5286,13 +5263,13 @@ case 192:
     ;
     break;}
 case 193:
-#line 2416 "Gmsh.y"
+#line 2393 "Gmsh.y"
 {
       extr.mesh.Recombine = true;
     ;
     break;}
 case 194:
-#line 2425 "Gmsh.y"
+#line 2402 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-3].l); i++){
 	double d;
@@ -5312,7 +5289,7 @@ case 194:
     ;
     break;}
 case 195:
-#line 2443 "Gmsh.y"
+#line 2420 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-6].l); i++){
 	double d;
@@ -5332,7 +5309,7 @@ case 195:
     ;
     break;}
 case 196:
-#line 2461 "Gmsh.y"
+#line 2438 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-6].l); i++){
 	double d;
@@ -5352,7 +5329,7 @@ case 196:
     ;
     break;}
 case 197:
-#line 2479 "Gmsh.y"
+#line 2456 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d);
       if(!s)
@@ -5383,7 +5360,7 @@ case 197:
     ;
     break;}
 case 198:
-#line 2508 "Gmsh.y"
+#line 2485 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-5].d);
       if(!s)
@@ -5420,7 +5397,7 @@ case 198:
     ;
     break;}
 case 199:
-#line 2543 "Gmsh.y"
+#line 2520 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-4].d);
       if(!s)
@@ -5449,7 +5426,7 @@ case 199:
     ;
     break;}
 case 200:
-#line 2570 "Gmsh.y"
+#line 2547 "Gmsh.y"
 {
       Volume *v = FindVolume((int)yyvsp[-4].d);
       if(!v)
@@ -5478,7 +5455,7 @@ case 200:
     ;
     break;}
 case 201:
-#line 2597 "Gmsh.y"
+#line 2574 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-3].l); i++){
 	double d;
@@ -5494,7 +5471,7 @@ case 201:
     ;
     break;}
 case 202:
-#line 2611 "Gmsh.y"
+#line 2588 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	double d;
@@ -5509,7 +5486,7 @@ case 202:
     ;
     break;}
 case 203:
-#line 2630 "Gmsh.y"
+#line 2607 "Gmsh.y"
 { 
       Surface *s = FindSurface((int)yyvsp[-1].d);
       if(s)
@@ -5517,7 +5494,7 @@ case 203:
     ;
     break;}
 case 204:
-#line 2636 "Gmsh.y"
+#line 2613 "Gmsh.y"
 {
       Surface *s = FindSurface((int)yyvsp[-1].d);
       if(s)
@@ -5525,61 +5502,61 @@ case 204:
     ;
     break;}
 case 205:
-#line 2642 "Gmsh.y"
+#line 2619 "Gmsh.y"
 {
     ;
     break;}
 case 206:
-#line 2645 "Gmsh.y"
+#line 2622 "Gmsh.y"
 {
     ;
     break;}
 case 207:
-#line 2652 "Gmsh.y"
+#line 2629 "Gmsh.y"
 { 
       ReplaceAllDuplicates();
     ;
     break;}
 case 208:
-#line 2656 "Gmsh.y"
+#line 2633 "Gmsh.y"
 { 
-      IntersectAllSegmentsTogether();
+      yymsg(GERROR, "Intersect is deprecated");
     ;
     break;}
 case 209:
-#line 2665 "Gmsh.y"
+#line 2642 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 210:
-#line 2666 "Gmsh.y"
+#line 2643 "Gmsh.y"
 { yyval.d = yyvsp[-1].d;           ;
     break;}
 case 211:
-#line 2667 "Gmsh.y"
+#line 2644 "Gmsh.y"
 { yyval.d = -yyvsp[0].d;          ;
     break;}
 case 212:
-#line 2668 "Gmsh.y"
+#line 2645 "Gmsh.y"
 { yyval.d = yyvsp[0].d;           ;
     break;}
 case 213:
-#line 2669 "Gmsh.y"
+#line 2646 "Gmsh.y"
 { yyval.d = !yyvsp[0].d;          ;
     break;}
 case 214:
-#line 2670 "Gmsh.y"
+#line 2647 "Gmsh.y"
 { yyval.d = yyvsp[-2].d - yyvsp[0].d;      ;
     break;}
 case 215:
-#line 2671 "Gmsh.y"
+#line 2648 "Gmsh.y"
 { yyval.d = yyvsp[-2].d + yyvsp[0].d;      ;
     break;}
 case 216:
-#line 2672 "Gmsh.y"
+#line 2649 "Gmsh.y"
 { yyval.d = yyvsp[-2].d * yyvsp[0].d;      ;
     break;}
 case 217:
-#line 2674 "Gmsh.y"
+#line 2651 "Gmsh.y"
 { 
       if(!yyvsp[0].d)
 	yymsg(GERROR, "Division by zero in '%g / %g'", yyvsp[-2].d, yyvsp[0].d);
@@ -5588,247 +5565,247 @@ case 217:
     ;
     break;}
 case 218:
-#line 2680 "Gmsh.y"
+#line 2657 "Gmsh.y"
 { yyval.d = (int)yyvsp[-2].d % (int)yyvsp[0].d;  ;
     break;}
 case 219:
-#line 2681 "Gmsh.y"
+#line 2658 "Gmsh.y"
 { yyval.d = pow(yyvsp[-2].d, yyvsp[0].d);  ;
     break;}
 case 220:
-#line 2682 "Gmsh.y"
+#line 2659 "Gmsh.y"
 { yyval.d = yyvsp[-2].d < yyvsp[0].d;      ;
     break;}
 case 221:
-#line 2683 "Gmsh.y"
+#line 2660 "Gmsh.y"
 { yyval.d = yyvsp[-2].d > yyvsp[0].d;      ;
     break;}
 case 222:
-#line 2684 "Gmsh.y"
+#line 2661 "Gmsh.y"
 { yyval.d = yyvsp[-2].d <= yyvsp[0].d;     ;
     break;}
 case 223:
-#line 2685 "Gmsh.y"
+#line 2662 "Gmsh.y"
 { yyval.d = yyvsp[-2].d >= yyvsp[0].d;     ;
     break;}
 case 224:
-#line 2686 "Gmsh.y"
+#line 2663 "Gmsh.y"
 { yyval.d = yyvsp[-2].d == yyvsp[0].d;     ;
     break;}
 case 225:
-#line 2687 "Gmsh.y"
+#line 2664 "Gmsh.y"
 { yyval.d = yyvsp[-2].d != yyvsp[0].d;     ;
     break;}
 case 226:
-#line 2688 "Gmsh.y"
+#line 2665 "Gmsh.y"
 { yyval.d = yyvsp[-2].d && yyvsp[0].d;     ;
     break;}
 case 227:
-#line 2689 "Gmsh.y"
+#line 2666 "Gmsh.y"
 { yyval.d = yyvsp[-2].d || yyvsp[0].d;     ;
     break;}
 case 228:
-#line 2690 "Gmsh.y"
+#line 2667 "Gmsh.y"
 { yyval.d = yyvsp[-4].d? yyvsp[-2].d : yyvsp[0].d;  ;
     break;}
 case 229:
-#line 2691 "Gmsh.y"
+#line 2668 "Gmsh.y"
 { yyval.d = exp(yyvsp[-1].d);      ;
     break;}
 case 230:
-#line 2692 "Gmsh.y"
+#line 2669 "Gmsh.y"
 { yyval.d = log(yyvsp[-1].d);      ;
     break;}
 case 231:
-#line 2693 "Gmsh.y"
+#line 2670 "Gmsh.y"
 { yyval.d = log10(yyvsp[-1].d);    ;
     break;}
 case 232:
-#line 2694 "Gmsh.y"
+#line 2671 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-1].d);     ;
     break;}
 case 233:
-#line 2695 "Gmsh.y"
+#line 2672 "Gmsh.y"
 { yyval.d = sin(yyvsp[-1].d);      ;
     break;}
 case 234:
-#line 2696 "Gmsh.y"
+#line 2673 "Gmsh.y"
 { yyval.d = asin(yyvsp[-1].d);     ;
     break;}
 case 235:
-#line 2697 "Gmsh.y"
+#line 2674 "Gmsh.y"
 { yyval.d = cos(yyvsp[-1].d);      ;
     break;}
 case 236:
-#line 2698 "Gmsh.y"
+#line 2675 "Gmsh.y"
 { yyval.d = acos(yyvsp[-1].d);     ;
     break;}
 case 237:
-#line 2699 "Gmsh.y"
+#line 2676 "Gmsh.y"
 { yyval.d = tan(yyvsp[-1].d);      ;
     break;}
 case 238:
-#line 2700 "Gmsh.y"
+#line 2677 "Gmsh.y"
 { yyval.d = atan(yyvsp[-1].d);     ;
     break;}
 case 239:
-#line 2701 "Gmsh.y"
+#line 2678 "Gmsh.y"
 { yyval.d = atan2(yyvsp[-3].d, yyvsp[-1].d);;
     break;}
 case 240:
-#line 2702 "Gmsh.y"
+#line 2679 "Gmsh.y"
 { yyval.d = sinh(yyvsp[-1].d);     ;
     break;}
 case 241:
-#line 2703 "Gmsh.y"
+#line 2680 "Gmsh.y"
 { yyval.d = cosh(yyvsp[-1].d);     ;
     break;}
 case 242:
-#line 2704 "Gmsh.y"
+#line 2681 "Gmsh.y"
 { yyval.d = tanh(yyvsp[-1].d);     ;
     break;}
 case 243:
-#line 2705 "Gmsh.y"
+#line 2682 "Gmsh.y"
 { yyval.d = fabs(yyvsp[-1].d);     ;
     break;}
 case 244:
-#line 2706 "Gmsh.y"
+#line 2683 "Gmsh.y"
 { yyval.d = floor(yyvsp[-1].d);    ;
     break;}
 case 245:
-#line 2707 "Gmsh.y"
+#line 2684 "Gmsh.y"
 { yyval.d = ceil(yyvsp[-1].d);     ;
     break;}
 case 246:
-#line 2708 "Gmsh.y"
+#line 2685 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d, yyvsp[-1].d); ;
     break;}
 case 247:
-#line 2709 "Gmsh.y"
+#line 2686 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d, yyvsp[-1].d); ;
     break;}
 case 248:
-#line 2710 "Gmsh.y"
+#line 2687 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-3].d*yyvsp[-3].d+yyvsp[-1].d*yyvsp[-1].d); ;
     break;}
 case 249:
-#line 2711 "Gmsh.y"
+#line 2688 "Gmsh.y"
 { yyval.d = yyvsp[-1].d*(double)rand()/(double)RAND_MAX; ;
     break;}
 case 250:
-#line 2713 "Gmsh.y"
+#line 2690 "Gmsh.y"
 { yyval.d = exp(yyvsp[-1].d);      ;
     break;}
 case 251:
-#line 2714 "Gmsh.y"
+#line 2691 "Gmsh.y"
 { yyval.d = log(yyvsp[-1].d);      ;
     break;}
 case 252:
-#line 2715 "Gmsh.y"
+#line 2692 "Gmsh.y"
 { yyval.d = log10(yyvsp[-1].d);    ;
     break;}
 case 253:
-#line 2716 "Gmsh.y"
+#line 2693 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-1].d);     ;
     break;}
 case 254:
-#line 2717 "Gmsh.y"
+#line 2694 "Gmsh.y"
 { yyval.d = sin(yyvsp[-1].d);      ;
     break;}
 case 255:
-#line 2718 "Gmsh.y"
+#line 2695 "Gmsh.y"
 { yyval.d = asin(yyvsp[-1].d);     ;
     break;}
 case 256:
-#line 2719 "Gmsh.y"
+#line 2696 "Gmsh.y"
 { yyval.d = cos(yyvsp[-1].d);      ;
     break;}
 case 257:
-#line 2720 "Gmsh.y"
+#line 2697 "Gmsh.y"
 { yyval.d = acos(yyvsp[-1].d);     ;
     break;}
 case 258:
-#line 2721 "Gmsh.y"
+#line 2698 "Gmsh.y"
 { yyval.d = tan(yyvsp[-1].d);      ;
     break;}
 case 259:
-#line 2722 "Gmsh.y"
+#line 2699 "Gmsh.y"
 { yyval.d = atan(yyvsp[-1].d);     ;
     break;}
 case 260:
-#line 2723 "Gmsh.y"
+#line 2700 "Gmsh.y"
 { yyval.d = atan2(yyvsp[-3].d, yyvsp[-1].d);;
     break;}
 case 261:
-#line 2724 "Gmsh.y"
+#line 2701 "Gmsh.y"
 { yyval.d = sinh(yyvsp[-1].d);     ;
     break;}
 case 262:
-#line 2725 "Gmsh.y"
+#line 2702 "Gmsh.y"
 { yyval.d = cosh(yyvsp[-1].d);     ;
     break;}
 case 263:
-#line 2726 "Gmsh.y"
+#line 2703 "Gmsh.y"
 { yyval.d = tanh(yyvsp[-1].d);     ;
     break;}
 case 264:
-#line 2727 "Gmsh.y"
+#line 2704 "Gmsh.y"
 { yyval.d = fabs(yyvsp[-1].d);     ;
     break;}
 case 265:
-#line 2728 "Gmsh.y"
+#line 2705 "Gmsh.y"
 { yyval.d = floor(yyvsp[-1].d);    ;
     break;}
 case 266:
-#line 2729 "Gmsh.y"
+#line 2706 "Gmsh.y"
 { yyval.d = ceil(yyvsp[-1].d);     ;
     break;}
 case 267:
-#line 2730 "Gmsh.y"
+#line 2707 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d, yyvsp[-1].d); ;
     break;}
 case 268:
-#line 2731 "Gmsh.y"
+#line 2708 "Gmsh.y"
 { yyval.d = fmod(yyvsp[-3].d, yyvsp[-1].d); ;
     break;}
 case 269:
-#line 2732 "Gmsh.y"
+#line 2709 "Gmsh.y"
 { yyval.d = sqrt(yyvsp[-3].d*yyvsp[-3].d+yyvsp[-1].d*yyvsp[-1].d); ;
     break;}
 case 270:
-#line 2733 "Gmsh.y"
+#line 2710 "Gmsh.y"
 { yyval.d = yyvsp[-1].d*(double)rand()/(double)RAND_MAX; ;
     break;}
 case 271:
-#line 2742 "Gmsh.y"
+#line 2719 "Gmsh.y"
 { yyval.d = yyvsp[0].d; ;
     break;}
 case 272:
-#line 2743 "Gmsh.y"
+#line 2720 "Gmsh.y"
 { yyval.d = 3.141592653589793; ;
     break;}
 case 273:
-#line 2744 "Gmsh.y"
+#line 2721 "Gmsh.y"
 { yyval.d = ParUtil::Instance()->rank(); ;
     break;}
 case 274:
-#line 2745 "Gmsh.y"
+#line 2722 "Gmsh.y"
 { yyval.d = ParUtil::Instance()->size(); ;
     break;}
 case 275:
-#line 2746 "Gmsh.y"
+#line 2723 "Gmsh.y"
 { yyval.d = Get_GmshMajorVersion(); ;
     break;}
 case 276:
-#line 2747 "Gmsh.y"
+#line 2724 "Gmsh.y"
 { yyval.d = Get_GmshMinorVersion(); ;
     break;}
 case 277:
-#line 2748 "Gmsh.y"
+#line 2725 "Gmsh.y"
 { yyval.d = Get_GmshPatchVersion(); ;
     break;}
 case 278:
-#line 2753 "Gmsh.y"
+#line 2730 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[0].c;
@@ -5843,7 +5820,7 @@ case 278:
     ;
     break;}
 case 279:
-#line 2769 "Gmsh.y"
+#line 2746 "Gmsh.y"
 {
       char tmpstring[1024];
       sprintf(tmpstring, "%s_%d", yyvsp[-4].c, (int)yyvsp[-1].d) ;
@@ -5860,7 +5837,7 @@ case 279:
     ;
     break;}
 case 280:
-#line 2784 "Gmsh.y"
+#line 2761 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-3].c;
@@ -5882,7 +5859,7 @@ case 280:
     ;
     break;}
 case 281:
-#line 2804 "Gmsh.y"
+#line 2781 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-2].c;
@@ -5898,7 +5875,7 @@ case 281:
     ;
     break;}
 case 282:
-#line 2818 "Gmsh.y"
+#line 2795 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-1].c;
@@ -5913,7 +5890,7 @@ case 282:
     ;
     break;}
 case 283:
-#line 2831 "Gmsh.y"
+#line 2808 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-4].c;
@@ -5935,7 +5912,7 @@ case 283:
     ;
     break;}
 case 284:
-#line 2854 "Gmsh.y"
+#line 2831 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -5955,7 +5932,7 @@ case 284:
     ;
     break;}
 case 285:
-#line 2872 "Gmsh.y"
+#line 2849 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -5975,7 +5952,7 @@ case 285:
     ;
     break;}
 case 286:
-#line 2890 "Gmsh.y"
+#line 2867 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -5995,7 +5972,7 @@ case 286:
     ;
     break;}
 case 287:
-#line 2908 "Gmsh.y"
+#line 2885 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -6015,124 +5992,124 @@ case 287:
     ;
     break;}
 case 288:
-#line 2926 "Gmsh.y"
+#line 2903 "Gmsh.y"
 { 
       yyval.d = GetValue(yyvsp[-3].c, yyvsp[-1].d);
       Free(yyvsp[-3].c);
     ;
     break;}
 case 289:
-#line 2934 "Gmsh.y"
+#line 2911 "Gmsh.y"
 {
       memcpy(yyval.v, yyvsp[0].v, 5*sizeof(double));
     ;
     break;}
 case 290:
-#line 2938 "Gmsh.y"
+#line 2915 "Gmsh.y"
 {
       for(int i = 0; i < 5; i++) yyval.v[i] = -yyvsp[0].v[i];
     ;
     break;}
 case 291:
-#line 2942 "Gmsh.y"
+#line 2919 "Gmsh.y"
 { 
       for(int i = 0; i < 5; i++) yyval.v[i] = yyvsp[0].v[i];
     ;
     break;}
 case 292:
-#line 2946 "Gmsh.y"
+#line 2923 "Gmsh.y"
 { 
       for(int i = 0; i < 5; i++) yyval.v[i] = yyvsp[-2].v[i] - yyvsp[0].v[i];
     ;
     break;}
 case 293:
-#line 2950 "Gmsh.y"
+#line 2927 "Gmsh.y"
 {
       for(int i = 0; i < 5; i++) yyval.v[i] = yyvsp[-2].v[i] + yyvsp[0].v[i];
     ;
     break;}
 case 294:
-#line 2957 "Gmsh.y"
+#line 2934 "Gmsh.y"
 { 
       yyval.v[0] = yyvsp[-9].d;  yyval.v[1] = yyvsp[-7].d;  yyval.v[2] = yyvsp[-5].d;  yyval.v[3] = yyvsp[-3].d; yyval.v[4] = yyvsp[-1].d;
     ;
     break;}
 case 295:
-#line 2961 "Gmsh.y"
+#line 2938 "Gmsh.y"
 { 
       yyval.v[0] = yyvsp[-7].d;  yyval.v[1] = yyvsp[-5].d;  yyval.v[2] = yyvsp[-3].d;  yyval.v[3] = yyvsp[-1].d; yyval.v[4] = 1.0;
     ;
     break;}
 case 296:
-#line 2965 "Gmsh.y"
+#line 2942 "Gmsh.y"
 {
       yyval.v[0] = yyvsp[-5].d;  yyval.v[1] = yyvsp[-3].d;  yyval.v[2] = yyvsp[-1].d;  yyval.v[3] = 0.0; yyval.v[4] = 1.0;
     ;
     break;}
 case 297:
-#line 2969 "Gmsh.y"
+#line 2946 "Gmsh.y"
 {
       yyval.v[0] = yyvsp[-5].d;  yyval.v[1] = yyvsp[-3].d;  yyval.v[2] = yyvsp[-1].d;  yyval.v[3] = 0.0; yyval.v[4] = 1.0;
     ;
     break;}
 case 298:
-#line 2976 "Gmsh.y"
+#line 2953 "Gmsh.y"
 {
     ;
     break;}
 case 299:
-#line 2979 "Gmsh.y"
+#line 2956 "Gmsh.y"
 {
        yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 300:
-#line 2983 "Gmsh.y"
+#line 2960 "Gmsh.y"
 {
        yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 301:
-#line 2990 "Gmsh.y"
+#line 2967 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(List_T*));
       List_Add(yyval.l, &(yyvsp[0].l));
     ;
     break;}
 case 302:
-#line 2995 "Gmsh.y"
+#line 2972 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].l));
     ;
     break;}
 case 303:
-#line 3003 "Gmsh.y"
+#line 2980 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       List_Add(yyval.l, &(yyvsp[0].d));
     ;
     break;}
 case 304:
-#line 3008 "Gmsh.y"
+#line 2985 "Gmsh.y"
 {
       yyval.l = yyvsp[0].l;
     ;
     break;}
 case 305:
-#line 3012 "Gmsh.y"
+#line 2989 "Gmsh.y"
 {
       // creates an empty list
       yyval.l = List_Create(2, 1, sizeof(double));
     ;
     break;}
 case 306:
-#line 3017 "Gmsh.y"
+#line 2994 "Gmsh.y"
 {
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 307:
-#line 3021 "Gmsh.y"
+#line 2998 "Gmsh.y"
 {
       yyval.l = yyvsp[-1].l;
       double *pd;
@@ -6143,7 +6120,7 @@ case 307:
     ;
     break;}
 case 308:
-#line 3033 "Gmsh.y"
+#line 3010 "Gmsh.y"
 { 
       yyval.l = List_Create(2, 1, sizeof(double)); 
       for(double d = yyvsp[-2].d; (yyvsp[-2].d < yyvsp[0].d) ? (d <= yyvsp[0].d) : (d >= yyvsp[0].d); (yyvsp[-2].d < yyvsp[0].d) ? (d += 1.) : (d -= 1.)) 
@@ -6151,7 +6128,7 @@ case 308:
     ;
     break;}
 case 309:
-#line 3039 "Gmsh.y"
+#line 3016 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double)); 
       if(!yyvsp[0].d || (yyvsp[-4].d < yyvsp[-2].d && yyvsp[0].d < 0) || (yyvsp[-4].d > yyvsp[-2].d && yyvsp[0].d > 0)){
@@ -6164,7 +6141,7 @@ case 309:
    ;
     break;}
 case 310:
-#line 3050 "Gmsh.y"
+#line 3027 "Gmsh.y"
 {
       // Returns the coordinates of a point and fills a list with it.
       // This allows to ensure e.g. that relative point positions are
@@ -6186,7 +6163,7 @@ case 310:
     ;
     break;}
 case 311:
-#line 3070 "Gmsh.y"
+#line 3047 "Gmsh.y"
 {
       yyval.l = List_Create(List_Nbr(yyvsp[0].l), 1, sizeof(double));
       for(int i = 0; i < List_Nbr(yyvsp[0].l); i++){
@@ -6198,7 +6175,7 @@ case 311:
     ;
     break;}
 case 312:
-#line 3080 "Gmsh.y"
+#line 3057 "Gmsh.y"
 {
       yyval.l = List_Create(List_Nbr(yyvsp[0].l), 1, sizeof(double));
       for(int i = 0; i < List_Nbr(yyvsp[0].l); i++){
@@ -6210,7 +6187,7 @@ case 312:
     ;
     break;}
 case 313:
-#line 3090 "Gmsh.y"
+#line 3067 "Gmsh.y"
 {
       yyval.l = List_Create(List_Nbr(yyvsp[0].l), 1, sizeof(double));
       for(int i = 0; i < List_Nbr(yyvsp[0].l); i++){
@@ -6222,7 +6199,7 @@ case 313:
     ;
     break;}
 case 314:
-#line 3100 "Gmsh.y"
+#line 3077 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -6241,7 +6218,7 @@ case 314:
     ;
     break;}
 case 315:
-#line 3117 "Gmsh.y"
+#line 3094 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -6262,7 +6239,7 @@ case 315:
     ;
     break;}
 case 316:
-#line 3136 "Gmsh.y"
+#line 3113 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -6288,7 +6265,7 @@ case 316:
     ;
     break;}
 case 317:
-#line 3160 "Gmsh.y"
+#line 3137 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -6316,26 +6293,26 @@ case 317:
     ;
     break;}
 case 318:
-#line 3189 "Gmsh.y"
+#line 3166 "Gmsh.y"
 {
       yyval.l = List_Create(2, 1, sizeof(double));
       List_Add(yyval.l, &(yyvsp[0].d));
     ;
     break;}
 case 319:
-#line 3194 "Gmsh.y"
+#line 3171 "Gmsh.y"
 {
       yyval.l = yyvsp[0].l;
     ;
     break;}
 case 320:
-#line 3198 "Gmsh.y"
+#line 3175 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].d));
     ;
     break;}
 case 321:
-#line 3202 "Gmsh.y"
+#line 3179 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[0].l); i++){
 	double d;
@@ -6346,19 +6323,19 @@ case 321:
     ;
     break;}
 case 322:
-#line 3215 "Gmsh.y"
+#line 3192 "Gmsh.y"
 {
       yyval.u = CTX.PACK_COLOR((int)yyvsp[-7].d, (int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d);
     ;
     break;}
 case 323:
-#line 3219 "Gmsh.y"
+#line 3196 "Gmsh.y"
 {
       yyval.u = CTX.PACK_COLOR((int)yyvsp[-5].d, (int)yyvsp[-3].d, (int)yyvsp[-1].d, 255);
     ;
     break;}
 case 324:
-#line 3231 "Gmsh.y"
+#line 3208 "Gmsh.y"
 {
       int flag;
       yyval.u = Get_ColorForString(ColorString, -1, yyvsp[0].c, &flag);
@@ -6367,7 +6344,7 @@ case 324:
     ;
     break;}
 case 325:
-#line 3238 "Gmsh.y"
+#line 3215 "Gmsh.y"
 {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -6388,13 +6365,13 @@ case 325:
     ;
     break;}
 case 326:
-#line 3260 "Gmsh.y"
+#line 3237 "Gmsh.y"
 {
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 327:
-#line 3264 "Gmsh.y"
+#line 3241 "Gmsh.y"
 {
       yyval.l = List_Create(256, 10, sizeof(unsigned int));
       GmshColorTable *ct = Get_ColorTable((int)yyvsp[-3].d);
@@ -6408,26 +6385,26 @@ case 327:
     ;
     break;}
 case 328:
-#line 3279 "Gmsh.y"
+#line 3256 "Gmsh.y"
 {
       yyval.l = List_Create(256, 10, sizeof(unsigned int));
       List_Add(yyval.l, &(yyvsp[0].u));
     ;
     break;}
 case 329:
-#line 3284 "Gmsh.y"
+#line 3261 "Gmsh.y"
 {
       List_Add(yyval.l, &(yyvsp[0].u));
     ;
     break;}
 case 330:
-#line 3291 "Gmsh.y"
+#line 3268 "Gmsh.y"
 {
       yyval.c = yyvsp[0].c;
     ;
     break;}
 case 331:
-#line 3295 "Gmsh.y"
+#line 3272 "Gmsh.y"
 {
       yyval.c = (char *)Malloc(32*sizeof(char));
       time_t now;
@@ -6437,7 +6414,7 @@ case 331:
     ;
     break;}
 case 332:
-#line 3303 "Gmsh.y"
+#line 3280 "Gmsh.y"
 {
       yyval.c = (char *)Malloc((strlen(yyvsp[-3].c)+strlen(yyvsp[-1].c)+1)*sizeof(char));
       strcpy(yyval.c, yyvsp[-3].c);
@@ -6447,7 +6424,7 @@ case 332:
     ;
     break;}
 case 333:
-#line 3311 "Gmsh.y"
+#line 3288 "Gmsh.y"
 {
       yyval.c = (char *)Malloc((strlen(yyvsp[-1].c)+1)*sizeof(char));
       int i;
@@ -6463,7 +6440,7 @@ case 333:
     ;
     break;}
 case 334:
-#line 3325 "Gmsh.y"
+#line 3302 "Gmsh.y"
 {
       yyval.c = (char *)Malloc((strlen(yyvsp[-1].c)+1)*sizeof(char));
       int i;
@@ -6479,13 +6456,13 @@ case 334:
     ;
     break;}
 case 335:
-#line 3339 "Gmsh.y"
+#line 3316 "Gmsh.y"
 {
       yyval.c = yyvsp[-1].c;
     ;
     break;}
 case 336:
-#line 3343 "Gmsh.y"
+#line 3320 "Gmsh.y"
 {
       char tmpstring[1024];
       int i = PrintListOfDouble(yyvsp[-3].c, yyvsp[-1].l, tmpstring);
@@ -6506,7 +6483,7 @@ case 336:
     ;
     break;}
 case 337:
-#line 3362 "Gmsh.y"
+#line 3339 "Gmsh.y"
 { 
       char* (*pStrOpt)(int num, int action, char *value);
       StringXString *pStrCat;
@@ -6530,7 +6507,7 @@ case 337:
     ;
     break;}
 case 338:
-#line 3384 "Gmsh.y"
+#line 3361 "Gmsh.y"
 { 
       char* (*pStrOpt)(int num, int action, char *value);
       StringXString *pStrCat;
@@ -6775,7 +6752,7 @@ yyerrhandle:
     }
   return 1;
 }
-#line 3407 "Gmsh.y"
+#line 3384 "Gmsh.y"
 
 
 void DeleteSymbol(void *a, void *b){
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 95d99ea43c0cf5b7ce69c281c7833d9d58cddd83..7fe8035770d13b8c8aca1dd7b7545cc06bdf8c9c 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,5 +1,5 @@
 %{
-// $Id: Gmsh.y,v 1.236 2006-11-25 00:44:29 geuzaine Exp $
+// $Id: Gmsh.y,v 1.237 2006-11-25 02:47:40 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
@@ -1052,20 +1052,8 @@ Shape :
     }
   | tAttractor tPoint ListOfDouble tAFFECT '{' FExpr ',' FExpr ',' FExpr '}'  tEND
     {
-      for(int i = 0; i < List_Nbr($3); i++){
-	double p;
-      	List_Read($3, i, &p);
-        Vertex *v = FindPoint((int)p);
-        if(!v)
-	  yymsg(WARNING, "Unknown point %d", (int)p);
-	else{
-	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
-					  $6, $8, $10, v, NULL, NULL);
-	  List_Add(THEM->Metric->Attractors, &a);
-        }
-      }
+      yymsg(GERROR, "Attractors are deprecated");
       List_Delete($3);
-      // dummy values
       $$.Type = 0;
       $$.Num = 0;
     }
@@ -1325,19 +1313,8 @@ Shape :
     }
   | tAttractor tLine ListOfDouble tAFFECT '{' FExpr ',' FExpr ',' FExpr '}'  tEND
     {
-      for(int i = 0; i < List_Nbr($3); i++){
-	double p;
-      	List_Read($3, i, &p);
-	Curve *c = FindCurve((int)p);
-        if(!c)
-	  yymsg(WARNING, "Unknown curve %d", (int)p);
-	else{
-	  Attractor *a = Create_Attractor(List_Nbr(THEM->Metric->Attractors)+1,
-					  $6, $8, $10, NULL, c, NULL);
-	  List_Add(THEM->Metric->Attractors, &a);
-        }
-      }
-      // dummy values
+      yymsg(GERROR, "Attractors are deprecated");
+      List_Delete($3);
       $$.Type = 0;
       $$.Num = 0;
     }
@@ -2654,7 +2631,7 @@ Coherence :
     }
   | tIntersect tEND
     { 
-      IntersectAllSegmentsTogether();
+      yymsg(GERROR, "Intersect is deprecated");
     }
 ;
 
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index cc408a7021b011d2bf2a8c80391fb916d838407d..fee711a38066ed63b51904dbd057c49156b3a2f9 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -2,7 +2,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.275 2006-11-25 00:44:32 geuzaine Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.276 2006-11-25 02:47:41 geuzaine Exp $
  */
 
 #define FLEX_SCANNER
@@ -727,7 +727,7 @@ char *yytext;
 #line 1 "Gmsh.l"
 #define INITIAL 0
 #line 2 "Gmsh.l"
-// $Id: Gmsh.yy.cpp,v 1.275 2006-11-25 00:44:32 geuzaine Exp $
+// $Id: Gmsh.yy.cpp,v 1.276 2006-11-25 02:47:41 geuzaine Exp $
 //
 // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 //
diff --git a/Parser/Makefile b/Parser/Makefile
index 2ef2be263190d6d84245e2ac34bd55657c6fd526..f2ee7e1af00b53a8c02455c8a476b288882163fc 100644
--- a/Parser/Makefile
+++ b/Parser/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.107 2006-11-16 18:48:01 geuzaine Exp $
+# $Id: Makefile,v 1.108 2006-11-25 02:47:41 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -85,51 +85,55 @@ Gmsh.tab.o: Gmsh.tab.cpp ../Plugin/PluginManager.h ../Plugin/Plugin.h \
   ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h \
   ../DataStr/Tree.h ../Common/Context.h ../Geo/Geo.h ../Geo/GeoUtils.h \
   ../Mesh/Mesh.h ../Common/GmshDefines.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Mesh/Nurbs.h \
-  ../Mesh/Vertex.h ../Mesh/Mesh.h ../Geo/CAD.h ../Geo/ExtrudeParams.h \
-  ../Graphics/Draw.h ../Mesh/Create.h ../Mesh/Vertex.h ../Mesh/Mesh.h \
-  ../Common/Colors.h ../Common/Options.h Parser.h OpenFile.h \
-  ../Common/CommandLine.h FunctionManager.h ../Common/OS.h CreateFile.h
+  ../Geo/ExtrudeParams.h ../Mesh/Nurbs.h ../Mesh/Vertex.h ../Mesh/Mesh.h \
+  ../Geo/CAD.h ../Geo/ExtrudeParams.h ../Graphics/Draw.h ../Mesh/Create.h \
+  ../Mesh/Vertex.h ../Mesh/Mesh.h ../Common/Colors.h ../Common/Options.h \
+  Parser.h OpenFile.h ../Common/CommandLine.h FunctionManager.h \
+  ../Common/OS.h CreateFile.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/MVertex.h \
+  ../Geo/SPoint3.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
+  ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h \
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h \
+  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/SBoundingBox3d.h ../Geo/gmshVertex.h ../Geo/GVertex.h \
+  ../Geo/gmshEdge.h ../Geo/GEdge.h ../Geo/gmshVertex.h ../Geo/Range.h \
+  ../Geo/gmshFace.h ../Geo/GFace.h ../Geo/gmshVertex.h ../Geo/Range.h \
+  ../Geo/gmshRegion.h ../Geo/GRegion.h
 Gmsh.yy.o: Gmsh.yy.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Numeric/Numeric.h ../Geo/Geo.h ../Geo/CAD.h ../Mesh/Mesh.h \
-  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Geo/ExtrudeParams.h Gmsh.tab.hpp
+  ../Common/GmshDefines.h ../Mesh/Vertex.h ../Geo/ExtrudeParams.h \
+  ../Geo/ExtrudeParams.h Gmsh.tab.hpp
 OpenFile.o: OpenFile.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h ../DataStr/Tools.h ../DataStr/List.h ../DataStr/Tree.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Common/Context.h \
-  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
-  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
-  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
-  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h Parser.h OpenFile.h \
-  ../Common/CommandLine.h ../Common/Views.h ../Common/ColorTable.h \
-  ../Common/VertexArray.h ../Common/SmoothNormals.h \
-  ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Mesh/Mesh.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Graphics/ReadImg.h ../Common/OS.h \
-  ../Common/GmshUI.h ../Graphics/Draw.h ../Graphics/SelectBuffer.h \
-  ../Fltk/GUI.h ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h \
+  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
+  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
+  ../Common/Context.h ../Geo/ExtrudeParams.h ../Geo/GFace.h \
+  ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
+  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
+  ../Common/SmoothNormals.h Parser.h OpenFile.h ../Common/CommandLine.h \
+  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
+  ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
+  ../Common/GmshMatrix.h ../Mesh/Mesh.h ../Mesh/Vertex.h \
+  ../Graphics/ReadImg.h ../Common/OS.h ../Common/GmshUI.h \
+  ../Graphics/Draw.h ../Graphics/SelectBuffer.h ../Fltk/GUI.h \
+  ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h \
   ../Fltk/Popup_Button.h ../Fltk/SpherePosition_Widget.h
 CreateFile.o: CreateFile.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../DataStr/Malloc.h ../DataStr/List.h ../DataStr/Tree.h \
@@ -138,21 +142,22 @@ CreateFile.o: CreateFile.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
-  ../Geo/GPoint.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Numeric/Numeric.h ../Geo/ExtrudeParams.h \
-  ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h ../Geo/GEntity.h \
-  ../Geo/MElement.h ../Geo/ExtrudeParams.h ../Geo/SBoundingBox3d.h \
-  ../Common/SmoothNormals.h ../Common/GmshUI.h ../Graphics/gl2ps.h \
-  ../Graphics/gl2gif.h ../Graphics/PixelBuffer.h ../Graphics/Draw.h \
-  ../Common/Views.h ../Common/ColorTable.h ../Common/VertexArray.h \
-  ../Common/SmoothNormals.h ../Common/AdaptiveViews.h \
-  ../Common/GmshMatrix.h ../Graphics/gl2jpeg.h ../Graphics/PixelBuffer.h \
-  ../Graphics/gl2png.h ../Graphics/PixelBuffer.h ../Graphics/gl2ppm.h \
+  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h ../Geo/GEntity.h \
+  ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
+  ../Geo/ExtrudeParams.h ../Geo/GFace.h ../Geo/GPoint.h ../Geo/GEntity.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/MElement.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
+  ../Geo/SBoundingBox3d.h ../Common/SmoothNormals.h ../Common/GmshUI.h \
+  ../Graphics/gl2ps.h ../Graphics/gl2gif.h ../Graphics/PixelBuffer.h \
+  ../Graphics/Draw.h ../Common/Views.h ../Common/ColorTable.h \
+  ../Common/VertexArray.h ../Common/SmoothNormals.h \
+  ../Common/AdaptiveViews.h ../Common/GmshMatrix.h ../Graphics/gl2jpeg.h \
+  ../Graphics/PixelBuffer.h ../Graphics/gl2png.h \
+  ../Graphics/PixelBuffer.h ../Graphics/gl2ppm.h \
   ../Graphics/PixelBuffer.h ../Graphics/gl2yuv.h \
   ../Graphics/PixelBuffer.h
 FunctionManager.o: FunctionManager.cpp FunctionManager.h
diff --git a/Plugin/Makefile b/Plugin/Makefile
index b8d756c8727464c1d730fb3a85c3582aff2ed479..323ebb439b8d511fd73d2fd018ccc50b20434399 100644
--- a/Plugin/Makefile
+++ b/Plugin/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.113 2006-11-16 18:48:01 geuzaine Exp $
+# $Id: Makefile,v 1.114 2006-11-25 02:47:41 geuzaine Exp $
 #
 # Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
 #
@@ -157,11 +157,7 @@ Triangulate.o: Triangulate.cpp ../Common/Gmsh.h ../Common/Message.h \
   ../Common/VertexArray.h ../Common/SmoothNormals.h ../Numeric/Numeric.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h Triangulate.h \
   ../Common/Context.h ../Geo/Geo.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Face.h ../Mesh/Vertex.h \
-  ../Mesh/Element.h ../Mesh/Edge.h ../Mesh/Vertex.h ../Mesh/Simplex.h \
-  ../Geo/ExtrudeParams.h ../Mesh/Metric.h ../Mesh/Vertex.h \
-  ../Mesh/Simplex.h ../Mesh/Mesh.h ../Mesh/Matrix.h ../Mesh/Utils.h \
+  ../Mesh/Vertex.h ../Geo/ExtrudeParams.h ../Mesh/Utils.h \
   ../Mesh/Vertex.h ../Mesh/Mesh.h ../Mesh/Create.h ../Mesh/Vertex.h \
   ../Mesh/Mesh.h
 Warp.o: Warp.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
@@ -195,11 +191,12 @@ ExtractEdges.o: ExtractEdges.cpp Plugin.h ../Common/Options.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/GPoint.h \
-  ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Geo/ExtrudeParams.h ../Geo/MElement.h \
-  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/ExtrudeParams.h
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint3.h \
+  ../Geo/SPoint2.h ../Geo/MElement.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Common/Hash.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/ExtrudeParams.h \
+  ../Geo/MElement.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/ExtrudeParams.h
 DecomposeInSimplex.o: DecomposeInSimplex.cpp Plugin.h ../Common/Options.h \
   ../Common/Message.h ../Common/Views.h ../Common/ColorTable.h \
   ../DataStr/List.h ../Common/VertexArray.h ../Common/SmoothNormals.h \
@@ -238,12 +235,8 @@ Annotate.o: Annotate.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
   ../Common/AdaptiveViews.h ../Common/GmshMatrix.h Annotate.h \
   ../Common/Context.h ../Common/GmshUI.h ../Fltk/GUI.h \
   ../Fltk/Opengl_Window.h ../Mesh/Mesh.h ../Common/GmshDefines.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Vertex.h ../Mesh/Element.h \
-  ../Mesh/Face.h ../Mesh/Vertex.h ../Mesh/Element.h ../Mesh/Edge.h \
-  ../Mesh/Vertex.h ../Mesh/Simplex.h ../Geo/ExtrudeParams.h \
-  ../Mesh/Metric.h ../Mesh/Vertex.h ../Mesh/Simplex.h ../Mesh/Mesh.h \
-  ../Mesh/Matrix.h ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h \
+  ../DataStr/Tree.h ../DataStr/avl.h ../Mesh/Vertex.h \
+  ../Geo/ExtrudeParams.h ../Fltk/Colorbar_Window.h ../Fltk/Popup_Button.h \
   ../Fltk/SpherePosition_Widget.h ../Graphics/Draw.h
 Remove.o: Remove.cpp Plugin.h ../Common/Options.h ../Common/Message.h \
   ../Common/Views.h ../Common/ColorTable.h ../DataStr/List.h \