From bf10363656bda1d9a400d7597d54d6dada181501 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 26 Sep 2007 20:52:01 +0000
Subject: [PATCH] removed global THEM

(once more step towards nicer integration of old GEO stuff)
---
 Box/Box.cpp                |   5 +-
 Common/CommandLine.cpp     |   3 +-
 Common/Makefile            |  23 ++-
 Fltk/Callbacks.cpp         |   3 +-
 Fltk/GUI_Classifier.cpp    |   2 -
 Fltk/Main.cpp              |   5 +-
 Fltk/Makefile              | 149 ++++++++--------
 Fltk/Opengl_Window.cpp     |   3 +-
 Geo/ExtrudeParams.cpp      |   2 +-
 Geo/GModel.cpp             |   7 +-
 Geo/GModel.h               |  17 +-
 Geo/GModelIO_Geo.cpp       |  38 ++--
 Geo/Geo.cpp                | 205 ++++++++++++----------
 Geo/Geo.h                  |   6 +-
 Geo/GeoStringInterface.cpp |   4 +-
 Geo/GeoStringInterface.h   |   3 +-
 Geo/Makefile               |  16 +-
 Geo/gmshEdge.cpp           |  14 +-
 Geo/gmshFace.cpp           |   6 +-
 Geo/gmshRegion.cpp         |   6 +-
 Parser/CreateFile.cpp      |   3 +-
 Parser/Gmsh.tab.cpp        | 350 ++++++++++++++++++-------------------
 Parser/Gmsh.y              |  64 +++----
 Parser/Gmsh.yy.cpp         |   4 +-
 Parser/Makefile            |  34 ++--
 Parser/OpenFile.cpp        |   7 +-
 26 files changed, 492 insertions(+), 487 deletions(-)

diff --git a/Box/Box.cpp b/Box/Box.cpp
index 7690ceb28a..06b7f20e4b 100644
--- a/Box/Box.cpp
+++ b/Box/Box.cpp
@@ -1,4 +1,4 @@
-// $Id: Box.cpp,v 1.38 2007-09-21 21:14:00 geuzaine Exp $
+// $Id: Box.cpp,v 1.39 2007-09-26 20:51:57 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -23,7 +23,6 @@
 #include "Gmsh.h"
 #include "OS.h"
 #include "Numeric.h"
-#include "Geo.h"
 #include "Generator.h"
 #include "Parser.h"
 #include "Context.h"
@@ -38,7 +37,6 @@
 #include "BackgroundMesh.h"
 
 Context_T CTX;
-Mesh *THEM = 0;
 
 // Print some help/info messages
 
@@ -79,7 +77,6 @@ int GMSHBOX(int argc, char *argv[])
   ParUtil::Instance()->init(argc, argv);
 
   new GModel;
-  THEM = new Mesh;
 
   InitSymbols();
   Init_Options(0);
diff --git a/Common/CommandLine.cpp b/Common/CommandLine.cpp
index 4e747388ee..a2eba03393 100644
--- a/Common/CommandLine.cpp
+++ b/Common/CommandLine.cpp
@@ -1,4 +1,4 @@
-// $Id: CommandLine.cpp,v 1.105 2007-09-24 08:14:28 geuzaine Exp $
+// $Id: CommandLine.cpp,v 1.106 2007-09-26 20:51:57 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -27,7 +27,6 @@
 #include "Numeric.h"
 #include "Context.h"
 #include "Options.h"
-#include "Geo.h"
 #include "PView.h"
 #include "OpenFile.h"
 #include "CreateFile.h"
diff --git a/Common/Makefile b/Common/Makefile
index 4568da7aaf..da9e4a798d 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.143 2007-09-22 20:35:18 geuzaine Exp $
+# $Id: Makefile,v 1.144 2007-09-26 20:51:58 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -85,20 +85,17 @@ CommandLine.o: CommandLine.cpp Gmsh.h Message.h ../DataStr/Malloc.h \
   ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Tools.h \
   ../DataStr/List.h ../DataStr/Tree.h GmshUI.h GmshDefines.h \
   GmshVersion.h CommandLine.h ../Numeric/Numeric.h Context.h Options.h \
-  ../Post/ColorTable.h ../Geo/Geo.h ../Common/GmshDefines.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Post/PView.h \
-  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Parser/OpenFile.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/MVertex.h \
+  ../Post/ColorTable.h ../Post/PView.h ../Common/SmoothData.h \
+  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Parser/OpenFile.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 ../Common/GmshDefines.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/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/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 \
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 1c20ea2f7b..c2ea60c999 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.549 2007-09-24 08:14:28 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.550 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -25,7 +25,6 @@
 
 #include "Gmsh.h"
 #include "GmshUI.h"
-#include "Geo.h"
 #include "GeoStringInterface.h"
 #include "findLinks.h"
 #include "Generator.h"
diff --git a/Fltk/GUI_Classifier.cpp b/Fltk/GUI_Classifier.cpp
index f6201f4d7b..83a48aea1e 100644
--- a/Fltk/GUI_Classifier.cpp
+++ b/Fltk/GUI_Classifier.cpp
@@ -1,5 +1,4 @@
 #include "GUI_Classifier.h"
-#include "Geo.h"
 #include "Gmsh.h"
 #include "Draw.h"
 #include "Options.h"
@@ -13,7 +12,6 @@
 #include "gmshEdge.h"
 #include "gmshFace.h"
 
-extern Mesh *THEM;
 extern Context_T CTX;
 
 void buildListOfEdgeAngle ( e2t_cont adj,std::vector<edge_angle> &edges_detected,std::vector<edge_angle> &edges_lonly);
diff --git a/Fltk/Main.cpp b/Fltk/Main.cpp
index c7344d3396..d8f3a96e42 100644
--- a/Fltk/Main.cpp
+++ b/Fltk/Main.cpp
@@ -1,4 +1,4 @@
-// $Id: Main.cpp,v 1.111 2007-09-21 21:14:00 geuzaine Exp $
+// $Id: Main.cpp,v 1.112 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -26,7 +26,6 @@
 #include "Gmsh.h"
 #include "GmshUI.h"
 #include "OS.h"
-#include "Geo.h"
 #include "Generator.h"
 #include "CreateFile.h"
 #include "Draw.h"
@@ -44,7 +43,6 @@
 #include "PView.h"
 
 Context_T CTX;
-Mesh *THEM = 0;
 GUI *WID = 0;
 
 int main(int argc, char *argv[])
@@ -70,7 +68,6 @@ int main(int argc, char *argv[])
 
   // Create a new model
   new GModel;
-  THEM = new Mesh;
 
   // Initialize the symbol tree that will hold variable names
   InitSymbols();
diff --git a/Fltk/Makefile b/Fltk/Makefile
index 2bbc978844..d8cbea875d 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.151 2007-09-22 20:35:18 geuzaine Exp $
+# $Id: Makefile,v 1.152 2007-09-26 20:51:58 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -68,31 +68,30 @@ Main.o: Main.cpp GUI.h Opengl_Window.h Colorbar_Window.h \
   SpherePosition_Widget.h ../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/OS.h ../Geo/Geo.h ../Common/GmshDefines.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
-  ../Mesh/Generator.h ../Parser/CreateFile.h ../Graphics/Draw.h \
+  ../Common/OS.h ../Mesh/Generator.h ../Parser/CreateFile.h \
+  ../Graphics/Draw.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
   ../Common/Context.h ../Common/Options.h ../Parser/Parser.h \
-  ../Parser/OpenFile.h ../Common/CommandLine.h Solvers.h \
-  ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Post/PView.h \
-  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../Common/GmshMatrix.h ../Geo/GModel.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.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/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 ../Mesh/Field.h \
-  ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
-  ../Mesh/BackgroundMesh.h
+  ../Parser/OpenFile.h ../Common/CommandLine.h ../Numeric/Numeric.h \
+  Solvers.h ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Post/PView.h \
+  ../Common/SmoothData.h ../Post/PViewData.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Post/AdaptiveViews.h ../Common/GmshMatrix.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.h ../Common/GmshDefines.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 ../Mesh/Field.h ../Geo/Geo.h \
+  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
+  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Post/OctreePost.h \
+  ../Common/Octree.h ../Common/OctreeInternals.h ../Mesh/BackgroundMesh.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 \
@@ -158,48 +157,48 @@ GUI_Classifier.o: GUI_Classifier.cpp GUI_Classifier.h ../Common/GmshUI.h \
   ../Geo/GEntity.h ../Geo/MElement.h ../Geo/ExtrudeParams.h \
   ../Geo/SBoundingBox3d.h GUI.h Opengl_Window.h Colorbar_Window.h \
   ../Post/ColorTable.h Popup_Button.h SpherePosition_Widget.h \
-  Shortcut_Window.h ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h \
-  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
-  ../Geo/SBoundingBox3d.h ../DataStr/Tree.h ../DataStr/avl.h \
-  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/Gmsh.h \
-  ../Common/Message.h ../DataStr/Malloc.h ../DataStr/Tools.h \
-  ../DataStr/List.h ../DataStr/Tree.h ../Graphics/Draw.h \
-  ../Common/Options.h ../Graphics/SelectBuffer.h GUI_Projection.h \
-  ../Geo/FProjectionFace.h ../Geo/GModel.h ../Geo/Range.h GUI_Extras.h \
-  ../Mesh/meshGFaceDelaunayInsertion.h ../Mesh/meshGFaceOptimize.h \
-  ../Geo/gmshEdge.h ../Geo/Geo.h ../Geo/GEdge.h ../Geo/gmshVertex.h \
-  ../Geo/Geo.h ../Geo/GVertex.h ../Geo/Range.h ../Geo/gmshFace.h \
-  ../Geo/Geo.h ../Geo/GFace.h ../Geo/gmshVertex.h ../Geo/Range.h
+  Shortcut_Window.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 \
+  ../Graphics/Draw.h ../Common/Options.h ../Graphics/SelectBuffer.h \
+  GUI_Projection.h ../Geo/FProjectionFace.h ../Geo/GModel.h \
+  ../Geo/Range.h GUI_Extras.h ../Mesh/meshGFaceDelaunayInsertion.h \
+  ../Mesh/meshGFaceOptimize.h ../Geo/gmshEdge.h ../Geo/Geo.h \
+  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
+  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Geo/GEdge.h \
+  ../Geo/gmshVertex.h ../Geo/Geo.h ../Geo/GVertex.h ../Geo/Range.h \
+  ../Geo/gmshFace.h ../Geo/Geo.h ../Geo/GFace.h ../Geo/gmshVertex.h \
+  ../Geo/Range.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 ../Common/GmshDefines.h \
-  ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
-  ../Geo/SPoint3.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Numeric/Numeric.h \
-  ../Geo/GeoStringInterface.h ../Geo/Geo.h ../Geo/findLinks.h \
+  ../Common/GmshUI.h ../Geo/GeoStringInterface.h ../Geo/findLinks.h \
   ../Mesh/Generator.h ../Mesh/HighOrder.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.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/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 \
-  ../Graphics/Draw.h ../Graphics/SelectBuffer.h ../Post/PView.h \
-  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Parser/CreateFile.h ../Parser/OpenFile.h ../Common/CommandLine.h \
-  ../Common/Options.h GUI.h Opengl_Window.h Colorbar_Window.h \
-  Popup_Button.h SpherePosition_Widget.h GUI_Extras.h Callbacks.h \
-  ../Plugin/Plugin.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../Common/GmshMatrix.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/GmshDefines.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 \
+  ../Common/SmoothData.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 ../Graphics/Draw.h ../Graphics/SelectBuffer.h \
+  ../Post/PView.h ../Post/PViewData.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Parser/CreateFile.h ../Parser/OpenFile.h \
+  ../Common/CommandLine.h ../Common/Options.h GUI.h Opengl_Window.h \
+  Colorbar_Window.h Popup_Button.h SpherePosition_Widget.h GUI_Extras.h \
+  Callbacks.h ../Plugin/Plugin.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Post/AdaptiveViews.h ../Common/GmshMatrix.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Visibility.h \
   ../Common/GmshDefines.h Solvers.h ../Common/OS.h ../Mesh/Field.h \
+  ../Geo/Geo.h ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h \
+  ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h \
   ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
   ../Mesh/BackgroundMesh.h
 Opengl.o: Opengl.cpp ../Common/Gmsh.h ../Common/Message.h \
@@ -225,23 +224,21 @@ Opengl_Window.o: Opengl_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 \
   ../Numeric/Numeric.h ../Common/GmshUI.h ../Common/Context.h \
-  ../Geo/Geo.h ../Common/GmshDefines.h ../Geo/gmshSurface.h ../Geo/Pair.h \
-  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
-  ../Graphics/Draw.h ../Graphics/SelectBuffer.h ../Geo/GVertex.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/MVertex.h ../Geo/SPoint3.h \
+  ../Graphics/Draw.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Graphics/SelectBuffer.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
+  ../Common/GmshDefines.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/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 Colorbar_Window.h \
-  ../Post/ColorTable.h Popup_Button.h SpherePosition_Widget.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 \
+  ../Common/SmoothData.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 Colorbar_Window.h ../Post/ColorTable.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 \
diff --git a/Fltk/Opengl_Window.cpp b/Fltk/Opengl_Window.cpp
index f258819b8a..5c22469b25 100644
--- a/Fltk/Opengl_Window.cpp
+++ b/Fltk/Opengl_Window.cpp
@@ -1,4 +1,4 @@
-// $Id: Opengl_Window.cpp,v 1.79 2007-09-03 20:09:14 geuzaine Exp $
+// $Id: Opengl_Window.cpp,v 1.80 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -23,7 +23,6 @@
 #include "Numeric.h"
 #include "GmshUI.h"
 #include "Context.h"
