From 7435035ce9e93f6bd707939ce712d11a4167d30b Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 22 Apr 2008 07:37:17 +0000
Subject: [PATCH] rewrote adaptive view stuff so we can use it on all types of
 views (model-based, multi timestep, multi-mesh)

---
 Common/Makefile          |   15 +-
 Common/Options.cpp       |   34 +-
 Fltk/Callbacks.cpp       |   16 +-
 Fltk/Makefile            |   28 +-
 Graphics/Makefile        |   27 +-
 Graphics/Post.cpp        |   29 +-
 Graphics/Scale.cpp       |    5 +-
 Mesh/Makefile            |   69 +--
 Parser/Gmsh.tab.cpp      |  735 ++++++++++++------------
 Parser/Gmsh.y            |   25 +-
 Parser/Gmsh.yy.cpp       |    2 +-
 Parser/Makefile          |   35 +-
 Plugin/Levelset.cpp      |  158 +++---
 Plugin/Makefile          |  332 ++++++-----
 Post/AdaptiveViews.cpp   | 1134 --------------------------------------
 Post/AdaptiveViews.h     |  292 ----------
 Post/Makefile            |   99 ++--
 Post/OctreePost.cpp      |    6 +-
 Post/PView.cpp           |   10 +-
 Post/PView.h             |    3 +-
 Post/PViewData.cpp       |   42 +-
 Post/PViewData.h         |   23 +-
 Post/PViewDataGModel.cpp |   37 +-
 Post/PViewDataGModel.h   |    4 +-
 Post/PViewDataList.cpp   |   76 ++-
 Post/PViewDataList.h     |    9 +-
 Post/adaptiveData.cpp    | 1124 +++++++++++++++++++++++++++++++++++++
 Post/adaptiveData.h      |  276 ++++++++++
 doc/texinfo/gmsh.texi    |    6 +-
 29 files changed, 2370 insertions(+), 2281 deletions(-)
 delete mode 100644 Post/AdaptiveViews.cpp
 delete mode 100644 Post/AdaptiveViews.h
 create mode 100644 Post/adaptiveData.cpp
 create mode 100644 Post/adaptiveData.h

diff --git a/Common/Makefile b/Common/Makefile
index 8effc9fddd..78e6b2ccd7 100644
--- a/Common/Makefile
+++ b/Common/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.167 2008-04-06 07:51:36 geuzaine Exp $
+# $Id: Makefile,v 1.168 2008-04-22 07:37:08 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -73,12 +73,12 @@ Octree.o: Octree.cpp Octree.h OctreeInternals.h
 OctreeInternals.o: OctreeInternals.cpp Message.h OctreeInternals.h
 Options.o: Options.cpp GmshUI.h GmshDefines.h Message.h \
   ../Graphics/Draw.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PView.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Mesh/Generator.h Context.h Options.h \
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/adaptiveData.h \
+  ../Common/GmshMatrix.h ../Mesh/Generator.h Context.h Options.h \
   ../Mesh/BackgroundMesh.h ../Plugin/PluginManager.h ../Plugin/Plugin.h \
   ../Common/Options.h ../Common/Message.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Fltk/Solvers.h ../Fltk/GUI.h \
+  ../Post/PViewData.h ../Fltk/Solvers.h ../Fltk/GUI.h \
   ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h ../Common/GmshUI.h \
   ../Fltk/Popup_Button.h ../Fltk/SpherePosition_Widget.h ../Mesh/Field.h \
   ../Geo/Geo.h ../Common/GmshDefines.h ../Geo/gmshSurface.h ../Geo/Pair.h \
@@ -96,14 +96,15 @@ CommandLine.o: CommandLine.cpp GmshUI.h GmshDefines.h GmshVersion.h \
   ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
   ../Geo/SBoundingBox3d.h ../Post/PView.h ../Post/PViewData.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Parser/CreateFile.h OS.h
+  ../DataStr/List.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Parser/CreateFile.h OS.h
 Gmsh.o: Gmsh.cpp ../Parser/Parser.h ../DataStr/List.h ../DataStr/Tree.h \
   ../DataStr/avl.h Options.h ../Post/ColorTable.h CommandLine.h OS.h \
   ../Plugin/PluginManager.h ../Plugin/Plugin.h ../Common/Options.h \
   ../Common/Message.h ../Post/PView.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
   ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
+  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 OS.o: OS.cpp Message.h
 Visibility.o: Visibility.cpp Visibility.h GmshDefines.h ../Geo/GVertex.h \
diff --git a/Common/Options.cpp b/Common/Options.cpp
index 597b952acb..cef0a33753 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -1,4 +1,4 @@
-// $Id: Options.cpp,v 1.394 2008-04-18 16:40:28 geuzaine Exp $
+// $Id: Options.cpp,v 1.395 2008-04-22 07:37:08 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -25,6 +25,7 @@
 #include "Message.h"
 #include "Draw.h"
 #include "PView.h"
+#include "adaptiveData.h"
 #include "Generator.h"
 #include "Context.h"
 #include "Options.h"