-#include "Geo.h"
 #include "Draw.h"
 #include "SelectBuffer.h"
 #include "GUI.h"
diff --git a/Geo/ExtrudeParams.cpp b/Geo/ExtrudeParams.cpp
index 983fbdc44b..0d84574f8f 100644
--- a/Geo/ExtrudeParams.cpp
+++ b/Geo/ExtrudeParams.cpp
@@ -1,4 +1,4 @@
-// $Id: ExtrudeParams.cpp,v 1.24 2007-03-05 09:30:53 geuzaine Exp $
+// $Id: ExtrudeParams.cpp,v 1.25 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index 5877607722..7c4e34cd88 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -1,4 +1,4 @@
-// $Id: GModel.cpp,v 1.48 2007-09-21 21:14:00 geuzaine Exp $
+// $Id: GModel.cpp,v 1.49 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -28,15 +28,18 @@
 std::vector<GModel*> GModel::list;
 
 GModel::GModel(std::string name)
-  : modelName(name), normals(0)
+  : geo_internals(0), occ_internals(0), modelName(name), normals(0)
 {
   list.push_back(this);
+  // at the moment we always create (at least an empty) GEO model
+  createGEOInternals();
 }
 
 GModel::~GModel()
 { 
   std::vector<GModel*>::iterator it = std::find(list.begin(), list.end(), this);
   if(it != list.end()) list.erase(it);
+  deleteGEOInternals();
   deleteOCCInternals();
   destroy();
 }
diff --git a/Geo/GModel.h b/Geo/GModel.h
index 77955f031b..e46154091b 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -30,16 +30,26 @@
 #include "SBoundingBox3d.h"
 #include "SmoothData.h"
 
-// OCC Internals have to be stored in the model
+// internal CAD representations
+class GEO_Internals;
 class OCC_Internals;
 
 // A geometric model. The model is a "not yet" non-manifold B-Rep.
 class GModel  
 {
- protected:
+ private:
+  void createGEOInternals();
+  void deleteGEOInternals();
+  GEO_Internals *geo_internals;
+
   void deleteOCCInternals();
   OCC_Internals *occ_internals;
 
+ public:
+  GEO_Internals *getGEOInternals(){ return geo_internals; }
+  OCC_Internals *getOCCInternals(){ return occ_internals; }
+
+ protected:
   std::string modelName;
   std::set<GRegion*, GEntityLessThan> regions;
   std::set<GFace*, GEntityLessThan> faces;
@@ -165,7 +175,7 @@ class GModel
   // =========================================
 
   // Gmsh native CAD format
-  int importTHEM();
+  int importGEOInternals();
   int readGEO(const std::string &name);
   int writeGEO(const std::string &name, bool printLabels=true);
 
@@ -176,7 +186,6 @@ class GModel
   int readOCCBREP(const std::string &name);
   int readOCCIGES(const std::string &name);
   int readOCCSTEP(const std::string &name);
-  void deleleOCCInternals();
 
   // Mesh IO
   // =========================================
diff --git a/Geo/GModelIO_Geo.cpp b/Geo/GModelIO_Geo.cpp
index 7513e85ca1..9a71a81a51 100644
--- a/Geo/GModelIO_Geo.cpp
+++ b/Geo/GModelIO_Geo.cpp
@@ -1,4 +1,4 @@
-// $Id: GModelIO_Geo.cpp,v 1.12 2007-09-04 13:47:01 remacle Exp $
+// $Id: GModelIO_Geo.cpp,v 1.13 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -31,18 +31,26 @@
 #include "gmshRegion.h"
 #include "Parser.h" // for Symbol_T
 
-extern Mesh *THEM;
-
 int GModel::readGEO(const std::string &name)
 {
   ParseFile((char*)name.c_str(), 1);
-  return importTHEM();
+  return importGEOInternals();
+}
+
+void GModel::createGEOInternals()
+{
+  geo_internals = new GEO_Internals;
+}
+
+void GModel::deleteGEOInternals()
+{
+  delete geo_internals;
 }
 
-int GModel::importTHEM()
+int GModel::importGEOInternals()
 {
-  if(Tree_Nbr(THEM->Points)) {
-    List_T *points = Tree2List(THEM->Points);
+  if(Tree_Nbr(geo_internals->Points)) {
+    List_T *points = Tree2List(geo_internals->Points);
     for(int i = 0; i < List_Nbr(points); i++){
       Vertex *p;
       List_Read(points, i, &p);
@@ -55,8 +63,8 @@ int GModel::importTHEM()
     }
     List_Delete(points);
   }
-  if(Tree_Nbr(THEM->Curves)) {
-    List_T *curves = Tree2List(THEM->Curves);
+  if(Tree_Nbr(geo_internals->Curves)) {
+    List_T *curves = Tree2List(geo_internals->Curves);
     for(int i = 0; i < List_Nbr(curves); i++){
       Curve *c;
       List_Read(curves, i, &c);
@@ -76,8 +84,8 @@ int GModel::importTHEM()
     }
     List_Delete(curves);
   }
-  if(Tree_Nbr(THEM->Surfaces)) {
-    List_T *surfaces = Tree2List(THEM->Surfaces);
+  if(Tree_Nbr(geo_internals->Surfaces)) {
+    List_T *surfaces = Tree2List(geo_internals->Surfaces);
     for(int i = 0; i < List_Nbr(surfaces); i++){
       Surface *s;
       List_Read(surfaces, i, &s);
@@ -93,8 +101,8 @@ int GModel::importTHEM()
     }
     List_Delete(surfaces);
   } 
-  if(Tree_Nbr(THEM->Volumes)) {
-    List_T *volumes = Tree2List(THEM->Volumes);
+  if(Tree_Nbr(geo_internals->Volumes)) {
+    List_T *volumes = Tree2List(geo_internals->Volumes);
     for(int i = 0; i < List_Nbr(volumes); i++){
       Volume *v;
       List_Read(volumes, i, &v);
@@ -110,9 +118,9 @@ int GModel::importTHEM()
     }
     List_Delete(volumes);
   }
-  for(int i = 0; i < List_Nbr(THEM->PhysicalGroups); i++){
+  for(int i = 0; i < List_Nbr(geo_internals->PhysicalGroups); i++){
     PhysicalGroup *p;
-    List_Read(THEM->PhysicalGroups, i, &p);
+    List_Read(geo_internals->PhysicalGroups, i, &p);
     for(int j = 0; j < List_Nbr(p->Entities); j++){
       int num;
       List_Read(p->Entities, j, &num);
diff --git a/Geo/Geo.cpp b/Geo/Geo.cpp
index e0bfde9253..fcc3f44327 100644
--- a/Geo/Geo.cpp
+++ b/Geo/Geo.cpp
@@ -1,4 +1,4 @@
-// $Id: Geo.cpp,v 1.97 2007-09-24 08:14:29 geuzaine Exp $
+// $Id: Geo.cpp,v 1.98 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -27,12 +27,11 @@
 #include "Parser.h"
 #include "Context.h"
 
-extern Mesh *THEM;
 extern Context_T CTX;
 
 static List_T *ListOfTransformedPoints = NULL;
 
-void Mesh::alloc_all()
+void GEO_Internals::alloc_all()
 {
   MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0;
   MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0;
@@ -45,7 +44,7 @@ void Mesh::alloc_all()
   PhysicalGroups = List_Create(5, 5, sizeof(PhysicalGroup *));
 }
 
-void Mesh::free_all()
+void GEO_Internals::free_all()
 {
   MaxPointNum = MaxLineNum = MaxLineLoopNum = MaxSurfaceNum = 0;
   MaxSurfaceLoopNum = MaxVolumeNum = MaxPhysicalNum = 0;
@@ -137,7 +136,8 @@ Vertex *Create_Vertex(int Num, double X, double Y, double Z, double lc, double u
   Vertex *pV = new Vertex(X, Y, Z, lc);
   pV->w = 1.0;
   pV->Num = Num;
-  THEM->MaxPointNum = IMAX(THEM->MaxPointNum, Num);
+  GModel::current()->getGEOInternals()->MaxPointNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxPointNum, Num);
   pV->u = u;
   pV->geometry = 0;
   return pV;
@@ -149,7 +149,8 @@ Vertex *Create_Vertex(int Num, double u, double v, gmshSurface *surf, double lc)
   Vertex *pV = new Vertex(p.x(),p.y(),p.z(),lc);
   pV->w = 1.0;
   pV->Num = Num;
-  THEM->MaxPointNum = IMAX(THEM->MaxPointNum, Num);
+  GModel::current()->getGEOInternals()->MaxPointNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxPointNum, Num);
   pV->u = u;
   pV->geometry = surf;
   pV->pntOnGeometry = SPoint2(u,v);
@@ -170,7 +171,8 @@ PhysicalGroup *Create_PhysicalGroup(int Num, int typ, List_T *intlist)
   PhysicalGroup *p = (PhysicalGroup *)Malloc(sizeof(PhysicalGroup));
   p->Entities = List_Create(List_Nbr(intlist), 1, sizeof(int));
   p->Num = Num;
-  THEM->MaxPhysicalNum = IMAX(THEM->MaxPhysicalNum, Num);
+  GModel::current()->getGEOInternals()->MaxPhysicalNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxPhysicalNum, Num);
   p->Typ = typ;
   p->Visible = 1;
   for(int i = 0; i < List_Nbr(intlist); i++) {
@@ -196,7 +198,8 @@ EdgeLoop *Create_EdgeLoop(int Num, List_T *intlist)
   EdgeLoop *l = (EdgeLoop *)Malloc(sizeof(EdgeLoop));
   l->Curves = List_Create(List_Nbr(intlist), 1, sizeof(int));
   l->Num = Num;
-  THEM->MaxLineLoopNum = IMAX(THEM->MaxLineLoopNum, Num);
+  GModel::current()->getGEOInternals()->MaxLineLoopNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxLineLoopNum, Num);
   for(int i = 0; i < List_Nbr(intlist); i++) {
     int j;
     List_Read(intlist, i, &j);
@@ -220,7 +223,8 @@ SurfaceLoop *Create_SurfaceLoop(int Num, List_T *intlist)
   SurfaceLoop *l = (SurfaceLoop *)Malloc(sizeof(SurfaceLoop));
   l->Surfaces = List_Create(List_Nbr(intlist), 1, sizeof(int));
   l->Num = Num;
-  THEM->MaxSurfaceLoopNum = IMAX(THEM->MaxSurfaceLoopNum, Num);
+  GModel::current()->getGEOInternals()->MaxSurfaceLoopNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxSurfaceLoopNum, Num);
   for(int i = 0; i < List_Nbr(intlist); i++) {
     int j;
     List_Read(intlist, i, &j);
@@ -492,7 +496,8 @@ Curve *Create_Curve(int Num, int Typ, int Order, List_T *Liste,
   pC->Extrude = NULL;
   pC->Typ = Typ;
   pC->Num = Num;
-  THEM->MaxLineNum = IMAX(THEM->MaxLineNum, Num);
+  GModel::current()->getGEOInternals()->MaxLineNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxLineNum, Num);
   pC->Method = LIBRE;
   pC->degre = Order;
   pC->Circle.n[0] = 0.0;
@@ -605,7 +610,8 @@ Surface *Create_Surface(int Num, int Typ)
   pS->Num = Num;
   pS->geometry = 0;
 
-  THEM->MaxSurfaceNum = IMAX(THEM->MaxSurfaceNum, Num);
+  GModel::current()->getGEOInternals()->MaxSurfaceNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxSurfaceNum, Num);
   pS->Typ = Typ;
   pS->Method = LIBRE;
   for(int i = 0; i < 5; i++)
@@ -643,7 +649,8 @@ Volume *Create_Volume(int Num, int Typ)
   pV->Color.type = 0;
   pV->Visible = 1;
   pV->Num = Num;
-  THEM->MaxVolumeNum = IMAX(THEM->MaxVolumeNum, Num);
+  GModel::current()->getGEOInternals()->MaxVolumeNum = 
+    IMAX(GModel::current()->getGEOInternals()->MaxVolumeNum, Num);
   pV->Typ = Typ;
   pV->Method = LIBRE;
   for(int i = 0; i < 8; i++)
@@ -671,7 +678,7 @@ void Free_Volume(void *a, void *b)
 
 int NEWPOINT(void)
 {
-  return (THEM->MaxPointNum + 1);
+  return (GModel::current()->getGEOInternals()->MaxPointNum + 1);
 }
 
 int NEWLINE(void)
@@ -679,7 +686,7 @@ int NEWLINE(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxLineNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxLineNum + 1);
 }
 
 int NEWLINELOOP(void)
@@ -687,7 +694,7 @@ int NEWLINELOOP(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxLineLoopNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxLineLoopNum + 1);
 }
 
 int NEWSURFACE(void)
@@ -695,7 +702,7 @@ int NEWSURFACE(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxSurfaceNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxSurfaceNum + 1);
 }
 
 int NEWSURFACELOOP(void)
@@ -703,7 +710,7 @@ int NEWSURFACELOOP(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxSurfaceLoopNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxSurfaceLoopNum + 1);
 }
 
 int NEWVOLUME(void)
@@ -711,7 +718,7 @@ int NEWVOLUME(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxVolumeNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxVolumeNum + 1);
 }
 
 int NEWPHYSICAL(void)
@@ -719,17 +726,17 @@ int NEWPHYSICAL(void)
   if(CTX.geom.old_newreg)
     return NEWREG();
   else
-    return (THEM->MaxPhysicalNum + 1);
+    return (GModel::current()->getGEOInternals()->MaxPhysicalNum + 1);
 }
 
 int NEWREG(void)
 {
-  return (IMAX(THEM->MaxLineNum,
-               IMAX(THEM->MaxLineLoopNum,
-                    IMAX(THEM->MaxSurfaceNum,
-                         IMAX(THEM->MaxSurfaceLoopNum,
-                              IMAX(THEM->MaxVolumeNum,
-                                   THEM->MaxPhysicalNum)))))
+  return (IMAX(GModel::current()->getGEOInternals()->MaxLineNum,
+               IMAX(GModel::current()->getGEOInternals()->MaxLineLoopNum,
+                    IMAX(GModel::current()->getGEOInternals()->MaxSurfaceNum,
+                         IMAX(GModel::current()->getGEOInternals()->MaxSurfaceLoopNum,
+                              IMAX(GModel::current()->getGEOInternals()->MaxVolumeNum,
+                                   GModel::current()->getGEOInternals()->MaxPhysicalNum)))))
           + 1);
 }
 
@@ -770,7 +777,7 @@ Vertex *FindPoint(int inum)
   Vertex C, *pc;
   pc = &C;
   pc->Num = inum;
-  if(Tree_Query(THEM->Points, &pc)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->Points, &pc)) {
     return pc;
   }
   return NULL;
@@ -781,7 +788,7 @@ Curve *FindCurve(int inum)
   Curve C, *pc;
   pc = &C;
   pc->Num = inum;
-  if(Tree_Query(THEM->Curves, &pc)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->Curves, &pc)) {
     return pc;
   }
   return NULL;
@@ -792,7 +799,7 @@ Surface *FindSurface(int inum)
   Surface S, *ps;
   ps = &S;
   ps->Num = inum;
-  if(Tree_Query(THEM->Surfaces, &ps)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->Surfaces, &ps)) {
     return ps;
   }
   return NULL;
@@ -803,7 +810,7 @@ Volume *FindVolume(int inum)
   Volume V, *pv;
   pv = &V;
   pv->Num = inum;
-  if(Tree_Query(THEM->Volumes, &pv)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->Volumes, &pv)) {
     return pv;
   }
   return NULL;
@@ -814,7 +821,7 @@ EdgeLoop *FindEdgeLoop(int inum)
   EdgeLoop S, *ps;
   ps = &S;
   ps->Num = inum;
-  if(Tree_Query(THEM->EdgeLoops, &ps)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->EdgeLoops, &ps)) {
     return ps;
   }
   return NULL;
@@ -825,7 +832,7 @@ SurfaceLoop *FindSurfaceLoop(int inum)
   SurfaceLoop S, *ps;
   ps = &S;
   ps->Num = inum;
-  if(Tree_Query(THEM->SurfaceLoops, &ps)) {
+  if(Tree_Query(GModel::current()->getGEOInternals()->SurfaceLoops, &ps)) {
     return ps;
   }
   return NULL;
@@ -837,8 +844,9 @@ PhysicalGroup *FindPhysicalGroup(int num, int type)
   pp = &P;
   pp->Num = num;
   pp->Typ = type;
-  if((ppp = (PhysicalGroup **)List_PQuery(THEM->PhysicalGroups, &pp,
-					  comparePhysicalGroup))) {
+  if((ppp = (PhysicalGroup **)
+      List_PQuery(GModel::current()->getGEOInternals()->PhysicalGroups, &pp,
+		  comparePhysicalGroup))) {
     return *ppp;
   }
   return NULL;
@@ -858,7 +866,7 @@ Vertex *DuplicateVertex(Vertex *v)
   if(!v) return NULL;
   Vertex *pv = Create_Vertex(NEWPOINT(), 0, 0, 0, 0, 0);
   CopyVertex(v, pv);
-  Tree_Insert(THEM->Points, &pv);
+  Tree_Insert(GModel::current()->getGEOInternals()->Points, &pv);
   return pv;
 }
 
@@ -898,7 +906,7 @@ void CopyCurve(Curve *c, Curve *cc)
     strcpy(cc->functw, c->functw);
   }
   End_Curve(cc);
-  Tree_Insert(THEM->Curves, &cc);
+  Tree_Insert(GModel::current()->getGEOInternals()->Curves, &cc);
 }
 
 Curve *DuplicateCurve(Curve *c)
@@ -945,7 +953,7 @@ void CopySurface(Surface *s, Surface *ss)
     List_Copy(s->Control_Points, ss->Control_Points);
   }
   End_Surface(ss);
-  Tree_Insert(THEM->Surfaces, &ss);
+  Tree_Insert(GModel::current()->getGEOInternals()->Surfaces, &ss);
 }
 
 Surface *DuplicateSurface(Surface *s)
@@ -1025,7 +1033,7 @@ void DeletePoint(int ip)
   Vertex *v = FindPoint(ip);
   if(!v)
     return;
-  List_T *Curves = Tree2List(THEM->Curves);
+  List_T *Curves = Tree2List(GModel::current()->getGEOInternals()->Curves);
   for(int i = 0; i < List_Nbr(Curves); i++) {
     Curve *c;
     List_Read(Curves, i, &c);
@@ -1037,9 +1045,9 @@ void DeletePoint(int ip)
     }
   }
   List_Delete(Curves);
-  if(v->Num == THEM->MaxPointNum)
-    THEM->MaxPointNum--;
-  Tree_Suppress(THEM->Points, &v);
+  if(v->Num == GModel::current()->getGEOInternals()->MaxPointNum)
+    GModel::current()->getGEOInternals()->MaxPointNum--;
+  Tree_Suppress(GModel::current()->getGEOInternals()->Points, &v);
   Free_Vertex(&v, NULL);
 }
 
@@ -1048,7 +1056,7 @@ void DeleteCurve(int ip)
   Curve *c = FindCurve(ip);
   if(!c)
     return;
-  List_T *Surfs = Tree2List(THEM->Surfaces);
+  List_T *Surfs = Tree2List(GModel::current()->getGEOInternals()->Surfaces);
   for(int i = 0; i < List_Nbr(Surfs); i++) {
     Surface *s;
     List_Read(Surfs, i, &s);
@@ -1060,9 +1068,9 @@ void DeleteCurve(int ip)
     }
   }
   List_Delete(Surfs);
-  if(c->Num == THEM->MaxLineNum)
-    THEM->MaxLineNum--;
-  Tree_Suppress(THEM->Curves, &c);
+  if(c->Num == GModel::current()->getGEOInternals()->MaxLineNum)
+    GModel::current()->getGEOInternals()->MaxLineNum--;
+  Tree_Suppress(GModel::current()->getGEOInternals()->Curves, &c);
   Free_Curve(&c, NULL);
 }
 
@@ -1071,7 +1079,7 @@ void DeleteSurface(int is)
   Surface *s = FindSurface(is);
   if(!s)
     return;
-  List_T *Vols = Tree2List(THEM->Volumes);
+  List_T *Vols = Tree2List(GModel::current()->getGEOInternals()->Volumes);
   for(int i = 0; i < List_Nbr(Vols); i++) {
     Volume *v;
     List_Read(Vols, i, &v);
@@ -1083,9 +1091,9 @@ void DeleteSurface(int is)
     }
   }
   List_Delete(Vols);
-  if(s->Num == THEM->MaxSurfaceNum)
-    THEM->MaxSurfaceNum--;
-  Tree_Suppress(THEM->Surfaces, &s);
+  if(s->Num == GModel::current()->getGEOInternals()->MaxSurfaceNum)
+    GModel::current()->getGEOInternals()->MaxSurfaceNum--;
+  Tree_Suppress(GModel::current()->getGEOInternals()->Surfaces, &s);
   Free_Surface(&s, NULL);
 }
 
@@ -1094,9 +1102,9 @@ void DeleteVolume(int iv)
   Volume *v = FindVolume(iv);
   if(!v)
     return;
-  if(v->Num == THEM->MaxVolumeNum)
-    THEM->MaxVolumeNum--;
-  Tree_Suppress(THEM->Volumes, &v);
+  if(v->Num == GModel::current()->getGEOInternals()->MaxVolumeNum)
+    GModel::current()->getGEOInternals()->MaxVolumeNum--;
+  Tree_Suppress(GModel::current()->getGEOInternals()->Volumes, &v);
   Free_Volume(&v, NULL);
 }
 