@@ -5500,13 +5501,18 @@ double opt_view_nb_timestep(OPT_ARGS_NUM)
 double opt_view_timestep(OPT_ARGS_NUM)
 {
   GET_VIEW(0.);
-  if(!data) return 0.;
+  if(!data) return 0;
   if(action & GMSH_SET) {
     opt->TimeStep = (int)val;
     if(opt->TimeStep > data->getNumTimeSteps() - 1)
       opt->TimeStep = 0;
     else if(opt->TimeStep < 0)
       opt->TimeStep = data->getNumTimeSteps() - 1;
+    if(data->isAdaptive()){
+      data->getAdaptiveData()->initWithLowResolution(opt->TimeStep);
+      data->getAdaptiveData()->changeResolution(opt->MaxRecursionLevel, 
+						opt->TargetError);
+    }
     if(view) view->setChanged(true);
   }
 #if defined(HAVE_FLTK)
@@ -5520,14 +5526,16 @@ double opt_view_min(OPT_ARGS_NUM)
 {
   GET_VIEW(0.);
   if(!data) return 0.;
-  return data->getMin();
+  // use adaptive data if available
+  return view->getData(true)->getMin();
 }
 
 double opt_view_max(OPT_ARGS_NUM)
 {
   GET_VIEW(0.);
   if(!data) return 0.;
-  return data->getMax();
+  // use adaptive data if available
+  return view->getData(true)->getMax();
 }
 
 double opt_view_custom_min(OPT_ARGS_NUM)
@@ -6000,15 +6008,12 @@ double opt_view_saturate_values(OPT_ARGS_NUM)
 double opt_view_max_recursion_level(OPT_ARGS_NUM)
 {
   GET_VIEW(0.);
-
   if(action & GMSH_SET) {
     opt->MaxRecursionLevel = (int)val;
     if(data && data->isAdaptive()){
-      PViewDataList *l = dynamic_cast<PViewDataList*>(data);
-      if(l){
-        l->adaptive->setGlobalResolutionLevel(l, opt->MaxRecursionLevel);
-        view->setChanged(true);
-      }
+      data->getAdaptiveData()->changeResolution(opt->MaxRecursionLevel, 
+						opt->TargetError);
+      view->setChanged(true);
     }
   }
 #if defined(HAVE_FLTK)
@@ -6022,15 +6027,12 @@ double opt_view_max_recursion_level(OPT_ARGS_NUM)
 double opt_view_target_error(OPT_ARGS_NUM)
 {
   GET_VIEW(0.);
-
   if(action & GMSH_SET) {
     opt->TargetError = val;
     if(data && data->isAdaptive()){
-      PViewDataList *l = dynamic_cast<PViewDataList*>(data);
-      if(l){
-        l->adaptive->setTolerance(opt->TargetError);
-        view->setChanged(true);
-      }
+      data->getAdaptiveData()->changeResolution(opt->MaxRecursionLevel, 
+						opt->TargetError);
+      view->setChanged(true);
     }
   }
 #if defined(HAVE_FLTK)
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 11c907cff2..8d2a1991a9 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.580 2008-04-18 16:40:28 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.581 2008-04-22 07:37:09 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -611,21 +611,21 @@ static const char *input_formats =
   "Gmsh mesh" TT "*.msh" NN
   "Gmsh post-processing view" TT "*.pos" NN
 #if defined(HAVE_OCC)
-  "STEP model" TT "*.step" NN
-  "IGES model" TT "*.iges" NN
+  "STEP model" TT "*.{stp,step}" NN
+  "IGES model" TT "*.{igs,iges}" NN
   "BRep model" TT "*.brep" NN
 #endif
   "I-deas universal mesh" TT "*.unv" NN
 #if defined(HAVE_MED)
-  "MED file" TT "*.med" NN
+  "MED file" TT "*.{med,mmed,rmed}" NN
 #endif
-  "Medit mesh" TT "*.mesh"
-  "Nastran bulk data file" TT "*.bdf" NN
+  "Medit mesh" TT "*.mesh" NN
+  "Nastran bulk data file" TT "*.{bdf,nas}" NN
   "Plot3D structured mesh" TT "*.p3d" NN
   "STL surface mesh" TT "*.stl" NN
-  "VRML surface mesh" TT "*.wrl" NN
+  "VRML surface mesh" TT "*.{wrl,vrml}" NN
 #if defined(HAVE_LIBJPEG)
-  "JPEG" TT "*.png" NN
+  "JPEG" TT "*.{jpg,jpeg}" NN
 #endif
 #if defined(HAVE_LIBPNG)
   "PNG" TT "*.png" NN
diff --git a/Fltk/Makefile b/Fltk/Makefile
index c142d681fe..696fde46b1 100644
--- a/Fltk/Makefile
+++ b/Fltk/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.180 2008-04-16 11:35:10 geuzaine Exp $
+# $Id: Makefile,v 1.181 2008-04-22 07:37:09 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -83,8 +83,8 @@ Main.o: Main.cpp GUI.h Opengl_Window.h Colorbar_Window.h \
   ../Common/Options.h ../Parser/Parser.h ../Parser/OpenFile.h \
   ../Common/CommandLine.h Solvers.h ../Plugin/PluginManager.h \
   ../Plugin/Plugin.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 \
+  ../Common/GmshMatrix.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
@@ -117,15 +117,14 @@ GUI.o: GUI.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
   ../Post/PViewOptions.h ../Post/ColorTable.h Callbacks.h Win32Icon.h \
   ../Parser/OpenFile.h ../Common/CommandLine.h ../Mesh/Generator.h \
   Solvers.h ../Plugin/PluginManager.h ../Plugin/Plugin.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../Common/GmshMatrix.h Shortcut_Window.h ../Geo/GModel.h \
-  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h \
-  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
-  ../Geo/GeoStringInterface.h
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  Shortcut_Window.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h \
+  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h \
+  ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h \
+  ../Geo/GEntity.h ../Geo/SBoundingBox3d.h ../Geo/GeoStringInterface.h
 GUI_Extras.o: GUI_Extras.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
   ../Parser/CreateFile.h ../Common/Options.h ../Post/ColorTable.h \
   ../Common/Context.h ../Graphics/Draw.h ../Geo/SBoundingBox3d.h \
@@ -222,9 +221,8 @@ Callbacks.o: Callbacks.cpp ../Common/GmshUI.h ../Common/Message.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Geo/SPoint2.h \
   ../Geo/ExtrudeParams.h ../Common/SmoothData.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 \
+  ../Common/GmshMatrix.h ../Plugin/PluginManager.h ../Plugin/Plugin.h \
+  ../Common/Visibility.h ../Common/GmshDefines.h Solvers.h ../Common/OS.h \
   ../Mesh/BackgroundMesh.h
 Opengl.o: Opengl.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Context.h \
diff --git a/Graphics/Makefile b/Graphics/Makefile
index dccb816f46..e05a6daec4 100644
--- a/Graphics/Makefile
+++ b/Graphics/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.148 2008-04-06 07:51:37 geuzaine Exp $
+# $Id: Makefile,v 1.149 2008-04-22 07:37:09 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -80,8 +80,8 @@ Draw.o: Draw.cpp ../Common/GmshUI.h ../Common/GmshDefines.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
   ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
   ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
-  ../Post/PView.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h
 Mesh.o: Mesh.cpp ../Common/Message.h ../Common/GmshUI.h ../Geo/GModel.h \
   ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -94,7 +94,9 @@ Mesh.o: Mesh.cpp ../Common/Message.h ../Common/GmshUI.h ../Geo/GModel.h \
   ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
   ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h Draw.h \
   ../Common/Context.h ../Common/OS.h gl2ps.h ../Common/VertexArray.h \
-  ../Common/Context.h ../Common/SmoothData.h
+  ../Common/Context.h ../Common/SmoothData.h ../Post/PView.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h
 Geom.o: Geom.cpp ../Common/GmshUI.h Draw.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/Context.h gl2ps.h ../Common/VertexArray.h \
   ../Geo/SVector3.h ../Geo/SPoint3.h ../Common/Context.h ../Geo/GModel.h \
@@ -107,9 +109,9 @@ Geom.o: Geom.cpp ../Common/GmshUI.h Draw.h ../Geo/SBoundingBox3d.h \
 Post.o: Post.cpp ../Common/Message.h ../Common/GmshUI.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h Draw.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h Iso.h ../Post/PView.h \
-  ../Post/PViewData.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Common/VertexArray.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Common/Context.h ../Common/SmoothData.h gl2ps.h
+  ../Post/PViewData.h ../DataStr/List.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Common/VertexArray.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Common/Context.h ../Common/SmoothData.h gl2ps.h
 SelectBuffer.o: SelectBuffer.cpp ../Common/Message.h ../Common/GmshUI.h \
   ../Common/GmshDefines.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
@@ -128,15 +130,14 @@ Entity.o: Entity.cpp ../Common/GmshUI.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h Draw.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Common/Context.h gl2ps.h
 ReadImg.o: ReadImg.cpp ReadImg.h ../Common/Message.h ../Common/GmshUI.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h
 Scale.o: Scale.cpp ../Common/GmshUI.h Draw.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewData.h \
+  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
   ../Post/PViewOptions.h ../Post/ColorTable.h ../Common/Context.h gl2ps.h
 Graph2D.o: Graph2D.cpp ../Common/GmshUI.h Draw.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewData.h \
+  ../Geo/SPoint3.h ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
   ../Post/PViewOptions.h ../Post/ColorTable.h gl2ps.h ../Common/Context.h \
   ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
 gl2ps.o: gl2ps.cpp gl2ps.h
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index cf2256f851..9e49d44d0e 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.163 2008-04-05 09:21:37 geuzaine Exp $
+// $Id: Post.cpp,v 1.164 2008-04-22 07:37:09 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -774,7 +774,8 @@ void addScalarElement(PView *p, int numEdges, double xyz[NMAX][3],
 void addVectorElement(PView *p, int ient, int iele, int numNodes, int numEdges, 
                       double xyz[NMAX][3], double val[NMAX][9], bool pre)
 {
-  PViewData *data = p->getData();
+  // use adaptive data if available
+  PViewData *data = p->getData(true);
   PViewOptions *opt = p->getOptions();
 
   int numComp2;
@@ -886,7 +887,8 @@ void addTensorElement(PView *p, int numNodes, int numEdges, double xyz[NMAX][3],
 
 void addElementsInArrays(PView *p, bool preprocessNormalsOnly)
 {
-  PViewData *data = p->getData();
+  // use adaptive data if available
+  PViewData *data = p->getData(true);
   PViewOptions *opt = p->getOptions();
   
   opt->TmpBBox.reset();
@@ -1138,7 +1140,8 @@ void drawTangentVectorGlyphs(PView *p, int numNodes, double xyz[NMAX][3],
 
 void drawGlyphs(PView *p)
 {
-  PViewData *data = p->getData();
+  // use adaptive data if available
+  PViewData *data = p->getData(true);
   PViewOptions *opt = p->getOptions();
 
   if(!opt->Normals && !opt->Tangents && opt->IntervalsType != PViewOptions::Numeric)
@@ -1179,21 +1182,21 @@ class initPView {
   // on Windows/Cygwin
   int _estimateNumPoints(PView *p)
   {
-    PViewData *data = p->getData();
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
     int heuristic = data->getNumPoints(opt->TimeStep);
     return heuristic + 10000;
   }
   int _estimateNumLines(PView *p)
   {
-    PViewData *data = p->getData();
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
     int heuristic = data->getNumLines(opt->TimeStep);
     return heuristic + 10000;
   }
   int _estimateNumTriangles(PView *p)
   {
-    PViewData *data = p->getData();
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
     int tris = data->getNumTriangles(opt->TimeStep);
     int quads = data->getNumQuadrangles(opt->TimeStep);
@@ -1214,7 +1217,7 @@ class initPView {
   }
   int _estimateNumVectors(PView *p)
   {
-    PViewData *data = p->getData();
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
     int heuristic = data->getNumVectors(opt->TimeStep);
     return heuristic + 1000;
@@ -1222,7 +1225,8 @@ class initPView {
  public :
   void operator () (PView *p)
   {
-    PViewData *data = p->getData();
+    // use adaptive data if available
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
 
     if(data->getDirty() || !data->getNumTimeSteps() || !p->getChanged()) return;
@@ -1239,6 +1243,8 @@ class initPView {
       opt->TmpMax = data->getMax(opt->TimeStep);
     }
     else{
+      // FIXME: this is not perfect for multi-step adaptive views, as
+      // we don't have the correct min/max info for the other steps
       opt->TmpMin = data->getMin();
       opt->TmpMax = data->getMax();
     }
@@ -1283,7 +1289,8 @@ class drawPView {
  public:
   void operator () (PView *p)
   {
-    PViewData *data = p->getData();
+    // use adaptive data if available
+    PViewData *data = p->getData(true);
     PViewOptions *opt = p->getOptions();
 
     if(data->getDirty() || !data->getNumTimeSteps()) return;
@@ -1336,6 +1343,8 @@ class drawPView {
       opt->TmpMax = data->getMax(opt->TimeStep);
     }
     else{
+      // FIXME: this is not perfect for multi-step adaptive views, as
+      // we don't have the correct min/max info for the other steps
       opt->TmpMin = data->getMin();
       opt->TmpMax = data->getMax();
     }
diff --git a/Graphics/Scale.cpp b/Graphics/Scale.cpp
index afef5c9e23..c876564511 100644
--- a/Graphics/Scale.cpp
+++ b/Graphics/Scale.cpp
@@ -1,4 +1,4 @@
-// $Id: Scale.cpp,v 1.70 2008-03-20 11:44:08 geuzaine Exp $
+// $Id: Scale.cpp,v 1.71 2008-04-22 07:37:09 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -201,7 +201,8 @@ static void drawScaleLabel(PView *p, double xmin, double ymin, double width,
 static void drawScale(PView *p, double xmin, double ymin, double width, 
                       double height, double tic, int horizontal)
 {
-  PViewData *data = p->getData();
+  // use adaptive data if available
+  PViewData *data = p->getData(true);
   PViewOptions *opt = p->getOptions();
 
   if(opt->ExternalViewIndex >= 0){
diff --git a/Mesh/Makefile b/Mesh/Makefile
index 5f6f29a552..5c992d6389 100644
--- a/Mesh/Makefile
+++ b/Mesh/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.213 2008-04-06 07:51:37 geuzaine Exp $
+# $Id: Makefile,v 1.214 2008-04-22 07:37:10 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -86,10 +86,10 @@ depend:
 # DO NOT DELETE THIS LINE
 Generator.o: Generator.cpp ../Common/Message.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../Common/Context.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Common/OS.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Common/OS.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
@@ -116,8 +116,7 @@ Field.o: Field.cpp ../Common/Context.h Field.h ../Geo/Geo.h \
   ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
   ../Common/Message.h ../Post/OctreePost.h ../Common/Octree.h \
-  ../Common/OctreeInternals.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../Common/GmshMatrix.h
+  ../Common/OctreeInternals.h ../Post/PViewDataList.h ../Post/PViewData.h
 meshGEdge.o: meshGEdge.cpp meshGEdge.h ../Geo/GEdge.h ../Geo/GEntity.h \
   ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h \
   ../Geo/SPoint3.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/GPoint.h \
@@ -154,12 +153,14 @@ meshGFace.o: meshGFace.cpp meshGFace.h meshGFaceBDS.h \
   ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h ../Geo/SPoint2.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
   ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
+  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
+  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
   ../Common/Context.h ../Common/Message.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h BDS.h ../Post/PView.h ../Post/PViewData.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h qualityMeasures.h 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 ../DataStr/List.h ../DataStr/Tree.h \
+  ../DataStr/List.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  qualityMeasures.h 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 ../DataStr/Tree.h \
   ../DataStr/avl.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h \
   ../Common/SmoothData.h ../Common/OS.h
 meshGFaceTransfinite.o: meshGFaceTransfinite.cpp meshGFace.h \
@@ -201,12 +202,13 @@ meshGFaceBDS.o: meshGFaceBDS.cpp meshGFace.h meshGFaceOptimize.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEdge.h ../Geo/GFace.h \
   ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
   ../Common/Message.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
-  BDS.h ../Post/PView.h ../Post/PViewData.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h qualityMeasures.h 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 \
-  ../DataStr/List.h ../DataStr/Tree.h ../DataStr/avl.h ../Geo/SPoint2.h \
-  ../Geo/ExtrudeParams.h ../Common/SmoothData.h ../Common/OS.h
+  BDS.h ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h qualityMeasures.h 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 ../DataStr/Tree.h ../DataStr/avl.h \
+  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
+  ../Common/OS.h
 meshGFaceDelaunayInsertion.o: meshGFaceDelaunayInsertion.cpp BDS.h \
   ../Geo/GFace.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -214,12 +216,13 @@ meshGFaceDelaunayInsertion.o: meshGFaceDelaunayInsertion.cpp BDS.h \
   ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Post/PView.h ../Post/PViewData.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h BackgroundMesh.h \
-  meshGFaceDelaunayInsertion.h ../Geo/MElement.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  meshGFaceOptimize.h meshGFace.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h ../Common/Message.h ../Common/Context.h
+  ../DataStr/List.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  BackgroundMesh.h meshGFaceDelaunayInsertion.h ../Geo/MElement.h \
+  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h meshGFaceOptimize.h meshGFace.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Message.h \
+  ../Common/Context.h
 meshGFaceOptimize.o: meshGFaceOptimize.cpp meshGFaceOptimize.h \
   ../Geo/MElement.h ../Common/GmshDefines.h ../Geo/MVertex.h \
   ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
@@ -335,11 +338,11 @@ qualityMeasures.o: qualityMeasures.cpp qualityMeasures.h BDS.h \
   ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Post/PView.h ../Post/PViewData.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Geo/MVertex.h \
-  ../Geo/SPoint3.h ../Geo/MElement.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h
+  ../DataStr/List.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MElement.h \
+  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/MEdge.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h \
+  ../Geo/SVector3.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
 BoundaryLayer.o: BoundaryLayer.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -360,11 +363,11 @@ BDS.o: BDS.cpp ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h BDS.h \
   ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h \
   ../Geo/SVector3.h ../Geo/Pair.h ../Post/PView.h ../Post/PViewData.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Common/Message.h \
-  meshGFaceDelaunayInsertion.h ../Geo/MElement.h ../Common/GmshDefines.h \
-  ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
-  ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h \
-  qualityMeasures.h
+  ../DataStr/List.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Common/Message.h meshGFaceDelaunayInsertion.h ../Geo/MElement.h \
+  ../Common/GmshDefines.h ../Geo/MVertex.h ../Geo/SPoint3.h \
+  ../Geo/MEdge.h ../Geo/MVertex.h ../Geo/SVector3.h ../Geo/MFace.h \
+  ../Geo/MVertex.h ../Geo/SVector3.h qualityMeasures.h
 HighOrder.o: HighOrder.cpp HighOrder.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
diff --git a/Parser/Gmsh.tab.cpp b/Parser/Gmsh.tab.cpp
index ac7ff1dea1..a3d08057ed 100644
--- a/Parser/Gmsh.tab.cpp
+++ b/Parser/Gmsh.tab.cpp
@@ -324,7 +324,7 @@
 /* Copy the first part of user declarations.  */
 #line 1 "Gmsh.y"
 
-// $Id: Gmsh.tab.cpp,v 1.358 2008-04-14 18:30:45 geuzaine Exp $
+// $Id: Gmsh.tab.cpp,v 1.359 2008-04-22 07:37:10 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -981,40 +981,40 @@ static const yytype_uint16 yyrline[] =
 {
        0,   145,   145,   146,   151,   153,   157,   158,   159,   160,
      161,   162,   163,   164,   165,   166,   167,   168,   169,   170,
-     174,   178,   185,   190,   205,   218,   247,   264,   273,   286,
-     289,   290,   291,   292,   293,   297,   299,   304,   306,   312,
-     456,   311,   470,   475,   484,   483,   498,   503,   512,   511,
-     525,   530,   541,   540,   552,   553,   554,   555,   556,   560,
-     561,   568,   599,   638,   692,   709,   727,   738,   755,   762,
-     777,   795,   821,   848,   862,   879,   894,   912,   932,   955,
-     964,   969,   988,  1007,  1031,  1041,  1056,  1060,  1073,  1095,
-    1111,  1133,  1151,  1169,  1187,  1213,  1231,  1257,  1277,  1295,
-    1313,  1339,  1356,  1375,  1393,  1431,  1437,  1443,  1450,  1475,
-    1500,  1516,  1536,  1554,  1571,  1592,  1597,  1602,  1607,  1612,
-    1623,  1629,  1638,  1639,  1644,  1647,  1651,  1674,  1697,  1720,
-    1748,  1757,  1761,  1774,  1790,  1805,  1819,  1825,  1831,  1840,
-    1854,  1902,  1918,  1931,  1950,  1960,  1982,  1986,  1991,  1996,
-    2008,  2025,  2042,  2069,  2096,  2127,  2135,  2141,  2148,  2152,
-    2161,  2169,  2177,  2186,  2185,  2198,  2197,  2210,  2209,  2222,
-    2221,  2233,  2232,  2248,  2255,  2262,  2269,  2276,  2283,  2290,
-    2297,  2304,  2312,  2311,  2323,  2322,  2334,  2333,  2345,  2344,
-    2356,  2355,  2367,  2366,  2378,  2377,  2389,  2388,  2400,  2399,
-    2414,  2417,  2423,  2432,  2452,  2475,  2479,  2503,  2521,  2539,
-    2557,  2586,  2621,  2626,  2653,  2667,  2680,  2697,  2703,  2709,
-    2712,  2721,  2731,  2732,  2733,  2734,  2735,  2736,  2737,  2738,
-    2739,  2746,  2747,  2748,  2749,  2750,  2751,  2752,  2753,  2754,
-    2755,  2756,  2757,  2758,  2759,  2760,  2761,  2762,  2763,  2764,
-    2765,  2766,  2767,  2768,  2769,  2770,  2771,  2772,  2773,  2774,
-    2775,  2776,  2777,  2779,  2780,  2781,  2782,  2783,  2784,  2785,
-    2786,  2787,  2788,  2789,  2790,  2791,  2792,  2793,  2794,  2795,
-    2796,  2797,  2798,  2799,  2808,  2809,  2810,  2811,  2812,  2813,
-    2814,  2818,  2834,  2849,  2869,  2882,  2895,  2918,  2936,  2954,
-    2972,  2990,  2998,  3002,  3006,  3010,  3014,  3021,  3025,  3029,
-    3033,  3040,  3045,  3053,  3058,  3062,  3067,  3071,  3079,  3090,
-    3098,  3106,  3112,  3123,  3143,  3153,  3163,  3180,  3207,  3212,
-    3216,  3220,  3233,  3237,  3249,  3256,  3277,  3281,  3296,  3301,
-    3308,  3312,  3319,  3323,  3331,  3339,  3353,  3367,  3371,  3390,
-    3413
+     174,   178,   185,   190,   205,   218,   247,   259,   268,   281,
+     284,   285,   286,   287,   288,   292,   294,   299,   301,   307,
+     451,   306,   465,   470,   479,   478,   493,   498,   507,   506,
+     520,   532,   550,   549,   561,   562,   563,   564,   565,   569,
+     570,   577,   608,   647,   701,   718,   736,   747,   764,   771,
+     786,   804,   830,   857,   871,   888,   903,   921,   941,   964,
+     973,   978,   997,  1016,  1040,  1050,  1065,  1069,  1082,  1104,
+    1120,  1142,  1160,  1178,  1196,  1222,  1240,  1266,  1286,  1304,
+    1322,  1348,  1365,  1384,  1402,  1440,  1446,  1452,  1459,  1484,
+    1509,  1525,  1545,  1563,  1580,  1601,  1606,  1611,  1616,  1621,
+    1632,  1638,  1647,  1648,  1653,  1656,  1660,  1683,  1706,  1729,
+    1757,  1766,  1770,  1783,  1799,  1814,  1828,  1834,  1840,  1849,
+    1863,  1911,  1927,  1940,  1959,  1969,  1991,  1995,  2000,  2005,
+    2017,  2034,  2051,  2078,  2105,  2136,  2144,  2150,  2157,  2161,
+    2170,  2178,  2186,  2195,  2194,  2207,  2206,  2219,  2218,  2231,
+    2230,  2242,  2241,  2257,  2264,  2271,  2278,  2285,  2292,  2299,
+    2306,  2313,  2321,  2320,  2332,  2331,  2343,  2342,  2354,  2353,
+    2365,  2364,  2376,  2375,  2387,  2386,  2398,  2397,  2409,  2408,
+    2423,  2426,  2432,  2441,  2461,  2484,  2488,  2512,  2530,  2548,
+    2566,  2595,  2630,  2635,  2662,  2676,  2689,  2706,  2712,  2718,
+    2721,  2730,  2740,  2741,  2742,  2743,  2744,  2745,  2746,  2747,
+    2748,  2755,  2756,  2757,  2758,  2759,  2760,  2761,  2762,  2763,
+    2764,  2765,  2766,  2767,  2768,  2769,  2770,  2771,  2772,  2773,
+    2774,  2775,  2776,  2777,  2778,  2779,  2780,  2781,  2782,  2783,
+    2784,  2785,  2786,  2788,  2789,  2790,  2791,  2792,  2793,  2794,
+    2795,  2796,  2797,  2798,  2799,  2800,  2801,  2802,  2803,  2804,
+    2805,  2806,  2807,  2808,  2817,  2818,  2819,  2820,  2821,  2822,
+    2823,  2827,  2843,  2858,  2878,  2891,  2904,  2927,  2945,  2963,
+    2981,  2999,  3007,  3011,  3015,  3019,  3023,  3030,  3034,  3038,
+    3042,  3049,  3054,  3062,  3067,  3071,  3076,  3080,  3088,  3099,
+    3107,  3115,  3121,  3132,  3152,  3162,  3172,  3189,  3216,  3221,
+    3225,  3229,  3242,  3246,  3258,  3265,  3286,  3290,  3305,  3310,
+    3317,  3321,  3328,  3332,  3340,  3348,  3362,  3376,  3380,  3399,
+    3422
 };
 #endif
 
@@ -3825,11 +3825,6 @@ yyreduce:
 	ViewData->setName((yyvsp[(2) - (6)].c));
 	ViewData->setFileName(gmsh_yyname);
 	ViewData->setFileIndex(gmsh_yyviewindex++);
-	if(ViewData->adaptive){
-	  ViewData->adaptive->setGlobalResolutionLevel
-	    (ViewData, PViewOptions::reference.MaxRecursionLevel);
-	  ViewData->adaptive->setTolerance(PViewOptions::reference.TargetError);
-	}
 	new PView(ViewData);
       }
       else
@@ -3839,7 +3834,7 @@ yyreduce:
     break;
 
   case 27:
-#line 265 "Gmsh.y"
+#line 260 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (6)].c), "View")){
 	int index = (int)(yyvsp[(4) - (6)].d);
@@ -3851,7 +3846,7 @@ yyreduce:
     break;
 
   case 28:
-#line 274 "Gmsh.y"
+#line 269 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (6)].c), "View")){
 	int index = (int)(yyvsp[(4) - (6)].d);
@@ -3863,34 +3858,34 @@ yyreduce:
     break;
 
   case 29:
-#line 286 "Gmsh.y"
+#line 281 "Gmsh.y"
     {
       ViewData = new PViewDataList(true); 
     ;}
     break;
 
   case 35:
-#line 298 "Gmsh.y"
+#line 293 "Gmsh.y"
     { ViewCoord[ViewCoordIdx++] = (yyvsp[(1) - (1)].d); ;}
     break;
 
   case 36:
-#line 300 "Gmsh.y"
+#line 295 "Gmsh.y"
     { ViewCoord[ViewCoordIdx++] = (yyvsp[(3) - (3)].d); ;}
     break;
 
   case 37:
-#line 305 "Gmsh.y"
+#line 300 "Gmsh.y"
     { if(ViewValueList) List_Add(ViewValueList, &(yyvsp[(1) - (1)].d)); ;}
     break;
 
   case 38:
-#line 307 "Gmsh.y"
+#line 302 "Gmsh.y"
     { if(ViewValueList) List_Add(ViewValueList, &(yyvsp[(3) - (3)].d)); ;}
     break;
 
   case 39:
-#line 312 "Gmsh.y"
+#line 307 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (1)].c), "SP")){
 	ViewValueList = ViewData->SP; ViewNumList = &ViewData->NbSP;
@@ -4037,7 +4032,7 @@ yyreduce:
     break;
 
   case 40:
-#line 456 "Gmsh.y"
+#line 451 "Gmsh.y"
     {
       if(ViewValueList){
 	for(int i = 0; i < 3; i++)
@@ -4048,14 +4043,14 @@ yyreduce:
     break;
 
   case 41:
-#line 464 "Gmsh.y"
+#line 459 "Gmsh.y"
     {
       if(ViewValueList) (*ViewNumList)++;
     ;}
     break;
 
   case 42:
-#line 471 "Gmsh.y"
+#line 466 "Gmsh.y"
     { 
       for(int i = 0; i < (int)strlen((yyvsp[(1) - (1)].c))+1; i++) List_Add(ViewData->T2C, &(yyvsp[(1) - (1)].c)[i]); 
       Free((yyvsp[(1) - (1)].c));
@@ -4063,7 +4058,7 @@ yyreduce:
     break;
 
   case 43:
-#line 476 "Gmsh.y"
+#line 471 "Gmsh.y"
     { 
       for(int i = 0; i < (int)strlen((yyvsp[(3) - (3)].c))+1; i++) List_Add(ViewData->T2C, &(yyvsp[(3) - (3)].c)[i]); 
       Free((yyvsp[(3) - (3)].c));
@@ -4071,7 +4066,7 @@ yyreduce:
     break;
 
   case 44:
-#line 484 "Gmsh.y"
+#line 479 "Gmsh.y"
     { 
       List_Add(ViewData->T2D, &(yyvsp[(3) - (8)].d)); 
       List_Add(ViewData->T2D, &(yyvsp[(5) - (8)].d));
@@ -4082,14 +4077,14 @@ yyreduce:
     break;
 
   case 45:
-#line 492 "Gmsh.y"
+#line 487 "Gmsh.y"
     {
       ViewData->NbT2++;
     ;}
     break;
 
   case 46:
-#line 499 "Gmsh.y"
+#line 494 "Gmsh.y"
     { 
       for(int i = 0; i < (int)strlen((yyvsp[(1) - (1)].c))+1; i++) List_Add(ViewData->T3C, &(yyvsp[(1) - (1)].c)[i]); 
       Free((yyvsp[(1) - (1)].c));
@@ -4097,7 +4092,7 @@ yyreduce:
     break;
 
   case 47:
-#line 504 "Gmsh.y"
+#line 499 "Gmsh.y"
     { 
       for(int i = 0; i < (int)strlen((yyvsp[(3) - (3)].c))+1; i++) List_Add(ViewData->T3C, &(yyvsp[(3) - (3)].c)[i]); 
       Free((yyvsp[(3) - (3)].c));
@@ -4105,7 +4100,7 @@ yyreduce:
     break;
 
   case 48:
-#line 512 "Gmsh.y"
+#line 507 "Gmsh.y"
     { 
       List_Add(ViewData->T3D, &(yyvsp[(3) - (10)].d)); List_Add(ViewData->T3D, &(yyvsp[(5) - (10)].d));
       List_Add(ViewData->T3D, &(yyvsp[(7) - (10)].d)); List_Add(ViewData->T3D, &(yyvsp[(9) - (10)].d)); 
@@ -4115,76 +4110,90 @@ yyreduce:
     break;
 
   case 49:
-#line 519 "Gmsh.y"
+#line 514 "Gmsh.y"
     {
       ViewData->NbT3++;
     ;}
     break;
 
   case 50:
-#line 527 "Gmsh.y"
+#line 522 "Gmsh.y"
     {
-      ViewData->adaptive = new Adaptive_Post_View(ViewData, (yyvsp[(3) - (8)].l), (yyvsp[(6) - (8)].l));
+      int type = 
+	(ViewData->NbSL || ViewData->NbVL) ? 1 : 
+	(ViewData->NbST || ViewData->NbVT) ? 3 : 
+	(ViewData->NbSQ || ViewData->NbVQ) ? 4 : 
+	(ViewData->NbSS || ViewData->NbVS) ? 6 : 
+      	(ViewData->NbSH || ViewData->NbVH) ? 12 : 
+	0;
+      ViewData->setInterpolationScheme(type, (yyvsp[(3) - (8)].l), (yyvsp[(6) - (8)].l));
     ;}
     break;
 
   case 51:
-#line 534 "Gmsh.y"
+#line 536 "Gmsh.y"
     {
-      ViewData->adaptive = new Adaptive_Post_View(ViewData, (yyvsp[(3) - (14)].l), (yyvsp[(6) - (14)].l), (yyvsp[(9) - (14)].l), (yyvsp[(12) - (14)].l));
+      int type = 
+	(ViewData->NbSL || ViewData->NbVL) ? 1 : 
+	(ViewData->NbST || ViewData->NbVT) ? 3 : 
+	(ViewData->NbSQ || ViewData->NbVQ) ? 4 : 
+	(ViewData->NbSS || ViewData->NbVS) ? 6 : 
+      	(ViewData->NbSH || ViewData->NbVH) ? 12 : 
+	0;
+      ViewData->setInterpolationScheme(type, (yyvsp[(3) - (14)].l), (yyvsp[(6) - (14)].l), (yyvsp[(9) - (14)].l), (yyvsp[(12) - (14)].l));
     ;}
     break;
 
   case 52:
-#line 541 "Gmsh.y"
+#line 550 "Gmsh.y"
     {
       ViewValueList = ViewData->Time;
     ;}
     break;
 
   case 53:
-#line 545 "Gmsh.y"
+#line 554 "Gmsh.y"
     {
     ;}
     break;
 
   case 54:
-#line 552 "Gmsh.y"
+#line 561 "Gmsh.y"
     { (yyval.i) = 0; ;}
     break;
 
   case 55:
-#line 553 "Gmsh.y"
+#line 562 "Gmsh.y"
     { (yyval.i) = 1; ;}
     break;
 
   case 56:
-#line 554 "Gmsh.y"
+#line 563 "Gmsh.y"
     { (yyval.i) = 2; ;}
     break;
 
   case 57:
-#line 555 "Gmsh.y"
+#line 564 "Gmsh.y"
     { (yyval.i) = 3; ;}
     break;
 
   case 58:
-#line 556 "Gmsh.y"
+#line 565 "Gmsh.y"
     { (yyval.i) = 4; ;}
     break;
 
   case 59:
-#line 560 "Gmsh.y"
+#line 569 "Gmsh.y"
     { (yyval.i) = 1; ;}
     break;
 
   case 60:
-#line 561 "Gmsh.y"
+#line 570 "Gmsh.y"
     { (yyval.i) = -1; ;}
     break;
 
   case 61:
-#line 569 "Gmsh.y"
+#line 578 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (4)].c);
@@ -4218,7 +4227,7 @@ yyreduce:
     break;
 
   case 62:
-#line 600 "Gmsh.y"
+#line 609 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (7)].c);
@@ -4260,7 +4269,7 @@ yyreduce:
     break;
 
   case 63:
-#line 639 "Gmsh.y"
+#line 648 "Gmsh.y"
     {
       if(List_Nbr((yyvsp[(4) - (9)].l)) != List_Nbr((yyvsp[(8) - (9)].l))){
 	yymsg(GERROR, "Incompatible array dimensions in affectation");
@@ -4317,7 +4326,7 @@ yyreduce:
     break;
 
   case 64:
-#line 693 "Gmsh.y"
+#line 702 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (6)].c);
@@ -4337,7 +4346,7 @@ yyreduce:
     break;
 
   case 65:
-#line 710 "Gmsh.y"
+#line 719 "Gmsh.y"
     {
       // appends to the list
       Symbol TheSymbol;
@@ -4358,7 +4367,7 @@ yyreduce:
     break;
 
   case 66:
-#line 728 "Gmsh.y"
+#line 737 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (3)].c);
@@ -4372,7 +4381,7 @@ yyreduce:
     break;
 
   case 67:
-#line 739 "Gmsh.y"
+#line 748 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (6)].c);
@@ -4391,14 +4400,14 @@ yyreduce:
     break;
 
   case 68:
-#line 756 "Gmsh.y"
+#line 765 "Gmsh.y"
     { 
       Msg(WARNING, "Named string expressions not implemented yet");
     ;}
     break;
 
   case 69:
-#line 763 "Gmsh.y"
+#line 772 "Gmsh.y"
     { 
       const char* (*pStrOpt)(int num, int action, const char *value);
       StringXString *pStrCat;
@@ -4416,7 +4425,7 @@ yyreduce:
     break;
 
   case 70:
-#line 778 "Gmsh.y"
+#line 787 "Gmsh.y"
     { 
       const char* (*pStrOpt)(int num, int action, const char *value);
       StringXString *pStrCat;
@@ -4434,7 +4443,7 @@ yyreduce:
     break;
 
   case 71:
-#line 796 "Gmsh.y"
+#line 805 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -4463,7 +4472,7 @@ yyreduce:
     break;
 
   case 72:
-#line 822 "Gmsh.y"
+#line 831 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -4493,7 +4502,7 @@ yyreduce:
     break;
 
   case 73:
-#line 849 "Gmsh.y"
+#line 858 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -4510,7 +4519,7 @@ yyreduce:
     break;
 
   case 74:
-#line 863 "Gmsh.y"
+#line 872 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -4527,7 +4536,7 @@ yyreduce:
     break;
 
   case 75:
-#line 880 "Gmsh.y"
+#line 889 "Gmsh.y"
     {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -4545,7 +4554,7 @@ yyreduce:
     break;
 
   case 76:
-#line 895 "Gmsh.y"
+#line 904 "Gmsh.y"
     {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -4563,7 +4572,7 @@ yyreduce:
     break;
 
   case 77:
-#line 913 "Gmsh.y"
+#line 922 "Gmsh.y"
     {
       GmshColorTable *ct = Get_ColorTable(0);
       if(!ct)
@@ -4586,7 +4595,7 @@ yyreduce:
     break;
 
   case 78:
-#line 933 "Gmsh.y"
+#line 942 "Gmsh.y"
     {
       GmshColorTable *ct = Get_ColorTable((int)(yyvsp[(3) - (9)].d));
       if(!ct)
@@ -4609,7 +4618,7 @@ yyreduce:
     break;
 
   case 79:
-#line 956 "Gmsh.y"
+#line 965 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (5)].c),"Background")){
 	GModel::current()->getFields()->background_field = (int)(yyvsp[(4) - (5)].d);
@@ -4621,7 +4630,7 @@ yyreduce:
     break;
 
   case 80:
-#line 965 "Gmsh.y"
+#line 974 "Gmsh.y"
     {
       if(!GModel::current()->getFields()->new_field((int)(yyvsp[(3) - (7)].d), (yyvsp[(6) - (7)].c)))
 	yymsg(GERROR, "Cannot create field %i of type '%s'", (int)(yyvsp[(3) - (7)].d), (yyvsp[(6) - (7)].c));
@@ -4629,7 +4638,7 @@ yyreduce:
     break;
 
   case 81:
-#line 970 "Gmsh.y"
+#line 979 "Gmsh.y"
     {
       Field *field = GModel::current()->getFields()->get((int)(yyvsp[(3) - (9)].d));
       if(field){
@@ -4651,7 +4660,7 @@ yyreduce:
     break;
 
   case 82:
-#line 989 "Gmsh.y"
+#line 998 "Gmsh.y"
     {
       Field *field = GModel::current()->getFields()->get((int)(yyvsp[(3) - (9)].d));
       if(field){
@@ -4673,7 +4682,7 @@ yyreduce:
     break;
 
   case 83:
-#line 1008 "Gmsh.y"
+#line 1017 "Gmsh.y"
     {
       Field *field = GModel::current()->getFields()->get((int)(yyvsp[(3) - (11)].d));
       if(field){
@@ -4697,7 +4706,7 @@ yyreduce:
     break;
 
   case 84:
-#line 1032 "Gmsh.y"
+#line 1041 "Gmsh.y"
     {
       try {
 	GMSH_PluginManager::instance()->setPluginOption((yyvsp[(3) - (9)].c), (yyvsp[(6) - (9)].c), (yyvsp[(8) - (9)].d)); 
@@ -4710,7 +4719,7 @@ yyreduce:
     break;
 
   case 85:
-#line 1042 "Gmsh.y"
+#line 1051 "Gmsh.y"
     {
       try {
 	GMSH_PluginManager::instance()->setPluginOption((yyvsp[(3) - (9)].c), (yyvsp[(6) - (9)].c), (yyvsp[(8) - (9)].c)); 
@@ -4723,14 +4732,14 @@ yyreduce:
     break;
 
   case 86:
-#line 1057 "Gmsh.y"
+#line 1066 "Gmsh.y"
     { 
       (yyval.i) = (int)(yyvsp[(1) - (1)].d); 
     ;}
     break;
 
   case 87:
-#line 1061 "Gmsh.y"
+#line 1070 "Gmsh.y"
     { 
       (yyval.i) = GModel::current()->setPhysicalName
 	(std::string((yyvsp[(1) - (1)].c)), ++GModel::current()->getGEOInternals()->MaxPhysicalNum);
@@ -4739,7 +4748,7 @@ yyreduce:
     break;
 
   case 88:
-#line 1074 "Gmsh.y"
+#line 1083 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindPoint(num)){
@@ -4764,7 +4773,7 @@ yyreduce:
     break;
 
   case 89:
-#line 1096 "Gmsh.y"
+#line 1105 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].i);
       if(FindPhysicalGroup(num, MSH_PHYSICAL_POINT)){
@@ -4783,7 +4792,7 @@ yyreduce:
     break;
 
   case 90:
-#line 1112 "Gmsh.y"
+#line 1121 "Gmsh.y"
     {      
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (6)].l)); i++){
 	double d;
@@ -4805,7 +4814,7 @@ yyreduce:
     break;
 
   case 91:
-#line 1134 "Gmsh.y"
+#line 1143 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -4826,7 +4835,7 @@ yyreduce:
     break;
 
   case 92:
-#line 1152 "Gmsh.y"
+#line 1161 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -4847,7 +4856,7 @@ yyreduce:
     break;
 
   case 93:
-#line 1170 "Gmsh.y"
+#line 1179 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -4868,7 +4877,7 @@ yyreduce:
     break;
 
   case 94:
-#line 1188 "Gmsh.y"
+#line 1197 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (9)].d);
       if(FindCurve(num)){
@@ -4897,7 +4906,7 @@ yyreduce:
     break;
 
   case 95:
-#line 1214 "Gmsh.y"
+#line 1223 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -4918,7 +4927,7 @@ yyreduce:
     break;
 
   case 96:
-#line 1232 "Gmsh.y"
+#line 1241 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (9)].d);
       if(FindCurve(num)){
@@ -4947,7 +4956,7 @@ yyreduce:
     break;
 
   case 97:
-#line 1259 "Gmsh.y"
+#line 1268 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (17)].d);
       if(FindCurve(num)){
@@ -4969,7 +4978,7 @@ yyreduce:
     break;
 
   case 98:
-#line 1278 "Gmsh.y"
+#line 1287 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -4990,7 +4999,7 @@ yyreduce:
     break;
 
   case 99:
-#line 1296 "Gmsh.y"
+#line 1305 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindCurve(num)){
@@ -5011,7 +5020,7 @@ yyreduce:
     break;
 
   case 100:
-#line 1314 "Gmsh.y"
+#line 1323 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (11)].d);
       if(List_Nbr((yyvsp[(6) - (11)].l)) + (int)(yyvsp[(10) - (11)].d) + 1 != List_Nbr((yyvsp[(8) - (11)].l))){
@@ -5040,7 +5049,7 @@ yyreduce:
     break;
 
   case 101:
-#line 1340 "Gmsh.y"
+#line 1349 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].d);
       if(FindEdgeLoop(num)){
@@ -5060,7 +5069,7 @@ yyreduce:
     break;
 
   case 102:
-#line 1357 "Gmsh.y"
+#line 1366 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].i);
       if(FindPhysicalGroup(num, MSH_PHYSICAL_LINE)){
@@ -5079,7 +5088,7 @@ yyreduce:
     break;
 
   case 103:
-#line 1376 "Gmsh.y"
+#line 1385 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].d);
       if(FindSurface(num)){
@@ -5100,7 +5109,7 @@ yyreduce:
     break;
 
   case 104:
-#line 1394 "Gmsh.y"
+#line 1403 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].d), type = 0;
       if(FindSurface(num)){
@@ -5141,7 +5150,7 @@ yyreduce:
     break;
 
   case 105:
-#line 1432 "Gmsh.y"
+#line 1441 "Gmsh.y"
     {
       myGmshSurface = 0;
       (yyval.s).Type = 0;
@@ -5150,7 +5159,7 @@ yyreduce:
     break;
 
   case 106:
-#line 1438 "Gmsh.y"
+#line 1447 "Gmsh.y"
     {
       myGmshSurface = gmshSurface::getSurface((int)(yyvsp[(3) - (4)].d));
       (yyval.s).Type = 0;
@@ -5159,7 +5168,7 @@ yyreduce:
     break;
 
   case 107:
-#line 1444 "Gmsh.y"
+#line 1453 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (10)].d);
       myGmshSurface = gmshParametricSurface::NewParametricSurface(num, (yyvsp[(7) - (10)].c), (yyvsp[(8) - (10)].c), (yyvsp[(9) - (10)].c));
@@ -5169,7 +5178,7 @@ yyreduce:
     break;
 
   case 108:
-#line 1451 "Gmsh.y"
+#line 1460 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if (List_Nbr((yyvsp[(6) - (7)].l)) != 2){
@@ -5197,7 +5206,7 @@ yyreduce:
     break;
 
   case 109:
-#line 1476 "Gmsh.y"
+#line 1485 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if (List_Nbr((yyvsp[(6) - (7)].l)) != 2){
@@ -5225,7 +5234,7 @@ yyreduce:
     break;
 
   case 110:
-#line 1501 "Gmsh.y"
+#line 1510 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].d);
       if(FindSurfaceLoop(num)){
@@ -5244,7 +5253,7 @@ yyreduce:
     break;
 
   case 111:
-#line 1517 "Gmsh.y"
+#line 1526 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].i);
       if(FindPhysicalGroup(num, MSH_PHYSICAL_SURFACE)){
@@ -5263,7 +5272,7 @@ yyreduce:
     break;
 
   case 112:
-#line 1537 "Gmsh.y"
+#line 1546 "Gmsh.y"
     {
       yymsg(GERROR, "'Complex Volume' command is deprecated: use 'Volume' instead");
       int num = (int)(yyvsp[(4) - (8)].d);
@@ -5284,7 +5293,7 @@ yyreduce:
     break;
 
   case 113:
-#line 1555 "Gmsh.y"
+#line 1564 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (7)].d);
       if(FindVolume(num)){
@@ -5304,7 +5313,7 @@ yyreduce:
     break;
 
   case 114:
-#line 1572 "Gmsh.y"
+#line 1581 "Gmsh.y"
     {
       int num = (int)(yyvsp[(4) - (8)].i);
       if(FindPhysicalGroup(num, MSH_PHYSICAL_VOLUME)){
@@ -5323,7 +5332,7 @@ yyreduce:
     break;
 
   case 115:
-#line 1593 "Gmsh.y"
+#line 1602 "Gmsh.y"
     {
       TranslateShapes((yyvsp[(2) - (5)].v)[0], (yyvsp[(2) - (5)].v)[1], (yyvsp[(2) - (5)].v)[2], (yyvsp[(4) - (5)].l));
       (yyval.l) = (yyvsp[(4) - (5)].l);
@@ -5331,7 +5340,7 @@ yyreduce:
     break;
 
   case 116:
-#line 1598 "Gmsh.y"
+#line 1607 "Gmsh.y"
     {
       RotateShapes((yyvsp[(3) - (11)].v)[0], (yyvsp[(3) - (11)].v)[1], (yyvsp[(3) - (11)].v)[2], (yyvsp[(5) - (11)].v)[0], (yyvsp[(5) - (11)].v)[1], (yyvsp[(5) - (11)].v)[2], (yyvsp[(7) - (11)].d), (yyvsp[(10) - (11)].l));
       (yyval.l) = (yyvsp[(10) - (11)].l);
@@ -5339,7 +5348,7 @@ yyreduce:
     break;
 
   case 117:
-#line 1603 "Gmsh.y"
+#line 1612 "Gmsh.y"
     {
       SymmetryShapes((yyvsp[(2) - (5)].v)[0], (yyvsp[(2) - (5)].v)[1], (yyvsp[(2) - (5)].v)[2], (yyvsp[(2) - (5)].v)[3], (yyvsp[(4) - (5)].l));
       (yyval.l) = (yyvsp[(4) - (5)].l);
@@ -5347,7 +5356,7 @@ yyreduce:
     break;
 
   case 118:
-#line 1608 "Gmsh.y"
+#line 1617 "Gmsh.y"
     {
       DilatShapes((yyvsp[(3) - (9)].v)[0], (yyvsp[(3) - (9)].v)[1], (yyvsp[(3) - (9)].v)[2], (yyvsp[(5) - (9)].d), (yyvsp[(8) - (9)].l));
       (yyval.l) = (yyvsp[(8) - (9)].l);
@@ -5355,7 +5364,7 @@ yyreduce:
     break;
 
   case 119:
-#line 1613 "Gmsh.y"
+#line 1622 "Gmsh.y"
     {
       (yyval.l) = List_Create(3, 3, sizeof(Shape));
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){
@@ -5369,7 +5378,7 @@ yyreduce:
     break;
 
   case 120:
-#line 1624 "Gmsh.y"
+#line 1633 "Gmsh.y"
     { 
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       IntersectCurvesWithSurface((yyvsp[(4) - (9)].l), (int)(yyvsp[(8) - (9)].d), (yyval.l));
@@ -5378,7 +5387,7 @@ yyreduce:
     break;
 
   case 121:
-#line 1630 "Gmsh.y"
+#line 1639 "Gmsh.y"
     { 
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       BoundaryShapes((yyvsp[(3) - (4)].l), (yyval.l));
@@ -5387,31 +5396,31 @@ yyreduce:
     break;
 
   case 122:
-#line 1638 "Gmsh.y"
+#line 1647 "Gmsh.y"
     { (yyval.l) = (yyvsp[(1) - (1)].l); ;}
     break;
 
   case 123:
-#line 1639 "Gmsh.y"
+#line 1648 "Gmsh.y"
     { (yyval.l) = (yyvsp[(1) - (1)].l); ;}
     break;
 
   case 124:
-#line 1644 "Gmsh.y"
+#line 1653 "Gmsh.y"
     {
       (yyval.l) = List_Create(3, 3, sizeof(Shape));
     ;}
     break;
 
   case 125:
-#line 1648 "Gmsh.y"
+#line 1657 "Gmsh.y"
     {
       List_Add((yyval.l), &(yyvsp[(2) - (2)].s));
     ;}
     break;
 
   case 126:
-#line 1652 "Gmsh.y"
+#line 1661 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(4) - (6)].l)); i++){
 	double d;
@@ -5437,7 +5446,7 @@ yyreduce:
     break;
 
   case 127:
-#line 1675 "Gmsh.y"
+#line 1684 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(4) - (6)].l)); i++){
 	double d;
@@ -5463,7 +5472,7 @@ yyreduce:
     break;
 
   case 128:
-#line 1698 "Gmsh.y"
+#line 1707 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(4) - (6)].l)); i++){
 	double d;
@@ -5489,7 +5498,7 @@ yyreduce:
     break;
 
   case 129:
-#line 1721 "Gmsh.y"
+#line 1730 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(4) - (6)].l)); i++){
 	double d;
@@ -5515,7 +5524,7 @@ yyreduce:
     break;
 
   case 130:
-#line 1749 "Gmsh.y"
+#line 1758 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){
 	Shape TheShape;
@@ -5527,14 +5536,14 @@ yyreduce:
     break;
 
   case 131:
-#line 1758 "Gmsh.y"
+#line 1767 "Gmsh.y"
     {
       GModel::current()->getFields()->delete_field((int)(yyvsp[(4) - (6)].d));
     ;}
     break;
 
   case 132:
-#line 1762 "Gmsh.y"
+#line 1771 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (6)].c), "View")){
 	int index = (int)(yyvsp[(4) - (6)].d);
@@ -5550,7 +5559,7 @@ yyreduce:
     break;
 
   case 133:
-#line 1775 "Gmsh.y"
+#line 1784 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (3)].c), "Meshes") || !strcmp((yyvsp[(2) - (3)].c), "All")){
 	GModel::current()->destroy();
@@ -5569,7 +5578,7 @@ yyreduce:
     break;
 
   case 134:
-#line 1791 "Gmsh.y"
+#line 1800 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (4)].c), "Empty") && !strcmp((yyvsp[(3) - (4)].c), "Views")){
 	for(int i = PView::list.size() - 1; i >= 0; i--)
@@ -5582,7 +5591,7 @@ yyreduce:
     break;
 
   case 135:
-#line 1806 "Gmsh.y"
+#line 1815 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(4) - (5)].l)); i++){
 	Shape TheShape;
@@ -5594,7 +5603,7 @@ yyreduce:
     break;
 
   case 136:
-#line 1820 "Gmsh.y"
+#line 1829 "Gmsh.y"
     {
       for(int i = 0; i < 4; i++)
 	VisibilityShape((yyvsp[(2) - (3)].c), i, 1);
@@ -5603,7 +5612,7 @@ yyreduce:
     break;
 
   case 137:
-#line 1826 "Gmsh.y"
+#line 1835 "Gmsh.y"
     {
       for(int i = 0; i < 4; i++)
 	VisibilityShape((yyvsp[(2) - (3)].c), i, 0);
@@ -5612,7 +5621,7 @@ yyreduce:
     break;
 
   case 138:
-#line 1832 "Gmsh.y"
+#line 1841 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){
 	Shape TheShape;
@@ -5624,7 +5633,7 @@ yyreduce:
     break;
 
   case 139:
-#line 1841 "Gmsh.y"
+#line 1850 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){
 	Shape TheShape;
@@ -5636,7 +5645,7 @@ yyreduce:
     break;
 
   case 140:
-#line 1855 "Gmsh.y"
+#line 1864 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (3)].c), "Include")){
 	char tmpstring[1024];
@@ -5687,7 +5696,7 @@ yyreduce:
     break;
 
   case 141:
-#line 1903 "Gmsh.y"
+#line 1912 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (7)].c), "Save") && !strcmp((yyvsp[(2) - (7)].c), "View")){
 	int index = (int)(yyvsp[(4) - (7)].d);
@@ -5706,7 +5715,7 @@ yyreduce:
     break;
 
   case 142:
-#line 1919 "Gmsh.y"
+#line 1928 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (7)].c), "Background") && !strcmp((yyvsp[(2) - (7)].c), "Mesh")  && !strcmp((yyvsp[(3) - (7)].c), "View")){
 	int index = (int)(yyvsp[(5) - (7)].d);
@@ -5722,7 +5731,7 @@ yyreduce:
     break;
 
   case 143:
-#line 1932 "Gmsh.y"
+#line 1941 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(1) - (3)].c), "Sleep")){
 	SleepInSeconds((yyvsp[(2) - (3)].d));
@@ -5744,7 +5753,7 @@ yyreduce:
     break;
 
   case 144:
-#line 1951 "Gmsh.y"
+#line 1960 "Gmsh.y"
     {
        try {
 	 GMSH_PluginManager::instance()->action((yyvsp[(3) - (7)].c), (yyvsp[(6) - (7)].c), 0);
@@ -5757,7 +5766,7 @@ yyreduce:
     break;
 
   case 145:
-#line 1961 "Gmsh.y"
+#line 1970 "Gmsh.y"
     {
       if(!strcmp((yyvsp[(2) - (3)].c), "ElementsFromAllViews"))
 	PView::combine(false, 1, CTX.post.combine_remove_orig);
@@ -5782,14 +5791,14 @@ yyreduce:
     break;
 
   case 146:
-#line 1983 "Gmsh.y"
+#line 1992 "Gmsh.y"
     {
       exit(0);
     ;}
     break;
 
   case 147:
-#line 1987 "Gmsh.y"
+#line 1996 "Gmsh.y"
     {
       CTX.forced_bbox = 0;
       SetBoundingBox();
@@ -5797,7 +5806,7 @@ yyreduce:
     break;
 
   case 148:
-#line 1992 "Gmsh.y"
+#line 2001 "Gmsh.y"
     {
       CTX.forced_bbox = 1;
       SetBoundingBox((yyvsp[(3) - (15)].d), (yyvsp[(5) - (15)].d), (yyvsp[(7) - (15)].d), (yyvsp[(9) - (15)].d), (yyvsp[(11) - (15)].d), (yyvsp[(13) - (15)].d));
@@ -5805,7 +5814,7 @@ yyreduce:
     break;
 
   case 149:
-#line 1997 "Gmsh.y"
+#line 2006 "Gmsh.y"
     {
 #if defined(HAVE_FLTK)
       Draw();
@@ -5814,7 +5823,7 @@ yyreduce:
     break;
 
   case 150:
-#line 2009 "Gmsh.y"
+#line 2018 "Gmsh.y"
     {
       LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(3) - (6)].d);
       LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(5) - (6)].d);
@@ -5834,7 +5843,7 @@ yyreduce:
     break;
 
   case 151:
-#line 2026 "Gmsh.y"
+#line 2035 "Gmsh.y"
     {
       LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(3) - (8)].d);
       LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(5) - (8)].d);
@@ -5854,7 +5863,7 @@ yyreduce:
     break;
 
   case 152:
-#line 2043 "Gmsh.y"
+#line 2052 "Gmsh.y"
     {
       LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(5) - (8)].d);
       LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(7) - (8)].d);
@@ -5884,7 +5893,7 @@ yyreduce:
     break;
 
   case 153:
-#line 2070 "Gmsh.y"
+#line 2079 "Gmsh.y"
     {
       LoopControlVariablesTab[ImbricatedLoop][0] = (yyvsp[(5) - (10)].d);
       LoopControlVariablesTab[ImbricatedLoop][1] = (yyvsp[(7) - (10)].d);
@@ -5914,7 +5923,7 @@ yyreduce:
     break;
 
   case 154:
-#line 2097 "Gmsh.y"
+#line 2106 "Gmsh.y"
     {
       if(ImbricatedLoop <= 0){
 	yymsg(GERROR, "Invalid For/EndFor loop");
@@ -5948,7 +5957,7 @@ yyreduce:
     break;
 
   case 155:
-#line 2128 "Gmsh.y"
+#line 2137 "Gmsh.y"
     {
       if(!FunctionManager::Instance()->createFunction((yyvsp[(2) - (2)].c), gmsh_yyin, gmsh_yyname,
 						      gmsh_yylineno))
@@ -5959,7 +5968,7 @@ yyreduce:
     break;
 
   case 156:
-#line 2136 "Gmsh.y"
+#line 2145 "Gmsh.y"
     {
       if(!FunctionManager::Instance()->leaveFunction(&gmsh_yyin, gmsh_yyname,
 						     gmsh_yylineno))
@@ -5968,7 +5977,7 @@ yyreduce:
     break;
 
   case 157:
-#line 2142 "Gmsh.y"
+#line 2151 "Gmsh.y"
     {
       if(!FunctionManager::Instance()->enterFunction((yyvsp[(2) - (3)].c), &gmsh_yyin, gmsh_yyname,
 						     gmsh_yylineno))
@@ -5978,20 +5987,20 @@ yyreduce:
     break;
 
   case 158:
-#line 2149 "Gmsh.y"
+#line 2158 "Gmsh.y"
     {
       if(!(yyvsp[(3) - (4)].d)) skip_until("If", "EndIf");
     ;}
     break;
 
   case 159:
-#line 2153 "Gmsh.y"
+#line 2162 "Gmsh.y"
     {
     ;}
     break;
 
   case 160:
-#line 2162 "Gmsh.y"
+#line 2171 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE, (yyvsp[(4) - (5)].l), 
@@ -6002,7 +6011,7 @@ yyreduce:
     break;
 
   case 161:
-#line 2170 "Gmsh.y"
+#line 2179 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(ROTATE, (yyvsp[(10) - (11)].l), 
@@ -6013,7 +6022,7 @@ yyreduce:
     break;
 
   case 162:
-#line 2178 "Gmsh.y"
+#line 2187 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE_ROTATE, (yyvsp[(12) - (13)].l), 
@@ -6024,14 +6033,14 @@ yyreduce:
     break;
 
   case 163:
-#line 2186 "Gmsh.y"
+#line 2195 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 164:
-#line 2190 "Gmsh.y"
+#line 2199 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE, (yyvsp[(4) - (7)].l), 
@@ -6042,14 +6051,14 @@ yyreduce:
     break;
 
   case 165:
-#line 2198 "Gmsh.y"
+#line 2207 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 166:
-#line 2202 "Gmsh.y"
+#line 2211 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(ROTATE, (yyvsp[(10) - (13)].l), 
@@ -6060,14 +6069,14 @@ yyreduce:
     break;
 
   case 167:
-#line 2210 "Gmsh.y"
+#line 2219 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 168:
-#line 2214 "Gmsh.y"
+#line 2223 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(TRANSLATE_ROTATE, (yyvsp[(12) - (15)].l), 
@@ -6078,14 +6087,14 @@ yyreduce:
     break;
 
   case 169:
-#line 2222 "Gmsh.y"
+#line 2231 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 170:
-#line 2226 "Gmsh.y"
+#line 2235 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShapes(BOUNDARY_LAYER, (yyvsp[(3) - (6)].l), 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
@@ -6095,14 +6104,14 @@ yyreduce:
     break;
 
   case 171:
-#line 2233 "Gmsh.y"
+#line 2242 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 172:
-#line 2237 "Gmsh.y"
+#line 2246 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       extr.mesh.ViewIndex = (int)(yyvsp[(4) - (10)].d);
@@ -6115,7 +6124,7 @@ yyreduce:
     break;
 
   case 173:
-#line 2249 "Gmsh.y"
+#line 2258 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_POINT, (int)(yyvsp[(4) - (8)].d), 
@@ -6125,7 +6134,7 @@ yyreduce:
     break;
 
   case 174:
-#line 2256 "Gmsh.y"
+#line 2265 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (8)].d), 
@@ -6135,7 +6144,7 @@ yyreduce:
     break;
 
   case 175:
-#line 2263 "Gmsh.y"
+#line 2272 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (8)].d), 
@@ -6145,7 +6154,7 @@ yyreduce:
     break;
 
   case 176:
-#line 2270 "Gmsh.y"
+#line 2279 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_POINT, (int)(yyvsp[(4) - (12)].d), 
@@ -6155,7 +6164,7 @@ yyreduce:
     break;
 
   case 177:
-#line 2277 "Gmsh.y"
+#line 2286 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (12)].d), 
@@ -6165,7 +6174,7 @@ yyreduce:
     break;
 
   case 178:
-#line 2284 "Gmsh.y"
+#line 2293 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (12)].d), 
@@ -6175,7 +6184,7 @@ yyreduce:
     break;
 
   case 179:
-#line 2291 "Gmsh.y"
+#line 2300 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_POINT, (int)(yyvsp[(4) - (14)].d), 
@@ -6185,7 +6194,7 @@ yyreduce:
     break;
 
   case 180:
-#line 2298 "Gmsh.y"
+#line 2307 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (14)].d), 
@@ -6195,7 +6204,7 @@ yyreduce:
     break;
 
   case 181:
-#line 2305 "Gmsh.y"
+#line 2314 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (14)].d), 
@@ -6205,14 +6214,14 @@ yyreduce:
     break;
 
   case 182:
-#line 2312 "Gmsh.y"
+#line 2321 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 183:
-#line 2316 "Gmsh.y"
+#line 2325 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_POINT, (int)(yyvsp[(4) - (12)].d), 
@@ -6222,14 +6231,14 @@ yyreduce:
     break;
 
   case 184:
-#line 2323 "Gmsh.y"
+#line 2332 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 185:
-#line 2327 "Gmsh.y"
+#line 2336 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (12)].d), 
@@ -6239,14 +6248,14 @@ yyreduce:
     break;
 
   case 186:
-#line 2334 "Gmsh.y"
+#line 2343 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 187:
-#line 2338 "Gmsh.y"
+#line 2347 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (12)].d), 
@@ -6256,14 +6265,14 @@ yyreduce:
     break;
 
   case 188:
-#line 2345 "Gmsh.y"
+#line 2354 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 189:
-#line 2349 "Gmsh.y"
+#line 2358 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_POINT, (int)(yyvsp[(4) - (16)].d), 
@@ -6273,14 +6282,14 @@ yyreduce:
     break;
 
   case 190:
-#line 2356 "Gmsh.y"
+#line 2365 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 191:
-#line 2360 "Gmsh.y"
+#line 2369 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (16)].d), 
@@ -6290,14 +6299,14 @@ yyreduce:
     break;
 
   case 192:
-#line 2367 "Gmsh.y"
+#line 2376 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 193:
-#line 2371 "Gmsh.y"
+#line 2380 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(ROTATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (16)].d), 
@@ -6307,14 +6316,14 @@ yyreduce:
     break;
 
   case 194:
-#line 2378 "Gmsh.y"
+#line 2387 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 195:
-#line 2382 "Gmsh.y"
+#line 2391 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_POINT, (int)(yyvsp[(4) - (18)].d), 
@@ -6324,14 +6333,14 @@ yyreduce:
     break;
 
   case 196:
-#line 2389 "Gmsh.y"
+#line 2398 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 197:
-#line 2393 "Gmsh.y"
+#line 2402 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SEGM_LINE, (int)(yyvsp[(4) - (18)].d), 
@@ -6341,14 +6350,14 @@ yyreduce:
     break;
 
   case 198:
-#line 2400 "Gmsh.y"
+#line 2409 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = extr.mesh.Recombine = false;
     ;}
     break;
 
   case 199:
-#line 2404 "Gmsh.y"
+#line 2413 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(Shape));
       ExtrudeShape(TRANSLATE_ROTATE, MSH_SURF_PLAN, (int)(yyvsp[(4) - (18)].d), 
@@ -6358,19 +6367,19 @@ yyreduce:
     break;
 
   case 200:
-#line 2415 "Gmsh.y"
+#line 2424 "Gmsh.y"
     {
     ;}
     break;
 
   case 201:
-#line 2418 "Gmsh.y"
+#line 2427 "Gmsh.y"
     {
     ;}
     break;
 
   case 202:
-#line 2424 "Gmsh.y"
+#line 2433 "Gmsh.y"
     {
       extr.mesh.ExtrudeMesh = true;
       extr.mesh.NbLayer = 1;
@@ -6382,7 +6391,7 @@ yyreduce:
     break;
 
   case 203:
-#line 2433 "Gmsh.y"
+#line 2442 "Gmsh.y"
     {
       double d;
       extr.mesh.ExtrudeMesh = true;
@@ -6405,7 +6414,7 @@ yyreduce:
     break;
 
   case 204:
-#line 2453 "Gmsh.y"
+#line 2462 "Gmsh.y"
     {
       yymsg(GERROR, "Explicit region numbers in layers are deprecated");
       double d;
@@ -6431,14 +6440,14 @@ yyreduce:
     break;
 
   case 205:
-#line 2476 "Gmsh.y"
+#line 2485 "Gmsh.y"
     {
       extr.mesh.Recombine = true;
     ;}
     break;
 
   case 206:
-#line 2480 "Gmsh.y"
+#line 2489 "Gmsh.y"
     {
       int num = (int)(yyvsp[(3) - (9)].d);
       if(FindSurface(num)){
@@ -6460,7 +6469,7 @@ yyreduce:
     break;
 
   case 207:
-#line 2504 "Gmsh.y"
+#line 2513 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (6)].l)); i++){
 	double d;
@@ -6481,7 +6490,7 @@ yyreduce:
     break;
 
   case 208:
-#line 2522 "Gmsh.y"
+#line 2531 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (9)].l)); i++){
 	double d;
@@ -6502,7 +6511,7 @@ yyreduce:
     break;
 
   case 209:
-#line 2540 "Gmsh.y"
+#line 2549 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (9)].l)); i++){
 	double d;
@@ -6523,7 +6532,7 @@ yyreduce:
     break;
 
   case 210:
-#line 2558 "Gmsh.y"
+#line 2567 "Gmsh.y"
     {
       Surface *s = FindSurface((int)(yyvsp[(4) - (8)].d));
       if(!s)
@@ -6555,7 +6564,7 @@ yyreduce:
     break;
 
   case 211:
-#line 2587 "Gmsh.y"
+#line 2596 "Gmsh.y"
     {
       Surface *s = FindSurface((int)(yyvsp[(4) - (9)].d));
       if(!s)
@@ -6593,7 +6602,7 @@ yyreduce:
     break;
 
   case 212:
-#line 2622 "Gmsh.y"
+#line 2631 "Gmsh.y"
     {
       yymsg(WARNING, "Elliptic Surface is deprecated: use Transfinite instead (with smoothing)");
       List_Delete((yyvsp[(7) - (8)].l));
@@ -6601,7 +6610,7 @@ yyreduce:
     break;
 
   case 213:
-#line 2627 "Gmsh.y"
+#line 2636 "Gmsh.y"
     {
       Volume *v = FindVolume((int)(yyvsp[(4) - (8)].d));
       if(!v)
@@ -6631,7 +6640,7 @@ yyreduce:
     break;
 
   case 214:
-#line 2654 "Gmsh.y"
+#line 2663 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (6)].l)); i++){
 	double d;
@@ -6648,7 +6657,7 @@ yyreduce:
     break;
 
   case 215:
-#line 2668 "Gmsh.y"
+#line 2677 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (4)].l)); i++){
 	double d;
@@ -6664,7 +6673,7 @@ yyreduce:
     break;
 
   case 216:
-#line 2681 "Gmsh.y"
+#line 2690 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (6)].l)); i++){
 	double d;
@@ -6678,7 +6687,7 @@ yyreduce:
     break;
 
   case 217:
-#line 2698 "Gmsh.y"
+#line 2707 "Gmsh.y"
     { 
       Surface *s = FindSurface((int)(yyvsp[(8) - (10)].d));
       if(s)
@@ -6687,7 +6696,7 @@ yyreduce:
     break;
 
   case 218:
-#line 2704 "Gmsh.y"
+#line 2713 "Gmsh.y"
     {
       Surface *s = FindSurface((int)(yyvsp[(8) - (10)].d));
       if(s)
@@ -6696,66 +6705,66 @@ yyreduce:
     break;
 
   case 219:
-#line 2710 "Gmsh.y"
+#line 2719 "Gmsh.y"
     {
     ;}
     break;
 
   case 220:
-#line 2713 "Gmsh.y"
+#line 2722 "Gmsh.y"
     {
     ;}
     break;
 
   case 221:
-#line 2722 "Gmsh.y"
+#line 2731 "Gmsh.y"
     { 
       ReplaceAllDuplicates();
     ;}
     break;
 
   case 222:
-#line 2731 "Gmsh.y"
+#line 2740 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (1)].d);           ;}
     break;
 
   case 223:
-#line 2732 "Gmsh.y"
+#line 2741 "Gmsh.y"
     { (yyval.d) = (yyvsp[(2) - (3)].d);           ;}
     break;
 
   case 224:
-#line 2733 "Gmsh.y"
+#line 2742 "Gmsh.y"
     { (yyval.d) = -(yyvsp[(2) - (2)].d);          ;}
     break;
 
   case 225:
-#line 2734 "Gmsh.y"
+#line 2743 "Gmsh.y"
     { (yyval.d) = (yyvsp[(2) - (2)].d);           ;}
     break;
 
   case 226:
-#line 2735 "Gmsh.y"
+#line 2744 "Gmsh.y"
     { (yyval.d) = !(yyvsp[(2) - (2)].d);          ;}
     break;
 
   case 227:
-#line 2736 "Gmsh.y"
+#line 2745 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) - (yyvsp[(3) - (3)].d);      ;}
     break;
 
   case 228:
-#line 2737 "Gmsh.y"
+#line 2746 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) + (yyvsp[(3) - (3)].d);      ;}
     break;
 
   case 229:
-#line 2738 "Gmsh.y"
+#line 2747 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) * (yyvsp[(3) - (3)].d);      ;}
     break;
 
   case 230:
-#line 2740 "Gmsh.y"
+#line 2749 "Gmsh.y"
     { 
       if(!(yyvsp[(3) - (3)].d))
 	yymsg(GERROR, "Division by zero in '%g / %g'", (yyvsp[(1) - (3)].d), (yyvsp[(3) - (3)].d));
@@ -6765,307 +6774,307 @@ yyreduce:
     break;
 
   case 231:
-#line 2746 "Gmsh.y"
+#line 2755 "Gmsh.y"
     { (yyval.d) = (int)(yyvsp[(1) - (3)].d) % (int)(yyvsp[(3) - (3)].d);  ;}
     break;
 
   case 232:
-#line 2747 "Gmsh.y"
+#line 2756 "Gmsh.y"
     { (yyval.d) = pow((yyvsp[(1) - (3)].d), (yyvsp[(3) - (3)].d));  ;}
     break;
 
   case 233:
-#line 2748 "Gmsh.y"
+#line 2757 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) < (yyvsp[(3) - (3)].d);      ;}
     break;
 
   case 234:
-#line 2749 "Gmsh.y"
+#line 2758 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) > (yyvsp[(3) - (3)].d);      ;}
     break;
 
   case 235:
-#line 2750 "Gmsh.y"
+#line 2759 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) <= (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 236:
-#line 2751 "Gmsh.y"
+#line 2760 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) >= (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 237:
-#line 2752 "Gmsh.y"
+#line 2761 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) == (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 238:
-#line 2753 "Gmsh.y"
+#line 2762 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) != (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 239:
-#line 2754 "Gmsh.y"
+#line 2763 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) && (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 240:
-#line 2755 "Gmsh.y"
+#line 2764 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (3)].d) || (yyvsp[(3) - (3)].d);     ;}
     break;
 
   case 241:
-#line 2756 "Gmsh.y"
+#line 2765 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (5)].d)? (yyvsp[(3) - (5)].d) : (yyvsp[(5) - (5)].d);  ;}
     break;
 
   case 242:
-#line 2757 "Gmsh.y"
+#line 2766 "Gmsh.y"
     { (yyval.d) = exp((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 243:
-#line 2758 "Gmsh.y"
+#line 2767 "Gmsh.y"
     { (yyval.d) = log((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 244:
-#line 2759 "Gmsh.y"
+#line 2768 "Gmsh.y"
     { (yyval.d) = log10((yyvsp[(3) - (4)].d));    ;}
     break;
 
   case 245:
-#line 2760 "Gmsh.y"
+#line 2769 "Gmsh.y"
     { (yyval.d) = sqrt((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 246:
-#line 2761 "Gmsh.y"
+#line 2770 "Gmsh.y"
     { (yyval.d) = sin((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 247:
-#line 2762 "Gmsh.y"
+#line 2771 "Gmsh.y"
     { (yyval.d) = asin((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 248:
-#line 2763 "Gmsh.y"
+#line 2772 "Gmsh.y"
     { (yyval.d) = cos((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 249:
-#line 2764 "Gmsh.y"
+#line 2773 "Gmsh.y"
     { (yyval.d) = acos((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 250:
-#line 2765 "Gmsh.y"
+#line 2774 "Gmsh.y"
     { (yyval.d) = tan((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 251:
-#line 2766 "Gmsh.y"
+#line 2775 "Gmsh.y"
     { (yyval.d) = atan((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 252:
-#line 2767 "Gmsh.y"
+#line 2776 "Gmsh.y"
     { (yyval.d) = atan2((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d));;}
     break;
 
   case 253:
-#line 2768 "Gmsh.y"
+#line 2777 "Gmsh.y"
     { (yyval.d) = sinh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 254:
-#line 2769 "Gmsh.y"
+#line 2778 "Gmsh.y"
     { (yyval.d) = cosh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 255:
-#line 2770 "Gmsh.y"
+#line 2779 "Gmsh.y"
     { (yyval.d) = tanh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 256:
-#line 2771 "Gmsh.y"
+#line 2780 "Gmsh.y"
     { (yyval.d) = fabs((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 257:
-#line 2772 "Gmsh.y"
+#line 2781 "Gmsh.y"
     { (yyval.d) = floor((yyvsp[(3) - (4)].d));    ;}
     break;
 
   case 258:
-#line 2773 "Gmsh.y"
+#line 2782 "Gmsh.y"
     { (yyval.d) = ceil((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 259:
-#line 2774 "Gmsh.y"
+#line 2783 "Gmsh.y"
     { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 260:
-#line 2775 "Gmsh.y"
+#line 2784 "Gmsh.y"
     { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 261:
-#line 2776 "Gmsh.y"
+#line 2785 "Gmsh.y"
     { (yyval.d) = sqrt((yyvsp[(3) - (6)].d)*(yyvsp[(3) - (6)].d)+(yyvsp[(5) - (6)].d)*(yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 262:
-#line 2777 "Gmsh.y"
+#line 2786 "Gmsh.y"
     { (yyval.d) = (yyvsp[(3) - (4)].d)*(double)rand()/(double)RAND_MAX; ;}
     break;
 
   case 263:
-#line 2779 "Gmsh.y"
+#line 2788 "Gmsh.y"
     { (yyval.d) = exp((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 264:
-#line 2780 "Gmsh.y"
+#line 2789 "Gmsh.y"
     { (yyval.d) = log((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 265:
-#line 2781 "Gmsh.y"
+#line 2790 "Gmsh.y"
     { (yyval.d) = log10((yyvsp[(3) - (4)].d));    ;}
     break;
 
   case 266:
-#line 2782 "Gmsh.y"
+#line 2791 "Gmsh.y"
     { (yyval.d) = sqrt((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 267:
-#line 2783 "Gmsh.y"
+#line 2792 "Gmsh.y"
     { (yyval.d) = sin((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 268:
-#line 2784 "Gmsh.y"
+#line 2793 "Gmsh.y"
     { (yyval.d) = asin((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 269:
-#line 2785 "Gmsh.y"
+#line 2794 "Gmsh.y"
     { (yyval.d) = cos((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 270:
-#line 2786 "Gmsh.y"
+#line 2795 "Gmsh.y"
     { (yyval.d) = acos((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 271:
-#line 2787 "Gmsh.y"
+#line 2796 "Gmsh.y"
     { (yyval.d) = tan((yyvsp[(3) - (4)].d));      ;}
     break;
 
   case 272:
-#line 2788 "Gmsh.y"
+#line 2797 "Gmsh.y"
     { (yyval.d) = atan((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 273:
-#line 2789 "Gmsh.y"
+#line 2798 "Gmsh.y"
     { (yyval.d) = atan2((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d));;}
     break;
 
   case 274:
-#line 2790 "Gmsh.y"
+#line 2799 "Gmsh.y"
     { (yyval.d) = sinh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 275:
-#line 2791 "Gmsh.y"
+#line 2800 "Gmsh.y"
     { (yyval.d) = cosh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 276:
-#line 2792 "Gmsh.y"
+#line 2801 "Gmsh.y"
     { (yyval.d) = tanh((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 277:
-#line 2793 "Gmsh.y"
+#line 2802 "Gmsh.y"
     { (yyval.d) = fabs((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 278:
-#line 2794 "Gmsh.y"
+#line 2803 "Gmsh.y"
     { (yyval.d) = floor((yyvsp[(3) - (4)].d));    ;}
     break;
 
   case 279:
-#line 2795 "Gmsh.y"
+#line 2804 "Gmsh.y"
     { (yyval.d) = ceil((yyvsp[(3) - (4)].d));     ;}
     break;
 
   case 280:
-#line 2796 "Gmsh.y"
+#line 2805 "Gmsh.y"
     { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 281:
-#line 2797 "Gmsh.y"
+#line 2806 "Gmsh.y"
     { (yyval.d) = fmod((yyvsp[(3) - (6)].d), (yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 282:
-#line 2798 "Gmsh.y"
+#line 2807 "Gmsh.y"
     { (yyval.d) = sqrt((yyvsp[(3) - (6)].d)*(yyvsp[(3) - (6)].d)+(yyvsp[(5) - (6)].d)*(yyvsp[(5) - (6)].d)); ;}
     break;
 
   case 283:
-#line 2799 "Gmsh.y"
+#line 2808 "Gmsh.y"
     { (yyval.d) = (yyvsp[(3) - (4)].d)*(double)rand()/(double)RAND_MAX; ;}
     break;
 
   case 284:
-#line 2808 "Gmsh.y"
+#line 2817 "Gmsh.y"
     { (yyval.d) = (yyvsp[(1) - (1)].d); ;}
     break;
 
   case 285:
-#line 2809 "Gmsh.y"
+#line 2818 "Gmsh.y"
     { (yyval.d) = 3.141592653589793; ;}
     break;
 
   case 286:
-#line 2810 "Gmsh.y"
+#line 2819 "Gmsh.y"
     { (yyval.d) = ParUtil::Instance()->rank(); ;}
     break;
 
   case 287:
-#line 2811 "Gmsh.y"
+#line 2820 "Gmsh.y"
     { (yyval.d) = ParUtil::Instance()->size(); ;}
     break;
 
   case 288:
-#line 2812 "Gmsh.y"
+#line 2821 "Gmsh.y"
     { (yyval.d) = Get_GmshMajorVersion(); ;}
     break;
 
   case 289:
-#line 2813 "Gmsh.y"
+#line 2822 "Gmsh.y"
     { (yyval.d) = Get_GmshMinorVersion(); ;}
     break;
 
   case 290:
-#line 2814 "Gmsh.y"
+#line 2823 "Gmsh.y"
     { (yyval.d) = Get_GmshPatchVersion(); ;}
     break;
 
   case 291:
-#line 2819 "Gmsh.y"
+#line 2828 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (1)].c);
@@ -7081,7 +7090,7 @@ yyreduce:
     break;
 
   case 292:
-#line 2835 "Gmsh.y"
+#line 2844 "Gmsh.y"
     {
       char tmpstring[1024];
       sprintf(tmpstring, "%s_%d", (yyvsp[(1) - (5)].c), (int)(yyvsp[(4) - (5)].d)) ;
@@ -7099,7 +7108,7 @@ yyreduce:
     break;
 
   case 293:
-#line 2850 "Gmsh.y"
+#line 2859 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (4)].c);
@@ -7122,7 +7131,7 @@ yyreduce:
     break;
 
   case 294:
-#line 2870 "Gmsh.y"
+#line 2879 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(2) - (4)].c);
@@ -7138,7 +7147,7 @@ yyreduce:
     break;
 
   case 295:
-#line 2883 "Gmsh.y"
+#line 2892 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (2)].c);
@@ -7154,7 +7163,7 @@ yyreduce:
     break;
 
   case 296:
-#line 2896 "Gmsh.y"
+#line 2905 "Gmsh.y"
     {
       Symbol TheSymbol;
       TheSymbol.Name = (yyvsp[(1) - (5)].c);
@@ -7177,7 +7186,7 @@ yyreduce:
     break;
 
   case 297:
-#line 2919 "Gmsh.y"
+#line 2928 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -7198,7 +7207,7 @@ yyreduce:
     break;
 
   case 298:
-#line 2937 "Gmsh.y"
+#line 2946 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -7219,7 +7228,7 @@ yyreduce:
     break;
 
   case 299:
-#line 2955 "Gmsh.y"
+#line 2964 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -7240,7 +7249,7 @@ yyreduce:
     break;
 
   case 300:
-#line 2973 "Gmsh.y"
+#line 2982 "Gmsh.y"
     {
       double (*pNumOpt)(int num, int action, double value);
       StringXNumber *pNumCat;
@@ -7261,7 +7270,7 @@ yyreduce:
     break;
 
   case 301:
-#line 2991 "Gmsh.y"
+#line 3000 "Gmsh.y"
     { 
       (yyval.d) = GetValue((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].d));
       Free((yyvsp[(3) - (6)].c));
@@ -7269,70 +7278,70 @@ yyreduce:
     break;
 
   case 302:
-#line 2999 "Gmsh.y"
+#line 3008 "Gmsh.y"
     {
       memcpy((yyval.v), (yyvsp[(1) - (1)].v), 5*sizeof(double));
     ;}
     break;
 
   case 303:
-#line 3003 "Gmsh.y"
+#line 3012 "Gmsh.y"
     {
       for(int i = 0; i < 5; i++) (yyval.v)[i] = -(yyvsp[(2) - (2)].v)[i];
     ;}
     break;
 
   case 304:
-#line 3007 "Gmsh.y"
+#line 3016 "Gmsh.y"
     { 
       for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(2) - (2)].v)[i];
     ;}
     break;
 
   case 305:
-#line 3011 "Gmsh.y"
+#line 3020 "Gmsh.y"
     { 
       for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(1) - (3)].v)[i] - (yyvsp[(3) - (3)].v)[i];
     ;}
     break;
 
   case 306:
-#line 3015 "Gmsh.y"
+#line 3024 "Gmsh.y"
     {
       for(int i = 0; i < 5; i++) (yyval.v)[i] = (yyvsp[(1) - (3)].v)[i] + (yyvsp[(3) - (3)].v)[i];
     ;}
     break;
 
   case 307:
-#line 3022 "Gmsh.y"
+#line 3031 "Gmsh.y"
     { 
       (yyval.v)[0] = (yyvsp[(2) - (11)].d);  (yyval.v)[1] = (yyvsp[(4) - (11)].d);  (yyval.v)[2] = (yyvsp[(6) - (11)].d);  (yyval.v)[3] = (yyvsp[(8) - (11)].d); (yyval.v)[4] = (yyvsp[(10) - (11)].d);
     ;}
     break;
 
   case 308:
-#line 3026 "Gmsh.y"
+#line 3035 "Gmsh.y"
     { 
       (yyval.v)[0] = (yyvsp[(2) - (9)].d);  (yyval.v)[1] = (yyvsp[(4) - (9)].d);  (yyval.v)[2] = (yyvsp[(6) - (9)].d);  (yyval.v)[3] = (yyvsp[(8) - (9)].d); (yyval.v)[4] = 1.0;
     ;}
     break;
 
   case 309:
-#line 3030 "Gmsh.y"
+#line 3039 "Gmsh.y"
     {
       (yyval.v)[0] = (yyvsp[(2) - (7)].d);  (yyval.v)[1] = (yyvsp[(4) - (7)].d);  (yyval.v)[2] = (yyvsp[(6) - (7)].d);  (yyval.v)[3] = 0.0; (yyval.v)[4] = 1.0;
     ;}
     break;
 
   case 310:
-#line 3034 "Gmsh.y"
+#line 3043 "Gmsh.y"
     {
       (yyval.v)[0] = (yyvsp[(2) - (7)].d);  (yyval.v)[1] = (yyvsp[(4) - (7)].d);  (yyval.v)[2] = (yyvsp[(6) - (7)].d);  (yyval.v)[3] = 0.0; (yyval.v)[4] = 1.0;
     ;}
     break;
 
   case 311:
-#line 3041 "Gmsh.y"
+#line 3050 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(List_T*));
       List_Add((yyval.l), &((yyvsp[(1) - (1)].l)));
@@ -7340,14 +7349,14 @@ yyreduce:
     break;
 
   case 312:
-#line 3046 "Gmsh.y"
+#line 3055 "Gmsh.y"
     {
       List_Add((yyval.l), &((yyvsp[(3) - (3)].l)));
     ;}
     break;
 
   case 313:
-#line 3054 "Gmsh.y"
+#line 3063 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(double));
       List_Add((yyval.l), &((yyvsp[(1) - (1)].d)));
@@ -7355,14 +7364,14 @@ yyreduce:
     break;
 
   case 314:
-#line 3059 "Gmsh.y"
+#line 3068 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(1) - (1)].l);
     ;}
     break;
 
   case 315:
-#line 3063 "Gmsh.y"
+#line 3072 "Gmsh.y"
     {
       // creates an empty list
       (yyval.l) = List_Create(2, 1, sizeof(double));
@@ -7370,14 +7379,14 @@ yyreduce:
     break;
 
   case 316:
-#line 3068 "Gmsh.y"
+#line 3077 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(2) - (3)].l);
     ;}
     break;
 
   case 317:
-#line 3072 "Gmsh.y"
+#line 3081 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(3) - (4)].l);
       for(int i = 0; i < List_Nbr((yyval.l)); i++){
@@ -7388,7 +7397,7 @@ yyreduce:
     break;
 
   case 318:
-#line 3080 "Gmsh.y"
+#line 3089 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(4) - (5)].l);
       for(int i = 0; i < List_Nbr((yyval.l)); i++){
@@ -7399,7 +7408,7 @@ yyreduce:
     break;
 
   case 319:
-#line 3091 "Gmsh.y"
+#line 3100 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(2) - (2)].l);
       for(int i = 0; i < List_Nbr((yyval.l)); i++){
@@ -7410,7 +7419,7 @@ yyreduce:
     break;
 
   case 320:
-#line 3099 "Gmsh.y"
+#line 3108 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(3) - (3)].l);
       for(int i = 0; i < List_Nbr((yyval.l)); i++){
@@ -7421,7 +7430,7 @@ yyreduce:
     break;
 
   case 321:
-#line 3107 "Gmsh.y"
+#line 3116 "Gmsh.y"
     { 
       (yyval.l) = List_Create(2, 1, sizeof(double)); 
       for(double d = (yyvsp[(1) - (3)].d); ((yyvsp[(1) - (3)].d) < (yyvsp[(3) - (3)].d)) ? (d <= (yyvsp[(3) - (3)].d)) : (d >= (yyvsp[(3) - (3)].d)); ((yyvsp[(1) - (3)].d) < (yyvsp[(3) - (3)].d)) ? (d += 1.) : (d -= 1.)) 
@@ -7430,7 +7439,7 @@ yyreduce:
     break;
 
   case 322:
-#line 3113 "Gmsh.y"
+#line 3122 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(double)); 
       if(!(yyvsp[(5) - (5)].d) || ((yyvsp[(1) - (5)].d) < (yyvsp[(3) - (5)].d) && (yyvsp[(5) - (5)].d) < 0) || ((yyvsp[(1) - (5)].d) > (yyvsp[(3) - (5)].d) && (yyvsp[(5) - (5)].d) > 0)){
@@ -7444,7 +7453,7 @@ yyreduce:
     break;
 
   case 323:
-#line 3124 "Gmsh.y"
+#line 3133 "Gmsh.y"
     {
       // Returns the coordinates of a point and fills a list with it.
       // This allows to ensure e.g. that relative point positions are
@@ -7467,7 +7476,7 @@ yyreduce:
     break;
 
   case 324:
-#line 3144 "Gmsh.y"
+#line 3153 "Gmsh.y"
     {
       (yyval.l) = List_Create(List_Nbr((yyvsp[(1) - (1)].l)), 1, sizeof(double));
       for(int i = 0; i < List_Nbr((yyvsp[(1) - (1)].l)); i++){
@@ -7480,7 +7489,7 @@ yyreduce:
     break;
 
   case 325:
-#line 3154 "Gmsh.y"
+#line 3163 "Gmsh.y"
     {
       (yyval.l) = List_Create(List_Nbr((yyvsp[(1) - (1)].l)), 1, sizeof(double));
       for(int i = 0; i < List_Nbr((yyvsp[(1) - (1)].l)); i++){
@@ -7493,7 +7502,7 @@ yyreduce:
     break;
 
   case 326:
-#line 3164 "Gmsh.y"
+#line 3173 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -7513,7 +7522,7 @@ yyreduce:
     break;
 
   case 327:
-#line 3181 "Gmsh.y"
+#line 3190 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(double));
       Symbol TheSymbol;
@@ -7540,7 +7549,7 @@ yyreduce:
     break;
 
   case 328:
-#line 3208 "Gmsh.y"
+#line 3217 "Gmsh.y"
     {
       (yyval.l) = List_Create(2, 1, sizeof(double));
       List_Add((yyval.l), &((yyvsp[(1) - (1)].d)));
@@ -7548,21 +7557,21 @@ yyreduce:
     break;
 
   case 329:
-#line 3213 "Gmsh.y"
+#line 3222 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(1) - (1)].l);
     ;}
     break;
 
   case 330:
-#line 3217 "Gmsh.y"
+#line 3226 "Gmsh.y"
     {
       List_Add((yyval.l), &((yyvsp[(3) - (3)].d)));
     ;}
     break;
 
   case 331:
-#line 3221 "Gmsh.y"
+#line 3230 "Gmsh.y"
     {
       for(int i = 0; i < List_Nbr((yyvsp[(3) - (3)].l)); i++){
 	double d;
@@ -7574,21 +7583,21 @@ yyreduce:
     break;
 
   case 332:
-#line 3234 "Gmsh.y"
+#line 3243 "Gmsh.y"
     {
       (yyval.u) = CTX.PACK_COLOR((int)(yyvsp[(2) - (9)].d), (int)(yyvsp[(4) - (9)].d), (int)(yyvsp[(6) - (9)].d), (int)(yyvsp[(8) - (9)].d));
     ;}
     break;
 
   case 333:
-#line 3238 "Gmsh.y"
+#line 3247 "Gmsh.y"
     {
       (yyval.u) = CTX.PACK_COLOR((int)(yyvsp[(2) - (7)].d), (int)(yyvsp[(4) - (7)].d), (int)(yyvsp[(6) - (7)].d), 255);
     ;}
     break;
 
   case 334:
-#line 3250 "Gmsh.y"
+#line 3259 "Gmsh.y"
     {
       int flag;
       (yyval.u) = Get_ColorForString(ColorString, -1, (yyvsp[(1) - (1)].c), &flag);
@@ -7598,7 +7607,7 @@ yyreduce:
     break;
 
   case 335:
-#line 3257 "Gmsh.y"
+#line 3266 "Gmsh.y"
     {
       unsigned int (*pColOpt)(int num, int action, unsigned int value);
       StringXColor *pColCat;
@@ -7619,14 +7628,14 @@ yyreduce:
     break;
 
   case 336:
-#line 3278 "Gmsh.y"
+#line 3287 "Gmsh.y"
     {
       (yyval.l) = (yyvsp[(2) - (3)].l);
     ;}
     break;
 
   case 337:
-#line 3282 "Gmsh.y"
+#line 3291 "Gmsh.y"
     {
       (yyval.l) = List_Create(256, 10, sizeof(unsigned int));
       GmshColorTable *ct = Get_ColorTable((int)(yyvsp[(3) - (6)].d));
@@ -7641,7 +7650,7 @@ yyreduce:
     break;
 
   case 338:
-#line 3297 "Gmsh.y"
+#line 3306 "Gmsh.y"
     {
       (yyval.l) = List_Create(256, 10, sizeof(unsigned int));
       List_Add((yyval.l), &((yyvsp[(1) - (1)].u)));
@@ -7649,35 +7658,35 @@ yyreduce:
     break;
 
   case 339:
-#line 3302 "Gmsh.y"
+#line 3311 "Gmsh.y"
     {
       List_Add((yyval.l), &((yyvsp[(3) - (3)].u)));
     ;}
     break;
 
   case 340:
-#line 3309 "Gmsh.y"
+#line 3318 "Gmsh.y"
     {
       (yyval.c) = (yyvsp[(1) - (1)].c);
     ;}
     break;
 
   case 341:
-#line 3313 "Gmsh.y"
+#line 3322 "Gmsh.y"
     {
       Msg(WARNING, "Named string expressions not implemented yet");
     ;}
     break;
 
   case 342:
-#line 3320 "Gmsh.y"
+#line 3329 "Gmsh.y"
     {
       (yyval.c) = (yyvsp[(1) - (1)].c);
     ;}
     break;
 
   case 343:
-#line 3324 "Gmsh.y"
+#line 3333 "Gmsh.y"
     {
       (yyval.c) = (char *)Malloc(32*sizeof(char));
       time_t now;
@@ -7688,7 +7697,7 @@ yyreduce:
     break;
 
   case 344:
-#line 3332 "Gmsh.y"
+#line 3341 "Gmsh.y"
     {
       (yyval.c) = (char *)Malloc((strlen((yyvsp[(3) - (6)].c))+strlen((yyvsp[(5) - (6)].c))+1)*sizeof(char));
       strcpy((yyval.c), (yyvsp[(3) - (6)].c));
@@ -7699,7 +7708,7 @@ yyreduce:
     break;
 
   case 345:
-#line 3340 "Gmsh.y"
+#line 3349 "Gmsh.y"
     {
       (yyval.c) = (char *)Malloc((strlen((yyvsp[(3) - (4)].c))+1)*sizeof(char));
       int i;
@@ -7716,7 +7725,7 @@ yyreduce:
     break;
 
   case 346:
-#line 3354 "Gmsh.y"
+#line 3363 "Gmsh.y"
     {
       (yyval.c) = (char *)Malloc((strlen((yyvsp[(3) - (4)].c))+1)*sizeof(char));
       int i;
@@ -7733,14 +7742,14 @@ yyreduce:
     break;
 
   case 347:
-#line 3368 "Gmsh.y"
+#line 3377 "Gmsh.y"
     {
       (yyval.c) = (yyvsp[(3) - (4)].c);
     ;}
     break;
 
   case 348:
-#line 3372 "Gmsh.y"
+#line 3381 "Gmsh.y"
     {
       char tmpstring[1024];
       int i = PrintListOfDouble((yyvsp[(3) - (6)].c), (yyvsp[(5) - (6)].l), tmpstring);
@@ -7762,7 +7771,7 @@ yyreduce:
     break;
 
   case 349:
-#line 3391 "Gmsh.y"
+#line 3400 "Gmsh.y"
     { 
       const char* (*pStrOpt)(int num, int action, const char *value);
       StringXString *pStrCat;
@@ -7788,7 +7797,7 @@ yyreduce:
     break;
 
   case 350:
-#line 3414 "Gmsh.y"
+#line 3423 "Gmsh.y"
     { 
       const char* (*pStrOpt)(int num, int action, const char *value);
       StringXString *pStrCat;
@@ -7815,7 +7824,7 @@ yyreduce:
 
 
 /* Line 1267 of yacc.c.  */
-#line 7819 "Gmsh.tab.cpp"
+#line 7828 "Gmsh.tab.cpp"
       default: break;
     }
   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -8029,7 +8038,7 @@ yyreturn:
 }
 
 
-#line 3438 "Gmsh.y"
+#line 3447 "Gmsh.y"
 
 
 void DeleteSymbol(void *a, void *b)
diff --git a/Parser/Gmsh.y b/Parser/Gmsh.y
index 14a9321533..ed647b572c 100644
--- a/Parser/Gmsh.y
+++ b/Parser/Gmsh.y
@@ -1,5 +1,5 @@
 %{
-// $Id: Gmsh.y,v 1.308 2008-03-29 10:19:41 geuzaine Exp $
+// $Id: Gmsh.y,v 1.309 2008-04-22 07:37:14 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -250,11 +250,6 @@ View :
 	ViewData->setName($2);
 	ViewData->setFileName(gmsh_yyname);
 	ViewData->setFileIndex(gmsh_yyviewindex++);
-	if(ViewData->adaptive){
-	  ViewData->adaptive->setGlobalResolutionLevel
-	    (ViewData, PViewOptions::reference.MaxRecursionLevel);
-	  ViewData->adaptive->setTolerance(PViewOptions::reference.TargetError);
-	}
 	new PView(ViewData);
       }
       else
@@ -525,14 +520,28 @@ InterpolationMatrix :
     tInterpolationScheme '{' RecursiveListOfListOfDouble '}' 
                          '{' RecursiveListOfListOfDouble '}'  tEND
     {
-      ViewData->adaptive = new Adaptive_Post_View(ViewData, $3, $6);
+      int type = 
+	(ViewData->NbSL || ViewData->NbVL) ? 1 : 
+	(ViewData->NbST || ViewData->NbVT) ? 3 : 
+	(ViewData->NbSQ || ViewData->NbVQ) ? 4 : 
+	(ViewData->NbSS || ViewData->NbVS) ? 6 : 
+      	(ViewData->NbSH || ViewData->NbVH) ? 12 : 
+	0;
+      ViewData->setInterpolationScheme(type, $3, $6);
     }
  |  tInterpolationScheme '{' RecursiveListOfListOfDouble '}' 
                          '{' RecursiveListOfListOfDouble '}'  
                          '{' RecursiveListOfListOfDouble '}'  
                          '{' RecursiveListOfListOfDouble '}'  tEND
     {
-      ViewData->adaptive = new Adaptive_Post_View(ViewData, $3, $6, $9, $12);
+      int type = 
+	(ViewData->NbSL || ViewData->NbVL) ? 1 : 
+	(ViewData->NbST || ViewData->NbVT) ? 3 : 
+	(ViewData->NbSQ || ViewData->NbVQ) ? 4 : 
+	(ViewData->NbSS || ViewData->NbVS) ? 6 : 
+      	(ViewData->NbSH || ViewData->NbVH) ? 12 : 
+	0;
+      ViewData->setInterpolationScheme(type, $3, $6, $9, $12);
     }
 ;
 
diff --git a/Parser/Gmsh.yy.cpp b/Parser/Gmsh.yy.cpp
index 3c206685c0..04b9fc3db7 100644
--- a/Parser/Gmsh.yy.cpp
+++ b/Parser/Gmsh.yy.cpp
@@ -835,7 +835,7 @@ int gmsh_yy_flex_debug = 0;
 char *gmsh_yytext;
 #line 1 "Gmsh.l"
 #line 2 "Gmsh.l"
-// $Id: Gmsh.yy.cpp,v 1.358 2008-04-14 18:30:49 geuzaine Exp $
+// $Id: Gmsh.yy.cpp,v 1.359 2008-04-22 07:37:15 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
diff --git a/Parser/Makefile b/Parser/Makefile
index c8c30d69fb..a17e45237e 100644
--- a/Parser/Makefile
+++ b/Parser/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.148 2008-04-06 07:51:37 geuzaine Exp $
+# $Id: Makefile,v 1.149 2008-04-22 07:37:16 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -74,23 +74,22 @@ Gmsh.tab.o: Gmsh.tab.cpp ../Common/Message.h ../DataStr/Malloc.h \
   ../Post/ColorTable.h ../Post/PView.h ../Post/PViewData.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
   ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../Common/GmshMatrix.h ../Parallel/ParUtil.h \
-  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Context.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.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/SBoundingBox3d.h ../Geo/SPoint2.h ../Geo/ExtrudeParams.h \
-  ../Common/SmoothData.h ../Geo/GeoInterpolation.h ../Geo/Geo.h \
-  ../Mesh/Generator.h ../Graphics/Draw.h ../Common/Colors.h \
-  ../Common/Options.h Parser.h OpenFile.h ../Common/CommandLine.h \
-  FunctionManager.h ../Common/OS.h CreateFile.h ../Mesh/Field.h \
-  ../Mesh/BackgroundMesh.h
+  ../Common/GmshMatrix.h ../Parallel/ParUtil.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h ../Common/Context.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SBoundingBox3d.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/SBoundingBox3d.h \
+  ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
+  ../Geo/GeoInterpolation.h ../Geo/Geo.h ../Mesh/Generator.h \
+  ../Graphics/Draw.h ../Common/Colors.h ../Common/Options.h Parser.h \
+  OpenFile.h ../Common/CommandLine.h FunctionManager.h ../Common/OS.h \
+  CreateFile.h ../Mesh/Field.h ../Mesh/BackgroundMesh.h
 Gmsh.yy.o: Gmsh.yy.cpp ../Common/Message.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../Geo/Geo.h ../Common/GmshDefines.h \
   ../Geo/gmshSurface.h ../Geo/Pair.h ../Geo/Range.h ../Geo/SPoint2.h \
diff --git a/Plugin/Levelset.cpp b/Plugin/Levelset.cpp
index 2283afe211..3c87c4693f 100644
--- a/Plugin/Levelset.cpp
+++ b/Plugin/Levelset.cpp
@@ -1,4 +1,4 @@
-// $Id: Levelset.cpp,v 1.45 2008-04-15 19:02:32 geuzaine Exp $
+// $Id: Levelset.cpp,v 1.46 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -23,6 +23,7 @@
 #include "MakeSimplex.h"
 #include "List.h"
 #include "Numeric.h"
+#include "adaptiveData.h"
 
 static const int exn[13][12][2] = {
   {{0,0}}, // point
@@ -408,17 +409,12 @@ void GMSH_LevelsetPlugin::_cutAndAddElements(PViewData *vdata, PViewData *wdata,
 PView *GMSH_LevelsetPlugin::execute(PView *v)
 {
   if(v->getData()->isAdaptive()){
-    PViewDataList *dv = getDataList(v);
-    if(dv){
-      dv->adaptive->setTolerance(_targetError);
-      if(dv->NbST || dv->NbSS || dv->NbSQ || dv->NbSH){
-        dv->adaptive->setAdaptiveResolutionLevel(dv, _recurLevel, this);
-        v->setChanged(true);
-      }
-    }
+    v->getData()->getAdaptiveData()->changeResolution(_recurLevel, _targetError, this);
+    v->setChanged(true);
   }
 
-  PViewData *vdata = v->getData(), *wdata;
+  // get adaptive data is available
+  PViewData *vdata = v->getData(true), *wdata;
   if(_valueView < 0) {
     wdata = vdata;
   }
@@ -501,7 +497,7 @@ PView *GMSH_LevelsetPlugin::execute(PView *v)
 // On high order maps, we draw only the elements that have a cut with
 // the levelset, this is as accurate as it should be
 
-static bool recur_sign_change(adapt_triangle *t, double val,
+static bool recur_sign_change(adaptiveTriangle *t, 
                               const GMSH_LevelsetPlugin *plug)
 {
   if(!t->e[0] || t->visible){
@@ -515,15 +511,15 @@ static bool recur_sign_change(adapt_triangle *t, double val,
     return t->visible;
   }
   else{
-    bool sc1 = recur_sign_change(t->e[0], val, plug);
-    bool sc2 = recur_sign_change(t->e[1], val, plug);
-    bool sc3 = recur_sign_change(t->e[2], val, plug);
-    bool sc4 = recur_sign_change(t->e[3], val, plug);
+    bool sc1 = recur_sign_change(t->e[0], plug);
+    bool sc2 = recur_sign_change(t->e[1], plug);
+    bool sc3 = recur_sign_change(t->e[2], plug);
+    bool sc4 = recur_sign_change(t->e[3], plug);
     if(sc1 || sc2 || sc3 || sc4){
-      if (!sc1) t->e[0]->visible = true;
-      if (!sc2) t->e[1]->visible = true;
-      if (!sc3) t->e[2]->visible = true;
-      if (!sc4) t->e[3]->visible = true;
+      if(!sc1) t->e[0]->visible = true;
+      if(!sc2) t->e[1]->visible = true;
+      if(!sc3) t->e[2]->visible = true;
+      if(!sc4) t->e[3]->visible = true;
       return true;
     }
     t->visible = false;
@@ -531,7 +527,38 @@ static bool recur_sign_change(adapt_triangle *t, double val,
   }      
 }
 
-static bool recur_sign_change(adapt_tet *t, double val, 
+static bool recur_sign_change(adaptiveQuadrangle *q, 
+                              const GMSH_LevelsetPlugin *plug)
+{
+  if(!q->e[0] || q->visible){
+    double v1 = plug->levelset(q->p[0]->X, q->p[0]->Y, q->p[0]->Z, q->p[0]->val);
+    double v2 = plug->levelset(q->p[1]->X, q->p[1]->Y, q->p[1]->Z, q->p[1]->val);
+    double v3 = plug->levelset(q->p[2]->X, q->p[2]->Y, q->p[2]->Z, q->p[2]->val);
+    double v4 = plug->levelset(q->p[3]->X, q->p[3]->Y, q->p[3]->Z, q->p[3]->val);
+    if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0)
+      q->visible = false;
+    else
+      q->visible = true;
+    return q->visible;
+  }
+  else{
+    bool sc1 = recur_sign_change(q->e[0], plug);
+    bool sc2 = recur_sign_change(q->e[1], plug);
+    bool sc3 = recur_sign_change(q->e[2], plug);
+    bool sc4 = recur_sign_change(q->e[3], plug);
+    if(sc1 || sc2 || sc3 || sc4 ){
+      if(!sc1) q->e[0]->visible = true;
+      if(!sc2) q->e[1]->visible = true;
+      if(!sc3) q->e[2]->visible = true;
+      if(!sc4) q->e[3]->visible = true;
+      return true;
+    }
+    q->visible = false;
+    return false;
+  }      
+}
+
+static bool recur_sign_change(adaptiveTetrahedron *t, 
                               const GMSH_LevelsetPlugin *plug)
 {
   if(!t->e[0] || t->visible){
@@ -546,14 +573,14 @@ static bool recur_sign_change(adapt_tet *t, double val,
     return t->visible;
   }
   else{
-    bool sc1 = recur_sign_change(t->e[0], val, plug);
-    bool sc2 = recur_sign_change(t->e[1], val, plug);
-    bool sc3 = recur_sign_change(t->e[2], val, plug);
-    bool sc4 = recur_sign_change(t->e[3], val, plug);
-    bool sc5 = recur_sign_change(t->e[4], val, plug);
-    bool sc6 = recur_sign_change(t->e[5], val, plug);
-    bool sc7 = recur_sign_change(t->e[6], val, plug);
-    bool sc8 = recur_sign_change(t->e[7], val, plug);
+    bool sc1 = recur_sign_change(t->e[0], plug);
+    bool sc2 = recur_sign_change(t->e[1], plug);
+    bool sc3 = recur_sign_change(t->e[2], plug);
+    bool sc4 = recur_sign_change(t->e[3], plug);
+    bool sc5 = recur_sign_change(t->e[4], plug);
+    bool sc6 = recur_sign_change(t->e[5], plug);
+    bool sc7 = recur_sign_change(t->e[6], plug);
+    bool sc8 = recur_sign_change(t->e[7], plug);
     if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8){
       if(!sc1) t->e[0]->visible = true;
       if(!sc2) t->e[1]->visible = true;
@@ -570,7 +597,7 @@ static bool recur_sign_change(adapt_tet *t, double val,
   }      
 }
 
-static bool recur_sign_change(adapt_hex *t, double val,
+static bool recur_sign_change(adaptiveHexahedron *t,
                               const GMSH_LevelsetPlugin *plug)
 {
   if (!t->e[0] || t->visible){
@@ -590,14 +617,14 @@ static bool recur_sign_change(adapt_hex *t, double val,
     return t->visible;
   }
   else{
-    bool sc1 = recur_sign_change(t->e[0], val, plug);
-    bool sc2 = recur_sign_change(t->e[1], val, plug);
-    bool sc3 = recur_sign_change(t->e[2], val, plug);
-    bool sc4 = recur_sign_change(t->e[3], val, plug);
-    bool sc5 = recur_sign_change(t->e[4], val, plug);
-    bool sc6 = recur_sign_change(t->e[5], val, plug);
-    bool sc7 = recur_sign_change(t->e[6], val, plug);
-    bool sc8 = recur_sign_change(t->e[7], val, plug);
+    bool sc1 = recur_sign_change(t->e[0], plug);
+    bool sc2 = recur_sign_change(t->e[1], plug);
+    bool sc3 = recur_sign_change(t->e[2], plug);
+    bool sc4 = recur_sign_change(t->e[3], plug);
+    bool sc5 = recur_sign_change(t->e[4], plug);
+    bool sc6 = recur_sign_change(t->e[5], plug);
+    bool sc7 = recur_sign_change(t->e[6], plug);
+    bool sc8 = recur_sign_change(t->e[7], plug);
     if(sc1 || sc2 || sc3 || sc4 || sc5 || sc6 || sc7 || sc8){
       if (!sc1) t->e[0]->visible = true;
       if (!sc2) t->e[1]->visible = true;
@@ -614,53 +641,22 @@ static bool recur_sign_change(adapt_hex *t, double val,
   }      
 }
 
-static bool recur_sign_change(adapt_quad *q, double val,
-                              const GMSH_LevelsetPlugin *plug)
-{
-  if(!q->e[0]|| q->visible){
-    double v1 = plug->levelset(q->p[0]->X, q->p[0]->Y, q->p[0]->Z, q->p[0]->val);
-    double v2 = plug->levelset(q->p[1]->X, q->p[1]->Y, q->p[1]->Z, q->p[1]->val);
-    double v3 = plug->levelset(q->p[2]->X, q->p[2]->Y, q->p[2]->Z, q->p[2]->val);
-    double v4 = plug->levelset(q->p[3]->X, q->p[3]->Y, q->p[3]->Z, q->p[3]->val);
-    if(v1 * v2 > 0 && v1 * v3 > 0 && v1 * v4 > 0)
-      q->visible = false;
-    else
-      q->visible = true;
-    return q->visible;
-  }
-  else{
-    bool sc1 = recur_sign_change(q->e[0], val, plug);
-    bool sc2 = recur_sign_change(q->e[1], val, plug);
-    bool sc3 = recur_sign_change(q->e[2], val, plug);
-    bool sc4 = recur_sign_change(q->e[3], val, plug);
-    if(sc1 || sc2 || sc3 || sc4 ){
-      if(!sc1) q->e[0]->visible = true;
-      if(!sc2) q->e[1]->visible = true;
-      if(!sc3) q->e[2]->visible = true;
-      if(!sc4) q->e[3]->visible = true;
-      return true;
-    }
-    q->visible = false;
-    return false;
-  }      
-}
-
-void GMSH_LevelsetPlugin::assignSpecificVisibility () const
+void GMSH_LevelsetPlugin::assignSpecificVisibility() const
 {
-  if(adapt_triangle::all_elems.size()){
-    adapt_triangle *t = *adapt_triangle::all_elems.begin();
-    if(!t->visible) t->visible = !recur_sign_change(t, _valueView, this);
+  if(adaptiveTriangle::all.size()){
+    adaptiveTriangle *t = *adaptiveTriangle::all.begin();
+    if(!t->visible) t->visible = !recur_sign_change(t, this);
   }
-  if(adapt_tet::all_elems.size()){
-    adapt_tet *te = *adapt_tet::all_elems.begin();
-    if(!te->visible) te->visible = !recur_sign_change(te, _valueView, this);
+  if(adaptiveQuadrangle::all.size()){
+    adaptiveQuadrangle *qe = *adaptiveQuadrangle::all.begin();
+    if(!qe->visible) qe->visible = !recur_sign_change(qe, this);
   }
-  if(adapt_quad::all_elems.size()){
-    adapt_quad *qe = *adapt_quad::all_elems.begin();
-    if(!qe->visible) qe->visible = !recur_sign_change(qe, _valueView, this);
+  if(adaptiveTetrahedron::all.size()){
+    adaptiveTetrahedron *te = *adaptiveTetrahedron::all.begin();
+    if(!te->visible) te->visible = !recur_sign_change(te, this);
   }
-  if(adapt_hex::all_elems.size()){
-    adapt_hex *he = *adapt_hex::all_elems.begin();
-    if(!he->visible) he->visible = !recur_sign_change(he, _valueView, this);
+  if(adaptiveHexahedron::all.size()){
+    adaptiveHexahedron *he = *adaptiveHexahedron::all.begin();
+    if(!he->visible) he->visible = !recur_sign_change(he, this);
   }
 }
diff --git a/Plugin/Makefile b/Plugin/Makefile
index d8a744838d..92f03adef5 100644
--- a/Plugin/Makefile
+++ b/Plugin/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.161 2008-04-06 07:51:37 geuzaine Exp $
+# $Id: Makefile,v 1.162 2008-04-22 07:37:16 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -75,113 +75,108 @@ depend:
 # DO NOT DELETE THIS LINE
 Plugin.o: Plugin.cpp Plugin.h ../Common/Options.h ../Post/ColorTable.h \
   ../Common/Message.h ../Post/PView.h ../Post/PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Common/GmshMatrix.h
 PluginManager.o: PluginManager.cpp Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h PluginManager.h CutMap.h Levelset.h CutGrid.h \
-  StreamLines.h CutPlane.h CutParametric.h CutSphere.h Skin.h \
-  ../DataStr/Tree.h ../DataStr/avl.h Extract.h ExtractElements.h \
-  ExtractEdges.h HarmonicToTime.h ModulusPhase.h Integrate.h Gradient.h \
-  Curl.h Divergence.h Annotate.h Remove.h MakeSimplex.h Smooth.h \
-  Transform.h TransformLatLon.h Triangulate.h Warp.h SphericalRaise.h \
-  Eigenvectors.h Eigenvalues.h Lambda2.h Evaluate.h ../Post/OctreePost.h \
-  ../Common/Octree.h ../Common/OctreeInternals.h Probe.h FieldView.h \
-  GSHHS.h ../Common/Context.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  PluginManager.h CutMap.h Levelset.h CutGrid.h StreamLines.h CutPlane.h \
+  CutParametric.h CutSphere.h Skin.h ../DataStr/Tree.h ../DataStr/avl.h \
+  Extract.h ExtractElements.h ExtractEdges.h HarmonicToTime.h \
+  ModulusPhase.h Integrate.h Gradient.h Curl.h Divergence.h Annotate.h \
+  Remove.h MakeSimplex.h Smooth.h Transform.h TransformLatLon.h \
+  Triangulate.h Warp.h SphericalRaise.h Eigenvectors.h Eigenvalues.h \
+  Lambda2.h Evaluate.h ../Post/OctreePost.h ../Common/Octree.h \
+  ../Common/OctreeInternals.h Probe.h FieldView.h GSHHS.h \
+  ../Common/Context.h
 Levelset.o: Levelset.cpp Levelset.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h MakeSimplex.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  MakeSimplex.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
+  ../Post/adaptiveData.h
 CutPlane.o: CutPlane.cpp CutPlane.h Levelset.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Common/Context.h \
-  ../Common/GmshUI.h ../Graphics/Draw.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Common/Context.h ../Common/GmshUI.h \
+  ../Graphics/Draw.h
 CutSphere.o: CutSphere.cpp CutSphere.h Levelset.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Common/Context.h \
-  ../Common/GmshUI.h ../Graphics/Draw.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Common/Context.h ../Common/GmshUI.h \
+  ../Graphics/Draw.h
 CutMap.o: CutMap.cpp CutMap.h Levelset.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/Context.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/Context.h
 Smooth.o: Smooth.cpp Smooth.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
 CutParametric.o: CutParametric.cpp ../Post/OctreePost.h \
   ../Common/Octree.h ../Common/OctreeInternals.h CutParametric.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Common/Context.h \
-  ../Common/GmshUI.h ../Graphics/Draw.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Common/Context.h ../Common/GmshUI.h \
+  ../Graphics/Draw.h
 Lambda2.o: Lambda2.cpp Lambda2.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 Eigenvectors.o: Eigenvectors.cpp Eigenvectors.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../Numeric/EigSolve.h
 Eigenvalues.o: Eigenvalues.cpp Eigenvalues.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
 StreamLines.o: StreamLines.cpp StreamLines.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Post/OctreePost.h ../Common/Octree.h \
-  ../Common/OctreeInternals.h ../Common/Context.h ../Common/GmshUI.h \
-  ../Graphics/Draw.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h \
+  ../Common/Context.h ../Common/GmshUI.h ../Graphics/Draw.h
 CutGrid.o: CutGrid.cpp ../Post/OctreePost.h ../Common/Octree.h \
   ../Common/OctreeInternals.h CutGrid.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/Context.h ../Common/GmshUI.h \
-  ../Graphics/Draw.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/Context.h ../Common/GmshUI.h ../Graphics/Draw.h
 Transform.o: Transform.cpp Transform.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
 TransformLatLon.o: TransformLatLon.cpp TransformLatLon.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h
 Triangulate.o: Triangulate.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Geo/GPoint.h \
@@ -200,38 +195,36 @@ Triangulate.o: Triangulate.cpp ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/MVertex.h ../Geo/SPoint3.h Triangulate.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.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 ../Common/Context.h
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/Context.h
 Warp.o: Warp.cpp Warp.h Plugin.h ../Common/Options.h ../Post/ColorTable.h \
   ../Common/Message.h ../Post/PView.h ../Post/PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  ../Common/SmoothData.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Common/GmshMatrix.h ../Common/SmoothData.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
 SphericalRaise.o: SphericalRaise.cpp SphericalRaise.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 Skin.o: Skin.cpp Skin.h Plugin.h ../Common/Options.h ../Post/ColorTable.h \
   ../Common/Message.h ../Post/PView.h ../Post/PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  ../DataStr/Tree.h ../DataStr/avl.h ../DataStr/Malloc.h \
-  ../Common/Context.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Common/GmshMatrix.h ../DataStr/Tree.h \
+  ../DataStr/avl.h ../DataStr/Malloc.h ../Common/Context.h
 GSHHS.o: GSHHS.cpp GSHHS.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Mesh/Field.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 ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Mesh/Field.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 ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../DataStr/Tree.h ../DataStr/avl.h \
   ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
@@ -243,51 +236,47 @@ GSHHS.o: GSHHS.cpp GSHHS.h Plugin.h ../Common/Options.h \
   ../Geo/GEntity.h ../Geo/SBoundingBox3d.h
 Extract.o: Extract.cpp Extract.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
 ExtractElements.o: ExtractElements.cpp ExtractElements.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 ExtractEdges.o: ExtractEdges.cpp ExtractEdges.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Mesh/BDS.h ../Geo/GFace.h \
-  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
-  ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h ../Geo/SVector3.h \
-  ../Geo/Pair.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h ../Mesh/BDS.h ../Geo/GFace.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/GEntity.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Geo/SPoint3.h ../Geo/SPoint2.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h
 MakeSimplex.o: MakeSimplex.cpp MakeSimplex.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
 Evaluate.o: Evaluate.cpp Evaluate.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Post/OctreePost.h ../Common/Octree.h \
-  ../Common/OctreeInternals.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Post/OctreePost.h ../Common/Octree.h ../Common/OctreeInternals.h
 FieldView.o: FieldView.cpp FieldView.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Mesh/Field.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 ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Mesh/Field.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 ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../DataStr/Tree.h ../DataStr/avl.h \
   ../Geo/SPoint2.h ../Geo/ExtrudeParams.h ../Common/SmoothData.h \
   ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
@@ -299,39 +288,38 @@ FieldView.o: FieldView.cpp FieldView.h Plugin.h ../Common/Options.h \
   ../Geo/GEntity.h ../Geo/SBoundingBox3d.h
 Integrate.o: Integrate.cpp Integrate.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 Gradient.o: Gradient.cpp Gradient.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 Curl.o: Curl.cpp Curl.h Plugin.h ../Common/Options.h ../Post/ColorTable.h \
   ../Common/Message.h ../Post/PView.h ../Post/PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
-  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
-  ../Post/AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
+  ../Post/PViewData.h ../Common/GmshMatrix.h ../Common/ShapeFunctions.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h
 Divergence.o: Divergence.cpp Divergence.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/ShapeFunctions.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h
 Annotate.o: Annotate.cpp Annotate.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/Context.h ../Common/GmshUI.h \
-  ../Fltk/GUI.h ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h \
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/Context.h ../Common/GmshUI.h ../Fltk/GUI.h \
+  ../Fltk/Opengl_Window.h ../Fltk/Colorbar_Window.h \
   ../Fltk/Popup_Button.h ../Fltk/SpherePosition_Widget.h ../Mesh/Field.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 \
@@ -341,27 +329,25 @@ Annotate.o: Annotate.cpp Annotate.h Plugin.h ../Common/Options.h \
   ../Graphics/Draw.h
 Remove.o: Remove.cpp Remove.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h
 Probe.o: Probe.cpp Probe.h Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Common/Context.h ../Post/OctreePost.h \
-  ../Common/Octree.h ../Common/OctreeInternals.h ../Common/GmshUI.h \
-  ../Graphics/Draw.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  ../Common/Context.h ../Post/OctreePost.h ../Common/Octree.h \
+  ../Common/OctreeInternals.h ../Common/GmshUI.h ../Graphics/Draw.h
 HarmonicToTime.o: HarmonicToTime.cpp HarmonicToTime.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h
 ModulusPhase.o: ModulusPhase.cpp ModulusPhase.h Plugin.h \
   ../Common/Options.h ../Post/ColorTable.h ../Common/Message.h \
-  ../Post/PView.h ../Post/PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
-  ../Post/PViewDataList.h ../Post/PViewData.h ../Post/AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h
+  ../Post/PView.h ../Post/PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Post/PViewOptions.h \
+  ../Post/ColorTable.h ../Post/PViewDataList.h ../Post/PViewData.h \
+  ../Common/GmshMatrix.h
diff --git a/Post/AdaptiveViews.cpp b/Post/AdaptiveViews.cpp
deleted file mode 100644
index c092cdca5f..0000000000
--- a/Post/AdaptiveViews.cpp
+++ /dev/null
@@ -1,1134 +0,0 @@
-//
-// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include <math.h>
-#include <list>
-#include <set>
-#include "AdaptiveViews.h"
-#include "Plugin.h"
-
-std::set<adapt_point> adapt_point::all_points;
-std::list<adapt_edge*> adapt_edge::all_elems;
-std::list<adapt_triangle*> adapt_triangle::all_elems;
-std::list<adapt_tet*> adapt_tet::all_elems;
-std::list<adapt_quad*> adapt_quad::all_elems;
-std::list<adapt_hex*> adapt_hex::all_elems;
-
-int adapt_edge::nbNod = 2;
-int adapt_triangle::nbNod = 3;
-int adapt_tet::nbNod = 4;
-int adapt_quad::nbNod = 4;
-int adapt_hex::nbNod = 8;
-
-void computeShapeFunctions(Double_Matrix *coeffs, Double_Matrix *eexps,
-                           double u, double v, double w, double *sf)
-{
-  static double powsuvw[256];
-  for(int j = 0; j < coeffs->size2(); ++j) {
-    double powu = (*eexps)(j, 0);
-    double powv = (*eexps)(j, 1);
-    double poww = (*eexps)(j, 2);
-    powsuvw[j] = pow(u, powu) * pow(v, powv) * pow(w, poww);
-  }
-
-  for(int i = 0; i < coeffs->size1(); ++i) {
-    sf[i] = 0.0;
-    for(int j = 0; j < coeffs->size2(); ++j) {
-      sf[i] += (*coeffs)(i, j) * powsuvw[j];
-    }
-  }
-}
-
-adapt_point *adapt_point::New(double x, double y, double z,
-                              Double_Matrix *coeffs, Double_Matrix *eexps)
-{
-  adapt_point p;
-  p.x = x;
-  p.y = y;
-  p.z = z;
-  std::set < adapt_point >::iterator it = all_points.find(p);
-  if(it == all_points.end()) {
-    all_points.insert(p);
-    it = all_points.find(p);
-    double *kkk = (double *)(it->shape_functions);
-    computeShapeFunctions(coeffs, eexps, x, y, z, kkk);
-    return (adapt_point *) &(*it);
-  }
-  else
-    return (adapt_point *) &(*it);
-}
-
-void adapt_edge::Create(int maxlevel, Double_Matrix *coeffs,
-                        Double_Matrix *eexps)
-{
-  int level = 0;
-  cleanElement<adapt_edge>();
-  adapt_point *p1 = adapt_point::New(-1, 0, 0, coeffs, eexps);
-  adapt_point *p2 = adapt_point::New(1, 0, 0, coeffs, eexps);
-  adapt_edge *t = new adapt_edge(p1, p2);
-  Recur_Create(t, maxlevel, level, coeffs, eexps);
-}
-
-void adapt_triangle::Create(int maxlevel, Double_Matrix *coeffs,
-                            Double_Matrix *eexps)
-{
-  int level = 0;
-  cleanElement<adapt_triangle>();
-  adapt_point *p1 = adapt_point::New(0, 0, 0, coeffs, eexps);
-  adapt_point *p2 = adapt_point::New(0, 1, 0, coeffs, eexps);
-  adapt_point *p3 = adapt_point::New(1, 0, 0, coeffs, eexps);
-  adapt_triangle *t = new adapt_triangle(p1, p2, p3);
-  Recur_Create(t, maxlevel, level, coeffs, eexps);
-}
-
-
-void adapt_quad::Create(int maxlevel, Double_Matrix *coeffs,
-                        Double_Matrix *eexps)
-{
-  int level = 0;
-  cleanElement<adapt_quad>();
-  adapt_point *p1 = adapt_point::New(-1, -1, 0, coeffs, eexps);
-  adapt_point *p2 = adapt_point::New(1, -1, 0, coeffs, eexps);
-  adapt_point *p3 = adapt_point::New(1, 1, 0, coeffs, eexps);
-  adapt_point *p4 = adapt_point::New(-1, 1, 0, coeffs, eexps);
-  adapt_quad *q = new adapt_quad(p1, p2, p3, p4);
-  Recur_Create(q, maxlevel, level, coeffs, eexps);
-}
-
-void adapt_tet::Create(int maxlevel, Double_Matrix *coeffs,
-                       Double_Matrix *eexps)
-{
-  int level = 0;
-  cleanElement<adapt_tet>();
-  adapt_point *p1 = adapt_point::New(0, 0, 0, coeffs, eexps);
-  adapt_point *p2 = adapt_point::New(0, 1, 0, coeffs, eexps);
-  adapt_point *p3 = adapt_point::New(1, 0, 0, coeffs, eexps);
-  adapt_point *p4 = adapt_point::New(0, 0, 1, coeffs, eexps);
-  adapt_tet *t = new adapt_tet(p1, p2, p3, p4);
-  Recur_Create(t, maxlevel, level, coeffs, eexps);
-}
-
-void adapt_hex::Create(int maxlevel, Double_Matrix *coeffs,
-                       Double_Matrix *eexps)
-{
-  int level = 0;
-  cleanElement<adapt_hex>();
-  adapt_point *p1 = adapt_point::New(-1, -1, -1, coeffs, eexps);
-  adapt_point *p2 = adapt_point::New(-1, 1, -1, coeffs, eexps);
-  adapt_point *p3 = adapt_point::New(1, 1, -1, coeffs, eexps);
-  adapt_point *p4 = adapt_point::New(1, -1, -1, coeffs, eexps);
-  adapt_point *p11 = adapt_point::New(-1, -1, 1, coeffs, eexps);
-  adapt_point *p21 = adapt_point::New(-1, 1, 1, coeffs, eexps);
-  adapt_point *p31 = adapt_point::New(1, 1, 1, coeffs, eexps);
-  adapt_point *p41 = adapt_point::New(1, -1, 1, coeffs, eexps);
-  adapt_hex *h = new adapt_hex(p1, p2, p3, p4, p11, p21, p31, p41);
-  Recur_Create(h, maxlevel, level, coeffs, eexps);
-}
-
-void adapt_edge::Recur_Create(adapt_edge *e, int maxlevel, int level,
-                              Double_Matrix *coeffs, Double_Matrix *eexps)
-{
-  all_elems.push_back(e);
-  if(level++ >= maxlevel) return;
-
-  /*
-     p1    p12    p2
-   */
-
-  adapt_point *p1 = e->p[0];
-  adapt_point *p2 = e->p[1];
-  adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5,
-                                      (p1->z + p2->z) * 0.5, coeffs, eexps);
-  adapt_edge *e1 = new adapt_edge(p1, p12);
-  Recur_Create(e1, maxlevel, level, coeffs, eexps);
-  adapt_edge *e2 = new adapt_edge(p12, p2);
-  Recur_Create(e2, maxlevel, level, coeffs, eexps);
-  e->e[0] = e1;
-  e->e[1] = e2;
-}
-
-void adapt_triangle::Recur_Create(adapt_triangle *t, int maxlevel, int level,
-                                  Double_Matrix *coeffs,
-                                  Double_Matrix *eexps)
-{
-  all_elems.push_back(t);
-  if(level++ >= maxlevel) return;
-
-  /*
-     p3
-
-     p13   p23
-
-     p1    p12    p2
-   */
-
-  adapt_point *p1 = t->p[0];
-  adapt_point *p2 = t->p[1];
-  adapt_point *p3 = t->p[2];
-  adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, 0, 
-                                      coeffs, eexps);
-  adapt_point *p13 = adapt_point::New((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5, 0, 
-                                      coeffs, eexps);
-  adapt_point *p23 = adapt_point::New((p3->x + p2->x) * 0.5, (p3->y + p2->y) * 0.5, 0, 
-                                      coeffs, eexps);
-  adapt_triangle *t1 = new adapt_triangle(p1, p12, p13);
-  Recur_Create(t1, maxlevel, level, coeffs, eexps);
-  adapt_triangle *t2 = new adapt_triangle(p2, p23, p12);
-  Recur_Create(t2, maxlevel, level, coeffs, eexps);
-  adapt_triangle *t3 = new adapt_triangle(p3, p13, p23);
-  Recur_Create(t3, maxlevel, level, coeffs, eexps);
-  adapt_triangle *t4 = new adapt_triangle(p12, p23, p13);
-  Recur_Create(t4, maxlevel, level, coeffs, eexps);
-  t->e[0] = t1;
-  t->e[1] = t2;
-  t->e[2] = t3;
-  t->e[3] = t4;
-}
-
-void adapt_quad::Recur_Create(adapt_quad *q, int maxlevel, int level,
-                              Double_Matrix *coeffs, Double_Matrix *eexps)
-{
-  all_elems.push_back(q);
-  if(level++ >= maxlevel) return;
-
-  /*
-     p4   p34    p3
-
-     p14  pc     p23
-
-     p1   p12    p2
-   */
-
-  adapt_point *p1 = q->p[0];
-  adapt_point *p2 = q->p[1];
-  adapt_point *p3 = q->p[2];
-  adapt_point *p4 = q->p[3];
-  adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5, 0,
-                                      coeffs, eexps);
-  adapt_point *p23 = adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5, 0,
-                                      coeffs, eexps);
-  adapt_point *p34 = adapt_point::New((p3->x + p4->x) * 0.5, (p3->y + p4->y) * 0.5, 0,
-                                      coeffs, eexps);
-  adapt_point *p14 = adapt_point::New((p1->x + p4->x) * 0.5, (p1->y + p4->y) * 0.5, 0, 
-                                      coeffs, eexps);
-  adapt_point *pc = adapt_point::New((p1->x + p2->x + p3->x + p4->x) * 0.25,
-                                     (p1->y + p2->y + p3->y + p4->y) * 0.25, 0, 
-                                     coeffs, eexps);
-  adapt_quad *q1 = new adapt_quad(p1, p12, pc, p14);
-  Recur_Create(q1, maxlevel, level, coeffs, eexps);
-  adapt_quad *q2 = new adapt_quad(p2, p23, pc, p12);
-  Recur_Create(q2, maxlevel, level, coeffs, eexps);
-  adapt_quad *q3 = new adapt_quad(p3, p34, pc, p23);
-  Recur_Create(q3, maxlevel, level, coeffs, eexps);
-  adapt_quad *q4 = new adapt_quad(p4, p14, pc, p34);
-  Recur_Create(q4, maxlevel, level, coeffs, eexps);
-  q->e[0] = q1;
-  q->e[1] = q2;
-  q->e[2] = q3;
-  q->e[3] = q4;
-}
-
-void adapt_tet::Recur_Create(adapt_tet *t, int maxlevel, int level,
-                             Double_Matrix *coeffs, Double_Matrix *eexps)
-{
-  all_elems.push_back(t);
-  if(level++ >= maxlevel) return;
-
-  adapt_point *p0 = t->p[0];
-  adapt_point *p1 = t->p[1];
-  adapt_point *p2 = t->p[2];
-  adapt_point *p3 = t->p[3];
-  adapt_point *pe0 =  adapt_point::New((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5,
-                                       (p0->z + p1->z) * 0.5, coeffs, eexps);
-  adapt_point *pe1 =  adapt_point::New((p0->x + p2->x) * 0.5, (p0->y + p2->y) * 0.5,
-                                       (p0->z + p2->z) * 0.5, coeffs, eexps);
-  adapt_point *pe2 =  adapt_point::New((p0->x + p3->x) * 0.5, (p0->y + p3->y) * 0.5,
-                                       (p0->z + p3->z) * 0.5, coeffs, eexps);
-  adapt_point *pe3 =  adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5,
-                                       (p1->z + p2->z) * 0.5, coeffs, eexps);
-  adapt_point *pe4 =  adapt_point::New((p1->x + p3->x) * 0.5, (p1->y + p3->y) * 0.5,
-                                       (p1->z + p3->z) * 0.5, coeffs, eexps);
-  adapt_point *pe5 =  adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5,
-                                       (p2->z + p3->z) * 0.5, coeffs, eexps);
-
-  adapt_tet *t1 = new adapt_tet(p0, pe0, pe2, pe1);
-  Recur_Create(t1, maxlevel, level, coeffs, eexps);
-  adapt_tet *t2 = new adapt_tet(p1, pe0, pe3, pe4);
-  Recur_Create(t2, maxlevel, level, coeffs, eexps);
-  adapt_tet *t3 = new adapt_tet(p2, pe3, pe1, pe5);
-  Recur_Create(t3, maxlevel, level, coeffs, eexps);
-  adapt_tet *t4 = new adapt_tet(p3, pe2, pe4, pe5);
-  Recur_Create(t4, maxlevel, level, coeffs, eexps);
-
-  adapt_tet *t5 = new adapt_tet(pe3, pe5, pe2, pe4);
-  Recur_Create(t5, maxlevel, level, coeffs, eexps);
-  adapt_tet *t6 = new adapt_tet(pe3, pe2, pe0, pe4);
-  Recur_Create(t6, maxlevel, level, coeffs, eexps);
-  adapt_tet *t7 = new adapt_tet(pe2, pe5, pe3, pe1);
-  Recur_Create(t7, maxlevel, level, coeffs, eexps);
-  adapt_tet *t8 = new adapt_tet(pe0, pe2, pe3, pe1);
-  Recur_Create(t8, maxlevel, level, coeffs, eexps);
-
-  t->e[0] = t1;
-  t->e[1] = t2;
-  t->e[2] = t3;
-  t->e[3] = t4;
-  t->e[4] = t5;
-  t->e[5] = t6;
-  t->e[6] = t7;
-  t->e[7] = t8;
-}
-
-void adapt_hex::Recur_Create(adapt_hex *h, int maxlevel, int level,
-                             Double_Matrix *coeffs, Double_Matrix *eexps)
-{
-  all_elems.push_back(h);
-  if(level++ >= maxlevel) return;
-
-  adapt_point *p0 = h->p[0];
-  adapt_point *p1 = h->p[1];
-  adapt_point *p2 = h->p[2];
-  adapt_point *p3 = h->p[3];
-  adapt_point *p4 = h->p[4];
-  adapt_point *p5 = h->p[5];
-  adapt_point *p6 = h->p[6];
-  adapt_point *p7 = h->p[7];
-  adapt_point *p01 = adapt_point::New((p0->x + p1->x) * 0.5, (p0->y + p1->y) * 0.5,
-                                      (p0->z + p1->z) * 0.5, coeffs, eexps);
-  adapt_point *p12 = adapt_point::New((p1->x + p2->x) * 0.5, (p1->y + p2->y) * 0.5,
-                                      (p1->z + p2->z) * 0.5, coeffs, eexps);
-  adapt_point *p23 = adapt_point::New((p2->x + p3->x) * 0.5, (p2->y + p3->y) * 0.5,
-                                      (p2->z + p3->z) * 0.5, coeffs, eexps);
-  adapt_point *p03 = adapt_point::New((p3->x + p0->x) * 0.5, (p3->y + p0->y) * 0.5,
-                                      (p3->z + p0->z) * 0.5, coeffs, eexps);
-  adapt_point *p45 = adapt_point::New((p4->x + p5->x) * 0.5, (p4->y + p5->y) * 0.5,
-                                      (p4->z + p5->z) * 0.5, coeffs, eexps);
-  adapt_point *p56 = adapt_point::New((p5->x + p6->x) * 0.5, (p5->y + p6->y) * 0.5,
-                                      (p5->z + p6->z) * 0.5, coeffs, eexps);
-  adapt_point *p67 = adapt_point::New((p6->x + p7->x) * 0.5, (p6->y + p7->y) * 0.5,
-                                      (p6->z + p7->z) * 0.5, coeffs, eexps);
-  adapt_point *p47 = adapt_point::New((p7->x + p4->x) * 0.5, (p7->y + p4->y) * 0.5,
-                                      (p7->z + p4->z) * 0.5, coeffs, eexps);
-  adapt_point *p04 = adapt_point::New((p4->x + p0->x) * 0.5, (p4->y + p0->y) * 0.5,
-                                      (p4->z + p0->z) * 0.5, coeffs, eexps);
-  adapt_point *p15 = adapt_point::New((p5->x + p1->x) * 0.5, (p5->y + p1->y) * 0.5,
-                                      (p5->z + p1->z) * 0.5, coeffs, eexps);
-  adapt_point *p26 = adapt_point::New((p6->x + p2->x) * 0.5, (p6->y + p2->y) * 0.5,
-                                      (p6->z + p2->z) * 0.5, coeffs, eexps);
-  adapt_point *p37 = adapt_point::New((p7->x + p3->x) * 0.5, (p7->y + p3->y) * 0.5,
-                                      (p7->z + p3->z) * 0.5, coeffs, eexps);
-
-  adapt_point *p0145 = adapt_point::New((p45->x + p01->x) * 0.5, (p45->y + p01->y) * 0.5,
-                                        (p45->z + p01->z) * 0.5, coeffs, eexps);
-  adapt_point *p1256 = adapt_point::New((p12->x + p56->x) * 0.5, (p12->y + p56->y) * 0.5,
-                                        (p12->z + p56->z) * 0.5, coeffs, eexps);
-  adapt_point *p2367 = adapt_point::New((p23->x + p67->x) * 0.5, (p23->y + p67->y) * 0.5,
-                                        (p23->z + p67->z) * 0.5, coeffs, eexps);
-  adapt_point *p0347 = adapt_point::New((p03->x + p47->x) * 0.5, (p03->y + p47->y) * 0.5,
-                                        (p03->z + p47->z) * 0.5, coeffs, eexps);
-  adapt_point *p4756 = adapt_point::New((p47->x + p56->x) * 0.5, (p47->y + p56->y) * 0.5,
-                                        (p47->z + p56->z) * 0.5, coeffs, eexps);
-  adapt_point *p0312 = adapt_point::New((p03->x + p12->x) * 0.5, (p03->y + p12->y) * 0.5,
-                                        (p03->z + p12->z) * 0.5, coeffs, eexps);
-
-  adapt_point *pc = 
-    adapt_point::New((p0->x + p1->x + p2->x + p3->x + p4->x + p5->x + p6->x + p7->x) * 0.125,
-                     (p0->y + p1->y + p2->y + p3->y + p4->y + p5->y + p6->y + p7->y) * 0.125,
-                     (p0->z + p1->z + p2->z + p3->z + p4->z + p5->z + p6->z + p7->z) * 0.125,
-                     coeffs, eexps);
-
-  adapt_hex *h1 = new adapt_hex(p0, p01, p0312, p03, p04, p0145, pc, p0347);    //p0
-  Recur_Create(h1, maxlevel, level, coeffs, eexps);
-  adapt_hex *h2 = new adapt_hex(p01, p0145, p15, p1, p0312, pc, p1256, p12);    //p1
-  Recur_Create(h2, maxlevel, level, coeffs, eexps);
-  adapt_hex *h3 = new adapt_hex(p04, p4, p45, p0145, p0347, p47, p4756, pc);    //p4
-  Recur_Create(h3, maxlevel, level, coeffs, eexps);
-  adapt_hex *h4 = new adapt_hex(p0145, p45, p5, p15, pc, p4756, p56, p1256);    //p5
-  Recur_Create(h4, maxlevel, level, coeffs, eexps);
-  adapt_hex *h5 = new adapt_hex(p0347, p47, p4756, pc, p37, p7, p67, p2367);    //p7
-  Recur_Create(h5, maxlevel, level, coeffs, eexps);
-  adapt_hex *h6 = new adapt_hex(pc, p4756, p56, p1256, p2367, p67, p6, p26);    //p6
-  Recur_Create(h6, maxlevel, level, coeffs, eexps);
-  adapt_hex *h7 = new adapt_hex(p03, p0347, pc, p0312, p3, p37, p2367, p23);    //p3
-  Recur_Create(h7, maxlevel, level, coeffs, eexps);
-  adapt_hex *h8 = new adapt_hex(p0312, pc, p1256, p12, p23, p2367, p26, p2);    //p2
-  Recur_Create(h8, maxlevel, level, coeffs, eexps);
-
-  h->e[0] = h1;
-  h->e[1] = h2;
-  h->e[2] = h3;
-  h->e[3] = h4;
-  h->e[4] = h5;
-  h->e[5] = h6;
-  h->e[6] = h7;
-  h->e[7] = h8;
-}
-
-void adapt_edge::Error(double AVG, double tol)
-{
-  adapt_edge *e = *all_elems.begin();
-  Recur_Error(e, AVG, tol);
-}
-
-void adapt_triangle::Error(double AVG, double tol)
-{
-  adapt_triangle *t = *all_elems.begin();
-  Recur_Error(t, AVG, tol);
-}
-
-void adapt_quad::Error(double AVG, double tol)
-{
-  adapt_quad *q = *all_elems.begin();
-  Recur_Error(q, AVG, tol);
-}
-
-void adapt_tet::Error(double AVG, double tol)
-{
-  adapt_tet *t = *all_elems.begin();
-  Recur_Error(t, AVG, tol);
-}
-void adapt_hex::Error(double AVG, double tol)
-{
-  adapt_hex *h = *all_elems.begin();
-  Recur_Error(h, AVG, tol);
-}
-
-void adapt_edge::Recur_Error(adapt_edge *e, double AVG, double tol)
-{
-  if(!e->e[0])
-    e->visible = true;
-  else {
-    double vr;
-    if(!e->e[0]->e[0]) {
-      double v1 = e->e[0]->V();
-      double v2 = e->e[1]->V();
-      vr = (v1 + v2) / 2.;
-      double v = e->V();
-      if(fabs(v - vr) > AVG * tol){
-        e->visible = false;
-        Recur_Error(e->e[0], AVG, tol);
-        Recur_Error(e->e[1], AVG, tol);
-      }
-      else
-        e->visible = true;
-    }
-    else {
-      double v11 = e->e[0]->e[0]->V();
-      double v12 = e->e[0]->e[1]->V();
-
-      double v21 = e->e[1]->e[0]->V();
-      double v22 = e->e[1]->e[1]->V();
-
-      double vr1 = (v11 + v12) / 2.;
-      double vr2 = (v21 + v22) / 2.;
-      vr = (vr1 + vr2) / 2.;
-      if(fabs(e->e[0]->V() - vr1) > AVG * tol ||
-         fabs(e->e[1]->V() - vr2) > AVG * tol ||
-         fabs(e->V() - vr) > AVG * tol) {
-        e->visible = false;
-        Recur_Error(e->e[0], AVG, tol);
-        Recur_Error(e->e[1], AVG, tol);
-      }
-      else
-        e->visible = true;
-    }
-  }
-}
-
-void adapt_triangle::Recur_Error(adapt_triangle *t, double AVG, double tol)
-{
-  if(!t->e[0])
-    t->visible = true;
-  else {
-    double vr;
-    if(!t->e[0]->e[0]) {
-      double v1 = t->e[0]->V();
-      double v2 = t->e[1]->V();
-      double v3 = t->e[2]->V();
-      double v4 = t->e[3]->V();
-      vr = (2 * v1 + 2 * v2 + 2 * v3 + v4) / 7.;
-      double v = t->V();
-      if(fabs(v - vr) > AVG * tol){
-        t->visible = false;
-        Recur_Error(t->e[0], AVG, tol);
-        Recur_Error(t->e[1], AVG, tol);
-        Recur_Error(t->e[2], AVG, tol);
-        Recur_Error(t->e[3], AVG, tol);
-      }
-      else
-        t->visible = true;
-    }
-    else {
-      double v11 = t->e[0]->e[0]->V();
-      double v12 = t->e[0]->e[1]->V();
-      double v13 = t->e[0]->e[2]->V();
-      double v14 = t->e[0]->e[3]->V();
-      double v21 = t->e[1]->e[0]->V();
-      double v22 = t->e[1]->e[1]->V();
-      double v23 = t->e[1]->e[2]->V();
-      double v24 = t->e[1]->e[3]->V();
-      double v31 = t->e[2]->e[0]->V();
-      double v32 = t->e[2]->e[1]->V();
-      double v33 = t->e[2]->e[2]->V();
-      double v34 = t->e[2]->e[3]->V();
-      double v41 = t->e[3]->e[0]->V();
-      double v42 = t->e[3]->e[1]->V();
-      double v43 = t->e[3]->e[2]->V();
-      double v44 = t->e[3]->e[3]->V();
-      double vr1 = (2 * v11 + 2 * v12 + 2 * v13 + v14) / 7.;
-      double vr2 = (2 * v21 + 2 * v22 + 2 * v23 + v24) / 7.;
-      double vr3 = (2 * v31 + 2 * v32 + 2 * v33 + v34) / 7.;
-      double vr4 = (2 * v41 + 2 * v42 + 2 * v43 + v44) / 7.;
-      vr = (2 * vr1 + 2 * vr2 + 2 * vr3 + vr4) / 7.;
-      if(fabs(t->e[0]->V() - vr1) > AVG * tol ||
-         fabs(t->e[1]->V() - vr2) > AVG * tol ||
-         fabs(t->e[2]->V() - vr3) > AVG * tol ||
-         fabs(t->e[3]->V() - vr4) > AVG * tol ||
-         fabs(t->V() - vr) > AVG * tol){
-        t->visible = false;
-        Recur_Error(t->e[0], AVG, tol);
-        Recur_Error(t->e[1], AVG, tol);
-        Recur_Error(t->e[2], AVG, tol);
-        Recur_Error(t->e[3], AVG, tol);
-      }
-      else
-        t->visible = true;
-    }
-  }
-}
-
-void adapt_quad::Recur_Error(adapt_quad *q, double AVG, double tol)
-{
-  if(!q->e[0])
-    q->visible = true;
-  else {
-    double vr;
-    if(!q->e[0]->e[0]) {
-      double v1 = q->e[0]->V();
-      double v2 = q->e[1]->V();
-      double v3 = q->e[2]->V();
-      double v4 = q->e[3]->V();
-      vr = (v1 + v2 + v3 + v4) / 4.;
-      double v = q->V();
-      if(fabs(v - vr) > AVG * tol){
-        q->visible = false;
-        Recur_Error(q->e[0], AVG, tol);
-        Recur_Error(q->e[1], AVG, tol);
-        Recur_Error(q->e[2], AVG, tol);
-        Recur_Error(q->e[3], AVG, tol);
-      }
-      else
-        q->visible = true;
-    }
-    else {
-      double v11 = q->e[0]->e[0]->V();
-      double v12 = q->e[0]->e[1]->V();
-      double v13 = q->e[0]->e[2]->V();
-      double v14 = q->e[0]->e[3]->V();
-      double v21 = q->e[1]->e[0]->V();
-      double v22 = q->e[1]->e[1]->V();
-      double v23 = q->e[1]->e[2]->V();
-      double v24 = q->e[1]->e[3]->V();
-      double v31 = q->e[2]->e[0]->V();
-      double v32 = q->e[2]->e[1]->V();
-      double v33 = q->e[2]->e[2]->V();
-      double v34 = q->e[2]->e[3]->V();
-      double v41 = q->e[3]->e[0]->V();
-      double v42 = q->e[3]->e[1]->V();
-      double v43 = q->e[3]->e[2]->V();
-      double v44 = q->e[3]->e[3]->V();
-      double vr1 = (v11 + v12 + v13 + v14) / 4.;
-      double vr2 = (v21 + v22 + v23 + v24) / 4.;
-      double vr3 = (v31 + v32 + v33 + v34) / 4.;
-      double vr4 = (v41 + v42 + v43 + v44) / 4.;
-      vr = (vr1 + vr2 + vr3 + vr4) / 4.;
-      if(fabs(q->e[0]->V() - vr1) > AVG * tol ||
-         fabs(q->e[1]->V() - vr2) > AVG * tol ||
-         fabs(q->e[2]->V() - vr3) > AVG * tol ||
-         fabs(q->e[3]->V() - vr4) > AVG * tol ||
-         fabs(q->V() - vr) > AVG * tol){
-        q->visible = false;
-        Recur_Error(q->e[0], AVG, tol);
-        Recur_Error(q->e[1], AVG, tol);
-        Recur_Error(q->e[2], AVG, tol);
-        Recur_Error(q->e[3], AVG, tol);
-      }
-      else
-        q->visible = true;
-    }
-  }
-}
-
-void adapt_tet::Recur_Error(adapt_tet *t, double AVG, double tol)
-{
-  if(!t->e[0])
-    t->visible = true;
-  else {
-    const double v1 = t->e[0]->V();
-    const double v2 = t->e[1]->V();
-    const double v3 = t->e[2]->V();
-    const double v4 = t->e[3]->V();
-    const double v5 = t->e[4]->V();
-    const double v6 = t->e[5]->V();
-    const double v7 = t->e[6]->V();
-    const double v8 = t->e[7]->V();
-    const double vr = (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8) * .125;
-    const double v = t->V();
-    if(!t->e[0]->e[0]) {
-      if(fabs(v - vr) > AVG * tol) {
-        t->visible = false;
-        Recur_Error(t->e[0], AVG, tol);
-        Recur_Error(t->e[1], AVG, tol);
-        Recur_Error(t->e[2], AVG, tol);
-        Recur_Error(t->e[3], AVG, tol);
-        Recur_Error(t->e[4], AVG, tol);
-        Recur_Error(t->e[5], AVG, tol);
-        Recur_Error(t->e[6], AVG, tol);
-        Recur_Error(t->e[7], AVG, tol);
-      }
-      else
-        t->visible = true;
-    }
-    else {
-      double vi[8][8];
-      for(int k = 0; k < 8; k++)
-        for(int l = 0; l < 8; l++)
-          vi[k][l] = t->e[k]->e[l]->V();
-      double vri[8];
-      for(int k = 0; k < 8; k++) {
-        vri[k] = 0.0;
-        for(int l = 0; l < 8; l++) {
-          vri[k] += vi[k][l];
-        }
-        vri[k] /= 8.0;
-      }
-      if(fabs(t->e[0]->V() - vri[0]) > AVG * tol ||
-         fabs(t->e[1]->V() - vri[1]) > AVG * tol ||
-         fabs(t->e[2]->V() - vri[2]) > AVG * tol ||
-         fabs(t->e[3]->V() - vri[3]) > AVG * tol ||
-         fabs(t->e[4]->V() - vri[4]) > AVG * tol ||
-         fabs(t->e[5]->V() - vri[5]) > AVG * tol ||
-         fabs(t->e[6]->V() - vri[6]) > AVG * tol ||
-         fabs(t->e[7]->V() - vri[7]) > AVG * tol ||
-         fabs(v - vr) > AVG * tol) {
-        t->visible = false;
-        Recur_Error(t->e[0], AVG, tol);
-        Recur_Error(t->e[1], AVG, tol);
-        Recur_Error(t->e[2], AVG, tol);
-        Recur_Error(t->e[3], AVG, tol);
-        Recur_Error(t->e[4], AVG, tol);
-        Recur_Error(t->e[5], AVG, tol);
-        Recur_Error(t->e[6], AVG, tol);
-        Recur_Error(t->e[7], AVG, tol);
-      }
-      else
-        t->visible = true;
-    }
-  }
-}
-
-void adapt_hex::Recur_Error(adapt_hex *h, double AVG, double tol)
-{
-  if(!h->e[0])
-    h->visible = true;
-  else {
-    double vr;
-    double v1 = h->e[0]->V();
-    double v2 = h->e[1]->V();
-    double v3 = h->e[2]->V();
-    double v4 = h->e[3]->V();
-    double v5 = h->e[4]->V();
-    double v6 = h->e[5]->V();
-    double v7 = h->e[6]->V();
-    double v8 = h->e[7]->V();
-    vr = (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8) * .125;
-    double v = h->V();
-    if(fabs(v - vr) > AVG * tol) {
-      h->visible = false;
-      Recur_Error(h->e[0], AVG, tol);
-      Recur_Error(h->e[1], AVG, tol);
-      Recur_Error(h->e[2], AVG, tol);
-      Recur_Error(h->e[3], AVG, tol);
-      Recur_Error(h->e[4], AVG, tol);
-      Recur_Error(h->e[5], AVG, tol);
-      Recur_Error(h->e[6], AVG, tol);
-      Recur_Error(h->e[7], AVG, tol);
-    }
-    else
-      h->visible = true;
-  }
-}
-
-template < class ELEM >
-int Adaptive_Post_View::zoomElement(int ielem,
-                                    int level,
-                                    int levelmax,
-                                    GMSH_Post_Plugin *plug,
-                                    List_T *theList, int *counter)
-{
-  const int nbNod = ELEM::nbNod;
-
-  typename std::set<adapt_point>::iterator it = adapt_point::all_points.begin();
-  typename std::set<adapt_point>::iterator ite = adapt_point::all_points.end();
-
-  const int N = _coefs->size1();
-  
-  Double_Vector val(N), res(adapt_point::all_points.size());
-  Double_Vector valx(N), resx(adapt_point::all_points.size());
-  Double_Vector valy(N), resy(adapt_point::all_points.size());
-  Double_Vector valz(N), resz(adapt_point::all_points.size());
-  Double_Matrix xyz(_STposX->size2(),3);
-  Double_Matrix XYZ(adapt_point::all_points.size(),3);
-
-  for(int k = 0; k < _STposX->size2(); ++k){
-    xyz(k, 0) = (*_STposX)(ielem, k);
-    xyz(k, 1) = (*_STposY)(ielem, k);
-    xyz(k, 2) = (*_STposZ)(ielem, k);
-  }
-
-  for(int k = 0; k < N; ++k){
-    val(k) = (*_STval)(ielem, k);
-  }
-
-  _Interpolate->mult(val,res);
-
-  if(_STvalX){
-    for(int k = 0; k < N; ++k){
-      valx(k) = (*_STvalX)(ielem, k);
-      valy(k) = (*_STvalY)(ielem, k);
-      valz(k) = (*_STvalZ)(ielem, k);
-    }           
-    _Interpolate->mult(valx, resx);
-    _Interpolate->mult(valy, resy);
-    _Interpolate->mult(valz, resz);
-  }
-
-  _Geometry->mult(xyz, XYZ);
-
-  int kk = 0;
-  for(; it !=ite; ++it){
-    adapt_point *p = (adapt_point*) &(*it);
-    p->val = res(kk);
-    if(_STvalX){
-      p->valx = resx(kk);
-      p->valy = resy(kk);
-      p->valz = resz(kk);
-    }
-    p->val = res(kk);
-    p->X = XYZ(kk, 0);
-    p->Y = XYZ(kk, 1);
-    p->Z = XYZ(kk, 2);
-    if(minval > p->val) minval = p->val;
-    if(maxval < p->val) maxval = p->val;
-    kk++;
-  }
-
-  typename std::list<ELEM*>::iterator itt = ELEM::all_elems.begin();
-  typename std::list<ELEM*>::iterator itte = ELEM::all_elems.end();
-
-  for(; itt != itte; itt++) {
-    (*itt)->visible = false;
-  }
-
-  if(!plug || tol != 0.0) {
-    ELEM::Error(maxval - minval, tol);
-  }
-
-  if(plug)
-    plug->assignSpecificVisibility();
-
-  itt = ELEM::all_elems.begin();
-
-   for(; itt != itte; itt++) {
-     if((*itt)->visible && !(*itt)->e[0] && level != levelmax)
-       return 0;
-   }
-
-  itt = ELEM::all_elems.begin();
-  adapt_point **p;
-
-  for(; itt != itte; itt++){
-    if((*itt)->visible){
-      p = (*itt)->p;
-      for(int k=0; k < nbNod; ++k) List_Add(theList, &p[k]->X);
-      for(int k=0; k < nbNod; ++k) List_Add(theList, &p[k]->Y);
-      for(int k=0; k < nbNod; ++k) List_Add(theList, &p[k]->Z);
-      if(_STvalX){
-        for(int k = 0; k < nbNod; ++k){
-          List_Add(theList, &p[k]->valx);
-          List_Add(theList, &p[k]->valy);
-          List_Add(theList, &p[k]->valz);
-        }
-      }
-      else{
-        for (int k = 0; k < nbNod; ++k) List_Add(theList, &p[k]->val);
-      }
-      (*counter)++;
-    }
-  }
-  
-  return 1;
-}
-
-/*
-  We first do the adaptive stuff at level 2 and will only process
-  elements that have reached the maximal recursion level
-
-  We compute first the matrix at max recursion level (those should be
-  stored on disk once in the GMSHPLUGINSHOME directory, i'll do that
-  at some point).
-*/
-
-void Adaptive_Post_View::setAdaptiveResolutionLevel(PViewDataList *data, int level,
-                                                    GMSH_Post_Plugin *plug)
-{
-
-  if(presentTol == tol && presentZoomLevel == level && !plug) return;
-
-  int *done = new int[_STposX->size1()];
-  for(int i = 0; i < _STposX->size1(); ++i)
-    done[i] = 0;
-  int level_act = (level > 2) ? 2 : level;
-  int nbelm = _STposX->size1();
-
-  int TYP = 0;
-  if(data->NbSL) {
-    TYP = 7;
-    List_Delete(data->SL);
-    data->NbSL = 0;
-    data->SL = List_Create(nbelm * 8, nbelm, sizeof(double));
-  }
-  if(data->NbVT) {
-    TYP = 5;
-    List_Delete(data->VT); 
-    data->NbVT = 0;
-    data->VT = List_Create(nbelm * 36, nbelm , sizeof(double)); 
-  }
-  else if(data->NbST) {
-    TYP = 1;
-    List_Delete(data->ST);
-    data->NbST = 0;
-    data->ST = List_Create(nbelm * 4, nbelm, sizeof(double));
-  }
-  if(data->NbSS) {
-    TYP = 3;
-    List_Delete(data->SS);
-    data->NbSS = 0;
-    data->SS = List_Create(nbelm * 4, nbelm, sizeof(double));
-  }
-  if(data->NbSQ) {
-    TYP = 2;
-    List_Delete(data->SQ);
-    data->NbSQ = 0;
-    data->SQ = List_Create(nbelm * 20, nbelm * 20, sizeof(double));
-  }
-  if(data->NbVQ) {
-    TYP = 6;
-    List_Delete(data->VQ);
-    data->NbVQ = 0;
-    data->VQ = List_Create(nbelm * 60, nbelm * 20, sizeof(double));
-  }
-  if(data->NbSH) {
-    TYP = 4;
-    List_Delete(data->SH);
-    data->NbSH = 0;
-    data->SH = List_Create(nbelm * 4, nbelm, sizeof(double));
-  }
-
-  data->NbTimeStep = 1;
-
-  while(1){
-    if(TYP == 7)
-      setAdaptiveResolutionLevel_TEMPL<adapt_edge>(level_act, level, plug, 
-                                                   &(data->SL), &(data->NbSL), done);
-    if(TYP == 1)
-      setAdaptiveResolutionLevel_TEMPL<adapt_triangle>(level_act, level, plug,
-                                                       &(data->ST), &(data->NbST), done);
-    if(TYP == 5)
-      setAdaptiveResolutionLevel_TEMPL<adapt_triangle>(level_act, level, plug,
-                                                       &(data->VT), &(data->NbVT), done);
-    if(TYP == 2)
-      setAdaptiveResolutionLevel_TEMPL<adapt_quad>(level_act, level, plug,
-                                                   &(data->SQ), &(data->NbSQ), done);
-    if(TYP == 6)
-      setAdaptiveResolutionLevel_TEMPL<adapt_quad>(level_act, level, plug,
-                                                   &(data->VQ), &(data->NbVQ), done);
-    if(TYP == 4)
-      setAdaptiveResolutionLevel_TEMPL<adapt_hex>(level_act, level, plug,
-                                                  &(data->SH), &(data->NbSH), done);
-    if(TYP == 3)
-      setAdaptiveResolutionLevel_TEMPL<adapt_tet>(level_act, level, plug,
-                                                  &(data->SS), &(data->NbSS), done);
-    int nbDone = 0;
-    for(int i = 0; i < _STposX->size1(); ++i) nbDone += done[i];
-    if(nbDone == _STposX->size1())  break;
-    if(level_act >= level) break;
-    level_act++;
-  }
-
-  data->finalize();
-
-  presentZoomLevel = level;
-  presentTol = tol;
-
-  delete [] done;
-}
-
-template<class ELEM> 
-void Adaptive_Post_View::setAdaptiveResolutionLevel_TEMPL(int level, int levelmax,
-                                                          GMSH_Post_Plugin *plug,
-                                                          List_T **myList,
-                                                          int *counter, int *done)
-{
-  const int N = _coefs->size1();
-  const int nbelm = _STposX->size1();
-
-  double sf[100];
-  ELEM::Create(level, _coefs, _eexps);
-  std::set<adapt_point>::iterator it = adapt_point::all_points.begin();
-  std::set<adapt_point>::iterator ite = adapt_point::all_points.end();
-
-  if(_Interpolate)
-    delete _Interpolate;
-  if(_Geometry)
-    delete _Geometry;
-  _Interpolate = new Double_Matrix(adapt_point::all_points.size(), N);
-  _Geometry = new Double_Matrix(adapt_point::all_points.size(), _STposX->size2());
-
-  int kk = 0;
-  for(; it != ite; ++it) {
-    adapt_point *p = (adapt_point *) & (*it);
-    for(int k = 0; k < N; ++k) {
-      (*_Interpolate)(kk, k) = p->shape_functions[k];
-    }
-
-    if(_coefsGeom){
-      computeShapeFunctions(_coefsGeom, _eexpsGeom, p->x, p->y, p->z, sf);
-    }
-    else{
-      ELEM::GSF(p->x, p->y, p->z, sf);
-    }
-    for(int k = 0; k < _STposX->size2(); k++)
-      (*_Geometry) (kk, k) = sf[k];
-    kk++;
-  }
-
-  for(int i = 0; i < nbelm; ++i) {//    if(!done[i])
-      done[i] = zoomElement<ELEM>(i, level, levelmax, plug, *myList, counter);
-  }
-}
-
-void Adaptive_Post_View::initWithLowResolution(PViewDataList *data)
-{
-  List_T *myList;
-  int nbelm;
-  int nbnod;
-  int nbComp = 1;
-
-  if(data->NbST){
-    myList = data->ST;
-    nbelm = data->NbST;
-    nbnod = 3;
-  }
-  else if(data->NbSL){
-    myList = data->SL;
-    nbelm = data->NbSL;
-    nbnod = 2;
-  }
-  else if(data->NbVT){
-    myList = data->VT;
-    nbelm = data->NbVT;
-    nbnod = 3;
-    nbComp = 3;
-  }
-  else if(data->NbVQ){
-    myList = data->VQ;
-    nbelm = data->NbVQ;
-    nbnod = 4;
-    nbComp = 3;
-  }
-  else if(data->NbSS){
-    myList = data->SS;
-    nbelm = data->NbSS;
-    nbnod = 4;
-  }
-  else if(data->NbSQ){
-    myList = data->SQ;
-    nbelm = data->NbSQ;
-    nbnod = 4;
-  }
-  else if(data->NbSH){
-    myList = data->SH;
-    nbelm = data->NbSH;
-    nbnod = 8;
-  }
-        else if(data->NbSI){
-                myList = data->SI;
-                nbelm = data->NbSI;
-                nbnod = 6;
-        }
-        else if(data->NbVI){
-                myList = data->VI;
-                nbelm = data->NbVI;
-                nbnod = 6;
-        }
-  else return;
-
-  // if there exists a polynomial representation
-  // of the geometry , then use it
-  if(_coefsGeom){
-    nbnod = _coefsGeom->size1();
-  }  
-
-  minval = VAL_INF;
-  maxval = -VAL_INF;
-
-  int nb = List_Nbr(myList) / (nbelm);
-
-  _STposX = new Double_Matrix(nbelm, nbnod);
-  _STposY = new Double_Matrix(nbelm, nbnod);
-  _STposZ = new Double_Matrix(nbelm, nbnod);
-  _STval = new Double_Matrix(nbelm, (nb - 3 * nbnod) / nbComp);
-
-  if(nbComp == 3){
-    _STvalX = new Double_Matrix(nbelm, (nb - 3 * nbnod) / nbComp);
-    _STvalY = new Double_Matrix(nbelm, (nb - 3 * nbnod) / nbComp);
-    _STvalZ = new Double_Matrix(nbelm, (nb - 3 * nbnod) / nbComp);
-  }
-
-  // Store non interpolated data
-  int k = 0;
-  for(int i = 0; i < List_Nbr(myList); i+= nb){    
-    double *x = (double*)List_Pointer_Fast(myList, i);
-    double *y = (double*)List_Pointer_Fast(myList, i + nbnod); 
-    double *z = (double*)List_Pointer_Fast(myList, i + 2 * nbnod); 
-    for(int NN = 0; NN < nbnod; NN++){
-      (*_STposX)(k, NN) = x[NN]; 
-      (*_STposY)(k, NN) = y[NN]; 
-      (*_STposZ)(k, NN) = z[NN]; 
-    }
-    double *val = (double*)List_Pointer_Fast(myList, i + 3 * nbnod);
-    if(nbComp == 1){
-      for(int j = 0; j < (nb - 3 * nbnod) / nbComp; j++){
-        (*_STval)(k, j) = val[j];
-      }           
-    }
-    else if(nbComp == 3){
-      int size = (nb - 3 * nbnod) / 3;
-      for(int j = 0; j < size; j++){
-        int index1 = j;
-        int index2 = j + size;
-        int index3 = j + 2 * size;
-        // adaptation of the visualization mesh bases on the norm squared of the vector 
-        (*_STval)(k, j) = (val[index1] * val[index1] + val[index2] * val[index2] + 
-                           val[index3] * val[index3]);      
-        (*_STvalX)(k, j) = val[index1];
-        (*_STvalY)(k, j) = val[index2];
-        (*_STvalZ)(k, j) = val[index3];
-      }                   
-    }
-    k++;
-  }
-  setAdaptiveResolutionLevel(data, 0);
-}
-
-Adaptive_Post_View::Adaptive_Post_View(PViewDataList *data, 
-                                       List_T *_c,
-                                       List_T *_pol,
-                                       List_T *_cGeom,
-                                       List_T *_polGeom)
-  : tol(1.e-3), _coefsGeom(0), _eexpsGeom(0)
-{
-
-  _Interpolate = _Geometry = 0;
-  _coefs = new Double_Matrix(List_Nbr(_c), List_Nbr(_c));
-  _eexps = new Double_Matrix(List_Nbr(_c), 3);
-
-  _STvalX = _STvalY = _STvalZ =0;
-
-  for(int i = 0; i < List_Nbr(_c); ++i) {
-    List_T **line = (List_T**)List_Pointer_Fast(_c, i);
-    List_T **eexp = (List_T**)List_Pointer_Fast(_pol, i);
-
-    double dpowu, dpowv, dpoww;
-
-    List_Read(*eexp, 0, &dpowu);
-    List_Read(*eexp, 1, &dpowv);
-    List_Read(*eexp, 2, &dpoww);
-
-    (*_eexps)(i, 0) = dpowu;
-    (*_eexps)(i, 1) = dpowv;
-    (*_eexps)(i, 2) = dpoww;
-
-    for(int j = 0; j < List_Nbr(*line); ++j) {
-      double val;
-      List_Read(*line, j, &val);
-      (*_coefs)(i, j) = val;
-    }
-  }
-
-  if(_cGeom && _polGeom){
-    _coefsGeom = new Double_Matrix(List_Nbr(_cGeom), List_Nbr(_cGeom));
-    _eexpsGeom = new Double_Matrix(List_Nbr(_cGeom), 3);
-    for(int i = 0; i < List_Nbr(_cGeom); ++i) {
-      List_T **line = (List_T**)List_Pointer_Fast(_cGeom, i);
-      List_T **eexp = (List_T**)List_Pointer_Fast(_polGeom, i);
-      double dpowu, dpowv, dpoww;
-      List_Read(*eexp, 0, &dpowu);
-      List_Read(*eexp, 1, &dpowv);
-      List_Read(*eexp, 2, &dpoww);
-      (*_eexpsGeom)(i, 0) = dpowu;
-      (*_eexpsGeom)(i, 1) = dpowv;
-      (*_eexpsGeom)(i, 2) = dpoww;
-      for(int j = 0; j < List_Nbr(*line); ++j) {
-        double val;
-        List_Read(*line, j, &val);
-        (*_coefsGeom)(i, j) = val;
-      }
-    }      
-  }
-  initWithLowResolution(data);
-}
-
-Adaptive_Post_View::~Adaptive_Post_View()
-{
-  delete _coefs;
-  delete _eexps;
-  delete _STposX;
-  delete _STposY;
-  delete _STposZ;
-  delete _STval;
-
-  if(_coefsGeom)
-    delete _coefsGeom;
-  if(_eexpsGeom)
-    delete _eexpsGeom;
-
-  if(_Interpolate)
-    delete _Interpolate;
-  if(_Geometry)
-    delete _Geometry;
-
-  cleanElement<adapt_edge>();
-  cleanElement<adapt_triangle>();
-  cleanElement<adapt_tet>();
-  cleanElement<adapt_hex>();
-  cleanElement<adapt_quad>();
-}
diff --git a/Post/AdaptiveViews.h b/Post/AdaptiveViews.h
deleted file mode 100644
index 3708ef8e10..0000000000
--- a/Post/AdaptiveViews.h
+++ /dev/null
@@ -1,292 +0,0 @@
-#ifndef _ADAPTIVE_VIEWS_H_
-#define _ADAPTIVE_VIEWS_H_
-
-// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-// USA.
-// 
-// Please report all bugs and problems to <gmsh@geuz.org>.
-
-#include <list>
-#include <set>
-#include "List.h"
-#include "GmshMatrix.h"
-
-class PViewDataList;
-class GMSH_Post_Plugin;
-
-// On a triangle, we suppose that there exists an interpolation scheme
-// such that u = \sum_i u_i \phi_i, phi_i being polynomials of order
-// p, i goes from 1...(p+1)(p+2)/2 and phi_i = \sum_j coeffs_{ij}
-// monomials_j and monomials are 1,x,y,x^2,xy,y^2,x^3,x^2y,xy^2,y^3...
-
-class adapt_point
-{
- public:
-  double x, y, z;
-  double X, Y, Z, val, valx, valy, valz;
-  double shape_functions[128];
-  static adapt_point *New(double x, double y, double z, 
-                          Double_Matrix *coeffs, Double_Matrix *eexps);
-  bool operator < (const adapt_point &other) const
-  {
-    if(other.x < x) return true;
-    if(other.x > x) return false;
-    if(other.y < y) return true;
-    if(other.y > y) return false;
-    if(other.z < z) return true;
-    return false;
-  }
-  static std::set<adapt_point> all_points;
-};
-
-class adapt_edge
-{
- public:
-  adapt_edge(adapt_point *p1, adapt_point *p2)
-    : visible(false)
-  {
-    p[0] = p1;
-    p[1] = p2;
-    e[0] = e[1] = 0;
-  } 
-  inline double V() const
-  {
-    return (p[0]->val + p[1]->val) / 2.;
-  }
-  inline static void GSF(const double u, const double v, double w, double sf[])
-  {
-    sf[0] = (1 - u) / 2.;
-    sf[1] = (1 + u) / 2.;
-  }
-  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Recur_Create(adapt_edge *e, int maxlevel, int level, 
-                           Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Error(double AVG, double tol);
-  static void Recur_Error(adapt_edge *e, double AVG, double tol);
-  bool visible;
-  adapt_point *p[2];
-  adapt_edge *e[2];
-  static std::list<adapt_edge*> all_elems;
-  static int nbNod;
-};
-
-class adapt_triangle
-{
- public:
-  adapt_triangle(adapt_point *p1, adapt_point *p2, adapt_point *p3)
-    : visible(false)
-  {
-    p[0] = p1;
-    p[1] = p2;
-    p[2] = p3;
-    e[0] = e[1] = e[2] = e[3] = 0;
-  }
-  inline double V() const
-  {
-    return (p[0]->val + p[1]->val + p[2]->val) / 3.;
-  }
-  static void GSF(const double u, const double v, double w, double sf[])
-  {
-    sf[0] = 1. - u - v;
-    sf[1] = u;
-    sf[2] = v;
-  }
-  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Recur_Create(adapt_triangle *t, int maxlevel, int level,
-                           Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Error(double AVG, double tol);
-  static void Recur_Error(adapt_triangle *t, double AVG, double tol);
-  bool visible;
-  adapt_point *p[3];
-  adapt_triangle *e[4];
-  static std::list<adapt_triangle*> all_elems;
-  static int nbNod;
-};
-
-class adapt_quad
-{
- public:
-  adapt_quad(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)    
-    : visible(false)
-  {
-    p[0] = p1;
-    p[1] = p2;
-    p[2] = p3;
-    p[3] = p4;
-    e[0] = e[1] = e[2] = e[3] = 0;
-  }
-  inline double V() const
-  {
-    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
-  }
-  inline static void GSF(const double u, const double v, double w, double sf[])
-  {
-    sf[0] = 0.25 * (1. - u) * (1. - v);
-    sf[1] = 0.25 * (1. + u) * (1. - v);
-    sf[2] = 0.25 * (1. + u) * (1. + v);
-    sf[3] = 0.25 * (1. - u) * (1. + v);
-  }
-  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Recur_Create(adapt_quad *q, int maxlevel, int level,
-                           Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Error(double AVG, double tol);
-  static void Recur_Error(adapt_quad *q, double AVG, double tol);
-  bool visible;
-  adapt_point *p[4];
-  adapt_quad *e[4];
-  static std::list<adapt_quad*> all_elems;
-  static int nbNod;
-};
-
-class adapt_tet
-{
- public:
-  adapt_tet(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4)
-    : visible(false)
-  {
-    p[0] = p1;
-    p[1] = p2;
-    p[2] = p3;
-    p[3] = p4;
-    e[0] = e[1] = e[2] = e[3] = 0;
-    e[4] = e[5] = e[6] = e[7] = 0;
-  }
-  inline static void GSF(const double u, const double v, double w, double sf[])
-  {
-    sf[0] = 1. - u - v - w;
-    sf[1] = u;
-    sf[2] = v;
-    sf[3] = w;
-  }
-  inline double V() const
-  {
-    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
-  }
-  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Recur_Create(adapt_tet *t, int maxlevel, int level, 
-                           Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Error(double AVG, double tol);
-  static void Recur_Error(adapt_tet *t, double AVG, double tol);
-  bool visible;
-  adapt_point *p[4];
-  adapt_tet *e[8];
-  static std::list<adapt_tet*> all_elems;
-  static int nbNod;
-};
-
-class adapt_hex
-{
- public:
-  adapt_hex(adapt_point *p1, adapt_point *p2, adapt_point *p3, adapt_point *p4,
-            adapt_point *p5, adapt_point *p6, adapt_point *p7, adapt_point *p8)    
-    : visible(false)
-  {
-    p[0] = p1;
-    p[1] = p2;
-    p[2] = p3;
-    p[3] = p4;
-    p[4] = p5;
-    p[5] = p6;
-    p[6] = p7;
-    p[7] = p8;
-    e[0] = e[1] = e[2] = e[3] = 0;
-    e[4] = e[5] = e[6] = e[7] = 0;
-  }
-  inline static void GSF(const double u, const double v, double w, double sf[])
-  {
-    sf[0] = 0.125 * (1 - u) * (1 - v) * (1 - w);
-    sf[1] = 0.125 * (1 + u) * (1 - v) * (1 - w);
-    sf[2] = 0.125 * (1 + u) * (1 + v) * (1 - w);
-    sf[3] = 0.125 * (1 - u) * (1 + v) * (1 - w);
-    sf[4] = 0.125 * (1 - u) * (1 - v) * (1 + w);
-    sf[5] = 0.125 * (1 + u) * (1 - v) * (1 + w);
-    sf[6] = 0.125 * (1 + u) * (1 + v) * (1 + w);
-    sf[7] = 0.125 * (1 - u) * (1 + v) * (1 + w);
-  }
-  inline double V() const
-  {
-    return (p[0]->val + p[1]->val + p[2]->val+ p[3]->val +
-            p[4]->val + p[5]->val + p[6]->val+ p[7]->val) / 8.;
-  }
-  static void Create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Recur_Create(adapt_hex *h, int maxlevel, int level,
-                           Double_Matrix *coeffs, Double_Matrix *eexps);
-  static void Error(double AVG, double tol);
-  static void Recur_Error(adapt_hex *h, double AVG, double tol);
-  bool visible;
-  adapt_point *p[8];
-  adapt_hex *e[8];
-  static std::list<adapt_hex*> all_elems;
-  static int nbNod;
-};
-
-class Adaptive_Post_View 
-{
-  double tol;
-  double minval, maxval;
-  int presentZoomLevel;
-  double presentTol;
-  Double_Matrix *_eexps;
-  Double_Matrix *_coefs;
-  Double_Matrix *_coefsGeom;
-  Double_Matrix *_eexpsGeom;
-  Double_Matrix *_STposX;
-  Double_Matrix *_STposY;
-  Double_Matrix *_STposZ;
-  Double_Matrix *_STval;
-  // for vectors
-  Double_Matrix *_STvalX;
-  Double_Matrix *_STvalY;
-  Double_Matrix *_STvalZ;
-  Double_Matrix *_Interpolate;
-  Double_Matrix *_Geometry;
-public:
-  Adaptive_Post_View(PViewDataList *data, List_T *_coeffs, List_T *_eexps, 
-                     List_T *_coeffsGeom=0, List_T *_eexpsGeom=0);
-  ~Adaptive_Post_View();
-  int getGlobalResolutionLevel() const { return presentZoomLevel; }
-  void setGlobalResolutionLevel(PViewDataList *data, int level)
-  {
-    setAdaptiveResolutionLevel(data, level);
-  }
-  void setAdaptiveResolutionLevel(PViewDataList *data, int levelmax, 
-                                  GMSH_Post_Plugin *plug=0);
-  template <class ELEM>
-  void setAdaptiveResolutionLevel_TEMPL(int level, int lemvelmax,
-                                        GMSH_Post_Plugin *plug, List_T **myList,
-                                        int *counter, int *done);
-  void initWithLowResolution(PViewDataList *data);
-  void setTolerance(const double eps) { tol = eps; }
-  double getTolerance() const { return tol; }
-  template <class ELEM>
-  int zoomElement(int ielem, int level, int levelmax, 
-                  GMSH_Post_Plugin *plug, List_T *theList, int *counter);
-};
-
-template <class ELEM>
-void cleanElement()
-{  
-  typename std::list<ELEM*>::iterator it = ELEM::all_elems.begin();
-  typename std::list<ELEM*>::iterator ite = ELEM::all_elems.end();
-  for(; it != ite; ++it){
-    delete *it;
-  }
-  ELEM::all_elems.clear();
-  adapt_point::all_points.clear();
-}
-
-#endif
diff --git a/Post/Makefile b/Post/Makefile
index fe6c12b19b..656e4f078b 100644
--- a/Post/Makefile
+++ b/Post/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.40 2008-04-06 07:51:37 geuzaine Exp $
+# $Id: Makefile,v 1.41 2008-04-22 07:37:16 geuzaine Exp $
 #
 # Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 #
@@ -35,7 +35,7 @@ SRC = PView.cpp PViewIO.cpp\
           PViewDataList.cpp PViewDataListIO.cpp\
           PViewDataGModel.cpp PViewDataGModelIO.cpp\
         PViewOptions.cpp\
-      AdaptiveViews.cpp\
+      adaptiveData.cpp\
       OctreePost.cpp\
       ColorTable.cpp
 
@@ -62,42 +62,40 @@ depend:
 	rm -f Makefile.new
 
 # DO NOT DELETE THIS LINE
-PView.o: PView.cpp PView.h PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h PViewOptions.h ColorTable.h PViewDataList.h \
-  AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  ../Common/VertexArray.h ../Geo/SVector3.h ../Geo/SPoint3.h \
-  ../Common/Context.h ../Common/SmoothData.h ../Common/Message.h
-PViewIO.o: PViewIO.cpp PView.h PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h PViewOptions.h ColorTable.h PViewDataList.h \
-  AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  PViewDataGModel.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
-  ../Common/StringUtils.h ../Common/Message.h
-PViewData.o: PViewData.cpp PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
-  ../Common/Message.h
+PView.o: PView.cpp PView.h PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h PViewOptions.h ColorTable.h \
+  PViewDataList.h ../Common/VertexArray.h ../Geo/SVector3.h \
+  ../Geo/SPoint3.h ../Common/Context.h ../Common/SmoothData.h \
+  adaptiveData.h ../Common/GmshMatrix.h ../Common/Message.h
+PViewIO.o: PViewIO.cpp PView.h PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h PViewOptions.h ColorTable.h \
+  PViewDataList.h PViewDataGModel.h ../Geo/GModel.h ../Geo/GVertex.h \
+  ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SBoundingBox3d.h ../Common/StringUtils.h ../Common/Message.h
+PViewData.o: PViewData.cpp PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h adaptiveData.h \
+  ../Common/GmshMatrix.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h ../Common/Message.h
 PViewDataIO.o: PViewDataIO.cpp ../Common/Message.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h PViewData.h ../Geo/SBoundingBox3d.h \
-  ../Geo/SPoint3.h
+  ../Numeric/NumericEmbedded.h PViewData.h ../DataStr/List.h \
+  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h
 PViewDataList.o: PViewDataList.cpp PViewDataList.h PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h ../Common/SmoothData.h ../Common/Message.h \
-  ../Common/Context.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h \
+  ../Common/SmoothData.h ../Common/Message.h ../Common/Context.h
 PViewDataListIO.o: PViewDataListIO.cpp PViewDataList.h PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h AdaptiveViews.h \
-  ../DataStr/List.h ../Common/GmshMatrix.h ../Numeric/Numeric.h \
-  ../Numeric/NumericEmbedded.h ../Common/Message.h ../Common/Context.h
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Message.h \
+  ../Common/Context.h
 PViewDataGModel.o: PViewDataGModel.cpp PViewDataGModel.h PViewData.h \
-  ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h PViewDataList.h \
-  AdaptiveViews.h ../DataStr/List.h ../Common/GmshMatrix.h \
-  ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h \
-  ../Geo/SPoint3.h ../Geo/SBoundingBox3d.h ../Geo/GPoint.h \
+  ../DataStr/List.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
+  PViewDataList.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
+  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
@@ -108,9 +106,8 @@ PViewDataGModel.o: PViewDataGModel.cpp PViewDataGModel.h PViewData.h \
   ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h ../Numeric/Numeric.h \
   ../Numeric/NumericEmbedded.h ../Common/Message.h
 PViewDataGModelIO.o: PViewDataGModelIO.cpp ../Common/Message.h \
-  PViewDataGModel.h PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  PViewDataList.h AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Geo/GModel.h ../Geo/GVertex.h \
+  PViewDataGModel.h PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h PViewDataList.h ../Geo/GModel.h ../Geo/GVertex.h \
   ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
   ../Geo/SBoundingBox3d.h ../Geo/GPoint.h ../Geo/SPoint2.h ../Geo/GEdge.h \
   ../Geo/GEntity.h ../Geo/GVertex.h ../Geo/SVector3.h ../Geo/SPoint3.h \
@@ -124,24 +121,24 @@ PViewDataGModelIO.o: PViewDataGModelIO.cpp ../Common/Message.h \
   ../Numeric/NumericEmbedded.h ../Common/StringUtils.h
 PViewOptions.o: PViewOptions.cpp PViewOptions.h ColorTable.h \
   ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h ../Common/Message.h
-AdaptiveViews.o: AdaptiveViews.cpp AdaptiveViews.h ../DataStr/List.h \
-  ../Common/GmshMatrix.h ../Plugin/Plugin.h ../Common/Options.h \
+adaptiveData.o: adaptiveData.cpp ../Plugin/Plugin.h ../Common/Options.h \
   ../Post/ColorTable.h ../Common/Message.h ../Post/PView.h \
-  ../Post/PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h \
-  ../Post/PViewOptions.h ../Post/ColorTable.h ../Post/PViewDataList.h \
-  ../Post/PViewData.h ../Post/AdaptiveViews.h
+  ../Post/PViewData.h ../DataStr/List.h ../Geo/SBoundingBox3d.h \
+  ../Geo/SPoint3.h ../Post/PViewOptions.h ../Post/ColorTable.h \
+  ../Post/PViewDataList.h ../Post/PViewData.h ../Common/GmshMatrix.h \
+  adaptiveData.h
 OctreePost.o: OctreePost.cpp ../Common/Octree.h \
   ../Common/OctreeInternals.h OctreePost.h ../DataStr/List.h PView.h \
   PViewData.h ../Geo/SBoundingBox3d.h ../Geo/SPoint3.h PViewOptions.h \
-  ColorTable.h PViewDataList.h AdaptiveViews.h ../Common/GmshMatrix.h \
-  PViewDataGModel.h ../Geo/GModel.h ../Geo/GVertex.h ../Geo/GEntity.h \
-  ../Geo/Range.h ../Geo/SPoint3.h ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h ../Geo/GPoint.h ../Geo/GEdgeLoop.h \
-  ../Geo/GEdge.h ../Geo/SPoint2.h ../Geo/SVector3.h ../Geo/Pair.h \
-  ../Geo/GRegion.h ../Geo/GEntity.h ../Geo/SBoundingBox3d.h \
-  ../Numeric/Numeric.h ../Numeric/NumericEmbedded.h ../Common/Message.h \
+  ColorTable.h PViewDataList.h PViewDataGModel.h ../Geo/GModel.h \
+  ../Geo/GVertex.h ../Geo/GEntity.h ../Geo/Range.h ../Geo/SPoint3.h \
+  ../Geo/SBoundingBox3d.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/GFace.h ../Geo/GEntity.h \
+  ../Geo/GPoint.h ../Geo/GEdgeLoop.h ../Geo/GEdge.h ../Geo/SPoint2.h \
+  ../Geo/SVector3.h ../Geo/Pair.h ../Geo/GRegion.h ../Geo/GEntity.h \
+  ../Geo/SBoundingBox3d.h ../Numeric/Numeric.h \
+  ../Numeric/NumericEmbedded.h ../Common/Message.h \
   ../Common/ShapeFunctions.h ../Geo/MElement.h ../Common/GmshDefines.h \
   ../Geo/MVertex.h ../Geo/SPoint3.h ../Geo/MEdge.h ../Geo/MVertex.h \
   ../Geo/SVector3.h ../Geo/MFace.h ../Geo/MVertex.h ../Geo/SVector3.h
diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp
index 9ff74cfa78..8f584ebb5a 100644
--- a/Post/OctreePost.cpp
+++ b/Post/OctreePost.cpp
@@ -1,4 +1,4 @@
-// $Id: OctreePost.cpp,v 1.11 2008-04-02 16:30:29 geuzaine Exp $
+// $Id: OctreePost.cpp,v 1.12 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -435,8 +435,8 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, doub
     if(timestep < 0 || step == timestep){
       for(int nod = 0; nod < e->getNumVertices(); nod++){
         for(int comp = 0; comp < nbComp; comp++){
-          if(!_theViewDataGModel->getValue(step, dataIndex[nod], nod, comp, 
-                                           nodeval[nod * nbComp + comp]))
+          if(!_theViewDataGModel->getValueByIndex(step, dataIndex[nod], nod, comp, 
+						  nodeval[nod * nbComp + comp]))
             return false;
         }
       }
diff --git a/Post/PView.cpp b/Post/PView.cpp
index 7efc380f1f..91faa1824d 100644
--- a/Post/PView.cpp
+++ b/Post/PView.cpp
@@ -1,4 +1,4 @@
-// $Id: PView.cpp,v 1.26 2008-03-29 10:19:43 geuzaine Exp $
+// $Id: PView.cpp,v 1.27 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -28,6 +28,7 @@
 #include "PViewDataList.h"
 #include "VertexArray.h"
 #include "SmoothData.h"
+#include "adaptiveData.h"
 #include "Message.h"
 
 int PView::_globalNum = 0;
@@ -145,6 +146,13 @@ void PView::setOptions(PViewOptions *val)
     *_options = PViewOptions::reference;
 }
 
+PViewData *PView::getData(bool useAdaptiveIfAvailable)
+{ 
+  if(useAdaptiveIfAvailable && _data->isAdaptive()) 
+    return _data->getAdaptiveData()->getData();
+  return _data;
+}
+
 void PView::setChanged(bool val)
 { 
   _changed = val; 
diff --git a/Post/PView.h b/Post/PView.h
index d2eaf2b6cb..fa5522ac9b 100644
--- a/Post/PView.h
+++ b/Post/PView.h
@@ -27,6 +27,7 @@
 
 class VertexArray;
 class smooth_normals;
+class GMSH_Post_Plugin;
 
 // a post-processing view
 class PView{
@@ -63,7 +64,7 @@ class PView{
   void deleteVertexArrays();
   PViewOptions *getOptions(){ return _options; }  
   void setOptions(PViewOptions *val=0);  
-  PViewData *getData(){ return _data; }
+  PViewData *getData(bool useAdaptiveIfAvailable=false);
   void setData(PViewData *val){ _data = val; }
   int getNum(){ return _num; }
   int getIndex(){ return _index; }
diff --git a/Post/PViewData.cpp b/Post/PViewData.cpp
index 72544dc6f7..524491bc5e 100644
--- a/Post/PViewData.cpp
+++ b/Post/PViewData.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewData.cpp,v 1.17 2008-04-06 09:20:17 geuzaine Exp $
+// $Id: PViewData.cpp,v 1.18 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -23,14 +23,32 @@
 // 
 
 #include "PViewData.h"
+#include "adaptiveData.h"
 #include "Numeric.h"
 #include "Message.h"
 
 PViewData::PViewData()
-  : _dirty(true), _fileIndex(0)
+  : _dirty(true), _fileIndex(0), _adaptive(0)
 {
 }
 
+PViewData::~PViewData()
+{
+  if(_adaptive) delete _adaptive;
+}
+
+bool PViewData::finalize()
+{ 
+  if(!_adaptive && _interpolation.size()){
+    Msg(INFO, "Initializing adaptive data %p interp size= %d",
+	this, _interpolation.size());
+    _adaptive = new adaptiveData(this);
+    _adaptive->initWithLowResolution(0);
+  }
+  _dirty = false;
+  return true;
+}
+
 bool PViewData::empty()
 {
   return (!getNumElements() && !getNumStrings2D() && !getNumStrings3D());
@@ -54,3 +72,23 @@ void PViewData::setValue(int step, int ent, int ele, int nod, int comp, double v
 {
   Msg(GERROR, "Cannot change field value in this view");
 }
+
+void PViewData::setInterpolationScheme(int type, List_T *coef, List_T *pol, 
+				       List_T *coefGeo, List_T *polGeo)
+{
+  Msg(DEBUG, "Storing interpolation scheme %d in view %p", type, this);
+  if(!type || !_interpolation[type].empty()) return;
+  if(coef) _interpolation[type].push_back(coef);
+  if(pol) _interpolation[type].push_back(pol);
+  if(coefGeo) _interpolation[type].push_back(coefGeo);
+  if(polGeo) _interpolation[type].push_back(polGeo);
+}
+
+int PViewData::getInterpolationScheme(int type, std::vector<List_T*> &p)
+{
+  if(_interpolation.count(type)){
+    p = _interpolation[type];
+    return p.size();
+  }
+  return 0;
+}
diff --git a/Post/PViewData.h b/Post/PViewData.h
index 6b37975f03..c0fc853e36 100644
--- a/Post/PViewData.h
+++ b/Post/PViewData.h
@@ -22,10 +22,13 @@
 
 #include <string>
 #include <vector>
+#include <map>
+#include "List.h"
 #include "SBoundingBox3d.h"
 
 #define VAL_INF 1.e200
 
+class adaptiveData;
 class GModel;
 class nameData;
 
@@ -40,12 +43,17 @@ class PViewData {
   std::string _fileName;
   // index of the view in the file
   int _fileIndex;
+  // adaptive visualization data
+  adaptiveData *_adaptive;
+ protected:
+  // interpolation matrices, indexed by element type
+  std::map<int, std::vector<List_T*> > _interpolation;
  public:
   PViewData();
-  virtual ~PViewData(){}
+  virtual ~PViewData();
   virtual bool getDirty(){ return _dirty; }
   virtual void setDirty(bool val){ _dirty = val; }
-  virtual bool finalize(){ _dirty = false; return true; }
+  virtual bool finalize();
   virtual std::string getName(){ return _name; }
   virtual void setName(std::string val){ _name = val; }
   virtual std::string getFileName(){ return _fileName; }
@@ -90,9 +98,13 @@ class PViewData {
   // Returns the number of componts available for the ele-th element
   // in the ent-th entity
   virtual int getNumComponents(int step, int ent, int ele) = 0;
+  // Returns the number of values available for the ele-th element
+  // in the ent-th entity
+  virtual int getNumValues(int step, int ent, int ele) = 0;
   // Gets/sets the comp-th component (at the step-th time step)
   // associated with the node-th node from the ele-th element in the
   // ent-th entity
+  virtual void getValue(int step, int ent, int ele, int idx, double &val) = 0;
   virtual void getValue(int step, int ent, int ele, int nod, int comp, double &val) = 0;
   virtual void setValue(int step, int ent, int ele, int nod, int comp, double val);
   // Returns a scalar value (same as value for scalars, norm for
@@ -113,7 +125,6 @@ class PViewData {
   virtual void smooth(){}
   virtual bool combineTime(nameData &nd){ return false; }
   virtual bool combineSpace(nameData &nd){ return false; }
-  virtual bool isAdaptive(){ return false; }
   virtual bool skipEntity(int step, int ent){ return false; }
   virtual bool skipElement(int step, int ent, int ele,
 			   bool checkVisibility=false){ return false; }
@@ -123,6 +134,12 @@ class PViewData {
   virtual bool hasModel(GModel *model, int step=-1){ return false; }
   virtual bool useGaussPoints(){ return false; }
 
+  bool isAdaptive(){ return _adaptive ? true : false; }
+  adaptiveData *getAdaptiveData(){ return _adaptive; }
+  void setInterpolationScheme(int type, List_T *coef, List_T *pol, 
+			      List_T *coefGeo=0, List_T *polGeo=0);
+  int getInterpolationScheme(int type, std::vector<List_T*> &p);
+
   // I/O routines
   virtual bool writeSTL(std::string fileName);
   virtual bool writeTXT(std::string fileName);
diff --git a/Post/PViewDataGModel.cpp b/Post/PViewDataGModel.cpp
index 13127cc271..212589fa65 100644
--- a/Post/PViewDataGModel.cpp
+++ b/Post/PViewDataGModel.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataGModel.cpp,v 1.52 2008-04-18 16:40:29 geuzaine Exp $
+// $Id: PViewDataGModel.cpp,v 1.53 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -28,7 +28,7 @@
 #include "Message.h"
 
 PViewDataGModel::PViewDataGModel(DataType type) 
-  : _min(VAL_INF), _max(-VAL_INF), _type(type)
+  : PViewData(), _min(VAL_INF), _max(-VAL_INF), _type(type)
 {
 }
 
@@ -58,8 +58,8 @@ bool PViewDataGModel::finalize()
     _min = std::min(_min, _steps[step]->getMin());
     _max = std::max(_max, _steps[step]->getMax());
   }
-  setDirty(false);
-  return true;
+
+  return PViewData::finalize();
 }
 
 int PViewDataGModel::getNumTimeSteps()
@@ -285,6 +285,29 @@ int PViewDataGModel::getNumComponents(int step, int ent, int ele)
   return _steps[step]->getNumComponents();
 }
 
+int PViewDataGModel::getNumValues(int step, int ent, int ele)
+{
+  if(_type == ElementNodeData){
+    return getNumNodes(step, ent, ele) * getNumComponents(step, ent, ele);
+  }
+  else{
+    Msg(GERROR, "getNumValues should not be used on this type of view");
+    return 0;
+  }
+}
+
+void PViewDataGModel::getValue(int step, int ent, int ele, int idx, double &val)
+{
+  if(_type == ElementNodeData){
+    stepData<double> *sd = _steps[step];
+    MElement *e = sd->getEntity(ent)->getMeshElement(ele);
+    val = sd->getData(e->getNum())[idx];
+  }
+  else{
+    Msg(GERROR, "getValue(index) should not be used on this type of view");
+  }
+}
+
 void PViewDataGModel::getValue(int step, int ent, int ele, int nod, int comp, double &val)
 {
   // no sanity checks (assumed to be guarded by skipElement)
@@ -351,7 +374,7 @@ void PViewDataGModel::smooth()
       for(int ele = 0; ele < getNumElements(step, ent); ele++){
 	MElement *e = _steps[step]->getEntity(ent)->getMeshElement(ele);
 	double val;
-	if(!getValue(step, e->getNum(), 0, 0, val)) continue;
+	if(!getValueByIndex(step, e->getNum(), 0, 0, val)) continue;
 	for(int nod = 0; nod < e->getNumVertices(); nod++){
 	  MVertex *v = e->getVertex(nod);
 	  if(nodeConnect.count(v->getNum()))
@@ -360,7 +383,7 @@ void PViewDataGModel::smooth()
 	    nodeConnect[v->getNum()] = 1;
 	  double *d = _steps2.back()->getData(v->getNum(), true);
 	  for(int j = 0; j < numComp; j++)
-	    if(getValue(step, e->getNum(), nod, j, val)) d[j] += val;
+	    if(getValueByIndex(step, e->getNum(), nod, j, val)) d[j] += val;
 	}
       }
     }
@@ -436,7 +459,7 @@ GEntity *PViewDataGModel::getEntity(int step, int ent)
   return _steps[step]->getEntity(ent);
 }
 
-bool PViewDataGModel::getValue(int step, int dataIndex, int nod, int comp, double &val)
+bool PViewDataGModel::getValueByIndex(int step, int dataIndex, int nod, int comp, double &val)
 {
   double *d = _steps[step]->getData(dataIndex);
   if(!d) return false;
diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h
index 407adc77d9..101f54d0c5 100644
--- a/Post/PViewDataGModel.h
+++ b/Post/PViewDataGModel.h
@@ -170,6 +170,8 @@ class PViewDataGModel : public PViewData {
   void setNode(int step, int ent, int ele, int nod, double x, double y, double z);
   void tagNode(int step, int ent, int ele, int nod, int tag);
   int getNumComponents(int step, int ent, int ele);
+  int getNumValues(int step, int ent, int ele);
+  void getValue(int step, int ent, int ele, int idx, double &val);
   void getValue(int step, int ent, int ele, int node, int comp, double &val);
   void setValue(int step, int ent, int ele, int node, int comp, double val);
   int getNumEdges(int step, int ent, int ele);
@@ -188,7 +190,7 @@ class PViewDataGModel : public PViewData {
   // direct access to GModel entities
   GEntity *getEntity(int step, int ent);
   // direct access to value by index
-  bool getValue(int step, int dataIndex, int node, int comp, double &val);
+  bool getValueByIndex(int step, int dataIndex, int node, int comp, double &val);
 
   // I/O routines
   bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary, 
diff --git a/Post/PViewDataList.cpp b/Post/PViewDataList.cpp
index be83f62e84..1f05060922 100644
--- a/Post/PViewDataList.cpp
+++ b/Post/PViewDataList.cpp
@@ -1,4 +1,4 @@
-// $Id: PViewDataList.cpp,v 1.22 2008-04-15 19:02:33 geuzaine Exp $
+// $Id: PViewDataList.cpp,v 1.23 2008-04-22 07:37:16 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -48,9 +48,10 @@ PViewDataList::PViewDataList(bool allocate)
     SI(0), VI(0), TI(0), SI2(0), VI2(0), TI2(0),
     NbSY(0), NbVY(0), NbTY(0), NbSY2(0), NbVY2(0), NbTY2(0),
     SY(0), VY(0), TY(0), SY2(0), VY2(0), TY2(0),
-    NbT2(0), NbT3(0), T2D(0), T2C(0), T3D(0), T3C(0), adaptive(0), 
+    NbT2(0), NbT3(0), T2D(0), T2C(0), T3D(0), T3C(0), 
     _lastElement(-1), _lastDimension(-1), _lastNumNodes(-1), 
-    _lastNumComponents(-1), _lastNumEdges(-1), _lastXYZ(0), _lastVal(0)
+    _lastNumComponents(-1), _lastNumValues(-1), _lastNumEdges(-1),
+    _lastXYZ(0), _lastVal(0)
 {
   for(int i = 0; i < 24; i++) _index[i] = 0;
 
@@ -86,21 +87,14 @@ PViewDataList::~PViewDataList()
   List_Delete(SY); List_Delete(VY); List_Delete(TY);
   List_Delete(T2D); List_Delete(T2C);
   List_Delete(T3D); List_Delete(T3C);
-  if(adaptive) delete adaptive;
 }
 
 bool PViewDataList::finalize()
 {
-  // sanity checks
-  if(!adaptive){ // if adaptive, just hope for the best ;-)
-    // check that number of values per element = 
-    // 3 * number of coordinates + (1,2,9) * integer * number of values
-  }
-
   BBox.reset();
   Min = VAL_INF;
   Max = -VAL_INF;
-
+ 
   // finalize text strings first, to get the max value of NbTimeStep
   // for strings-only views (strings are designed to degrade
   // gracefully when some have fewer time steps than others). If there
@@ -108,21 +102,21 @@ bool PViewDataList::finalize()
   // minimum number of time steps common to all elements.
   _stat(T2D, T2C, 4); _stat(T3D, T3C, 5);
 
-  // convert all "old-style" (non adaptive) 2nd order elements into
-  // linear elements *and* free all the data associated with the 2nd
-  // order elements (this is a temporary solution, until we use
+  // FIXME: convert all "old-style" 2nd order elements into linear
+  // elements *and* free all the data associated with the 2nd order
+  // elements (this is a temporary solution, until we use
   // Adaptive_Views on all curved elements)
   _splitCurvedElements();
 
   // compute min/max and other statistics for all element lists
-  _stat(SP, 1, NbSP, 1); _stat(VP, 3, NbVP, 1); _stat(TP, 9, NbTP, 1);
-  _stat(SL, 1, NbSL, 2); _stat(VL, 3, NbVL, 2); _stat(TL, 9, NbTL, 2);
-  _stat(ST, 1, NbST, 3); _stat(VT, 3, NbVT, 3); _stat(TT, 9, NbTT, 3);
-  _stat(SQ, 1, NbSQ, 4); _stat(VQ, 3, NbVQ, 4); _stat(TQ, 9, NbTQ, 4);
-  _stat(SS, 1, NbSS, 4); _stat(VS, 3, NbVS, 4); _stat(TS, 9, NbTS, 4);
-  _stat(SH, 1, NbSH, 8); _stat(VH, 3, NbVH, 8); _stat(TH, 9, NbTH, 8);
-  _stat(SI, 1, NbSI, 6); _stat(VI, 3, NbVI, 6); _stat(TI, 9, NbTI, 6);
-  _stat(SY, 1, NbSY, 5); _stat(VY, 3, NbVY, 5); _stat(TY, 9, NbTY, 5);
+  _stat(SP, 1, NbSP, 1, 0); _stat(VP, 3, NbVP, 1, 0); _stat(TP, 9, NbTP, 1, 0);
+  _stat(SL, 1, NbSL, 2, 1); _stat(VL, 3, NbVL, 2, 1); _stat(TL, 9, NbTL, 2, 1);
+  _stat(ST, 1, NbST, 3, 3); _stat(VT, 3, NbVT, 3, 3); _stat(TT, 9, NbTT, 3, 3);
+  _stat(SQ, 1, NbSQ, 4, 4); _stat(VQ, 3, NbVQ, 4, 4); _stat(TQ, 9, NbTQ, 4, 4);
+  _stat(SS, 1, NbSS, 4, 6); _stat(VS, 3, NbVS, 4, 6); _stat(TS, 9, NbTS, 4, 6);
+  _stat(SH, 1, NbSH, 8,12); _stat(VH, 3, NbVH, 8,12); _stat(TH, 9, NbTH, 8,12);
+  _stat(SI, 1, NbSI, 6, 9); _stat(VI, 3, NbVI, 6, 9); _stat(TI, 9, NbTI, 6, 9);
+  _stat(SY, 1, NbSY, 5, 8); _stat(VY, 3, NbVY, 5, 8); _stat(TY, 9, NbTY, 5, 8);
 
   // add dummy time values if none (or too few) time values are
   // provided (e.g. using the old parsed format)
@@ -144,10 +138,8 @@ bool PViewDataList::finalize()
   }
 
   if(CTX.post.smooth) smooth();
-  
-  setDirty(false);
 
-  return true;
+  return PViewData::finalize();
 }
 
 int PViewDataList::getNumScalars(int step)
@@ -218,11 +210,19 @@ void PViewDataList::_stat(List_T *D, List_T *C, int nb)
   }
 }
 
-void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod)
+void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod, int nbedg)
 {
   // compute statistics for element lists
   if(!nbelm) return;
 
+  int nbval = nbcomp * nbnod;
+
+  if(_interpolation.count(nbedg)){
+    nbval = List_Nbr(_interpolation[nbedg][0]);
+    if(nbval != nbcomp * nbnod)
+      Msg(INFO, "Adaptive view with %d values per element", nbval);
+  }
+  
   int nb = List_Nbr(list) / nbelm;
   for(int i = 0; i < List_Nbr(list); i += nb){
     int N = nb - 3 * nbnod;
@@ -237,7 +237,7 @@ void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod)
 
     // update num time steps
     if(Min == VAL_INF || Max == -VAL_INF){
-      NbTimeStep = N / (nbcomp * nbnod);
+      NbTimeStep = N / nbval;
       TimeStepMin.clear();
       TimeStepMax.clear();
       for(int j = 0; j < NbTimeStep; j++){
@@ -245,9 +245,9 @@ void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod)
         TimeStepMax.push_back(-VAL_INF);
       }
     }
-    else if(N / (nbcomp * nbnod) < NbTimeStep){
+    else if(N / nbval < NbTimeStep){
       // if some elts have less steps, reduce the total number!
-      NbTimeStep = N / (nbcomp * nbnod);
+      NbTimeStep = N / nbval;
     }
     
     // update min/max
@@ -255,7 +255,7 @@ void PViewDataList::_stat(List_T *list, int nbcomp, int nbelm, int nbnod)
       double l0 = ComputeScalarRep(nbcomp, &V[j]);
       Min = std::min(l0, Min);
       Max = std::max(l0, Max);
-      int ts = j / (nbcomp * nbnod);
+      int ts = j / nbval;
       if(ts < NbTimeStep){ // security
         TimeStepMin[ts] = std::min(l0, TimeStepMin[ts]);
         TimeStepMax[ts] = std::max(l0, TimeStepMax[ts]);
@@ -274,6 +274,7 @@ void PViewDataList::_setLast(int ele, int dim, int nbnod, int nbcomp, int nbedg,
   int nb = List_Nbr(list) / nblist;
   _lastXYZ = (double*)List_Pointer_Fast(list, ele * nb);
   _lastVal = (double*)List_Pointer_Fast(list, ele * nb + 3 * _lastNumNodes);
+  _lastNumValues = (nb - 3 * nbnod) / NbTimeStep;
 }
 
 void PViewDataList::_setLast(int ele)
@@ -359,9 +360,23 @@ int PViewDataList::getNumComponents(int step, int ent, int ele)
   return _lastNumComponents;
 }
 
+int PViewDataList::getNumValues(int step, int ent, int ele)
+{
+  if(ele != _lastElement) _setLast(ele);
+  return _lastNumValues;
+}
+
+void PViewDataList::getValue(int step, int ent, int ele, int idx, double &val)
+{
+  if(ele != _lastElement) _setLast(ele);
+  if(step >= NbTimeStep) step = 0;
+  val = _lastVal[step * _lastNumValues + idx];
+}
+
 void PViewDataList::getValue(int step, int ent, int ele, int nod, int comp, double &val)
 {
   if(ele != _lastElement) _setLast(ele);
+  if(step >= NbTimeStep) step = 0;
   val = _lastVal[step * _lastNumNodes  * _lastNumComponents + 
                  nod * _lastNumComponents +
                  comp];
@@ -370,6 +385,7 @@ void PViewDataList::getValue(int step, int ent, int ele, int nod, int comp, doub
 void PViewDataList::setValue(int step, int ent, int ele, int nod, int comp, double val)
 {
   if(ele != _lastElement) _setLast(ele);
+  if(step >= NbTimeStep) step = 0;
   _lastVal[step * _lastNumNodes  * _lastNumComponents + 
 	   nod * _lastNumComponents +
 	   comp] = val;
diff --git a/Post/PViewDataList.h b/Post/PViewDataList.h
index 4355a87d93..7bee621d4c 100644
--- a/Post/PViewDataList.h
+++ b/Post/PViewDataList.h
@@ -23,7 +23,6 @@
 #include <vector>
 #include <string>
 #include "PViewData.h"
-#include "AdaptiveViews.h"
 #include "SBoundingBox3d.h"
 #include "List.h"
 
@@ -56,14 +55,13 @@ class PViewDataList : public PViewData {
   List_T *SY, *VY, *TY, *SY2, *VY2, *TY2; // pyramids
   int NbT2, NbT3;
   List_T *T2D, *T2C, *T3D, *T3C; // 2D and 3D text strings
-  Adaptive_Post_View *adaptive;
  private:
   int _index[24];
   int _lastElement, _lastDimension;
-  int _lastNumNodes, _lastNumComponents, _lastNumEdges;
+  int _lastNumNodes, _lastNumComponents, _lastNumValues, _lastNumEdges;
   double *_lastXYZ, *_lastVal;
   void _stat(List_T *D, List_T *C, int nb);
-  void _stat(List_T *list, int nbcomp, int nbelm, int nbnod);
+  void _stat(List_T *list, int nbcomp, int nbelm, int nbnod, int nbedg);
   void _setLast(int ele);
   void _setLast(int ele, int dim, int nbnod, int nbcomp, int nbedg,
                 List_T *list, int nblist);
@@ -97,6 +95,8 @@ class PViewDataList : public PViewData {
   int getNode(int step, int ent, int ele, int nod, double &x, double &y, double &z);
   void setNode(int step, int ent, int ele, int nod, double x, double y, double z);
   int getNumComponents(int step, int ent, int ele);
+  int getNumValues(int step, int ent, int ele);
+  void getValue(int step, int ent, int ele, int idx, double &val);
   void getValue(int step, int ent, int ele, int nod, int comp, double &val);
   void setValue(int step, int ent, int ele, int nod, int comp, double val);
   int getNumEdges(int step, int ent, int ele);
@@ -110,7 +110,6 @@ class PViewDataList : public PViewData {
   void smooth();
   bool combineTime(nameData &nd);
   bool combineSpace(nameData &nd);
-  bool isAdaptive(){ return adaptive ? true : false; }
 
   // specific to list-based data sets
   void getRawData(int type, List_T **l, int **ne, int *nc, int *nn);
diff --git a/Post/adaptiveData.cpp b/Post/adaptiveData.cpp
new file mode 100644
index 0000000000..69a10fe8c5
--- /dev/null
+++ b/Post/adaptiveData.cpp
@@ -0,0 +1,1124 @@
+//
+// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+// 
+// Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include <math.h>
+#include <list>
+#include <set>
+#include "Plugin.h"
+#include "adaptiveData.h"
+
+std::set<adaptivePoint> adaptivePoint::all;
+std::list<adaptiveLine*> adaptiveLine::all;
+std::list<adaptiveTriangle*> adaptiveTriangle::all;
+std::list<adaptiveQuadrangle*> adaptiveQuadrangle::all;
+std::list<adaptiveTetrahedron*> adaptiveTetrahedron::all;
+std::list<adaptiveHexahedron*> adaptiveHexahedron::all;
+
+int adaptiveLine::numNodes = 2;
+int adaptiveTriangle::numNodes = 3;
+int adaptiveQuadrangle::numNodes = 4;
+int adaptiveTetrahedron::numNodes = 4;
+int adaptiveHexahedron::numNodes = 8;
+
+int adaptiveLine::numEdges = 1;
+int adaptiveTriangle::numEdges = 3;
+int adaptiveQuadrangle::numEdges = 4;
+int adaptiveTetrahedron::numEdges = 6;
+int adaptiveHexahedron::numEdges = 12;
+
+template <class T>
+static void cleanElement()
+{  
+  for(typename std::list<T*>::iterator it = T::all.begin(); it != T::all.end(); ++it)
+    delete *it;
+  T::all.clear();
+  adaptivePoint::all.clear();
+}
+
+static void computeShapeFunctions(Double_Matrix *coeffs, Double_Matrix *eexps,
+				  double u, double v, double w, double *sf)
+{
+  static double powsuvw[256];
+  for(int j = 0; j < coeffs->size2(); ++j) {
+    double powu = (*eexps)(j, 0);
+    double powv = (*eexps)(j, 1);
+    double poww = (*eexps)(j, 2);
+    powsuvw[j] = pow(u, powu) * pow(v, powv) * pow(w, poww);
+  }
+  for(int i = 0; i < coeffs->size1(); ++i) {
+    sf[i] = 0.;
+    for(int j = 0; j < coeffs->size2(); ++j) {
+      sf[i] += (*coeffs)(i, j) * powsuvw[j];
+    }
+  }
+}
+
+adaptivePoint *adaptivePoint::create(double x, double y, double z,
+				     Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  adaptivePoint p;
+  p.x = x;
+  p.y = y;
+  p.z = z;
+  std::set<adaptivePoint>::iterator it = all.find(p);
+  if(it == all.end()) {
+    all.insert(p);
+    it = all.find(p);
+    computeShapeFunctions(coeffs, eexps, x, y, z, (double*)it->shapeFunctions);
+  }
+  return (adaptivePoint*)&(*it);
+}
+
+void adaptiveLine::create(int maxlevel, 
+			  Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  cleanElement<adaptiveLine>();
+  adaptivePoint *p1 = adaptivePoint::create(-1, 0, 0, coeffs, eexps);
+  adaptivePoint *p2 = adaptivePoint::create(1, 0, 0, coeffs, eexps);
+  adaptiveLine *t = new adaptiveLine(p1, p2);
+  recurCreate(t, maxlevel, 0, coeffs, eexps);
+}
+
+void adaptiveLine::recurCreate(adaptiveLine *e, int maxlevel, int level,
+			       Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  all.push_back(e);
+  if(level++ >= maxlevel) return;
+
+  // p1    p12    p2
+  adaptivePoint *p1 = e->p[0];
+  adaptivePoint *p2 = e->p[1];
+  adaptivePoint *p12 = adaptivePoint::create((p1->x + p2->x) * 0.5, 
+					     (p1->y + p2->y) * 0.5,
+					     (p1->z + p2->z) * 0.5, 
+					     coeffs, eexps);
+  adaptiveLine *e1 = new adaptiveLine(p1, p12);
+  recurCreate(e1, maxlevel, level, coeffs, eexps);
+  adaptiveLine *e2 = new adaptiveLine(p12, p2);
+  recurCreate(e2, maxlevel, level, coeffs, eexps);
+  e->e[0] = e1;
+  e->e[1] = e2;
+}
+
+void adaptiveLine::error(double AVG, double tol)
+{
+  adaptiveLine *e = *all.begin();
+  recurError(e, AVG, tol);
+}
+
+void adaptiveLine::recurError(adaptiveLine *e, double AVG, double tol)
+{
+  if(!e->e[0])
+    e->visible = true;
+  else {
+    double vr;
+    if(!e->e[0]->e[0]) {
+      double v1 = e->e[0]->V();
+      double v2 = e->e[1]->V();
+      vr = (v1 + v2) / 2.;
+      double v = e->V();
+      if(fabs(v - vr) > AVG * tol){
+        e->visible = false;
+        recurError(e->e[0], AVG, tol);
+        recurError(e->e[1], AVG, tol);
+      }
+      else
+        e->visible = true;
+    }
+    else {
+      double v11 = e->e[0]->e[0]->V();
+      double v12 = e->e[0]->e[1]->V();
+      double v21 = e->e[1]->e[0]->V();
+      double v22 = e->e[1]->e[1]->V();
+      double vr1 = (v11 + v12) / 2.;
+      double vr2 = (v21 + v22) / 2.;
+      vr = (vr1 + vr2) / 2.;
+      if(fabs(e->e[0]->V() - vr1) > AVG * tol ||
+         fabs(e->e[1]->V() - vr2) > AVG * tol ||
+         fabs(e->V() - vr) > AVG * tol) {
+        e->visible = false;
+        recurError(e->e[0], AVG, tol);
+        recurError(e->e[1], AVG, tol);
+      }
+      else
+        e->visible = true;
+    }
+  }
+}
+
+void adaptiveTriangle::create(int maxlevel, 
+			      Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  cleanElement<adaptiveTriangle>();
+  adaptivePoint *p1 = adaptivePoint::create(0, 0, 0, coeffs, eexps);
+  adaptivePoint *p2 = adaptivePoint::create(0, 1, 0, coeffs, eexps);
+  adaptivePoint *p3 = adaptivePoint::create(1, 0, 0, coeffs, eexps);
+  adaptiveTriangle *t = new adaptiveTriangle(p1, p2, p3);
+  recurCreate(t, maxlevel, 0, coeffs, eexps);
+}
+
+void adaptiveTriangle::recurCreate(adaptiveTriangle *t, int maxlevel, int level,
+				   Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  all.push_back(t);
+  if(level++ >= maxlevel) return;
+
+  // p3
+  // p13   p23
+  // p1    p12    p2
+  adaptivePoint *p1 = t->p[0];
+  adaptivePoint *p2 = t->p[1];
+  adaptivePoint *p3 = t->p[2];
+  adaptivePoint *p12 = adaptivePoint::create((p1->x + p2->x) * 0.5, 
+					     (p1->y + p2->y) * 0.5, 
+					     (p1->z + p2->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p13 = adaptivePoint::create((p1->x + p3->x) * 0.5, 
+					     (p1->y + p3->y) * 0.5, 
+					     (p1->z + p3->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p23 = adaptivePoint::create((p3->x + p2->x) * 0.5, 
+					     (p3->y + p2->y) * 0.5, 
+					     (p3->z + p2->z) * 0.5, 
+					     coeffs, eexps);
+  adaptiveTriangle *t1 = new adaptiveTriangle(p1, p12, p13);
+  recurCreate(t1, maxlevel, level, coeffs, eexps);
+  adaptiveTriangle *t2 = new adaptiveTriangle(p2, p23, p12);
+  recurCreate(t2, maxlevel, level, coeffs, eexps);
+  adaptiveTriangle *t3 = new adaptiveTriangle(p3, p13, p23);
+  recurCreate(t3, maxlevel, level, coeffs, eexps);
+  adaptiveTriangle *t4 = new adaptiveTriangle(p12, p23, p13);
+  recurCreate(t4, maxlevel, level, coeffs, eexps);
+  t->e[0] = t1;
+  t->e[1] = t2;
+  t->e[2] = t3;
+  t->e[3] = t4;
+}
+
+void adaptiveTriangle::error(double AVG, double tol)
+{
+  adaptiveTriangle *t = *all.begin();
+  recurError(t, AVG, tol);
+}
+
+void adaptiveTriangle::recurError(adaptiveTriangle *t, double AVG, double tol)
+{
+  if(!t->e[0])
+    t->visible = true;
+  else {
+    double vr;
+    if(!t->e[0]->e[0]) {
+      double v1 = t->e[0]->V();
+      double v2 = t->e[1]->V();
+      double v3 = t->e[2]->V();
+      double v4 = t->e[3]->V();
+      vr = (2 * v1 + 2 * v2 + 2 * v3 + v4) / 7.;
+      double v = t->V();
+      if(fabs(v - vr) > AVG * tol){
+        t->visible = false;
+        recurError(t->e[0], AVG, tol);
+        recurError(t->e[1], AVG, tol);
+        recurError(t->e[2], AVG, tol);
+        recurError(t->e[3], AVG, tol);
+      }
+      else
+        t->visible = true;
+    }
+    else {
+      double v11 = t->e[0]->e[0]->V();
+      double v12 = t->e[0]->e[1]->V();
+      double v13 = t->e[0]->e[2]->V();
+      double v14 = t->e[0]->e[3]->V();
+      double v21 = t->e[1]->e[0]->V();
+      double v22 = t->e[1]->e[1]->V();
+      double v23 = t->e[1]->e[2]->V();
+      double v24 = t->e[1]->e[3]->V();
+      double v31 = t->e[2]->e[0]->V();
+      double v32 = t->e[2]->e[1]->V();
+      double v33 = t->e[2]->e[2]->V();
+      double v34 = t->e[2]->e[3]->V();
+      double v41 = t->e[3]->e[0]->V();
+      double v42 = t->e[3]->e[1]->V();
+      double v43 = t->e[3]->e[2]->V();
+      double v44 = t->e[3]->e[3]->V();
+      double vr1 = (2 * v11 + 2 * v12 + 2 * v13 + v14) / 7.;
+      double vr2 = (2 * v21 + 2 * v22 + 2 * v23 + v24) / 7.;
+      double vr3 = (2 * v31 + 2 * v32 + 2 * v33 + v34) / 7.;
+      double vr4 = (2 * v41 + 2 * v42 + 2 * v43 + v44) / 7.;
+      vr = (2 * vr1 + 2 * vr2 + 2 * vr3 + vr4) / 7.;
+      if(fabs(t->e[0]->V() - vr1) > AVG * tol ||
+         fabs(t->e[1]->V() - vr2) > AVG * tol ||
+         fabs(t->e[2]->V() - vr3) > AVG * tol ||
+         fabs(t->e[3]->V() - vr4) > AVG * tol ||
+         fabs(t->V() - vr) > AVG * tol){
+        t->visible = false;
+        recurError(t->e[0], AVG, tol);
+        recurError(t->e[1], AVG, tol);
+        recurError(t->e[2], AVG, tol);
+        recurError(t->e[3], AVG, tol);
+      }
+      else
+        t->visible = true;
+    }
+  }
+}
+
+void adaptiveQuadrangle::create(int maxlevel, 
+				Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  cleanElement<adaptiveQuadrangle>();
+  adaptivePoint *p1 = adaptivePoint::create(-1, -1, 0, coeffs, eexps);
+  adaptivePoint *p2 = adaptivePoint::create(1, -1, 0, coeffs, eexps);
+  adaptivePoint *p3 = adaptivePoint::create(1, 1, 0, coeffs, eexps);
+  adaptivePoint *p4 = adaptivePoint::create(-1, 1, 0, coeffs, eexps);
+  adaptiveQuadrangle *q = new adaptiveQuadrangle(p1, p2, p3, p4);
+  recurCreate(q, maxlevel, 0, coeffs, eexps);
+}
+
+void adaptiveQuadrangle::recurCreate(adaptiveQuadrangle *q, int maxlevel, int level,
+				     Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  all.push_back(q);
+  if(level++ >= maxlevel) return;
+
+  // p4   p34    p3
+  // p14  pc     p23
+  // p1   p12    p2
+  adaptivePoint *p1 = q->p[0];
+  adaptivePoint *p2 = q->p[1];
+  adaptivePoint *p3 = q->p[2];
+  adaptivePoint *p4 = q->p[3];
+  adaptivePoint *p12 = adaptivePoint::create((p1->x + p2->x) * 0.5, 
+					     (p1->y + p2->y) * 0.5, 
+					     (p1->z + p2->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p23 = adaptivePoint::create((p2->x + p3->x) * 0.5, 
+					     (p2->y + p3->y) * 0.5, 
+					     (p2->z + p3->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p34 = adaptivePoint::create((p3->x + p4->x) * 0.5,
+					     (p3->y + p4->y) * 0.5, 
+					     (p3->z + p4->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p14 = adaptivePoint::create((p1->x + p4->x) * 0.5,
+					     (p1->y + p4->y) * 0.5, 
+					     (p1->z + p4->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *pc = adaptivePoint::create((p1->x + p2->x + p3->x + p4->x) * 0.25,
+					    (p1->y + p2->y + p3->y + p4->y) * 0.25, 
+					    (p1->z + p2->z + p3->z + p4->z) * 0.25, 
+					    coeffs, eexps);
+  adaptiveQuadrangle *q1 = new adaptiveQuadrangle(p1, p12, pc, p14);
+  recurCreate(q1, maxlevel, level, coeffs, eexps);
+  adaptiveQuadrangle *q2 = new adaptiveQuadrangle(p2, p23, pc, p12);
+  recurCreate(q2, maxlevel, level, coeffs, eexps);
+  adaptiveQuadrangle *q3 = new adaptiveQuadrangle(p3, p34, pc, p23);
+  recurCreate(q3, maxlevel, level, coeffs, eexps);
+  adaptiveQuadrangle *q4 = new adaptiveQuadrangle(p4, p14, pc, p34);
+  recurCreate(q4, maxlevel, level, coeffs, eexps);
+  q->e[0] = q1;
+  q->e[1] = q2;
+  q->e[2] = q3;
+  q->e[3] = q4;
+}
+
+void adaptiveQuadrangle::error(double AVG, double tol)
+{
+  adaptiveQuadrangle *q = *all.begin();
+  recurError(q, AVG, tol);
+}
+
+void adaptiveQuadrangle::recurError(adaptiveQuadrangle *q, double AVG, double tol)
+{
+  if(!q->e[0])
+    q->visible = true;
+  else {
+    double vr;
+    if(!q->e[0]->e[0]) {
+      double v1 = q->e[0]->V();
+      double v2 = q->e[1]->V();
+      double v3 = q->e[2]->V();
+      double v4 = q->e[3]->V();
+      vr = (v1 + v2 + v3 + v4) / 4.;
+      double v = q->V();
+      if(fabs(v - vr) > AVG * tol){
+        q->visible = false;
+        recurError(q->e[0], AVG, tol);
+        recurError(q->e[1], AVG, tol);
+        recurError(q->e[2], AVG, tol);
+        recurError(q->e[3], AVG, tol);
+      }
+      else
+        q->visible = true;
+    }
+    else {
+      double v11 = q->e[0]->e[0]->V();
+      double v12 = q->e[0]->e[1]->V();
+      double v13 = q->e[0]->e[2]->V();
+      double v14 = q->e[0]->e[3]->V();
+      double v21 = q->e[1]->e[0]->V();
+      double v22 = q->e[1]->e[1]->V();
+      double v23 = q->e[1]->e[2]->V();
+      double v24 = q->e[1]->e[3]->V();
+      double v31 = q->e[2]->e[0]->V();
+      double v32 = q->e[2]->e[1]->V();
+      double v33 = q->e[2]->e[2]->V();
+      double v34 = q->e[2]->e[3]->V();
+      double v41 = q->e[3]->e[0]->V();
+      double v42 = q->e[3]->e[1]->V();
+      double v43 = q->e[3]->e[2]->V();
+      double v44 = q->e[3]->e[3]->V();
+      double vr1 = (v11 + v12 + v13 + v14) / 4.;
+      double vr2 = (v21 + v22 + v23 + v24) / 4.;
+      double vr3 = (v31 + v32 + v33 + v34) / 4.;
+      double vr4 = (v41 + v42 + v43 + v44) / 4.;
+      vr = (vr1 + vr2 + vr3 + vr4) / 4.;
+      if(fabs(q->e[0]->V() - vr1) > AVG * tol ||
+         fabs(q->e[1]->V() - vr2) > AVG * tol ||
+         fabs(q->e[2]->V() - vr3) > AVG * tol ||
+         fabs(q->e[3]->V() - vr4) > AVG * tol ||
+         fabs(q->V() - vr) > AVG * tol){
+        q->visible = false;
+        recurError(q->e[0], AVG, tol);
+        recurError(q->e[1], AVG, tol);
+        recurError(q->e[2], AVG, tol);
+        recurError(q->e[3], AVG, tol);
+      }
+      else
+        q->visible = true;
+    }
+  }
+}
+
+void adaptiveTetrahedron::create(int maxlevel,
+				 Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  cleanElement<adaptiveTetrahedron>();
+  adaptivePoint *p1 = adaptivePoint::create(0, 0, 0, coeffs, eexps);
+  adaptivePoint *p2 = adaptivePoint::create(0, 1, 0, coeffs, eexps);
+  adaptivePoint *p3 = adaptivePoint::create(1, 0, 0, coeffs, eexps);
+  adaptivePoint *p4 = adaptivePoint::create(0, 0, 1, coeffs, eexps);
+  adaptiveTetrahedron *t = new adaptiveTetrahedron(p1, p2, p3, p4);
+  recurCreate(t, maxlevel, 0, coeffs, eexps);
+}
+
+void adaptiveTetrahedron::recurCreate(adaptiveTetrahedron *t, int maxlevel, int level,
+			              Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  all.push_back(t);
+  if(level++ >= maxlevel) return;
+
+  adaptivePoint *p0 = t->p[0];
+  adaptivePoint *p1 = t->p[1];
+  adaptivePoint *p2 = t->p[2];
+  adaptivePoint *p3 = t->p[3];
+  adaptivePoint *pe0 =  adaptivePoint::create((p0->x + p1->x) * 0.5, 
+					      (p0->y + p1->y) * 0.5,
+					      (p0->z + p1->z) * 0.5,
+					      coeffs, eexps);
+  adaptivePoint *pe1 =  adaptivePoint::create((p0->x + p2->x) * 0.5,
+					      (p0->y + p2->y) * 0.5,
+					      (p0->z + p2->z) * 0.5,
+					      coeffs, eexps);
+  adaptivePoint *pe2 =  adaptivePoint::create((p0->x + p3->x) * 0.5, 
+					      (p0->y + p3->y) * 0.5,
+					      (p0->z + p3->z) * 0.5,
+					      coeffs, eexps);
+  adaptivePoint *pe3 =  adaptivePoint::create((p1->x + p2->x) * 0.5, 
+					      (p1->y + p2->y) * 0.5,
+					      (p1->z + p2->z) * 0.5, 
+					      coeffs, eexps);
+  adaptivePoint *pe4 =  adaptivePoint::create((p1->x + p3->x) * 0.5, 
+					      (p1->y + p3->y) * 0.5,
+					      (p1->z + p3->z) * 0.5,
+					      coeffs, eexps);
+  adaptivePoint *pe5 =  adaptivePoint::create((p2->x + p3->x) * 0.5, 
+					      (p2->y + p3->y) * 0.5,
+					      (p2->z + p3->z) * 0.5,
+					      coeffs, eexps);
+  adaptiveTetrahedron *t1 = new adaptiveTetrahedron(p0, pe0, pe2, pe1);
+  recurCreate(t1, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t2 = new adaptiveTetrahedron(p1, pe0, pe3, pe4);
+  recurCreate(t2, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t3 = new adaptiveTetrahedron(p2, pe3, pe1, pe5);
+  recurCreate(t3, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t4 = new adaptiveTetrahedron(p3, pe2, pe4, pe5);
+  recurCreate(t4, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t5 = new adaptiveTetrahedron(pe3, pe5, pe2, pe4);
+  recurCreate(t5, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t6 = new adaptiveTetrahedron(pe3, pe2, pe0, pe4);
+  recurCreate(t6, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t7 = new adaptiveTetrahedron(pe2, pe5, pe3, pe1);
+  recurCreate(t7, maxlevel, level, coeffs, eexps);
+  adaptiveTetrahedron *t8 = new adaptiveTetrahedron(pe0, pe2, pe3, pe1);
+  recurCreate(t8, maxlevel, level, coeffs, eexps);
+  t->e[0] = t1;
+  t->e[1] = t2;
+  t->e[2] = t3;
+  t->e[3] = t4;
+  t->e[4] = t5;
+  t->e[5] = t6;
+  t->e[6] = t7;
+  t->e[7] = t8;
+}
+
+void adaptiveTetrahedron::error(double AVG, double tol)
+{
+  adaptiveTetrahedron *t = *all.begin();
+  recurError(t, AVG, tol);
+}
+
+void adaptiveTetrahedron::recurError(adaptiveTetrahedron *t, double AVG, double tol)
+{
+  if(!t->e[0])
+    t->visible = true;
+  else {
+    const double v1 = t->e[0]->V();
+    const double v2 = t->e[1]->V();
+    const double v3 = t->e[2]->V();
+    const double v4 = t->e[3]->V();
+    const double v5 = t->e[4]->V();
+    const double v6 = t->e[5]->V();
+    const double v7 = t->e[6]->V();
+    const double v8 = t->e[7]->V();
+    const double vr = (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8) * .125;
+    const double v = t->V();
+    if(!t->e[0]->e[0]) {
+      if(fabs(v - vr) > AVG * tol) {
+        t->visible = false;
+        recurError(t->e[0], AVG, tol);
+        recurError(t->e[1], AVG, tol);
+        recurError(t->e[2], AVG, tol);
+        recurError(t->e[3], AVG, tol);
+        recurError(t->e[4], AVG, tol);
+        recurError(t->e[5], AVG, tol);
+        recurError(t->e[6], AVG, tol);
+        recurError(t->e[7], AVG, tol);
+      }
+      else
+        t->visible = true;
+    }
+    else {
+      double vi[8][8];
+      for(int k = 0; k < 8; k++)
+        for(int l = 0; l < 8; l++)
+          vi[k][l] = t->e[k]->e[l]->V();
+      double vri[8];
+      for(int k = 0; k < 8; k++) {
+        vri[k] = 0.0;
+        for(int l = 0; l < 8; l++) {
+          vri[k] += vi[k][l];
+        }
+        vri[k] /= 8.0;
+      }
+      if(fabs(t->e[0]->V() - vri[0]) > AVG * tol ||
+         fabs(t->e[1]->V() - vri[1]) > AVG * tol ||
+         fabs(t->e[2]->V() - vri[2]) > AVG * tol ||
+         fabs(t->e[3]->V() - vri[3]) > AVG * tol ||
+         fabs(t->e[4]->V() - vri[4]) > AVG * tol ||
+         fabs(t->e[5]->V() - vri[5]) > AVG * tol ||
+         fabs(t->e[6]->V() - vri[6]) > AVG * tol ||
+         fabs(t->e[7]->V() - vri[7]) > AVG * tol ||
+         fabs(v - vr) > AVG * tol) {
+        t->visible = false;
+        recurError(t->e[0], AVG, tol);
+        recurError(t->e[1], AVG, tol);
+        recurError(t->e[2], AVG, tol);
+        recurError(t->e[3], AVG, tol);
+        recurError(t->e[4], AVG, tol);
+        recurError(t->e[5], AVG, tol);
+        recurError(t->e[6], AVG, tol);
+        recurError(t->e[7], AVG, tol);
+      }
+      else
+        t->visible = true;
+    }
+  }
+}
+
+void adaptiveHexahedron::create(int maxlevel, 
+				Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  cleanElement<adaptiveHexahedron>();
+  adaptivePoint *p1 = adaptivePoint::create(-1, -1, -1, coeffs, eexps);
+  adaptivePoint *p2 = adaptivePoint::create(-1, 1, -1, coeffs, eexps);
+  adaptivePoint *p3 = adaptivePoint::create(1, 1, -1, coeffs, eexps);
+  adaptivePoint *p4 = adaptivePoint::create(1, -1, -1, coeffs, eexps);
+  adaptivePoint *p11 = adaptivePoint::create(-1, -1, 1, coeffs, eexps);
+  adaptivePoint *p21 = adaptivePoint::create(-1, 1, 1, coeffs, eexps);
+  adaptivePoint *p31 = adaptivePoint::create(1, 1, 1, coeffs, eexps);
+  adaptivePoint *p41 = adaptivePoint::create(1, -1, 1, coeffs, eexps);
+  adaptiveHexahedron *h = new adaptiveHexahedron(p1, p2, p3, p4, p11, p21, p31, p41);
+  recurCreate(h, maxlevel, 0, coeffs, eexps);
+}
+
+void adaptiveHexahedron::recurCreate(adaptiveHexahedron *h, int maxlevel, int level,
+				     Double_Matrix *coeffs, Double_Matrix *eexps)
+{
+  all.push_back(h);
+  if(level++ >= maxlevel) return;
+
+  adaptivePoint *p0 = h->p[0];
+  adaptivePoint *p1 = h->p[1];
+  adaptivePoint *p2 = h->p[2];
+  adaptivePoint *p3 = h->p[3];
+  adaptivePoint *p4 = h->p[4];
+  adaptivePoint *p5 = h->p[5];
+  adaptivePoint *p6 = h->p[6];
+  adaptivePoint *p7 = h->p[7];
+  adaptivePoint *p01 = adaptivePoint::create((p0->x + p1->x) * 0.5,
+					     (p0->y + p1->y) * 0.5,
+					     (p0->z + p1->z) * 0.5, 
+					     coeffs, eexps);
+  adaptivePoint *p12 = adaptivePoint::create((p1->x + p2->x) * 0.5,
+					     (p1->y + p2->y) * 0.5,
+					     (p1->z + p2->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p23 = adaptivePoint::create((p2->x + p3->x) * 0.5, 
+					     (p2->y + p3->y) * 0.5,
+					     (p2->z + p3->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p03 = adaptivePoint::create((p3->x + p0->x) * 0.5, 
+					     (p3->y + p0->y) * 0.5,
+					     (p3->z + p0->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p45 = adaptivePoint::create((p4->x + p5->x) * 0.5,
+					     (p4->y + p5->y) * 0.5,
+					     (p4->z + p5->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p56 = adaptivePoint::create((p5->x + p6->x) * 0.5,
+					     (p5->y + p6->y) * 0.5,
+					     (p5->z + p6->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p67 = adaptivePoint::create((p6->x + p7->x) * 0.5, 
+					     (p6->y + p7->y) * 0.5,
+					     (p6->z + p7->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p47 = adaptivePoint::create((p7->x + p4->x) * 0.5,
+					     (p7->y + p4->y) * 0.5,
+					     (p7->z + p4->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p04 = adaptivePoint::create((p4->x + p0->x) * 0.5,
+					     (p4->y + p0->y) * 0.5,
+					     (p4->z + p0->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p15 = adaptivePoint::create((p5->x + p1->x) * 0.5,
+					     (p5->y + p1->y) * 0.5,
+					     (p5->z + p1->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p26 = adaptivePoint::create((p6->x + p2->x) * 0.5,
+					     (p6->y + p2->y) * 0.5,
+					     (p6->z + p2->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p37 = adaptivePoint::create((p7->x + p3->x) * 0.5,
+					     (p7->y + p3->y) * 0.5,
+					     (p7->z + p3->z) * 0.5,
+					     coeffs, eexps);
+  adaptivePoint *p0145 = adaptivePoint::create((p45->x + p01->x) * 0.5,
+					       (p45->y + p01->y) * 0.5,
+					       (p45->z + p01->z) * 0.5, 
+					       coeffs, eexps);
+  adaptivePoint *p1256 = adaptivePoint::create((p12->x + p56->x) * 0.5, 
+					       (p12->y + p56->y) * 0.5,
+					       (p12->z + p56->z) * 0.5, 
+					       coeffs, eexps);
+  adaptivePoint *p2367 = adaptivePoint::create((p23->x + p67->x) * 0.5, 
+					       (p23->y + p67->y) * 0.5,
+					       (p23->z + p67->z) * 0.5, 
+					       coeffs, eexps);
+  adaptivePoint *p0347 = adaptivePoint::create((p03->x + p47->x) * 0.5, 
+					       (p03->y + p47->y) * 0.5,
+					       (p03->z + p47->z) * 0.5,
+					       coeffs, eexps);
+  adaptivePoint *p4756 = adaptivePoint::create((p47->x + p56->x) * 0.5, 
+					       (p47->y + p56->y) * 0.5,
+					       (p47->z + p56->z) * 0.5, 
+					       coeffs, eexps);
+  adaptivePoint *p0312 = adaptivePoint::create((p03->x + p12->x) * 0.5,
+					       (p03->y + p12->y) * 0.5,
+					       (p03->z + p12->z) * 0.5,
+					       coeffs, eexps);
+  adaptivePoint *pc = adaptivePoint::create
+    ((p0->x + p1->x + p2->x + p3->x + p4->x + p5->x + p6->x + p7->x) * 0.125,
+     (p0->y + p1->y + p2->y + p3->y + p4->y + p5->y + p6->y + p7->y) * 0.125,
+     (p0->z + p1->z + p2->z + p3->z + p4->z + p5->z + p6->z + p7->z) * 0.125,
+     coeffs, eexps);
+
+  adaptiveHexahedron *h1 = new adaptiveHexahedron
+    (p0, p01, p0312, p03, p04, p0145, pc, p0347); // p0
+  recurCreate(h1, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h2 = new adaptiveHexahedron
+    (p01, p0145, p15, p1, p0312, pc, p1256, p12); // p1
+  recurCreate(h2, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h3 = new adaptiveHexahedron
+    (p04, p4, p45, p0145, p0347, p47, p4756, pc); // p4
+  recurCreate(h3, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h4 = new adaptiveHexahedron
+    (p0145, p45, p5, p15, pc, p4756, p56, p1256); // p5
+  recurCreate(h4, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h5 = new adaptiveHexahedron
+    (p0347, p47, p4756, pc, p37, p7, p67, p2367); // p7
+  recurCreate(h5, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h6 = new adaptiveHexahedron
+    (pc, p4756, p56, p1256, p2367, p67, p6, p26); // p6
+  recurCreate(h6, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h7 = new adaptiveHexahedron
+    (p03, p0347, pc, p0312, p3, p37, p2367, p23); // p3
+  recurCreate(h7, maxlevel, level, coeffs, eexps);
+  adaptiveHexahedron *h8 = new adaptiveHexahedron
+    (p0312, pc, p1256, p12, p23, p2367, p26, p2); //p2
+  recurCreate(h8, maxlevel, level, coeffs, eexps);
+  h->e[0] = h1;
+  h->e[1] = h2;
+  h->e[2] = h3;
+  h->e[3] = h4;
+  h->e[4] = h5;
+  h->e[5] = h6;
+  h->e[6] = h7;
+  h->e[7] = h8;
+}
+
+void adaptiveHexahedron::error(double AVG, double tol)
+{
+  adaptiveHexahedron *h = *all.begin();
+  recurError(h, AVG, tol);
+}
+
+void adaptiveHexahedron::recurError(adaptiveHexahedron *h, double AVG, double tol)
+{
+  if(!h->e[0])
+    h->visible = true;
+  else {
+    double vr;
+    double v1 = h->e[0]->V();
+    double v2 = h->e[1]->V();
+    double v3 = h->e[2]->V();
+    double v4 = h->e[3]->V();
+    double v5 = h->e[4]->V();
+    double v6 = h->e[5]->V();
+    double v7 = h->e[6]->V();
+    double v8 = h->e[7]->V();
+    vr = (v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8) * .125;
+    double v = h->V();
+    if(fabs(v - vr) > AVG * tol) {
+      h->visible = false;
+      recurError(h->e[0], AVG, tol);
+      recurError(h->e[1], AVG, tol);
+      recurError(h->e[2], AVG, tol);
+      recurError(h->e[3], AVG, tol);
+      recurError(h->e[4], AVG, tol);
+      recurError(h->e[5], AVG, tol);
+      recurError(h->e[6], AVG, tol);
+      recurError(h->e[7], AVG, tol);
+    }
+    else
+      h->visible = true;
+  }
+}
+
+template <class T>
+adaptiveElements<T>::adaptiveElements(List_T *listEle, int *numEle,
+				      List_T *coef, List_T *pol,
+				      List_T *coefGeom, List_T *polGeom)
+  : _resolutionLevel(-1), _tolerance(1.e-3), _minVal(0.), _maxVal(0.), 
+    _listEle(listEle), _numEle(numEle), _coefsGeom(0), _eexpsGeom(0), 
+    _posX(0), _posY(0), _posZ(0), _val(0), _valX(0), _valY(0), _valZ(0),
+    _interpolate(0), _geometry(0)
+{
+  _coefs = new Double_Matrix(List_Nbr(coef), List_Nbr(coef));
+  _eexps = new Double_Matrix(List_Nbr(coef), 3);
+
+  for(int i = 0; i < List_Nbr(coef); ++i) {
+    List_T **line = (List_T**)List_Pointer_Fast(coef, i);
+    List_T **eexp = (List_T**)List_Pointer_Fast(pol, i);
+    double dpowu, dpowv, dpoww;
+    List_Read(*eexp, 0, &dpowu);
+    List_Read(*eexp, 1, &dpowv);
+    List_Read(*eexp, 2, &dpoww);
+    (*_eexps)(i, 0) = dpowu;
+    (*_eexps)(i, 1) = dpowv;
+    (*_eexps)(i, 2) = dpoww;
+    for(int j = 0; j < List_Nbr(*line); ++j) {
+      double val;
+      List_Read(*line, j, &val);
+      (*_coefs)(i, j) = val;
+    }
+  }
+
+  if(coefGeom && polGeom){
+    _coefsGeom = new Double_Matrix(List_Nbr(coefGeom), List_Nbr(coefGeom));
+    _eexpsGeom = new Double_Matrix(List_Nbr(coefGeom), 3);
+    for(int i = 0; i < List_Nbr(coefGeom); ++i) {
+      List_T **line = (List_T**)List_Pointer_Fast(coefGeom, i);
+      List_T **eexp = (List_T**)List_Pointer_Fast(polGeom, i);
+      double dpowu, dpowv, dpoww;
+      List_Read(*eexp, 0, &dpowu);
+      List_Read(*eexp, 1, &dpowv);
+      List_Read(*eexp, 2, &dpoww);
+      (*_eexpsGeom)(i, 0) = dpowu;
+      (*_eexpsGeom)(i, 1) = dpowv;
+      (*_eexpsGeom)(i, 2) = dpoww;
+      for(int j = 0; j < List_Nbr(*line); ++j) {
+        double val;
+        List_Read(*line, j, &val);
+        (*_coefsGeom)(i, j) = val;
+      }
+    }      
+  }
+}
+
+template <class T>
+adaptiveElements<T>::~adaptiveElements()
+{
+  delete _coefs;
+  delete _eexps;
+  if(_posX) delete _posX;
+  if(_posY) delete _posY;
+  if(_posZ) delete _posZ;
+  if(_val) delete _val;
+  if(_valX) delete _valX;
+  if(_valY) delete _valY;
+  if(_valZ) delete _valZ;
+  if(_coefsGeom) delete _coefsGeom;
+  if(_eexpsGeom) delete _eexpsGeom;
+  if(_interpolate) delete _interpolate;
+  if(_geometry) delete _geometry;
+  cleanElement<T>();
+}
+
+template <class T>
+void adaptiveElements<T>::initWithLowResolution(PViewData *data, int step)
+{
+  int numComp = data->getNumComponents(0, 0, 0);
+  if(numComp != 1 && numComp != 3) return;
+
+  int numEle = 0;
+  switch(T::numEdges){
+  case 1: numEle = data->getNumLines(); break;
+  case 3: numEle = data->getNumTriangles(); break;
+  case 4: numEle = data->getNumQuadrangles(); break;
+  case 6: numEle = data->getNumTetrahedra(); break;
+  case 12: numEle = data->getNumHexahedra(); break;
+  }
+  if(!numEle) return;
+
+  int numNodes;
+  if(_coefsGeom)
+    numNodes = _coefsGeom->size1();
+  else
+    numNodes = T::numNodes;
+
+  int numVal = _coefs->size1();
+
+  _minVal = VAL_INF;
+  _maxVal = -VAL_INF;
+
+  if(_posX) delete _posX;
+  if(_posY) delete _posY;
+  if(_posZ) delete _posZ;
+  if(_val) delete _val;
+  if(_valX) delete _valX;
+  if(_valY) delete _valY;
+  if(_valZ) delete _valZ;
+  _posX = new Double_Matrix(numEle, numNodes);
+  _posY = new Double_Matrix(numEle, numNodes);
+  _posZ = new Double_Matrix(numEle, numNodes);
+  _val = new Double_Matrix(numEle, numVal / numComp);
+  if(numComp == 3){
+    _valX = new Double_Matrix(numEle, numVal / numComp);
+    _valY = new Double_Matrix(numEle, numVal / numComp);
+    _valZ = new Double_Matrix(numEle, numVal / numComp);
+  }
+
+  // store non-interpolated data
+  int k = 0;
+  for(int ent = 0; ent < data->getNumEntities(step); ent++){    
+    for(int ele = 0; ele < data->getNumElements(step, ent); ele++){    
+      if(data->skipElement(step, ent, ele) ||
+	 data->getNumEdges(step, ent, ele) != T::numEdges) continue;
+      if(numNodes != data->getNumNodes(step, ent, ele)){
+	Msg(GERROR, "Wrong number of nodes (%d) in element %d", numNodes, ele);
+	continue;
+      }
+      if(numVal != data->getNumValues(step, ent, ele)){
+	Msg(GERROR, "Wrong number of values (%d) in element %d", numVal, ele);
+	continue;
+      }
+      for(int nod = 0; nod < numNodes; nod++){
+	double x, y, z;
+	data->getNode(step, ent, ele, nod, x, y, z);
+	(*_posX)(k, nod) = x; 
+	(*_posY)(k, nod) = y; 
+	(*_posZ)(k, nod) = z; 
+      }
+      if(numComp == 1){
+	for(int i = 0; i < numVal; i++){
+	  double val;
+	  data->getValue(step, ent, ele, i, val);
+	  (*_val)(k, i) = val;
+	}
+      }
+      else if(numComp == 3){
+	for(int i = 0; i < numVal / 3; i++){
+	  double val[3];
+	  // adaptation of the visualization mesh bases on the norm
+	  // squared of the vector
+	  for(int j = 0; j < 3; j++)
+	    data->getValue(step, ent, ele, 3 * i + j, val[j]);
+	  (*_val)(k, i) = (val[0] * val[0] + val[1] * val[1] + val[2] * val[2]);
+	  (*_valX)(k, i) = val[0];
+	  (*_valY)(k, i) = val[1];
+	  (*_valZ)(k, i) = val[2];
+	}
+      }
+      k++;
+    }
+  }
+  changeResolution(0, _tolerance);
+}
+
+template <class T>
+void adaptiveElements<T>::changeResolution(int level, double tol, GMSH_Post_Plugin *plug)
+{
+  if(!_val) return; // error
+
+  //if(level == _resolutionLevel && tol == _tolerance && !plug) return;
+
+  _resolutionLevel = level;
+  _tolerance = tol;
+
+  List_Reset(_listEle);
+  *_numEle = 0;
+  std::vector<int> done(_posX->size1(), 0);
+
+  // We first do the adaptive stuff at level 2 and will only process
+  // elements that have reached the maximal recursion level
+  int level_act = (level > 2) ? 2 : level;
+  while(1){
+    _changeResolution(level_act, plug, &done[0]);
+    int numDone = 0;
+    for(int i = 0; i < _posX->size1(); ++i) numDone += done[i];
+    if(numDone == _posX->size1()) break;
+    if(level_act >= level) break;
+    level_act++;
+  }
+}
+
+template <class T> 
+void adaptiveElements<T>::_changeResolution(int level, GMSH_Post_Plugin *plug, int *done)
+{
+  const int N = _coefs->size1();
+  const int nbelm = _posX->size1();
+
+  double sf[100];
+  T::create(level, _coefs, _eexps);
+
+  if(_interpolate) delete _interpolate;
+  _interpolate = new Double_Matrix(adaptivePoint::all.size(), N);
+
+  if(_geometry) delete _geometry;
+  _geometry = new Double_Matrix(adaptivePoint::all.size(), _posX->size2());
+
+  int kk = 0;
+  for(std::set<adaptivePoint>::iterator it = adaptivePoint::all.begin(); 
+      it != adaptivePoint::all.end(); ++it) {
+    adaptivePoint *p = (adaptivePoint*)&(*it);
+    for(int k = 0; k < N; ++k)
+      (*_interpolate)(kk, k) = p->shapeFunctions[k];
+    if(_coefsGeom)
+      computeShapeFunctions(_coefsGeom, _eexpsGeom, p->x, p->y, p->z, sf);
+    else
+      T::GSF(p->x, p->y, p->z, sf);
+    for(int k = 0; k < _posX->size2(); k++)
+      (*_geometry) (kk, k) = sf[k];
+    kk++;
+  }
+
+  for(int i = 0; i < nbelm; ++i)
+    done[i] = _zoomElement(i, level, plug);
+}
+
+template <class T>
+int adaptiveElements<T>::_zoomElement(int ielem, int level, GMSH_Post_Plugin *plug)
+{
+  const int N = _coefs->size1();
+  
+  Double_Vector val(N), res(adaptivePoint::all.size());
+  Double_Vector valx(N), resx(adaptivePoint::all.size());
+  Double_Vector valy(N), resy(adaptivePoint::all.size());
+  Double_Vector valz(N), resz(adaptivePoint::all.size());
+  Double_Matrix xyz(_posX->size2(), 3);
+  Double_Matrix XYZ(adaptivePoint::all.size(), 3);
+
+  for(int k = 0; k < _posX->size2(); ++k){
+    xyz(k, 0) = (*_posX)(ielem, k);
+    xyz(k, 1) = (*_posY)(ielem, k);
+    xyz(k, 2) = (*_posZ)(ielem, k);
+  }
+
+  for(int k = 0; k < N; ++k)
+    val(k) = (*_val)(ielem, k);
+
+  _interpolate->mult(val, res);
+
+  if(_valX){
+    for(int k = 0; k < N; ++k){
+      valx(k) = (*_valX)(ielem, k);
+      valy(k) = (*_valY)(ielem, k);
+      valz(k) = (*_valZ)(ielem, k);
+    }           
+    _interpolate->mult(valx, resx);
+    _interpolate->mult(valy, resy);
+    _interpolate->mult(valz, resz);
+  }
+
+  _geometry->mult(xyz, XYZ);
+
+  int k = 0;
+  for(std::set<adaptivePoint>::iterator it = adaptivePoint::all.begin();
+      it != adaptivePoint::all.end(); ++it){
+    adaptivePoint *p = (adaptivePoint*)&(*it);
+    p->val = res(k);
+    if(_valX){
+      p->valx = resx(k);
+      p->valy = resy(k);
+      p->valz = resz(k);
+    }
+    p->val = res(k);
+    p->X = XYZ(k, 0);
+    p->Y = XYZ(k, 1);
+    p->Z = XYZ(k, 2);
+    if(_minVal > p->val) _minVal = p->val;
+    if(_maxVal < p->val) _maxVal = p->val;
+    k++;
+  }
+
+  for(typename std::list<T*>::iterator it = T::all.begin(); 
+      it != T::all.end(); it++) 
+    (*it)->visible = false;
+
+  if(!plug || _tolerance != 0.)
+    T::error(_maxVal - _minVal, _tolerance);
+
+  if(plug)
+    plug->assignSpecificVisibility();
+
+  for(typename std::list<T*>::iterator it = T::all.begin(); 
+      it != T::all.end(); it++){
+    if((*it)->visible && !(*it)->e[0] && level != _resolutionLevel)
+      return 0;
+  }
+  
+  adaptivePoint **p;
+  for(typename std::list<T*>::iterator it = T::all.begin(); 
+      it != T::all.end(); it++){
+    if((*it)->visible){
+      p = (*it)->p;
+      for(int k = 0; k < T::numNodes; ++k) List_Add(_listEle, &p[k]->X);
+      for(int k = 0; k < T::numNodes; ++k) List_Add(_listEle, &p[k]->Y);
+      for(int k = 0; k < T::numNodes; ++k) List_Add(_listEle, &p[k]->Z);
+      if(_valX){
+        for(int k = 0; k < T::numNodes; ++k){
+          List_Add(_listEle, &p[k]->valx);
+          List_Add(_listEle, &p[k]->valy);
+          List_Add(_listEle, &p[k]->valz);
+        }
+      }
+      else{
+        for (int k = 0; k < T::numNodes; ++k) 
+	  List_Add(_listEle, &p[k]->val);
+      }
+      (*_numEle)++;
+    }
+  }
+  return 1;
+}
+
+adaptiveData::adaptiveData(PViewData *data)
+  : _inData(data), _lines(0), _triangles(0), _quadrangles(0), 
+    _tetrahedra(0), _hexahedra(0)
+{
+  // We could do this, but it's a bit tricky (need to set a flag in
+  // the view to say "don't use the adaptive stuff anymore!")
+  /*
+  if(dynamic_cast<PViewDataList*>(_inData) && _inData->getNumTimeSteps() == 1)
+    _outData = (PViewDataList*)_inData;
+  else
+  */
+  _outData = new PViewDataList(true);
+
+  int numComp = _inData->getNumComponents(0, 0, 0);
+  std::vector<List_T*> p;
+  if(_inData->getNumLines() && _inData->getInterpolationScheme(1, p) >= 2)
+    _lines = new adaptiveElements<adaptiveLine>
+      ((numComp == 1) ? _outData->SL : _outData->VL,
+       (numComp == 1) ? &_outData->NbSL : &_outData->NbVL,
+       p[0], p[1], (p.size() == 4) ? p[2] : 0, (p.size() == 4) ? p[3] : 0);
+  if(_inData->getNumTriangles() && _inData->getInterpolationScheme(3, p) >= 2)
+    _triangles = new adaptiveElements<adaptiveTriangle>
+      ((numComp == 1) ? _outData->ST : _outData->VT,
+       (numComp == 1) ? &_outData->NbST : &_outData->NbVT,
+       p[0], p[1], (p.size() == 4) ? p[2] : 0, (p.size() == 4) ? p[3] : 0);
+  if(_inData->getNumQuadrangles() && _inData->getInterpolationScheme(4, p) >= 2)
+    _quadrangles = new adaptiveElements<adaptiveQuadrangle>
+      ((numComp == 1) ? _outData->SQ : _outData->VQ,
+       (numComp == 1) ? &_outData->NbSQ : &_outData->NbVQ,
+       p[0], p[1], (p.size() == 4) ? p[2] : 0, (p.size() == 4) ? p[3] : 0);
+  if(_inData->getNumTetrahedra() && _inData->getInterpolationScheme(6, p) >= 2)
+    _tetrahedra = new adaptiveElements<adaptiveTetrahedron>
+      ((numComp == 1) ? _outData->SS : _outData->VS,
+       (numComp == 1) ? &_outData->NbSS : &_outData->NbVS,
+       p[0], p[1], (p.size() == 4) ? p[2] : 0, (p.size() == 4) ? p[3] : 0);
+  if(_inData->getNumHexahedra() && _inData->getInterpolationScheme(12, p) >= 2)
+    _hexahedra = new adaptiveElements<adaptiveHexahedron>
+      ((numComp == 1) ? _outData->SH : _outData->VH,
+       (numComp == 1) ? &_outData->NbSH : &_outData->NbVH, 
+       p[0], p[1], (p.size() == 4) ? p[2] : 0, (p.size() == 4) ? p[3] : 0);
+}
+
+void adaptiveData::initWithLowResolution(int step)
+{
+  if(_lines) _lines->initWithLowResolution(_inData, step);
+  if(_triangles) _triangles->initWithLowResolution(_inData, step);
+  if(_quadrangles) _quadrangles->initWithLowResolution(_inData, step);
+  if(_tetrahedra) _tetrahedra->initWithLowResolution(_inData, step);
+  if(_hexahedra) _hexahedra->initWithLowResolution(_inData, step);
+  _outData->finalize();
+}
+
+void adaptiveData::changeResolution(int level, double tol, GMSH_Post_Plugin *plug)
+{
+  if(_lines) _lines->changeResolution(level, tol, plug);
+  if(_triangles) _triangles->changeResolution(level, tol, plug);
+  if(_quadrangles) _quadrangles->changeResolution(level, tol, plug);
+  if(_tetrahedra) _tetrahedra->changeResolution(level, tol, plug);
+  if(_hexahedra) _hexahedra->changeResolution(level, tol, plug);
+  _outData->finalize();
+}
+
+adaptiveData::~adaptiveData()
+{
+  if(_lines) delete _lines;
+  if(_triangles) delete _triangles;
+  if(_quadrangles) delete _quadrangles;
+  if(_tetrahedra) delete _tetrahedra;
+  if(_hexahedra) delete _hexahedra;
+  if(_inData != _outData) delete _outData;
+}
diff --git a/Post/adaptiveData.h b/Post/adaptiveData.h
new file mode 100644
index 0000000000..8019be84ca
--- /dev/null
+++ b/Post/adaptiveData.h
@@ -0,0 +1,276 @@
+#ifndef _ADAPTIVE_DATA_H_
+#define _ADAPTIVE_DATA_H_
+
+// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+// 
+// Please report all bugs and problems to <gmsh@geuz.org>.
+
+#include <list>
+#include <set>
+#include "List.h"
+#include "GmshMatrix.h"
+
+class PViewData;
+class PViewDataList;
+class GMSH_Post_Plugin;
+
+class adaptivePoint {
+ public:
+  double x, y, z, X, Y, Z;
+  double val, valx, valy, valz;
+  double shapeFunctions[128];
+  static std::set<adaptivePoint> all;
+ public:
+  static adaptivePoint *create(double x, double y, double z, 
+			       Double_Matrix *coeffs, Double_Matrix *eexps);
+  bool operator < (const adaptivePoint &other) const
+  {
+    if(other.x < x) return true;
+    if(other.x > x) return false;
+    if(other.y < y) return true;
+    if(other.y > y) return false;
+    if(other.z < z) return true;
+    return false;
+  }
+};
+
+class adaptiveLine {
+ public:
+  bool visible;
+  adaptivePoint *p[2];
+  adaptiveLine *e[2];
+  static std::list<adaptiveLine*> all;
+  static int numNodes, numEdges;
+ public:
+  adaptiveLine(adaptivePoint *p1, adaptivePoint *p2)
+    : visible(false)
+  {
+    p[0] = p1;
+    p[1] = p2;
+    e[0] = e[1] = 0;
+  } 
+  inline double V() const
+  {
+    return (p[0]->val + p[1]->val) / 2.;
+  }
+  inline static void GSF(double u, double v, double w, double sf[])
+  {
+    sf[0] = (1 - u) / 2.;
+    sf[1] = (1 + u) / 2.;
+  }
+  static void create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void recurCreate(adaptiveLine *e, int maxlevel, int level, 
+			  Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void error(double AVG, double tol);
+  static void recurError(adaptiveLine *e, double AVG, double tol);
+};
+
+class adaptiveTriangle {
+ public:
+  bool visible;
+  adaptivePoint *p[3];
+  adaptiveTriangle *e[4];
+  static std::list<adaptiveTriangle*> all;
+  static int numNodes, numEdges;
+ public:
+  adaptiveTriangle(adaptivePoint *p1, adaptivePoint *p2, adaptivePoint *p3)
+    : visible(false)
+  {
+    p[0] = p1;
+    p[1] = p2;
+    p[2] = p3;
+    e[0] = e[1] = e[2] = e[3] = 0;
+  }
+  inline double V() const
+  {
+    return (p[0]->val + p[1]->val + p[2]->val) / 3.;
+  }
+  inline static void GSF(double u, double v, double w, double sf[])
+  {
+    sf[0] = 1. - u - v;
+    sf[1] = u;
+    sf[2] = v;
+  }
+  static void create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void recurCreate(adaptiveTriangle *t, int maxlevel, int level,
+			  Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void error(double AVG, double tol);
+  static void recurError(adaptiveTriangle *t, double AVG, double tol);
+};
+
+class adaptiveQuadrangle {
+ public:
+  bool visible;
+  adaptivePoint *p[4];
+  adaptiveQuadrangle *e[4];
+  static std::list<adaptiveQuadrangle*> all;
+  static int numNodes, numEdges;
+ public:
+  adaptiveQuadrangle(adaptivePoint *p1, adaptivePoint *p2, 
+		     adaptivePoint *p3, adaptivePoint *p4)    
+    : visible(false)
+  {
+    p[0] = p1;
+    p[1] = p2;
+    p[2] = p3;
+    p[3] = p4;
+    e[0] = e[1] = e[2] = e[3] = 0;
+  }
+  inline double V() const
+  {
+    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
+  }
+  inline static void GSF(double u, double v, double w, double sf[])
+  {
+    sf[0] = 0.25 * (1. - u) * (1. - v);
+    sf[1] = 0.25 * (1. + u) * (1. - v);
+    sf[2] = 0.25 * (1. + u) * (1. + v);
+    sf[3] = 0.25 * (1. - u) * (1. + v);
+  }
+  static void create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void recurCreate(adaptiveQuadrangle *q, int maxlevel, int level,
+			  Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void error(double AVG, double tol);
+  static void recurError(adaptiveQuadrangle *q, double AVG, double tol);
+};
+
+class adaptiveTetrahedron {
+ public:
+  bool visible;
+  adaptivePoint *p[4];
+  adaptiveTetrahedron *e[8];
+  static std::list<adaptiveTetrahedron*> all;
+  static int numNodes, numEdges;
+ public:
+  adaptiveTetrahedron(adaptivePoint *p1, adaptivePoint *p2, 
+		      adaptivePoint *p3, adaptivePoint *p4)
+    : visible(false)
+  {
+    p[0] = p1;
+    p[1] = p2;
+    p[2] = p3;
+    p[3] = p4;
+    e[0] = e[1] = e[2] = e[3] = 0;
+    e[4] = e[5] = e[6] = e[7] = 0;
+  }
+  inline double V() const
+  {
+    return (p[0]->val + p[1]->val + p[2]->val + p[3]->val) / 4.;
+  }
+  inline static void GSF(double u, double v, double w, double sf[])
+  {
+    sf[0] = 1. - u - v - w;
+    sf[1] = u;
+    sf[2] = v;
+    sf[3] = w;
+  }
+  static void create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void recurCreate(adaptiveTetrahedron *t, int maxlevel, int level, 
+			  Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void error(double AVG, double tol);
+  static void recurError(adaptiveTetrahedron *t, double AVG, double tol);
+};
+
+class adaptiveHexahedron {
+ public:
+  bool visible;
+  adaptivePoint *p[8];
+  adaptiveHexahedron *e[8];
+  static std::list<adaptiveHexahedron*> all;
+  static int numNodes, numEdges;
+ public:
+  adaptiveHexahedron(adaptivePoint *p1, adaptivePoint *p2, adaptivePoint *p3, 
+		     adaptivePoint *p4, adaptivePoint *p5, adaptivePoint *p6, 
+		     adaptivePoint *p7, adaptivePoint *p8)
+    : visible(false)
+  {
+    p[0] = p1;
+    p[1] = p2;
+    p[2] = p3;
+    p[3] = p4;
+    p[4] = p5;
+    p[5] = p6;
+    p[6] = p7;
+    p[7] = p8;
+    e[0] = e[1] = e[2] = e[3] = 0;
+    e[4] = e[5] = e[6] = e[7] = 0;
+  }
+  inline double V() const
+  {
+    return (p[0]->val + p[1]->val + p[2]->val+ p[3]->val +
+            p[4]->val + p[5]->val + p[6]->val+ p[7]->val) / 8.;
+  }
+  inline static void GSF(double u, double v, double w, double sf[])
+  {
+    sf[0] = 0.125 * (1 - u) * (1 - v) * (1 - w);
+    sf[1] = 0.125 * (1 + u) * (1 - v) * (1 - w);
+    sf[2] = 0.125 * (1 + u) * (1 + v) * (1 - w);
+    sf[3] = 0.125 * (1 - u) * (1 + v) * (1 - w);
+    sf[4] = 0.125 * (1 - u) * (1 - v) * (1 + w);
+    sf[5] = 0.125 * (1 + u) * (1 - v) * (1 + w);
+    sf[6] = 0.125 * (1 + u) * (1 + v) * (1 + w);
+    sf[7] = 0.125 * (1 - u) * (1 + v) * (1 + w);
+  }
+  static void create(int maxlevel, Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void recurCreate(adaptiveHexahedron *h, int maxlevel, int level,
+			  Double_Matrix *coeffs, Double_Matrix *eexps);
+  static void error(double AVG, double tol);
+  static void recurError(adaptiveHexahedron *h, double AVG, double tol);
+};
+
+template <class T>
+class adaptiveElements {
+ private:
+  int _resolutionLevel;
+  double _tolerance, _minVal, _maxVal;
+  List_T *_listEle;
+  int *_numEle;
+  Double_Matrix *_coefs, *_eexps;
+  Double_Matrix *_coefsGeom, *_eexpsGeom;
+  Double_Matrix *_posX, *_posY, *_posZ;
+  Double_Matrix *_val, *_valX, *_valY, *_valZ;
+  Double_Matrix *_interpolate, *_geometry;
+  void _changeResolution(int level, GMSH_Post_Plugin *plug, int *done);
+  int _zoomElement(int ielem, int level, GMSH_Post_Plugin *plug);
+ public:
+  adaptiveElements(List_T *listEle, int *numEle,
+		   List_T *coeffs, List_T *eexps, 
+		   List_T *coeffsGeom=0, List_T *eexpsGeom=0);
+  ~adaptiveElements();
+  void initWithLowResolution(PViewData *data, int step);
+  void changeResolution(int level, double tol, GMSH_Post_Plugin *plug=0);
+};
+
+class adaptiveData {
+ private:
+  PViewData *_inData;
+  PViewDataList *_outData;
+  adaptiveElements<adaptiveLine> *_lines;
+  adaptiveElements<adaptiveTriangle> *_triangles;
+  adaptiveElements<adaptiveQuadrangle> *_quadrangles;
+  adaptiveElements<adaptiveTetrahedron> *_tetrahedra;
+  adaptiveElements<adaptiveHexahedron> *_hexahedra;
+ public:
+  adaptiveData(PViewData *data);
+  ~adaptiveData();
+  PViewData *getData(){ return (PViewData*)_outData; }
+  void initWithLowResolution(int step);
+  void changeResolution(int level, double tol, GMSH_Post_Plugin *plug=0);
+};
+
+#endif
diff --git a/doc/texinfo/gmsh.texi b/doc/texinfo/gmsh.texi
index e5ab74a622..754fb97954 100644
--- a/doc/texinfo/gmsh.texi
+++ b/doc/texinfo/gmsh.texi
@@ -1,5 +1,5 @@
 \input texinfo.tex @c -*-texinfo-*-
-@c $Id: gmsh.texi,v 1.247 2008-04-17 21:05:52 geuzaine Exp $
+@c $Id: gmsh.texi,v 1.248 2008-04-22 07:37:17 geuzaine Exp $
 @c
 @c Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 @c
@@ -2983,7 +2983,7 @@ information about the file (@code{$MeshFormat}), followed by several
 optional sections defining the nodes (@code{$Nodes}), elements
 (@code{$Elements}), region names (@code{$PhysicalName}) and
 post-processing datasets (@code{$NodeData}, @code{$ElementData},
-@code{$ElememtNodeData}). Sections can be repeated in the same file, and
+@code{$ElementNodeData}). Sections can be repeated in the same file, and
 post-processing sections can be put into separate files (e.g. one file
 per time step).
 
@@ -3211,7 +3211,7 @@ $Elements
 $EndElements
 
 [ all other sections are identical to ASCII, except that @var{node-number},
-  @var{elm-number}, @var{number-of-nodes-per-elemenr} and @var{values} are written in
+  @var{elm-number}, @var{number-of-nodes-per-element} and @var{values} are written in
   binary format ]
 @end example
 
-- 
GitLab