@@ -1262,10 +1270,10 @@ void VisibilityShape(char *str, int Type, int Mode)
 
   if(!strcmp(str, "all") || !strcmp(str, "*")) {
     switch (Type) {
-    case 0: Tree_Action(THEM->Points, vis_nod); break;
-    case 1: Tree_Action(THEM->Curves, vis_cur); break;
-    case 2: Tree_Action(THEM->Surfaces, vis_sur); break;
-    case 3: Tree_Action(THEM->Volumes, vis_vol); break;
+    case 0: Tree_Action(GModel::current()->getGEOInternals()->Points, vis_nod); break;
+    case 1: Tree_Action(GModel::current()->getGEOInternals()->Curves, vis_cur); break;
+    case 2: Tree_Action(GModel::current()->getGEOInternals()->Surfaces, vis_sur); break;
+    case 3: Tree_Action(GModel::current()->getGEOInternals()->Volumes, vis_vol); break;
     }
   }
   else {
@@ -1322,12 +1330,12 @@ Curve *CreateReversedCurve(Curve *c)
   End_Curve(newc);
 
   Curve **pc;
-  if((pc = (Curve **)Tree_PQuery(THEM->Curves, &newc))) {
+  if((pc = (Curve **)Tree_PQuery(GModel::current()->getGEOInternals()->Curves, &newc))) {
     Free_Curve(&newc, NULL);
     return *pc;
   }
   else{
-    Tree_Add(THEM->Curves, &newc);
+    Tree_Add(GModel::current()->getGEOInternals()->Curves, &newc);
     return newc;
   }
 }
@@ -1337,7 +1345,7 @@ int recognize_seg(int typ, List_T *liste, int *seg)
   int i, beg, end;
   Curve *pc;
 
-  List_T *temp = Tree2List(THEM->Curves);
+  List_T *temp = Tree2List(GModel::current()->getGEOInternals()->Curves);
   List_Read(liste, 0, &beg);
   List_Read(liste, List_Nbr(liste) - 1, &end);
   for(i = 0; i < List_Nbr(temp); i++) {
@@ -1359,7 +1367,7 @@ int recognize_loop(List_T *liste, int *loop)
 
   res = 0;
   *loop = 0;
-  List_T *temp = Tree2List(THEM->EdgeLoops);
+  List_T *temp = Tree2List(GModel::current()->getGEOInternals()->EdgeLoops);
   for(i = 0; i < List_Nbr(temp); i++) {
     List_Read(temp, i, &pe);
     if(!compare2Lists(pe->Curves, liste, fcmp_absint)) {
@@ -1379,7 +1387,7 @@ int recognize_surfloop(List_T *liste, int *loop)
 
   res = 0;
   *loop = 0;
-  List_T *temp = Tree2List(THEM->SurfaceLoops);
+  List_T *temp = Tree2List(GModel::current()->getGEOInternals()->SurfaceLoops);
   for(i = 0; i < List_Nbr(temp); i++) {
     List_Read(temp, i, &pe);
     if(!compare2Lists(pe->Curves, liste, fcmp_absint)) {
@@ -1597,7 +1605,7 @@ void ApplyTransformationToPoint(double matrix[4][4], Vertex *v,
   // doing). Instead of adding one more option, let's just bypass all
   // the checks if auto_coherence==0...
   if(CTX.geom.auto_coherence && end_curve_surface){
-    List_T *All = Tree2List(THEM->Curves);
+    List_T *All = Tree2List(GModel::current()->getGEOInternals()->Curves);
     for(int i = 0; i < List_Nbr(All); i++) {
       Curve *c;
       List_Read(All, i, &c);
@@ -1610,7 +1618,7 @@ void ApplyTransformationToPoint(double matrix[4][4], Vertex *v,
       }
     }
     List_Delete(All);
-    All = Tree2List(THEM->Surfaces);
+    All = Tree2List(GModel::current()->getGEOInternals()->Surfaces);
     for(int i = 0; i < List_Nbr(All); i++) {
       Surface *s;
       List_Read(All, i, &s);
@@ -1921,7 +1929,7 @@ int Extrude_ProtudePoint(int type, int ip,
   pv = &V;
   pv->Num = ip;
   *pc = *prc = NULL;
-  if(!Tree_Query(THEM->Points, &pv))
+  if(!Tree_Query(GModel::current()->getGEOInternals()->Points, &pv))
     return 0;
 
   Msg(DEBUG, "Extrude Point %d", ip);
@@ -2057,7 +2065,7 @@ int Extrude_ProtudePoint(int type, int ip,
   }
 
   End_Curve(c);
-  Tree_Add(THEM->Curves, &c);
+  Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
   CreateReversedCurve(c);
   *pc = c;
   *prc = FindCurve(-c->Num);
@@ -2218,7 +2226,7 @@ int Extrude_ProtudeCurve(int type, int ic,
   }
 
   End_Surface(s);
-  Tree_Add(THEM->Surfaces, &s);
+  Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
 
   List_Reset(ListOfTransformedPoints);
 
@@ -2385,12 +2393,12 @@ int Extrude_ProtudeSurface(int type, int is,
 
   // this is done only for backward compatibility with the old
   // numbering scheme
-  Tree_Suppress(THEM->Surfaces, &chapeau);
+  Tree_Suppress(GModel::current()->getGEOInternals()->Surfaces, &chapeau);
   chapeau->Num = NEWSURFACE();
-  THEM->MaxSurfaceNum = chapeau->Num;
-  Tree_Add(THEM->Surfaces, &chapeau);
+  GModel::current()->getGEOInternals()->MaxSurfaceNum = chapeau->Num;
+  Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &chapeau);
 
-  Tree_Add(THEM->Volumes, &v);
+  Tree_Add(GModel::current()->getGEOInternals()->Volumes, &v);
 
   *pv = v;
 
@@ -2612,19 +2620,22 @@ int compareTwoSurfaces(const void *a, const void *b)
 void MaxNumPoint(void *a, void *b)
 {
   Vertex *v = *(Vertex **)a;
-  THEM->MaxPointNum = MAX(THEM->MaxPointNum, v->Num);
+  GModel::current()->getGEOInternals()->MaxPointNum = 
+    MAX(GModel::current()->getGEOInternals()->MaxPointNum, v->Num);
 }
 
 void MaxNumCurve(void *a, void *b)
 {
   Curve *c = *(Curve **)a;
-  THEM->MaxLineNum = MAX(THEM->MaxLineNum, c->Num);
+  GModel::current()->getGEOInternals()->MaxLineNum = 
+    MAX(GModel::current()->getGEOInternals()->MaxLineNum, c->Num);
 }
 
 void MaxNumSurface(void *a, void *b)
 {
   Surface *s = *(Surface **)a;
-  THEM->MaxSurfaceNum = MAX(THEM->MaxSurfaceNum, s->Num);
+  GModel::current()->getGEOInternals()->MaxSurfaceNum =
+    MAX(GModel::current()->getGEOInternals()->MaxSurfaceNum, s->Num);
 }
 
 void ReplaceDuplicatePoints()
@@ -2641,9 +2652,9 @@ void ReplaceDuplicatePoints()
 
   // Create unique points
 
-  start = Tree_Nbr(THEM->Points);
+  start = Tree_Nbr(GModel::current()->getGEOInternals()->Points);
 
-  All = Tree2List(THEM->Points);
+  All = Tree2List(GModel::current()->getGEOInternals()->Points);
   allNonDuplicatedPoints = Tree_Create(sizeof(Vertex *), compareTwoPoints);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &v);
@@ -2651,13 +2662,13 @@ void ReplaceDuplicatePoints()
       Tree_Insert(allNonDuplicatedPoints, &v);
     }
     else {
-      Tree_Suppress(THEM->Points, &v);
+      Tree_Suppress(GModel::current()->getGEOInternals()->Points, &v);
       //List_Add(points2delete,&v);      
     }
   }
   List_Delete(All);
 
-  end = Tree_Nbr(THEM->Points);
+  end = Tree_Nbr(GModel::current()->getGEOInternals()->Points);
 
   if(start == end) {
     Tree_Delete(allNonDuplicatedPoints);
@@ -2668,13 +2679,13 @@ void ReplaceDuplicatePoints()
   Msg(DEBUG, "Removed %d duplicate points", start - end);
 
   if(CTX.geom.old_newreg) {
-    THEM->MaxPointNum = 0;
-    Tree_Action(THEM->Points, MaxNumPoint);
+    GModel::current()->getGEOInternals()->MaxPointNum = 0;
+    Tree_Action(GModel::current()->getGEOInternals()->Points, MaxNumPoint);
   }
 
   // Replace old points in curves
 
-  All = Tree2List(THEM->Curves);
+  All = Tree2List(GModel::current()->getGEOInternals()->Curves);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &c);
     if(!Tree_Query(allNonDuplicatedPoints, &c->beg))
@@ -2693,7 +2704,7 @@ void ReplaceDuplicatePoints()
 
   // Replace old points in surfaces
 
-  All = Tree2List(THEM->Surfaces);
+  All = Tree2List(GModel::current()->getGEOInternals()->Surfaces);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &s);
     for(j = 0; j < List_Nbr(s->Control_Points); j++) {
@@ -2715,7 +2726,7 @@ void ReplaceDuplicatePoints()
   
   // Replace old points in volumes
 
-  All = Tree2List(THEM->Volumes);
+  All = Tree2List(GModel::current()->getGEOInternals()->Volumes);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &vol);
     for(j = 0; j < List_Nbr(vol->TrsfPoints); j++){
@@ -2747,9 +2758,9 @@ void ReplaceDuplicateCurves()
 
   // Create unique curves
 
-  start = Tree_Nbr(THEM->Curves);
+  start = Tree_Nbr(GModel::current()->getGEOInternals()->Curves);
 
-  All = Tree2List(THEM->Curves);
+  All = Tree2List(GModel::current()->getGEOInternals()->Curves);
   allNonDuplicatedCurves = Tree_Create(sizeof(Curve *), compareTwoCurves);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &c);
@@ -2764,19 +2775,19 @@ void ReplaceDuplicateCurves()
         Tree_Insert(allNonDuplicatedCurves, &c2);
       }
       else {
-        Tree_Suppress(THEM->Curves, &c);
+        Tree_Suppress(GModel::current()->getGEOInternals()->Curves, &c);
         if(!(c2 = FindCurve(-c->Num))) {
           Msg(GERROR, "Unknown curve %d", -c->Num);
           List_Delete(All);
           return;
         }
-        Tree_Suppress(THEM->Curves, &c2);
+        Tree_Suppress(GModel::current()->getGEOInternals()->Curves, &c2);
       }
     }
   }
   List_Delete(All);
 
-  end = Tree_Nbr(THEM->Curves);
+  end = Tree_Nbr(GModel::current()->getGEOInternals()->Curves);
 
   if(start == end) {
     Tree_Delete(allNonDuplicatedCurves);
@@ -2786,13 +2797,13 @@ void ReplaceDuplicateCurves()
   Msg(DEBUG, "Removed %d duplicate curves", start - end);
 
   if(CTX.geom.old_newreg) {
-    THEM->MaxLineNum = 0;
-    Tree_Action(THEM->Curves, MaxNumCurve);
+    GModel::current()->getGEOInternals()->MaxLineNum = 0;
+    Tree_Action(GModel::current()->getGEOInternals()->Curves, MaxNumCurve);
   }
 
   // Replace old curves in surfaces
 
-  All = Tree2List(THEM->Surfaces);
+  All = Tree2List(GModel::current()->getGEOInternals()->Surfaces);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &s);
     for(j = 0; j < List_Nbr(s->Generatrices); j++) {
@@ -2821,9 +2832,9 @@ void ReplaceDuplicateSurfaces()
 
   // Create unique surfaces
 
-  start = Tree_Nbr(THEM->Surfaces);
+  start = Tree_Nbr(GModel::current()->getGEOInternals()->Surfaces);
 
-  All = Tree2List(THEM->Surfaces);
+  All = Tree2List(GModel::current()->getGEOInternals()->Surfaces);
   allNonDuplicatedSurfaces = Tree_Create(sizeof(Surface *), compareTwoSurfaces);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &s);
@@ -2832,13 +2843,13 @@ void ReplaceDuplicateSurfaces()
         Tree_Insert(allNonDuplicatedSurfaces, &s);
       }
       else {
-        Tree_Suppress(THEM->Surfaces, &s);
+        Tree_Suppress(GModel::current()->getGEOInternals()->Surfaces, &s);
       }
     }
   }
   List_Delete(All);
 
-  end = Tree_Nbr(THEM->Surfaces);
+  end = Tree_Nbr(GModel::current()->getGEOInternals()->Surfaces);
 
   if(start == end) {
     Tree_Delete(allNonDuplicatedSurfaces);
@@ -2848,13 +2859,13 @@ void ReplaceDuplicateSurfaces()
   Msg(DEBUG, "Removed %d duplicate surfaces", start - end);
 
   if(CTX.geom.old_newreg) {
-    THEM->MaxSurfaceNum = 0;
-    Tree_Action(THEM->Surfaces, MaxNumSurface);
+    GModel::current()->getGEOInternals()->MaxSurfaceNum = 0;
+    Tree_Action(GModel::current()->getGEOInternals()->Surfaces, MaxNumSurface);
   } 
 
   // Replace old surfaces in volumes
 
-  All = Tree2List(THEM->Volumes);
+  All = Tree2List(GModel::current()->getGEOInternals()->Volumes);
   for(i = 0; i < List_Nbr(All); i++) {
     List_Read(All, i, &vol);
     for(j = 0; j < List_Nbr(vol->Surfaces); j++) {
@@ -3023,7 +3034,7 @@ bool IntersectCurvesWithSurface(List_T *curve_ids, int surface_id, List_T *shape
       if(IntersectCurveSurface(c, s, x)){
 	Vertex p = InterpolateCurve(c, x[3], 0);
 	Vertex *v = Create_Vertex(NEWPOINT(), p.Pos.X, p.Pos.Y, p.Pos.Z, p.lc, p.u);
-	Tree_Insert(THEM->Points, &v);
+	Tree_Insert(GModel::current()->getGEOInternals()->Points, &v);
 	Shape s;
 	s.Type = MSH_POINT;
 	s.Num = v->Num;
diff --git a/Geo/Geo.h b/Geo/Geo.h
index 3803836965..4a4cae8570 100644
--- a/Geo/Geo.h
+++ b/Geo/Geo.h
@@ -198,7 +198,7 @@ typedef struct{
   List_T *Entities;
 }PhysicalGroup;
 
-class Mesh{
+class GEO_Internals{
  private:
   void alloc_all();
   void free_all();
@@ -212,8 +212,8 @@ class Mesh{
   List_T *PhysicalGroups;
   int MaxPointNum, MaxLineNum, MaxLineLoopNum, MaxSurfaceNum;
   int MaxSurfaceLoopNum, MaxVolumeNum, MaxPhysicalNum;
-  Mesh(){ alloc_all(); }
-  ~Mesh(){ free_all(); }
+  GEO_Internals(){ alloc_all(); }
+  ~GEO_Internals(){ free_all(); }
   void destroy(){ free_all(); alloc_all(); }
 };
 
diff --git a/Geo/GeoStringInterface.cpp b/Geo/GeoStringInterface.cpp
index 173975c291..08e8a2ce3f 100644
--- a/Geo/GeoStringInterface.cpp
+++ b/Geo/GeoStringInterface.cpp
@@ -1,4 +1,4 @@
-// $Id: GeoStringInterface.cpp,v 1.11 2007-08-27 19:53:43 geuzaine Exp $
+// $Id: GeoStringInterface.cpp,v 1.12 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -98,7 +98,7 @@ void add_infile(char *text, char *fich, bool deleted_something)
     // could have deleted some entities
     GModel::current()->destroy();
   }
-  GModel::current()->importTHEM();
+  GModel::current()->importGEOInternals();
   CTX.mesh.changed = ENT_ALL;
 
   FILE *file;
diff --git a/Geo/GeoStringInterface.h b/Geo/GeoStringInterface.h
index 5ab4cd5a49..8fec3ae5b1 100644
--- a/Geo/GeoStringInterface.h
+++ b/Geo/GeoStringInterface.h
@@ -20,10 +20,9 @@
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
-#include "Geo.h"
 #include "List.h"
 
-double evaluate_scalarfunction (char *var, double val, char *funct);
+double evaluate_scalarfunction(char *var, double val, char *funct);
 
 void coherence(char *fich);
 void delet(List_T *list, char *fich, char *what);
diff --git a/Geo/Makefile b/Geo/Makefile
index 2d7e6b091b..654e52beb8 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.165 2007-09-22 20:35:18 geuzaine Exp $
+# $Id: Makefile,v 1.166 2007-09-26 20:51:58 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -109,13 +109,13 @@ gmshVertex.o: gmshVertex.cpp GFace.h GPoint.h GEntity.h Range.h SPoint3.h \
   ExtrudeParams.h ../Common/SmoothData.h Pair.h gmshVertex.h Geo.h \
   gmshSurface.h ../DataStr/Tree.h ../DataStr/avl.h GeoInterpolation.h \
   ../Common/Message.h
-gmshEdge.o: gmshEdge.cpp GFace.h GPoint.h GEntity.h Range.h SPoint3.h \
-  SBoundingBox3d.h ../Common/GmshDefines.h GEdgeLoop.h GEdge.h GVertex.h \
-  MVertex.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 ../Common/SmoothData.h Pair.h gmshEdge.h Geo.h \
-  gmshSurface.h ../DataStr/Tree.h ../DataStr/avl.h gmshVertex.h \
-  GeoInterpolation.h ../Common/Message.h
+gmshEdge.o: gmshEdge.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 ../Common/SmoothData.h GFace.h GEdgeLoop.h Pair.h \
+  GRegion.h gmshEdge.h Geo.h gmshSurface.h ../DataStr/Tree.h \
+  ../DataStr/avl.h gmshVertex.h GeoInterpolation.h ../Common/Message.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 \
diff --git a/Geo/gmshEdge.cpp b/Geo/gmshEdge.cpp
index 7540384c7a..69f80226b1 100644
--- a/Geo/gmshEdge.cpp
+++ b/Geo/gmshEdge.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshEdge.cpp,v 1.37 2007-08-29 14:18:25 geuzaine Exp $
+// $Id: gmshEdge.cpp,v 1.38 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -19,6 +19,7 @@
 // 
 // Please report all bugs and problems to <gmsh@geuz.org>.
 
+#include "GModel.h"
 #include "GFace.h"
 #include "gmshEdge.h"
 #include "Geo.h"
@@ -27,19 +28,18 @@
 #include "Context.h"
 
 extern Context_T CTX;
-extern Mesh *THEM;
 
-gmshEdge::gmshEdge(GModel *model, Curve *edge, GVertex *v1, GVertex *v2)
-  : GEdge(model, edge->Num, v1, v2), c(edge)
+gmshEdge::gmshEdge(GModel *m, Curve *edge, GVertex *v1, GVertex *v2)
+  : GEdge(m, edge->Num, v1, v2), c(edge)
 {
   resetMeshAttributes();
 }
 
-gmshEdge::gmshEdge(GModel *model, int num)
-  : GEdge(model, num, 0, 0)
+gmshEdge::gmshEdge(GModel *m, int num)
+  : GEdge(m, num, 0, 0)
 {
   c = Create_Curve(num, MSH_SEGM_DISCRETE, 0, NULL, NULL, -1, -1, 0., 1.);
-  Tree_Add(THEM->Curves, &c);
+  Tree_Add(m->getGEOInternals()->Curves, &c);
   CreateReversedCurve(c);
 }
 
diff --git a/Geo/gmshFace.cpp b/Geo/gmshFace.cpp
index 62fcc2c288..d7ce397c2b 100644
--- a/Geo/gmshFace.cpp
+++ b/Geo/gmshFace.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshFace.cpp,v 1.41 2007-09-10 13:37:21 remacle Exp $
+// $Id: gmshFace.cpp,v 1.42 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -28,8 +28,6 @@
 #include "Numeric.h"
 #include "Message.h"
 
-extern Mesh *THEM;
-
 gmshFace::gmshFace(GModel *m, Surface *face)
   : GFace(m, face->Num), s(face)
 {
@@ -97,7 +95,7 @@ gmshFace::gmshFace(GModel *m, int num)
   : GFace(m, num)
 {
   s = Create_Surface(num, MSH_SURF_DISCRETE);
-  Tree_Add(THEM->Surfaces, &s);
+  Tree_Add(m->getGEOInternals()->Surfaces, &s);
 }
 
 void gmshFace::setModelEdges(std::list<GEdge*>&ed)
diff --git a/Geo/gmshRegion.cpp b/Geo/gmshRegion.cpp
index 9421e0f2aa..1b1b931be8 100644
--- a/Geo/gmshRegion.cpp
+++ b/Geo/gmshRegion.cpp
@@ -1,4 +1,4 @@
-// $Id: gmshRegion.cpp,v 1.15 2007-09-04 13:47:01 remacle Exp $
+// $Id: gmshRegion.cpp,v 1.16 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -25,8 +25,6 @@
 #include "Geo.h"
 #include "Message.h"
 
-extern Mesh *THEM;
-
 gmshRegion::gmshRegion(GModel *m, ::Volume * volume)
   : GRegion(m, volume->Num), v(volume)
 {
@@ -62,7 +60,7 @@ gmshRegion::gmshRegion(GModel *m, int num)
   : GRegion(m, num)
 {
   v = Create_Volume(num, MSH_VOLUME_DISCRETE);
-  Tree_Add(THEM->Volumes, &v);
+  Tree_Add(m->getGEOInternals()->Volumes, &v);
 }
 
 void gmshRegion::resetMeshAttributes()
diff --git a/Parser/CreateFile.cpp b/Parser/CreateFile.cpp
index a903424ca4..9a07773a60 100644
--- a/Parser/CreateFile.cpp
+++ b/Parser/CreateFile.cpp
@@ -1,4 +1,4 @@
-// $Id: CreateFile.cpp,v 1.19 2007-08-21 19:05:40 geuzaine Exp $
+// $Id: CreateFile.cpp,v 1.20 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -23,7 +23,6 @@
 #include "OpenFile.h"
 #include "Context.h"
 #include "Options.h"
-#include "Geo.h"
 #include "GModel.h"
 
 #if defined(HAVE_FLTK)
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index 140e6daf17..36a87b55fd 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -132,7 +132,7 @@
 
 #line 1 "Gmsh.y"
 
-// $Id: Gmsh.tab.cpp,v 1.334 2007-09-12 05:42:40 geuzaine Exp $
+// $Id: Gmsh.tab.cpp,v 1.335 2007-09-26 20:51:58 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -183,7 +183,6 @@
 Tree_T *Symbol_T = NULL;
 
 extern Context_T CTX;
-extern Mesh *THEM;
 
 static ExtrudeParams extr;
 
@@ -206,7 +205,7 @@ void yymsg(int type, char *fmt, ...);
 void skip_until(char *skip, char *until);
 int PrintListOfDouble(char *format, List_T *list, char *buffer);
 
-#line 77 "Gmsh.y"
+#line 76 "Gmsh.y"
 typedef union {
   char *c;
   int i;
@@ -530,20 +529,20 @@ static const short yyrhs[] = {   149,
 
 #if YYDEBUG != 0
 static const short yyrline[] = { 0,
-   143,   145,   150,   152,   155,   157,   158,   159,   160,   161,
-   162,   163,   164,   165,   166,   167,   168,   169,   172,   177,
-   183,   189,   204,   217,   245,   258,   267,   278,   283,   284,
-   285,   286,   287,   290,   293,   297,   300,   304,   449,   457,
-   463,   469,   476,   485,   491,   497,   504,   512,   518,   524,
-   533,   538,   545,   547,   548,   549,   550,   553,   555,   558,
-   593,   632,   686,   703,   721,   732,   749,   756,   770,   787,
-   813,   840,   854,   871,   885,   902,   922,   945,   955,   969,
-   974,   983,  1009,  1025,  1046,  1053,  1064,  1079,  1087,  1102,
-  1109,  1121,  1155,  1191,  1213,  1231,  1249,  1267,  1293,  1311,
-  1337,  1357,  1375,  1393,  1419,  1436,  1455,  1473,  1511,  1515,
-  1519,  1524,  1546,  1568,  1584,  1604,  1621,  1638,  1658,  1664,
-  1669,  1674,  1679,  1690,  1696,  1704,  1706,  1709,  1714,  1718,
-  1741,  1764,  1787,  1814,  1824,  1837,  1852,  1866,  1880,  1887,
+   142,   144,   149,   151,   154,   156,   157,   158,   159,   160,
+   161,   162,   163,   164,   165,   166,   167,   168,   171,   176,
+   182,   188,   203,   216,   244,   257,   266,   277,   282,   283,
+   284,   285,   286,   289,   292,   296,   299,   303,   448,   456,
+   462,   468,   475,   484,   490,   496,   503,   511,   517,   523,
+   532,   537,   544,   546,   547,   548,   549,   552,   554,   557,
+   592,   631,   685,   702,   720,   731,   748,   755,   769,   786,
+   812,   839,   853,   870,   884,   901,   921,   944,   954,   968,
+   973,   982,  1008,  1024,  1045,  1052,  1063,  1078,  1086,  1101,
+  1108,  1120,  1154,  1190,  1212,  1230,  1248,  1266,  1292,  1310,
+  1336,  1356,  1374,  1392,  1418,  1435,  1454,  1472,  1510,  1514,
+  1518,  1523,  1545,  1567,  1583,  1603,  1620,  1637,  1657,  1663,
+  1668,  1673,  1678,  1689,  1695,  1703,  1705,  1708,  1713,  1717,
+  1740,  1763,  1786,  1813,  1823,  1836,  1852,  1866,  1880,  1887,
   1893,  1902,  1915,  1964,  1980,  1996,  2015,  2025,  2047,  2051,
   2056,  2061,  2071,  2088,  2104,  2129,  2155,  2186,  2193,  2198,
   2204,  2208,  2216,  2225,  2233,  2241,  2245,  2253,  2257,  2265,
@@ -2832,86 +2831,86 @@ yyreduce:
   switch (yyn) {
 
 case 2:
-#line 145 "Gmsh.y"
+#line 144 "Gmsh.y"
 { yyerrok; return 1; ;
     break;}
 case 5:
-#line 156 "Gmsh.y"
+#line 155 "Gmsh.y"
 { return 1; ;
     break;}
 case 6:
-#line 157 "Gmsh.y"
+#line 156 "Gmsh.y"
 { return 1; ;
     break;}
 case 7:
-#line 158 "Gmsh.y"
+#line 157 "Gmsh.y"
 { return 1; ;
     break;}
 case 8:
-#line 159 "Gmsh.y"
+#line 158 "Gmsh.y"
 { return 1; ;
     break;}
 case 9:
-#line 160 "Gmsh.y"
+#line 159 "Gmsh.y"
 { List_Delete(yyvsp[0].l); return 1; ;
     break;}
 case 10:
-#line 161 "Gmsh.y"
+#line 160 "Gmsh.y"
 { return 1; ;
     break;}
 case 11:
-#line 162 "Gmsh.y"
+#line 161 "Gmsh.y"
 { return 1; ;
     break;}
 case 12:
-#line 163 "Gmsh.y"
+#line 162 "Gmsh.y"
 { return 1; ;
     break;}
 case 13:
-#line 164 "Gmsh.y"
+#line 163 "Gmsh.y"
 { List_Delete(yyvsp[0].l); return 1; ;
     break;}
 case 14:
-#line 165 "Gmsh.y"
+#line 164 "Gmsh.y"
 { return 1; ;
     break;}
 case 15:
-#line 166 "Gmsh.y"
+#line 165 "Gmsh.y"
 { return 1; ;
     break;}
 case 16:
-#line 167 "Gmsh.y"
+#line 166 "Gmsh.y"
 { return 1; ;
     break;}
 case 17:
-#line 168 "Gmsh.y"
+#line 167 "Gmsh.y"
 { return 1; ;
     break;}
 case 18:
-#line 169 "Gmsh.y"
+#line 168 "Gmsh.y"
 { return 1; ;
     break;}
 case 19:
-#line 174 "Gmsh.y"
+#line 173 "Gmsh.y"
 {
       yyval.c = "w";
     ;
     break;}
 case 20:
-#line 178 "Gmsh.y"
+#line 177 "Gmsh.y"
 {
       yyval.c = "a";
     ;
     break;}
 case 21:
-#line 185 "Gmsh.y"
+#line 184 "Gmsh.y"
 {
       Msg(DIRECT, yyvsp[-2].c);
       Free(yyvsp[-2].c);
     ;
     break;}
 case 22:
-#line 190 "Gmsh.y"
+#line 189 "Gmsh.y"
 {
       char tmpstring[1024];
       FixRelativePath(yyvsp[-1].c, tmpstring);
@@ -2928,7 +2927,7 @@ case 22:
     ;
     break;}
 case 23:
-#line 205 "Gmsh.y"
+#line 204 "Gmsh.y"
 {
       char tmpstring[1024];
       int i = PrintListOfDouble(yyvsp[-4].c, yyvsp[-2].l, tmpstring);
@@ -2943,7 +2942,7 @@ case 23:
     ;
     break;}
 case 24:
-#line 218 "Gmsh.y"
+#line 217 "Gmsh.y"
 {
       char tmpstring[1024];
       int i = PrintListOfDouble(yyvsp[-6].c, yyvsp[-4].l, tmpstring);
@@ -2969,7 +2968,7 @@ case 24:
     ;
     break;}
 case 25:
-#line 247 "Gmsh.y"
+#line 246 "Gmsh.y"
 { 
       if(!strcmp(yyvsp[-5].c, "View") && ViewData->finalize()){
 	ViewData->setName(yyvsp[-4].c);
@@ -2983,7 +2982,7 @@ case 25:
     ;
     break;}
 case 26:
-#line 259 "Gmsh.y"
+#line 258 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")){
 	int index = (int)yyvsp[-2].d;
@@ -2994,7 +2993,7 @@ case 26:
     ;
     break;}
 case 27:
-#line 268 "Gmsh.y"
+#line 267 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")){
 	int index = (int)yyvsp[-2].d;
@@ -3005,29 +3004,29 @@ case 27:
     ;
     break;}
 case 28:
-#line 280 "Gmsh.y"
+#line 279 "Gmsh.y"
 {
       ViewData = new PViewDataList(true); 
     ;
     break;}
 case 34:
-#line 292 "Gmsh.y"
+#line 291 "Gmsh.y"
 { ViewCoord[ViewCoordIdx++] = yyvsp[0].d; ;
     break;}
 case 35:
-#line 294 "Gmsh.y"
+#line 293 "Gmsh.y"
 { ViewCoord[ViewCoordIdx++] = yyvsp[0].d; ;
     break;}
 case 36:
-#line 299 "Gmsh.y"
+#line 298 "Gmsh.y"
 { if(ViewValueList) List_Add(ViewValueList, &yyvsp[0].d); ;
     break;}
 case 37:
-#line 301 "Gmsh.y"
+#line 300 "Gmsh.y"
 { if(ViewValueList) List_Add(ViewValueList, &yyvsp[0].d); ;
     break;}
 case 38:
-#line 306 "Gmsh.y"
+#line 305 "Gmsh.y"
 {
       if(!strcmp(yyvsp[0].c, "SP")){
 	ViewValueList = ViewData->SP; ViewNumList = &ViewData->NbSP;
@@ -3173,7 +3172,7 @@ case 38:
     ;
     break;}
 case 39:
-#line 450 "Gmsh.y"
+#line 449 "Gmsh.y"
 {
       if(ViewValueList){
 	for(int i = 0; i < 3; i++)
@@ -3183,27 +3182,27 @@ case 39:
     ;
     break;}
 case 40:
-#line 458 "Gmsh.y"
+#line 457 "Gmsh.y"
 {
       if(ViewValueList) (*ViewNumList)++;
     ;
     break;}
 case 41:
-#line 465 "Gmsh.y"
+#line 464 "Gmsh.y"
 { 
       for(int i = 0; i < (int)strlen(yyvsp[0].c)+1; i++) List_Add(ViewData->T2C, &yyvsp[0].c[i]); 
       Free(yyvsp[0].c);
     ;
     break;}
 case 42:
-#line 470 "Gmsh.y"
+#line 469 "Gmsh.y"
 { 
       for(int i = 0; i < (int)strlen(yyvsp[0].c)+1; i++) List_Add(ViewData->T2C, &yyvsp[0].c[i]); 
       Free(yyvsp[0].c);
     ;
     break;}
 case 43:
-#line 478 "Gmsh.y"
+#line 477 "Gmsh.y"
 { 
       List_Add(ViewData->T2D, &yyvsp[-5].d); 
       List_Add(ViewData->T2D, &yyvsp[-3].d);
@@ -3213,27 +3212,27 @@ case 43:
     ;
     break;}
 case 44:
-#line 486 "Gmsh.y"
+#line 485 "Gmsh.y"
 {
       ViewData->NbT2++;
     ;
     break;}
 case 45:
-#line 493 "Gmsh.y"
+#line 492 "Gmsh.y"
 { 
       for(int i = 0; i < (int)strlen(yyvsp[0].c)+1; i++) List_Add(ViewData->T3C, &yyvsp[0].c[i]); 
       Free(yyvsp[0].c);
     ;
     break;}
 case 46:
-#line 498 "Gmsh.y"
+#line 497 "Gmsh.y"
 { 
       for(int i = 0; i < (int)strlen(yyvsp[0].c)+1; i++) List_Add(ViewData->T3C, &yyvsp[0].c[i]); 
       Free(yyvsp[0].c);
     ;
     break;}
 case 47:
-#line 506 "Gmsh.y"
+#line 505 "Gmsh.y"
 { 
       List_Add(ViewData->T3D, &yyvsp[-7].d); List_Add(ViewData->T3D, &yyvsp[-5].d);
       List_Add(ViewData->T3D, &yyvsp[-3].d); List_Add(ViewData->T3D, &yyvsp[-1].d); 
@@ -3242,64 +3241,64 @@ case 47:
     ;
     break;}
 case 48:
-#line 513 "Gmsh.y"
+#line 512 "Gmsh.y"
 {
       ViewData->NbT3++;
     ;
     break;}
 case 49:
-#line 521 "Gmsh.y"
+#line 520 "Gmsh.y"
 {
       ViewData->adaptive = new Adaptive_Post_View(ViewData, yyvsp[-5].l, yyvsp[-2].l);
     ;
     break;}
 case 50:
-#line 528 "Gmsh.y"
+#line 527 "Gmsh.y"
 {
       ViewData->adaptive = new Adaptive_Post_View(ViewData, yyvsp[-11].l, yyvsp[-8].l, yyvsp[-5].l, yyvsp[-2].l);
     ;
     break;}
 case 51:
-#line 535 "Gmsh.y"
+#line 534 "Gmsh.y"
 {
       ViewValueList = ViewData->Time;
     ;
     break;}
 case 52:
-#line 539 "Gmsh.y"
+#line 538 "Gmsh.y"
 {
     ;
     break;}
 case 53:
-#line 546 "Gmsh.y"
+#line 545 "Gmsh.y"
 { yyval.i = 0; ;
     break;}
 case 54:
-#line 547 "Gmsh.y"
+#line 546 "Gmsh.y"
 { yyval.i = 1; ;
     break;}
 case 55:
-#line 548 "Gmsh.y"
+#line 547 "Gmsh.y"
 { yyval.i = 2; ;
     break;}
 case 56:
-#line 549 "Gmsh.y"
+#line 548 "Gmsh.y"
 { yyval.i = 3; ;
     break;}
 case 57:
-#line 550 "Gmsh.y"
+#line 549 "Gmsh.y"
 { yyval.i = 4; ;
     break;}
 case 58:
-#line 554 "Gmsh.y"
+#line 553 "Gmsh.y"
 { yyval.i = 1; ;
     break;}
 case 59:
-#line 555 "Gmsh.y"
+#line 554 "Gmsh.y"
 { yyval.i = -1; ;
     break;}
 case 60:
-#line 563 "Gmsh.y"
+#line 562 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-3].c;
@@ -3332,7 +3331,7 @@ case 60:
     ;
     break;}
 case 61:
-#line 594 "Gmsh.y"
+#line 593 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-6].c;
@@ -3373,7 +3372,7 @@ case 61:
     ;
     break;}
 case 62:
-#line 633 "Gmsh.y"
+#line 632 "Gmsh.y"
 {
       if(List_Nbr(yyvsp[-5].l) != List_Nbr(yyvsp[-1].l)){
 	yymsg(GERROR, "Incompatible array dimensions in affectation");
@@ -3429,7 +3428,7 @@ case 62:
     ;
     break;}
 case 63:
-#line 687 "Gmsh.y"
+#line 686 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-5].c;
@@ -3448,7 +3447,7 @@ case 63:
     ;
     break;}
 case 64:
-#line 704 "Gmsh.y"
+#line 703 "Gmsh.y"
 {
       // appends to the list
       Symbol TheSymbol;
@@ -3468,7 +3467,7 @@ case 64:
     ;
     break;}
 case 65:
-#line 722 "Gmsh.y"
+#line 721 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-2].c;
@@ -3481,7 +3480,7 @@ case 65:
     ;
     break;}
 case 66:
-#line 733 "Gmsh.y"
+#line 732 "Gmsh.y"
 {
       Symbol TheSymbol;
       TheSymbol.Name = yyvsp[-5].c;
@@ -3499,13 +3498,13 @@ case 66:
     ;
     break;}
 case 67:
-#line 750 "Gmsh.y"
+#line 749 "Gmsh.y"
 { 
       Msg(WARNING, "Named string expressions not implemented yet");
     ;
     break;}
 case 68:
-#line 757 "Gmsh.y"
+#line 756 "Gmsh.y"
 { 
       char* (*pStrOpt)(int num, int action, char *value);
       StringXString *pStrCat;
@@ -3521,7 +3520,7 @@ case 68:
     ;
     break;}
 case 69:
-#line 771 "Gmsh.y"
+#line 770 "Gmsh.y"
 { 
       char* (*pStrOpt)(int num, int action, char *value);
       StringXString *pStrCat;
@@ -3537,7 +3536,7 @@ case 69:
     ;
     break;}
 case 70:
-#line 788 "Gmsh.y"
+#line 787 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -3565,7 +3564,7 @@ case 70:
     ;
     break;}
 case 71:
-#line 814 "Gmsh.y"
+#line 813 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -3594,7 +3593,7 @@ case 71:
     ;
     break;}
 case 72:
-#line 841 "Gmsh.y"
+#line 840 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -3610,7 +3609,7 @@ case 72:
     ;
     break;}
 case 73:
-#line 855 "Gmsh.y"
+#line 854 "Gmsh.y"
 {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -3626,7 +3625,7 @@ case 73:
     ;
     break;}
 case 74:
-#line 872 "Gmsh.y"
+#line 871 "Gmsh.y"
 {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -3642,7 +3641,7 @@ case 74:
     ;
     break;}
 case 75:
-#line 886 "Gmsh.y"
+#line 885 "Gmsh.y"
 {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -3658,7 +3657,7 @@ case 75:
     ;
     break;}
 case 76:
-#line 903 "Gmsh.y"
+#line 902 "Gmsh.y"
 {
       GmshColorTable *ct = Get_ColorTable(0);
       if(!ct)
@@ -3680,7 +3679,7 @@ case 76:
     ;
     break;}
 case 77:
-#line 923 "Gmsh.y"
+#line 922 "Gmsh.y"
 {
       GmshColorTable *ct = Get_ColorTable((int)yyvsp[-6].d);
       if(!ct)
@@ -3702,7 +3701,7 @@ case 77:
     ;
     break;}
 case 78:
-#line 946 "Gmsh.y"
+#line 945 "Gmsh.y"
 {
       try {
 	GMSH_PluginManager::instance()->setPluginOption(yyvsp[-6].c, yyvsp[-3].c, yyvsp[-1].d); 
@@ -3714,7 +3713,7 @@ case 78:
     ;
     break;}
 case 79:
-#line 956 "Gmsh.y"
+#line 955 "Gmsh.y"
 {
       try {
 	GMSH_PluginManager::instance()->setPluginOption(yyvsp[-6].c, yyvsp[-3].c, yyvsp[-1].c); 
@@ -3726,21 +3725,21 @@ case 79:
     ;
     break;}
 case 80:
-#line 971 "Gmsh.y"
+#line 970 "Gmsh.y"
 { 
       yyval.i = (int)yyvsp[0].d; 
     ;
     break;}
 case 81:
-#line 975 "Gmsh.y"
+#line 974 "Gmsh.y"
 { 
-      yyval.i = GModel::current()->setPhysicalName(std::string(yyvsp[0].c),
-					      ++THEM->MaxPhysicalNum);
+      yyval.i = GModel::current()->setPhysicalName
+	(std::string(yyvsp[0].c), ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
       Free(yyvsp[0].c);
     ;
     break;}
 case 82:
-#line 988 "Gmsh.y"
+#line 987 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindPoint(num)){
@@ -3756,7 +3755,7 @@ case 82:
 	  v = Create_Vertex(num, x, y, z, lc, 1.0);
 	else
 	  v = Create_Vertex(num, x, y, myGmshSurface, lc);
-	Tree_Add(THEM->Points, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Points, &v);
 	AddToTemporaryBoundingBox(v->Pos.X, v->Pos.Y, v->Pos.Z);
       }
       yyval.s.Type = MSH_POINT;
@@ -3764,7 +3763,7 @@ case 82:
     ;
     break;}
 case 83:
-#line 1010 "Gmsh.y"
+#line 1009 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].i;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_POINT)){
@@ -3774,7 +3773,7 @@ case 83:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_POINT, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_PHYSICAL_POINT;
@@ -3782,7 +3781,7 @@ case 83:
     ;
     break;}
 case 84:
-#line 1026 "Gmsh.y"
+#line 1025 "Gmsh.y"
 {
       AttractorField *att = new AttractorField();
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -3805,7 +3804,7 @@ case 84:
     ;
     break;}
 case 85:
-#line 1047 "Gmsh.y"
+#line 1046 "Gmsh.y"
 {
       fields.insert(new LatLonField(fields.get((int)yyvsp[-1].d)), (int)yyvsp[-4].d);
       // dummy values
@@ -3814,7 +3813,7 @@ case 85:
     ;
     break;}
 case 86:
-#line 1054 "Gmsh.y"
+#line 1053 "Gmsh.y"
 {
       int index = (int)yyvsp[-1].d;
       if(index >= 0 && index < PView::list.size()) 
@@ -3827,7 +3826,7 @@ case 86:
     ;
     break;}
 case 87:
-#line 1065 "Gmsh.y"
+#line 1064 "Gmsh.y"
 {
       double pars[] = {0, CTX.lc/10, CTX.lc, CTX.lc/100, CTX.lc/20};
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -3844,7 +3843,7 @@ case 87:
     ;
     break;}
 case 88:
-#line 1080 "Gmsh.y"
+#line 1079 "Gmsh.y"
 {
       std::list<Field*> *flist = new std::list<Field*>;
       fields.insert(new FunctionField(flist,yyvsp[-1].c), (int)yyvsp[-4].d);
@@ -3854,7 +3853,7 @@ case 88:
     ;
     break;}
 case 89:
-#line 1088 "Gmsh.y"
+#line 1087 "Gmsh.y"
 {
       std::list<Field*> *flist = new std::list<Field*>;
       flist->resize(0);
@@ -3871,7 +3870,7 @@ case 89:
     ;
     break;}
 case 90:
-#line 1103 "Gmsh.y"
+#line 1102 "Gmsh.y"
 {
       fields.insert(new StructuredField(yyvsp[-1].c), (int)yyvsp[-4].d);
       // dummy values
@@ -3880,7 +3879,7 @@ case 90:
     ;
     break;}
 case 91:
-#line 1110 "Gmsh.y"
+#line 1109 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	double id;
@@ -3893,7 +3892,7 @@ case 91:
     ;
     break;}
 case 92:
-#line 1122 "Gmsh.y"
+#line 1121 "Gmsh.y"
 {
       double pars[] = { CTX.lc/10, CTX.lc/100., CTX.lc/20, 1, 3 };
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -3929,7 +3928,7 @@ case 92:
     ;
     break;}
 case 93:
-#line 1156 "Gmsh.y"
+#line 1155 "Gmsh.y"
 {
       double pars[] = { CTX.lc/10, CTX.lc/100., CTX.lc/20, 10, 3 };
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -3967,7 +3966,7 @@ case 93:
     ;
     break;}
 case 94:
-#line 1192 "Gmsh.y"
+#line 1191 "Gmsh.y"
 {      
       for(int i = 0; i < List_Nbr(yyvsp[-3].l); i++){
 	double d;
@@ -3988,7 +3987,7 @@ case 94:
     ;
     break;}
 case 95:
-#line 1214 "Gmsh.y"
+#line 1213 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -3998,7 +3997,7 @@ case 95:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_LINE, 1, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4008,7 +4007,7 @@ case 95:
     ;
     break;}
 case 96:
-#line 1232 "Gmsh.y"
+#line 1231 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -4018,7 +4017,7 @@ case 96:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_SPLN, 3, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4028,7 +4027,7 @@ case 96:
     ;
     break;}
 case 97:
-#line 1250 "Gmsh.y"
+#line 1249 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -4038,7 +4037,7 @@ case 97:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_CIRC, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4048,7 +4047,7 @@ case 97:
     ;
     break;}
 case 98:
-#line 1268 "Gmsh.y"
+#line 1267 "Gmsh.y"
 {
       int num = (int)yyvsp[-6].d;
       if(FindCurve(num)){
@@ -4062,7 +4061,7 @@ case 98:
 	c->Circle.n[1] = yyvsp[-1].v[1];
 	c->Circle.n[2] = yyvsp[-1].v[2];
 	End_Curve(c);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	Curve *rc = CreateReversedCurve(c);
 	rc->Circle.n[0] = yyvsp[-1].v[0];
 	rc->Circle.n[1] = yyvsp[-1].v[1];
@@ -4076,7 +4075,7 @@ case 98:
     ;
     break;}
 case 99:
-#line 1294 "Gmsh.y"
+#line 1293 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -4086,7 +4085,7 @@ case 99:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_ELLI, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4096,7 +4095,7 @@ case 99:
     ;
     break;}
 case 100:
-#line 1312 "Gmsh.y"
+#line 1311 "Gmsh.y"
 {
       int num = (int)yyvsp[-6].d;
       if(FindCurve(num)){
@@ -4110,7 +4109,7 @@ case 100:
 	c->Circle.n[1] = yyvsp[-1].v[1];
 	c->Circle.n[2] = yyvsp[-1].v[2];
 	End_Curve(c);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	Curve *rc = CreateReversedCurve(c);
 	rc->Circle.n[0] = yyvsp[-1].v[0];
 	rc->Circle.n[1] = yyvsp[-1].v[1];
@@ -4124,7 +4123,7 @@ case 100:
     ;
     break;}
 case 101:
-#line 1339 "Gmsh.y"
+#line 1338 "Gmsh.y"
 {
       int num = (int)yyvsp[-14].d;
       if(FindCurve(num)){
@@ -4136,7 +4135,7 @@ case 101:
 	strcpy(c->functu, yyvsp[-6].c);
 	strcpy(c->functv, yyvsp[-4].c);
 	strcpy(c->functw, yyvsp[-2].c);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
       }
       Free(yyvsp[-6].c); Free(yyvsp[-4].c); Free(yyvsp[-2].c);
@@ -4145,7 +4144,7 @@ case 101:
     ;
     break;}
 case 102:
-#line 1358 "Gmsh.y"
+#line 1357 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -4155,7 +4154,7 @@ case 102:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_BSPLN, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4165,7 +4164,7 @@ case 102:
     ;
     break;}
 case 103:
-#line 1376 "Gmsh.y"
+#line 1375 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindCurve(num)){
@@ -4175,7 +4174,7 @@ case 103:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	Curve *c = Create_Curve(num, MSH_SEGM_BEZIER, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -4185,7 +4184,7 @@ case 103:
     ;
     break;}
 case 104:
-#line 1394 "Gmsh.y"
+#line 1393 "Gmsh.y"
 {
       int num = (int)yyvsp[-8].d;
       if(List_Nbr(yyvsp[-5].l) + (int)yyvsp[-1].d + 1 != List_Nbr(yyvsp[-3].l)){
@@ -4201,7 +4200,7 @@ case 104:
 	  List_T *temp = ListOfDouble2ListOfInt(yyvsp[-5].l);
 	  Curve *c = Create_Curve(num, MSH_SEGM_NURBS, (int)yyvsp[-1].d, temp, yyvsp[-3].l,
 				  -1, -1, 0., 1.);
-	  Tree_Add(THEM->Curves, &c);
+	  Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	  CreateReversedCurve(c);
 	  List_Delete(temp);
 	}
@@ -4213,7 +4212,7 @@ case 104:
     ;
     break;}
 case 105:
-#line 1420 "Gmsh.y"
+#line 1419 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindEdgeLoop(num)){
@@ -4223,7 +4222,7 @@ case 105:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	sortEdgesInLoop(num, temp);
 	EdgeLoop *l = Create_EdgeLoop(num, temp);
-	Tree_Add(THEM->EdgeLoops, &l);
+	Tree_Add(GModel::current()->getGEOInternals()->EdgeLoops, &l);
 	List_Delete(temp);
       }
       List_Delete(yyvsp[-1].l);
@@ -4232,7 +4231,7 @@ case 105:
     ;
     break;}
 case 106:
-#line 1437 "Gmsh.y"
+#line 1436 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].i;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_LINE)){
@@ -4242,7 +4241,7 @@ case 106:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_LINE, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_PHYSICAL_LINE;
@@ -4250,7 +4249,7 @@ case 106:
     ;
     break;}
 case 107:
-#line 1456 "Gmsh.y"
+#line 1455 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindSurface(num)){
@@ -4262,7 +4261,7 @@ case 107:
 	setSurfaceGeneratrices(s, temp);
 	List_Delete(temp);
 	End_Surface(s);
-	Tree_Add(THEM->Surfaces, &s);
+	Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_SURF_PLAN;
@@ -4270,7 +4269,7 @@ case 107:
     ;
     break;}
 case 108:
-#line 1474 "Gmsh.y"
+#line 1473 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d, type = 0;
       if(FindSurface(num)){
@@ -4301,7 +4300,7 @@ case 108:
 	  setSurfaceGeneratrices(s, temp);
 	  List_Delete(temp);
 	  End_Surface(s);
-	  Tree_Add(THEM->Surfaces, &s);
+	  Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
 	}
       }
       List_Delete(yyvsp[-1].l);
@@ -4310,26 +4309,26 @@ case 108:
     ;
     break;}
 case 109:
-#line 1512 "Gmsh.y"
+#line 1511 "Gmsh.y"
 {
       myGmshSurface = 0;
     ;
     break;}
 case 110:
-#line 1516 "Gmsh.y"
+#line 1515 "Gmsh.y"
 {
       myGmshSurface = gmshSurface :: surfaceByTag ( (int) yyvsp[-1].d);
     ;
     break;}
 case 111:
-#line 1520 "Gmsh.y"
+#line 1519 "Gmsh.y"
 {
       int num = (int)yyvsp[-6].d, type = 0;
       myGmshSurface = gmshParametricSurface::NewParametricSurface ((int)yyvsp[-6].d,yyvsp[-3].c,yyvsp[-2].c,yyvsp[-1].c);
     ;
     break;}
 case 112:
-#line 1525 "Gmsh.y"
+#line 1524 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d, type = 0;
       if (List_Nbr(yyvsp[-1].l) != 2){
@@ -4353,7 +4352,7 @@ case 112:
     ;
     break;}
 case 113:
-#line 1547 "Gmsh.y"
+#line 1546 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d, type = 0;
       if (List_Nbr(yyvsp[-1].l) != 2){
@@ -4377,7 +4376,7 @@ case 113:
     ;
     break;}
 case 114:
-#line 1569 "Gmsh.y"
+#line 1568 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindSurfaceLoop(num)){
@@ -4386,7 +4385,7 @@ case 114:
       else{
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	SurfaceLoop *l = Create_SurfaceLoop(num, temp);
-	Tree_Add(THEM->SurfaceLoops, &l);
+	Tree_Add(GModel::current()->getGEOInternals()->SurfaceLoops, &l);
 	List_Delete(temp);
       }
       List_Delete(yyvsp[-1].l);
@@ -4395,7 +4394,7 @@ case 114:
     ;
     break;}
 case 115:
-#line 1585 "Gmsh.y"
+#line 1584 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].i;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_SURFACE)){
@@ -4405,7 +4404,7 @@ case 115:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_SURFACE, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_PHYSICAL_SURFACE;
@@ -4413,7 +4412,7 @@ case 115:
     ;
     break;}
 case 116:
-#line 1605 "Gmsh.y"
+#line 1604 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindVolume(num)){
@@ -4424,7 +4423,7 @@ case 116:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	setVolumeSurfaces(v, temp);
 	List_Delete(temp);
-	Tree_Add(THEM->Volumes, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Volumes, &v);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_VOLUME;
@@ -4432,7 +4431,7 @@ case 116:
     ;
     break;}
 case 117:
-#line 1622 "Gmsh.y"
+#line 1621 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].d;
       if(FindVolume(num)){
@@ -4443,7 +4442,7 @@ case 117:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	setVolumeSurfaces(v, temp);
 	List_Delete(temp);
-	Tree_Add(THEM->Volumes, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Volumes, &v);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_VOLUME;
@@ -4451,7 +4450,7 @@ case 117:
     ;
     break;}
 case 118:
-#line 1639 "Gmsh.y"
+#line 1638 "Gmsh.y"
 {
       int num = (int)yyvsp[-4].i;
       if(FindPhysicalGroup(num, MSH_PHYSICAL_VOLUME)){
@@ -4461,7 +4460,7 @@ case 118:
 	List_T *temp = ListOfDouble2ListOfInt(yyvsp[-1].l);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_VOLUME, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete(yyvsp[-1].l);
       yyval.s.Type = MSH_PHYSICAL_VOLUME;
@@ -4469,35 +4468,35 @@ case 118:
     ;
     break;}
 case 119:
-#line 1660 "Gmsh.y"
+#line 1659 "Gmsh.y"
 {
       TranslateShapes(yyvsp[-3].v[0], yyvsp[-3].v[1], yyvsp[-3].v[2], yyvsp[-1].l);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 120:
-#line 1665 "Gmsh.y"
+#line 1664 "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);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 121:
-#line 1670 "Gmsh.y"
+#line 1669 "Gmsh.y"
 {
       SymmetryShapes(yyvsp[-3].v[0], yyvsp[-3].v[1], yyvsp[-3].v[2], yyvsp[-3].v[3], yyvsp[-1].l);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 122:
-#line 1675 "Gmsh.y"
+#line 1674 "Gmsh.y"
 {
       DilatShapes(yyvsp[-6].v[0], yyvsp[-6].v[1], yyvsp[-6].v[2], yyvsp[-4].d, yyvsp[-1].l);
       yyval.l = yyvsp[-1].l;
     ;
     break;}
 case 123:
-#line 1680 "Gmsh.y"
+#line 1679 "Gmsh.y"
 {
       yyval.l = List_Create(3, 3, sizeof(Shape));
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
@@ -4510,7 +4509,7 @@ case 123:
     ;
     break;}
 case 124:
-#line 1691 "Gmsh.y"
+#line 1690 "Gmsh.y"
 { 
       yyval.l = List_Create(2, 1, sizeof(Shape));
       IntersectCurvesWithSurface(yyvsp[-5].l, (int)yyvsp[-1].d, yyval.l);
@@ -4518,7 +4517,7 @@ case 124:
     ;
     break;}
 case 125:
-#line 1697 "Gmsh.y"
+#line 1696 "Gmsh.y"
 { 
       yyval.l = List_Create(2, 1, sizeof(Shape));
       BoundaryShapes(yyvsp[-1].l, yyval.l);
@@ -4526,27 +4525,27 @@ case 125:
     ;
     break;}
 case 126:
-#line 1705 "Gmsh.y"
+#line 1704 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 127:
-#line 1706 "Gmsh.y"
+#line 1705 "Gmsh.y"
 { yyval.l = yyvsp[0].l; ;
     break;}
 case 128:
-#line 1711 "Gmsh.y"
+#line 1710 "Gmsh.y"
 {
       yyval.l = List_Create(3, 3, sizeof(Shape));
     ;
     break;}
 case 129:
-#line 1715 "Gmsh.y"
+#line 1714 "Gmsh.y"
 {
       List_Add(yyval.l, &yyvsp[0].s);
     ;
     break;}
 case 130:
-#line 1719 "Gmsh.y"
+#line 1718 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4571,7 +4570,7 @@ case 130:
     ;
     break;}
 case 131:
-#line 1742 "Gmsh.y"
+#line 1741 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4596,7 +4595,7 @@ case 131:
     ;
     break;}
 case 132:
-#line 1765 "Gmsh.y"
+#line 1764 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4621,7 +4620,7 @@ case 132:
     ;
     break;}
 case 133:
-#line 1788 "Gmsh.y"
+#line 1787 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-2].l); i++){
 	double d;
@@ -4646,7 +4645,7 @@ case 133:
     ;
     break;}
 case 134:
-#line 1816 "Gmsh.y"
+#line 1815 "Gmsh.y"
 {
       for(int i = 0; i < List_Nbr(yyvsp[-1].l); i++){
 	Shape TheShape;
@@ -4657,7 +4656,7 @@ case 134:
     ;
     break;}
 case 135:
-#line 1825 "Gmsh.y"
+#line 1824 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-4].c, "View")){
 	int index = (int)yyvsp[-2].d;
@@ -4672,15 +4671,16 @@ case 135:
     ;
     break;}
 case 136:
-#line 1838 "Gmsh.y"
+#line 1837 "Gmsh.y"
 {
       if(!strcmp(yyvsp[-1].c, "Meshes") || !strcmp(yyvsp[-1].c, "All")){
 	GModel::current()->destroy();
-	THEM->destroy();
+	GModel::current()->getGEOInternals()->destroy();
       }
       else if(!strcmp(yyvsp[-1].c, "Physicals")){
-	List_Action(THEM->PhysicalGroups, Free_PhysicalGroup);
-	List_Reset(THEM->PhysicalGroups);
+	List_Action(GModel::current()->getGEOInternals()->PhysicalGroups, 
+		    Free_PhysicalGroup);
+	List_Reset(GModel::current()->getGEOInternals()->PhysicalGroups);
 	GModel::current()->deletePhysicalGroups();
       }
       else
@@ -4769,10 +4769,10 @@ case 143:
       }
       else if(!strcmp(yyvsp[-2].c, "Print")){
 #if defined(HAVE_FLTK)
-	// make sure we have the latest data from THEM in GModel
+	// make sure we have the latest data from GEO_Internals in GModel
 	// (fixes bug where we would have no geometry in the picture if
 	// the print command is in the same file as the geometry)
-	GModel::current()->importTHEM();
+	GModel::current()->importGEOInternals();
 	char tmpstring[1024];
 	FixRelativePath(yyvsp[-1].c, tmpstring);
 	CreateOutputFile(tmpstring, CTX.print.format);
@@ -4780,7 +4780,7 @@ case 143:
       }
       else if(!strcmp(yyvsp[-2].c, "Save")){
 #if defined(HAVE_FLTK)
-	GModel::current()->importTHEM();
+	GModel::current()->importGEOInternals();
 	char tmpstring[1024];
 	FixRelativePath(yyvsp[-1].c, tmpstring);
 	CreateOutputFile(tmpstring, CTX.mesh.format);
@@ -5488,7 +5488,7 @@ case 209:
       }
       else{
 	Surface *s = Create_Surface(num, MSH_SURF_DISCRETE);
-	Tree_Add(THEM->Surfaces, &s);
+	Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
 	extr.mesh.Holes[num].first = yyvsp[-1].d;
 	extr.mesh.Holes[num].second.clear();
 	for(int i = 0; i < List_Nbr(yyvsp[-3].l); i++){
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 923d9fd469..e03753d602 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,5 +1,5 @@
 %{
-// $Id: Gmsh.y,v 1.288 2007-09-12 05:42:41 geuzaine Exp $
+// $Id: Gmsh.y,v 1.289 2007-09-26 20:52:00 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -50,7 +50,6 @@
 Tree_T *Symbol_T = NULL;
 
 extern Context_T CTX;
-extern Mesh *THEM;
 
 static ExtrudeParams extr;
 
@@ -973,8 +972,8 @@ PhysicalId :
     }
   | StringExpr
     { 
-      $$ = GModel::current()->setPhysicalName(std::string($1),
-					      ++THEM->MaxPhysicalNum);
+      $$ = GModel::current()->setPhysicalName
+	(std::string($1), ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
       Free($1);
     }
 ;
@@ -1000,7 +999,7 @@ Shape :
 	  v = Create_Vertex(num, x, y, z, lc, 1.0);
 	else
 	  v = Create_Vertex(num, x, y, myGmshSurface, lc);
-	Tree_Add(THEM->Points, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Points, &v);
 	AddToTemporaryBoundingBox(v->Pos.X, v->Pos.Y, v->Pos.Z);
       }
       $$.Type = MSH_POINT;
@@ -1016,7 +1015,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_POINT, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete($7);
       $$.Type = MSH_PHYSICAL_POINT;
@@ -1220,7 +1219,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_LINE, 1, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1238,7 +1237,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_SPLN, 3, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1256,7 +1255,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_CIRC, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1278,7 +1277,7 @@ Shape :
 	c->Circle.n[1] = $8[1];
 	c->Circle.n[2] = $8[2];
 	End_Curve(c);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	Curve *rc = CreateReversedCurve(c);
 	rc->Circle.n[0] = $8[0];
 	rc->Circle.n[1] = $8[1];
@@ -1300,7 +1299,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_ELLI, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1322,7 +1321,7 @@ Shape :
 	c->Circle.n[1] = $8[1];
 	c->Circle.n[2] = $8[2];
 	End_Curve(c);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	Curve *rc = CreateReversedCurve(c);
 	rc->Circle.n[0] = $8[0];
 	rc->Circle.n[1] = $8[1];
@@ -1347,7 +1346,7 @@ Shape :
 	strcpy(c->functu, $11);
 	strcpy(c->functv, $13);
 	strcpy(c->functw, $15);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
       }
       Free($11); Free($13); Free($15);
@@ -1364,7 +1363,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_BSPLN, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1382,7 +1381,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	Curve *c = Create_Curve(num, MSH_SEGM_BEZIER, 2, temp, NULL,
 				-1, -1, 0., 1.);
-	Tree_Add(THEM->Curves, &c);
+	Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	CreateReversedCurve(c);
 	List_Delete(temp);
       }
@@ -1406,7 +1405,7 @@ Shape :
 	  List_T *temp = ListOfDouble2ListOfInt($6);
 	  Curve *c = Create_Curve(num, MSH_SEGM_NURBS, (int)$10, temp, $8,
 				  -1, -1, 0., 1.);
-	  Tree_Add(THEM->Curves, &c);
+	  Tree_Add(GModel::current()->getGEOInternals()->Curves, &c);
 	  CreateReversedCurve(c);
 	  List_Delete(temp);
 	}
@@ -1426,7 +1425,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	sortEdgesInLoop(num, temp);
 	EdgeLoop *l = Create_EdgeLoop(num, temp);
-	Tree_Add(THEM->EdgeLoops, &l);
+	Tree_Add(GModel::current()->getGEOInternals()->EdgeLoops, &l);
 	List_Delete(temp);
       }
       List_Delete($7);
@@ -1443,7 +1442,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_LINE, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete($7);
       $$.Type = MSH_PHYSICAL_LINE;
@@ -1464,7 +1463,7 @@ Shape :
 	setSurfaceGeneratrices(s, temp);
 	List_Delete(temp);
 	End_Surface(s);
-	Tree_Add(THEM->Surfaces, &s);
+	Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
       }
       List_Delete($7);
       $$.Type = MSH_SURF_PLAN;
@@ -1501,7 +1500,7 @@ Shape :
 	  setSurfaceGeneratrices(s, temp);
 	  List_Delete(temp);
 	  End_Surface(s);
-	  Tree_Add(THEM->Surfaces, &s);
+	  Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
 	}
       }
       List_Delete($7);
@@ -1574,7 +1573,7 @@ Shape :
       else{
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	SurfaceLoop *l = Create_SurfaceLoop(num, temp);
-	Tree_Add(THEM->SurfaceLoops, &l);
+	Tree_Add(GModel::current()->getGEOInternals()->SurfaceLoops, &l);
 	List_Delete(temp);
       }
       List_Delete($7);
@@ -1591,7 +1590,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_SURFACE, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete($7);
       $$.Type = MSH_PHYSICAL_SURFACE;
@@ -1612,7 +1611,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	setVolumeSurfaces(v, temp);
 	List_Delete(temp);
-	Tree_Add(THEM->Volumes, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Volumes, &v);
       }
       List_Delete($7);
       $$.Type = MSH_VOLUME;
@@ -1629,7 +1628,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($6);
 	setVolumeSurfaces(v, temp);
 	List_Delete(temp);
-	Tree_Add(THEM->Volumes, &v);
+	Tree_Add(GModel::current()->getGEOInternals()->Volumes, &v);
       }
       List_Delete($6);
       $$.Type = MSH_VOLUME;
@@ -1645,7 +1644,7 @@ Shape :
 	List_T *temp = ListOfDouble2ListOfInt($7);
 	PhysicalGroup *p = Create_PhysicalGroup(num, MSH_PHYSICAL_VOLUME, temp);
 	List_Delete(temp);
-	List_Add(THEM->PhysicalGroups, &p);
+	List_Add(GModel::current()->getGEOInternals()->PhysicalGroups, &p);
       }
       List_Delete($7);
       $$.Type = MSH_PHYSICAL_VOLUME;
@@ -1838,11 +1837,12 @@ Delete :
     {
       if(!strcmp($2, "Meshes") || !strcmp($2, "All")){
 	GModel::current()->destroy();
-	THEM->destroy();
+	GModel::current()->getGEOInternals()->destroy();
       }
       else if(!strcmp($2, "Physicals")){
-	List_Action(THEM->PhysicalGroups, Free_PhysicalGroup);
-	List_Reset(THEM->PhysicalGroups);
+	List_Action(GModel::current()->getGEOInternals()->PhysicalGroups, 
+		    Free_PhysicalGroup);
+	List_Reset(GModel::current()->getGEOInternals()->PhysicalGroups);
 	GModel::current()->deletePhysicalGroups();
       }
       else
@@ -1932,10 +1932,10 @@ Command :
       }
       else if(!strcmp($1, "Print")){
 #if defined(HAVE_FLTK)
-	// make sure we have the latest data from THEM in GModel
+	// make sure we have the latest data from GEO_Internals in GModel
 	// (fixes bug where we would have no geometry in the picture if
 	// the print command is in the same file as the geometry)
-	GModel::current()->importTHEM();
+	GModel::current()->importGEOInternals();
 	char tmpstring[1024];
 	FixRelativePath($2, tmpstring);
 	CreateOutputFile(tmpstring, CTX.print.format);
@@ -1943,7 +1943,7 @@ Command :
       }
       else if(!strcmp($1, "Save")){
 #if defined(HAVE_FLTK)
-	GModel::current()->importTHEM();
+	GModel::current()->importGEOInternals();
 	char tmpstring[1024];
 	FixRelativePath($2, tmpstring);
 	CreateOutputFile(tmpstring, CTX.mesh.format);
@@ -2540,7 +2540,7 @@ ExtrudeParameter :
       }
       else{
 	Surface *s = Create_Surface(num, MSH_SURF_DISCRETE);
-	Tree_Add(THEM->Surfaces, &s);
+	Tree_Add(GModel::current()->getGEOInternals()->Surfaces, &s);
 	extr.mesh.Holes[num].first = $8;
 	extr.mesh.Holes[num].second.clear();
 	for(int i = 0; i < List_Nbr($6); i++){
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index 6108a85ab1..f407ec9668 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.333 2007-09-12 05:42:41 geuzaine Exp $
+ * $Header: /cvsroot/gmsh/Parser/Gmsh.yy.cpp,v 1.334 2007-09-26 20:52:00 geuzaine Exp $
  */
 
 #define FLEX_SCANNER
@@ -757,7 +757,7 @@ char *yytext;
 #line 1 "Gmsh.l"
 #define INITIAL 0
 #line 2 "Gmsh.l"
-// $Id: Gmsh.yy.cpp,v 1.333 2007-09-12 05:42:41 geuzaine Exp $
+// $Id: Gmsh.yy.cpp,v 1.334 2007-09-26 20:52:00 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
diff --git a/Parser/Makefile b/Parser/Makefile
index 89f6bba3fb..367edd5b73 100644
--- a/Parser/Makefile
+++ b/Parser/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.129 2007-09-22 20:35:18 geuzaine Exp $
+# $Id: Makefile,v 1.130 2007-09-26 20:52:01 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -142,24 +142,22 @@ CreateFile.o: CreateFile.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 \
   OpenFile.h ../Common/Context.h ../Common/Options.h ../Post/ColorTable.h \
-  ../Geo/Geo.h ../Common/GmshDefines.h ../Geo/gmshSurface.h ../Geo/Pair.h \
-  ../Geo/Range.h ../Geo/SPoint2.h ../Geo/SPoint3.h ../Geo/SVector3.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
   ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
-  ../Numeric/Numeric.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/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 ../Common/GmshUI.h ../Graphics/gl2ps.h \
-  ../Graphics/gl2gif.h ../Graphics/PixelBuffer.h ../Graphics/Draw.h \
-  ../Graphics/gl2jpeg.h ../Graphics/PixelBuffer.h ../Graphics/gl2png.h \
+  ../Common/GmshDefines.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 \
+  ../Geo/ExtrudeParams.h ../Common/SmoothData.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/GmshUI.h ../Graphics/gl2ps.h ../Graphics/gl2gif.h \
+  ../Graphics/PixelBuffer.h ../Graphics/Draw.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
diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp
index efc3b64980..65d85e2f56 100644
--- a/Parser/OpenFile.cpp
+++ b/Parser/OpenFile.cpp
@@ -1,4 +1,4 @@
-// $Id: OpenFile.cpp,v 1.163 2007-09-24 08:14:29 geuzaine Exp $
+// $Id: OpenFile.cpp,v 1.164 2007-09-26 20:52:01 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -45,7 +45,6 @@ extern GUI *WID;
 #endif
 
 extern Context_T CTX;
-extern Mesh *THEM;
 
 void FixRelativePath(char *in, char *out){
   if(in[0] == '/' || in[0] == '\\' || (strlen(in)>2 && in[1] == ':')){
@@ -253,7 +252,7 @@ void ParseString(char *str)
     fprintf(fp, "\n");
     fclose(fp);
     ParseFile(CTX.tmp_filename_fullpath, 1);
-    GModel::current()->importTHEM();
+    GModel::current()->importGEOInternals();
   }
 }
 
@@ -415,7 +414,7 @@ void OpenProject(char *name)
   CTX.threads_lock = 1;
 
   GModel::current()->destroy();
-  THEM->destroy();
+  GModel::current()->getGEOInternals()->destroy();
 
   // Initialize pseudo random mesh generator to the same seed
   srand(1);
-- 
GitLab