From d3dbbcfaed749193770c224315ec1438292c3ca0 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 5 Apr 2008 17:49:23 +0000
Subject: [PATCH] ported Warp, SphericalRaise and Eigenvalues plugins to the
 new post-pro API

---
 Plugin/Annotate.cpp        |   7 +-
 Plugin/Annotate.h          |   6 +-
 Plugin/Curl.cpp            |   9 +-
 Plugin/Curl.h              |   4 +-
 Plugin/CutGrid.cpp         |   7 +-
 Plugin/CutGrid.h           |  14 +--
 Plugin/CutMap.cpp          |   7 +-
 Plugin/CutMap.h            |   6 +-
 Plugin/CutParametric.cpp   |   8 +-
 Plugin/CutParametric.h     |   4 +-
 Plugin/CutPlane.cpp        |   7 +-
 Plugin/CutPlane.h          |   2 +-
 Plugin/CutSphere.cpp       |   7 +-
 Plugin/CutSphere.h         |   4 +-
 Plugin/Divergence.cpp      |   9 +-
 Plugin/Divergence.h        |   4 +-
 Plugin/Eigenvalues.cpp     | 124 ++++++++++---------
 Plugin/Eigenvalues.h       |   2 +-
 Plugin/Evaluate.cpp        |   8 +-
 Plugin/Evaluate.h          |   2 +-
 Plugin/Extract.cpp         |   7 +-
 Plugin/Extract.h           |   2 +-
 Plugin/ExtractElements.cpp |   7 +-
 Plugin/ExtractElements.h   |   2 +-
 Plugin/Gradient.cpp        |   9 +-
 Plugin/Gradient.h          |   4 +-
 Plugin/Probe.cpp           |   7 +-
 Plugin/Probe.h             |   2 +-
 Plugin/Remove.cpp          |   7 +-
 Plugin/Remove.h            |   4 +-
 Plugin/Skin.cpp            |   7 +-
 Plugin/Skin.h              |   4 +-
 Plugin/Smooth.cpp          |   8 +-
 Plugin/Smooth.h            |   4 +-
 Plugin/SphericalRaise.cpp  | 109 ++++++++---------
 Plugin/SphericalRaise.h    |   4 +-
 Plugin/Transform.cpp       |   7 +-
 Plugin/Transform.h         |   4 +-
 Plugin/Triangulate.cpp     |   7 +-
 Plugin/Triangulate.h       |   2 +-
 Plugin/Warp.cpp            | 245 +++++++++++++------------------------
 Plugin/Warp.h              |   4 +-
 42 files changed, 265 insertions(+), 432 deletions(-)

diff --git a/Plugin/Annotate.cpp b/Plugin/Annotate.cpp
index 1b694d8c96..9d4d60ba4a 100644
--- a/Plugin/Annotate.cpp
+++ b/Plugin/Annotate.cpp
@@ -1,4 +1,4 @@
-// $Id: Annotate.cpp,v 1.21 2008-03-20 11:44:12 geuzaine Exp $
+// $Id: Annotate.cpp,v 1.22 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -54,11 +54,6 @@ extern "C"
   }
 }
 
-GMSH_AnnotatePlugin::GMSH_AnnotatePlugin()
-{
-  ;
-}
-
 static double getStyle()
 {
   int fontsize = (int)AnnotateOptions_Number[4].def, font = 0, align = 0;
diff --git a/Plugin/Annotate.h b/Plugin/Annotate.h
index 604f8f9099..76a7fb5087 100644
--- a/Plugin/Annotate.h
+++ b/Plugin/Annotate.h
@@ -34,14 +34,14 @@ private:
                          double step, double min, double max);
   static const char *callbackStr(int num, int action, const char *value, const char **opt);
 public:
-  GMSH_AnnotatePlugin();
+  GMSH_AnnotatePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   int getNbOptionsStr() const;
-  StringXString* getOptionStr(int iopt);  
+  StringXString *getOptionStr(int iopt);  
   PView *execute(PView *);
 
   static double callbackX(int, int, double);
diff --git a/Plugin/Curl.cpp b/Plugin/Curl.cpp
index 51fcd68521..795fb6fe84 100644
--- a/Plugin/Curl.cpp
+++ b/Plugin/Curl.cpp
@@ -1,4 +1,4 @@
-// $Id: Curl.cpp,v 1.8 2008-04-05 09:21:37 geuzaine Exp $
+// $Id: Curl.cpp,v 1.9 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -34,18 +34,13 @@ extern "C"
   }
 }
 
-GMSH_CurlPlugin::GMSH_CurlPlugin()
-{
-  ;
-}
-
 void GMSH_CurlPlugin::getName(char *name) const
 {
   strcpy(name, "Curl");
 }
 
 void GMSH_CurlPlugin::getInfos(char *author, char *copyright,
-                                    char *help_text) const
+			       char *help_text) const
 {
   strcpy(author, "C. Geuzaine");
   strcpy(copyright, "DGR (www.multiphysics.com)");
diff --git a/Plugin/Curl.h b/Plugin/Curl.h
index 0a16c4f154..9a1fb708f3 100644
--- a/Plugin/Curl.h
+++ b/Plugin/Curl.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_CurlPlugin : public GMSH_Post_Plugin
 {
  public:
-  GMSH_CurlPlugin();
+  GMSH_CurlPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/CutGrid.cpp b/Plugin/CutGrid.cpp
index 2768f6a1ab..0b09f5b008 100644
--- a/Plugin/CutGrid.cpp
+++ b/Plugin/CutGrid.cpp
@@ -1,4 +1,4 @@
-// $Id: CutGrid.cpp,v 1.26 2008-03-20 11:44:12 geuzaine Exp $
+// $Id: CutGrid.cpp,v 1.27 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -54,11 +54,6 @@ extern "C"
   }
 }
 
-GMSH_CutGridPlugin::GMSH_CutGridPlugin()
-{
-  ;
-}
-
 void GMSH_CutGridPlugin::draw()
 {
 #if defined(HAVE_FLTK)
diff --git a/Plugin/CutGrid.h b/Plugin/CutGrid.h
index 57adfe30bf..e50e90b079 100644
--- a/Plugin/CutGrid.h
+++ b/Plugin/CutGrid.h
@@ -38,15 +38,13 @@ class GMSH_CutGridPlugin : public GMSH_Post_Plugin
                  List_T *Q, int *nQ);
   PView *GenerateView (PView *v, int connectPoints);
 public:
-  GMSH_CutGridPlugin();
-  void getName  (char *name) const;
-  void getInfos (char *author, 
-                 char *copyright,
-                 char *help_text) const;
-  void catchErrorMessage (char *errorMessage) const;
+  GMSH_CutGridPlugin(){}
+  void getName(char *name) const;
+  void getInfos(char *author, char *copyright, char *help_text) const;
+  void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber *getOption (int iopt);  
-  PView *execute (PView *);
+  StringXNumber *getOption(int iopt);  
+  PView *execute(PView *);
 
   static int getNbU ();
   static int getNbV ();
diff --git a/Plugin/CutMap.cpp b/Plugin/CutMap.cpp
index 654d8d366e..e1a76f480c 100644
--- a/Plugin/CutMap.cpp
+++ b/Plugin/CutMap.cpp
@@ -1,4 +1,4 @@
-// $Id: CutMap.cpp,v 1.58 2008-03-20 11:44:12 geuzaine Exp $
+// $Id: CutMap.cpp,v 1.59 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -42,11 +42,6 @@ extern "C"
   }
 }
 
-GMSH_CutMapPlugin::GMSH_CutMapPlugin()
-{
-  ;
-}
-
 double GMSH_CutMapPlugin::callbackA(int num, int action, double value)
 {
   double min = 0., max = 1.;
diff --git a/Plugin/CutMap.h b/Plugin/CutMap.h
index 1a08923fde..badd4e6cb4 100644
--- a/Plugin/CutMap.h
+++ b/Plugin/CutMap.h
@@ -31,13 +31,13 @@ class GMSH_CutMapPlugin : public GMSH_LevelsetPlugin
 {
   double levelset(double x, double y, double z, double val) const;
  public:
-  GMSH_CutMapPlugin();
+  GMSH_CutMapPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption (int iopt);  
-  PView *execute (PView *);
+  StringXNumber *getOption(int iopt);  
+  PView *execute(PView *);
   static double callbackA(int, int, double);
   static double callbackVol(int, int, double);
   static double callbackRecur(int, int, double);
diff --git a/Plugin/CutParametric.cpp b/Plugin/CutParametric.cpp
index aecf25a143..ca4b429e90 100644
--- a/Plugin/CutParametric.cpp
+++ b/Plugin/CutParametric.cpp
@@ -1,4 +1,4 @@
-// $Id: CutParametric.cpp,v 1.27 2008-03-20 11:44:12 geuzaine Exp $
+// $Id: CutParametric.cpp,v 1.28 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -57,12 +57,6 @@ extern "C"
   }
 }
 
-
-GMSH_CutParametricPlugin::GMSH_CutParametricPlugin()
-{
-  ;
-}
-
 static double getU(int i)
 {
   double minU = CutParametricOptions_Number[0].def;
diff --git a/Plugin/CutParametric.h b/Plugin/CutParametric.h
index abf8176691..b085506621 100644
--- a/Plugin/CutParametric.h
+++ b/Plugin/CutParametric.h
@@ -40,14 +40,14 @@ private:
   static int recompute;
   static std::vector<double> x, y, z;
 public:
-  GMSH_CutParametricPlugin();
+  GMSH_CutParametricPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
   StringXNumber *getOption(int iopt);  
   int getNbOptionsStr() const;
-  StringXString* getOptionStr(int iopt);  
+  StringXString *getOptionStr(int iopt);  
   PView *execute(PView *);
 
   static double callbackMinU(int, int, double);
diff --git a/Plugin/CutPlane.cpp b/Plugin/CutPlane.cpp
index 19f25977ef..792c27b2d3 100644
--- a/Plugin/CutPlane.cpp
+++ b/Plugin/CutPlane.cpp
@@ -1,4 +1,4 @@
-// $Id: CutPlane.cpp,v 1.56 2008-03-20 11:44:13 geuzaine Exp $
+// $Id: CutPlane.cpp,v 1.57 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -51,11 +51,6 @@ extern "C"
   }
 }
 
-GMSH_CutPlanePlugin::GMSH_CutPlanePlugin()
-{
-  ;
-}
-
 void GMSH_CutPlanePlugin::draw()
 {
 #if defined(HAVE_FLTK)
diff --git a/Plugin/CutPlane.h b/Plugin/CutPlane.h
index 656bf9d1ee..68f0f7303b 100644
--- a/Plugin/CutPlane.h
+++ b/Plugin/CutPlane.h
@@ -34,7 +34,7 @@ class GMSH_CutPlanePlugin : public GMSH_LevelsetPlugin
                          double step, double min, double max);
   static int iview;
 public:
-  GMSH_CutPlanePlugin();
+  GMSH_CutPlanePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/CutSphere.cpp b/Plugin/CutSphere.cpp
index 438c40782a..ea203df8ba 100644
--- a/Plugin/CutSphere.cpp
+++ b/Plugin/CutSphere.cpp
@@ -1,4 +1,4 @@
-// $Id: CutSphere.cpp,v 1.50 2008-03-20 11:44:13 geuzaine Exp $
+// $Id: CutSphere.cpp,v 1.51 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -49,11 +49,6 @@ extern "C"
   }
 }
 
-GMSH_CutSpherePlugin::GMSH_CutSpherePlugin()
-{
-  ;
-}
-
 void GMSH_CutSpherePlugin::draw()
 {
 #if defined(HAVE_FLTK)
diff --git a/Plugin/CutSphere.h b/Plugin/CutSphere.h
index 546afc647b..d6b5d33c78 100644
--- a/Plugin/CutSphere.h
+++ b/Plugin/CutSphere.h
@@ -33,12 +33,12 @@ class GMSH_CutSpherePlugin : public GMSH_LevelsetPlugin
   static double callback(int num, int action, double value, double *opt,
                          double step, double min, double max);
 public:
-  GMSH_CutSpherePlugin();
+  GMSH_CutSpherePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 
   static double callbackX(int, int, double);
diff --git a/Plugin/Divergence.cpp b/Plugin/Divergence.cpp
index 3c36f84292..8dc1c56dce 100644
--- a/Plugin/Divergence.cpp
+++ b/Plugin/Divergence.cpp
@@ -1,4 +1,4 @@
-// $Id: Divergence.cpp,v 1.8 2008-04-05 09:21:37 geuzaine Exp $
+// $Id: Divergence.cpp,v 1.9 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -34,18 +34,13 @@ extern "C"
   }
 }
 
-GMSH_DivergencePlugin::GMSH_DivergencePlugin()
-{
-  ;
-}
-
 void GMSH_DivergencePlugin::getName(char *name) const
 {
   strcpy(name, "Divergence");
 }
 
 void GMSH_DivergencePlugin::getInfos(char *author, char *copyright,
-                                    char *help_text) const
+				     char *help_text) const
 {
   strcpy(author, "C. Geuzaine");
   strcpy(copyright, "DGR (www.multiphysics.com)");
diff --git a/Plugin/Divergence.h b/Plugin/Divergence.h
index 6c0e1126ae..1a7dd26b2b 100644
--- a/Plugin/Divergence.h
+++ b/Plugin/Divergence.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_DivergencePlugin : public GMSH_Post_Plugin
 {
  public:
-  GMSH_DivergencePlugin();
+  GMSH_DivergencePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Eigenvalues.cpp b/Plugin/Eigenvalues.cpp
index 3ea813d948..f9c381bbce 100644
--- a/Plugin/Eigenvalues.cpp
+++ b/Plugin/Eigenvalues.cpp
@@ -1,4 +1,4 @@
-// $Id: Eigenvalues.cpp,v 1.7 2008-03-20 11:44:13 geuzaine Exp $
+// $Id: Eigenvalues.cpp,v 1.8 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -71,39 +71,18 @@ void GMSH_EigenvaluesPlugin::catchErrorMessage(char *errorMessage) const
   strcpy(errorMessage, "Eigenvalues failed...");
 }
 
-static void eigenvalues(List_T *inList, int inNb, 
-                        int nbNod, int nbTime,
-                        List_T *minList, int *minNb, 
-                        List_T *midList, int *midNb, 
-                        List_T *maxList, int *maxNb)
+static List_T *incrementList(PViewDataList *data2, int numEdges)
 {
-  if(!inNb) return;
-
-  int nb = List_Nbr(inList) / inNb;
-  for(int i = 0; i < List_Nbr(inList); i += nb) {
-    for(int j = 0; j < 3 * nbNod; j++){
-      List_Add(minList, List_Pointer_Fast(inList, i + j));
-      List_Add(midList, List_Pointer_Fast(inList, i + j));
-      List_Add(maxList, List_Pointer_Fast(inList, i + j));
-    }
-    for(int j = 0; j < nbTime; j++){
-      for(int k = 0; k < nbNod; k++){
-        double *v = (double *)List_Pointer_Fast(inList, i + 3 * nbNod + 
-                                                nbNod * 9 * j + 9 * k);
-        double w[3], A[3][3] = { {v[0], v[1], v[2]},
-                                 {v[3], v[4], v[5]},
-                                 {v[6], v[7], v[8]} };
-        eigenvalue(A, w);
-        for(int l = 0; l < 3; l++){
-          List_Add(minList, &w[2]);
-          List_Add(midList, &w[1]);
-          List_Add(maxList, &w[0]);
-        }
-      }
-    }
-    (*minNb)++;
-    (*midNb)++;
-    (*maxNb)++;
+  switch(numEdges){
+  case 0: data2->NbSP++; return data2->SP;
+  case 1: data2->NbSL++; return data2->SL;
+  case 3: data2->NbST++; return data2->ST;
+  case 4: data2->NbSQ++; return data2->SQ;
+  case 6: data2->NbSS++; return data2->SS;
+  case 12: data2->NbSH++; return data2->SH;
+  case 9: data2->NbSI++; return data2->SI;
+  case 8: data2->NbSY++; return data2->SY;
+  default: return 0;
   }
 }
 
@@ -114,8 +93,11 @@ PView *GMSH_EigenvaluesPlugin::execute(PView *v)
   PView *v1 = getView(iView, v);
   if(!v1) return v;
 
-  PViewDataList *data1 = getDataList(v1);
-  if(!data1) return v;
+  PViewData *data1 = v1->getData();
+  if(data1->hasMultipleMeshes()){
+    Msg(GERROR, "Eigenvalues plugin cannot be run on multi-mesh views");
+    return v;
+  }
 
   PView *min = new PView(true);
   PView *mid = new PView(true);
@@ -125,27 +107,57 @@ PView *GMSH_EigenvaluesPlugin::execute(PView *v)
   PViewDataList *dmid = getDataList(mid);
   PViewDataList *dmax = getDataList(max);
 
-  eigenvalues(data1->TP, data1->NbTP, 1, data1->getNumTimeSteps(),
-              dmin->SP, &dmin->NbSP, dmid->SP, &dmid->NbSP, dmax->SP, &dmax->NbSP);
-  eigenvalues(data1->TL, data1->NbTL, 2, data1->getNumTimeSteps(),
-              dmin->SL, &dmin->NbSL, dmid->SL, &dmid->NbSL, dmax->SL, &dmax->NbSL);
-  eigenvalues(data1->TT, data1->NbTT, 3, data1->getNumTimeSteps(),
-              dmin->ST, &dmin->NbST, dmid->ST, &dmid->NbST, dmax->ST, &dmax->NbST);
-  eigenvalues(data1->TQ, data1->NbTQ, 4, data1->getNumTimeSteps(),
-              dmin->SQ, &dmin->NbSQ, dmid->SQ, &dmid->NbSQ, dmax->SQ, &dmax->NbSQ);
-  eigenvalues(data1->TS, data1->NbTS, 4, data1->getNumTimeSteps(),
-              dmin->SS, &dmin->NbSS, dmid->SS, &dmid->NbSS, dmax->SS, &dmax->NbSS);
-  eigenvalues(data1->TH, data1->NbTH, 8, data1->getNumTimeSteps(),
-              dmin->SH, &dmin->NbSH, dmid->SH, &dmid->NbSH, dmax->SH, &dmax->NbSH);
-  eigenvalues(data1->TI, data1->NbTI, 6, data1->getNumTimeSteps(),
-              dmin->SI, &dmin->NbSI, dmid->SI, &dmid->NbSI, dmax->SI, &dmax->NbSI);
-  eigenvalues(data1->TY, data1->NbTY, 5, data1->getNumTimeSteps(),
-              dmin->SY, &dmin->NbSY, dmid->SY, &dmid->NbSY, dmax->SY, &dmax->NbSY);
-
-  for(int i = 0; i < List_Nbr(data1->Time); i++){
-    List_Add(dmin->Time, List_Pointer(data1->Time, i));
-    List_Add(dmid->Time, List_Pointer(data1->Time, i));
-    List_Add(dmax->Time, List_Pointer(data1->Time, i));
+  for(int ent = 0; ent < data1->getNumEntities(0); ent++){
+    for(int ele = 0; ele < data1->getNumElements(0, ent); ele++){
+      if(data1->skipElement(0, ent, ele)) continue;
+      int numComp = data1->getNumComponents(0, ent, ele);
+      if(numComp != 9) continue;
+      int numEdges = data1->getNumEdges(0, ent, ele);
+      List_T *outmin = incrementList(dmin, numEdges);
+      List_T *outmid = incrementList(dmid, numEdges);
+      List_T *outmax = incrementList(dmax, numEdges);
+      if(!outmin || !outmid || !outmax) continue;
+      int numNodes = data1->getNumNodes(0, ent, ele);
+      double x[8], y[8], z[8];
+      for(int nod = 0; nod < numNodes; nod++)
+	data1->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]);
+      for(int nod = 0; nod < numNodes; nod++){
+	List_Add(outmin, &x[nod]);
+	List_Add(outmid, &x[nod]);
+	List_Add(outmax, &x[nod]);
+      }
+      for(int nod = 0; nod < numNodes; nod++){
+	List_Add(outmin, &y[nod]);
+	List_Add(outmid, &y[nod]);
+	List_Add(outmax, &y[nod]);
+      }
+      for(int nod = 0; nod < numNodes; nod++){
+	List_Add(outmin, &z[nod]);
+	List_Add(outmid, &z[nod]);
+	List_Add(outmax, &z[nod]);
+      }
+      for(int step = 0; step < data1->getNumTimeSteps(); step++){
+	for(int nod = 0; nod < numNodes; nod++){
+	  double val[9];
+	  for(int comp = 0; comp < numComp; comp++)
+	    data1->getValue(step, ent, ele, nod, comp, val[comp]);
+	  double w[3], A[3][3] = { {val[0], val[1], val[2]},
+				   {val[3], val[4], val[5]},
+				   {val[6], val[7], val[8]} };
+	  eigenvalue(A, w);
+	  List_Add(outmin, &w[2]);
+	  List_Add(outmid, &w[1]);
+	  List_Add(outmax, &w[0]);
+	}
+      }
+    }
+  }
+  
+  for(int i = 0; i < data1->getNumTimeSteps(); i++){
+    double time = data1->getTime(i);
+    List_Add(dmin->Time, &time);
+    List_Add(dmid->Time, &time);
+    List_Add(dmax->Time, &time);
   }
   dmin->setName(data1->getName() + "_MinEigenvalues");
   dmin->setFileName(data1->getName() + "_MinEigenvalues.pos");
diff --git a/Plugin/Eigenvalues.h b/Plugin/Eigenvalues.h
index 4142aea88e..f761bce36e 100644
--- a/Plugin/Eigenvalues.h
+++ b/Plugin/Eigenvalues.h
@@ -35,7 +35,7 @@ class GMSH_EigenvaluesPlugin : public GMSH_Post_Plugin
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Evaluate.cpp b/Plugin/Evaluate.cpp
index 79396180fe..f6891baa37 100644
--- a/Plugin/Evaluate.cpp
+++ b/Plugin/Evaluate.cpp
@@ -1,4 +1,4 @@
-// $Id: Evaluate.cpp,v 1.36 2008-03-21 17:09:06 geuzaine Exp $
+// $Id: Evaluate.cpp,v 1.37 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -45,12 +45,6 @@ extern "C"
   }
 }
 
-
-GMSH_EvaluatePlugin::GMSH_EvaluatePlugin()
-{
-  ;
-}
-
 void GMSH_EvaluatePlugin::getName(char *name) const
 {
   strcpy(name, "Evaluate");
diff --git a/Plugin/Evaluate.h b/Plugin/Evaluate.h
index 7af0203450..17cc1c2b0d 100644
--- a/Plugin/Evaluate.h
+++ b/Plugin/Evaluate.h
@@ -38,7 +38,7 @@ private:
                 int timeStep, int timeStep2,
                 const char *expression);
 public:
-  GMSH_EvaluatePlugin();
+  GMSH_EvaluatePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/Extract.cpp b/Plugin/Extract.cpp
index 25a4eb564e..012f21c437 100644
--- a/Plugin/Extract.cpp
+++ b/Plugin/Extract.cpp
@@ -1,4 +1,4 @@
-// $Id: Extract.cpp,v 1.27 2008-03-20 11:44:13 geuzaine Exp $
+// $Id: Extract.cpp,v 1.28 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -54,11 +54,6 @@ extern "C"
   }
 }
 
-GMSH_ExtractPlugin::GMSH_ExtractPlugin()
-{
-  ;
-}
-
 void GMSH_ExtractPlugin::getName(char *name) const
 {
   strcpy(name, "Extract");
diff --git a/Plugin/Extract.h b/Plugin/Extract.h
index 8068b0b810..8555eb4038 100644
--- a/Plugin/Extract.h
+++ b/Plugin/Extract.h
@@ -30,7 +30,7 @@ extern "C"
 class GMSH_ExtractPlugin : public GMSH_Post_Plugin
 {
  public:
-  GMSH_ExtractPlugin();
+  GMSH_ExtractPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/ExtractElements.cpp b/Plugin/ExtractElements.cpp
index efa5985402..c8832ef5af 100644
--- a/Plugin/ExtractElements.cpp
+++ b/Plugin/ExtractElements.cpp
@@ -1,4 +1,4 @@
-// $Id: ExtractElements.cpp,v 1.12 2008-03-20 11:44:13 geuzaine Exp $
+// $Id: ExtractElements.cpp,v 1.13 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -37,11 +37,6 @@ extern "C"
   }
 }
 
-GMSH_ExtractElementsPlugin::GMSH_ExtractElementsPlugin()
-{
-  ;
-}
-
 void GMSH_ExtractElementsPlugin::getName(char *name) const
 {
   strcpy(name, "Extract Elements");
diff --git a/Plugin/ExtractElements.h b/Plugin/ExtractElements.h
index f4f2f57b1e..62c17886b6 100644
--- a/Plugin/ExtractElements.h
+++ b/Plugin/ExtractElements.h
@@ -30,7 +30,7 @@ extern "C"
 class GMSH_ExtractElementsPlugin : public GMSH_Post_Plugin
 {
  public:
-  GMSH_ExtractElementsPlugin();
+  GMSH_ExtractElementsPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/Gradient.cpp b/Plugin/Gradient.cpp
index b96daa4d7a..2779dd3b7c 100644
--- a/Plugin/Gradient.cpp
+++ b/Plugin/Gradient.cpp
@@ -1,4 +1,4 @@
-// $Id: Gradient.cpp,v 1.13 2008-04-05 09:21:37 geuzaine Exp $
+// $Id: Gradient.cpp,v 1.14 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -34,18 +34,13 @@ extern "C"
   }
 }
 
-GMSH_GradientPlugin::GMSH_GradientPlugin()
-{
-  ;
-}
-
 void GMSH_GradientPlugin::getName(char *name) const
 {
   strcpy(name, "Gradient");
 }
 
 void GMSH_GradientPlugin::getInfos(char *author, char *copyright,
-                                    char *help_text) const
+				   char *help_text) const
 {
   strcpy(author, "C. Geuzaine");
   strcpy(copyright, "DGR (www.multiphysics.com)");
diff --git a/Plugin/Gradient.h b/Plugin/Gradient.h
index 86315daa78..5ace582bd9 100644
--- a/Plugin/Gradient.h
+++ b/Plugin/Gradient.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_GradientPlugin : public GMSH_Post_Plugin
 {
  public:
-  GMSH_GradientPlugin();
+  GMSH_GradientPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Probe.cpp b/Plugin/Probe.cpp
index 4094118c68..6c75bfd8e3 100644
--- a/Plugin/Probe.cpp
+++ b/Plugin/Probe.cpp
@@ -1,4 +1,4 @@
-// $Id: Probe.cpp,v 1.21 2008-03-20 11:44:14 geuzaine Exp $
+// $Id: Probe.cpp,v 1.22 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -47,11 +47,6 @@ extern "C"
   }
 }
 
-GMSH_ProbePlugin::GMSH_ProbePlugin()
-{
-  ;
-}
-
 void GMSH_ProbePlugin::draw()
 {
 #if defined(HAVE_FLTK)
diff --git a/Plugin/Probe.h b/Plugin/Probe.h
index 961fa14247..6a6ba2eef0 100644
--- a/Plugin/Probe.h
+++ b/Plugin/Probe.h
@@ -33,7 +33,7 @@ class GMSH_ProbePlugin : public GMSH_Post_Plugin
   static double callback(int num, int action, double value, double *opt);
   static int iview;
 public:
-  GMSH_ProbePlugin();
+  GMSH_ProbePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/Remove.cpp b/Plugin/Remove.cpp
index 74cd3c09d7..bc9283c3a1 100644
--- a/Plugin/Remove.cpp
+++ b/Plugin/Remove.cpp
@@ -1,4 +1,4 @@
-// $Id: Remove.cpp,v 1.14 2008-03-20 11:44:14 geuzaine Exp $
+// $Id: Remove.cpp,v 1.15 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -46,11 +46,6 @@ extern "C"
   }
 }
 
-GMSH_RemovePlugin::GMSH_RemovePlugin()
-{
-  ;
-}
-
 void GMSH_RemovePlugin::getName(char *name) const
 {
   strcpy(name, "Remove");
diff --git a/Plugin/Remove.h b/Plugin/Remove.h
index b7b4a100ac..e7295d1c8a 100644
--- a/Plugin/Remove.h
+++ b/Plugin/Remove.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_RemovePlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_RemovePlugin();
+  GMSH_RemovePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Skin.cpp b/Plugin/Skin.cpp
index 51b6aa048b..ca9aeb90f2 100644
--- a/Plugin/Skin.cpp
+++ b/Plugin/Skin.cpp
@@ -1,4 +1,4 @@
-// $Id: Skin.cpp,v 1.37 2008-03-20 11:44:14 geuzaine Exp $
+// $Id: Skin.cpp,v 1.38 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -44,11 +44,6 @@ extern "C"
   }
 }
 
-GMSH_SkinPlugin::GMSH_SkinPlugin()
-{
-  ;
-}
-
 void GMSH_SkinPlugin::getName(char *name) const
 {
   strcpy(name, "Skin");
diff --git a/Plugin/Skin.h b/Plugin/Skin.h
index d3b7005983..ba4436cefc 100644
--- a/Plugin/Skin.h
+++ b/Plugin/Skin.h
@@ -43,12 +43,12 @@ class GMSH_SkinPlugin : public GMSH_Post_Plugin
   void skinList(List_T *inList, int inNbList, 
                 int inNbNod, int inNbFac, int fxn[6][4]);
  public:
-  GMSH_SkinPlugin();
+  GMSH_SkinPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Smooth.cpp b/Plugin/Smooth.cpp
index 01d526b8cf..1f97c6862f 100644
--- a/Plugin/Smooth.cpp
+++ b/Plugin/Smooth.cpp
@@ -1,4 +1,4 @@
-// $Id: Smooth.cpp,v 1.31 2008-03-20 11:44:14 geuzaine Exp $
+// $Id: Smooth.cpp,v 1.32 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -33,12 +33,6 @@ extern "C"
   }
 }
 
-
-GMSH_SmoothPlugin::GMSH_SmoothPlugin()
-{
-  ;
-}
-
 void GMSH_SmoothPlugin::getName(char *name) const
 {
   strcpy(name, "Smooth");
diff --git a/Plugin/Smooth.h b/Plugin/Smooth.h
index 33edc0396d..9b369f2a78 100644
--- a/Plugin/Smooth.h
+++ b/Plugin/Smooth.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_SmoothPlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_SmoothPlugin();
+  GMSH_SmoothPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/SphericalRaise.cpp b/Plugin/SphericalRaise.cpp
index 2218427752..9624fd84b7 100644
--- a/Plugin/SphericalRaise.cpp
+++ b/Plugin/SphericalRaise.cpp
@@ -1,4 +1,4 @@
-// $Id: SphericalRaise.cpp,v 1.32 2008-03-20 11:44:14 geuzaine Exp $
+// $Id: SphericalRaise.cpp,v 1.33 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -40,12 +40,6 @@ extern "C"
   }
 }
 
-
-GMSH_SphericalRaisePlugin::GMSH_SphericalRaisePlugin()
-{
-  ;
-}
-
 void GMSH_SphericalRaisePlugin::getName(char *name) const
 {
   strcpy(name, "Spherical Raise");
@@ -89,47 +83,6 @@ void GMSH_SphericalRaisePlugin::catchErrorMessage(char *errorMessage) const
   strcpy(errorMessage, "SphericalRaise failed...");
 }
 
-static void sphericalRaise(PViewData *data, List_T *list, int nbElm,
-                           int nbNod, int timeStep, double center[3], 
-                           double raise, double offset)
-{
-  double *x, *y, *z, *val, d[3], coef;
-  int nb, i, j;
-
-  if(!nbElm)
-    return;
-
-  if(timeStep < 0 || timeStep > data->getNumTimeSteps() - 1){
-    Msg(GERROR, "Invalid TimeStep (%d) in view", timeStep);
-    return;
-  }
-
-  // for each element
-  //   for each node
-  //      compute d=(x-Xc,y-Yc,z-Zc)
-  //      norm d
-  //      get nodal value val at xyz
-  //      compute (x,y,z)_new = (x,y,z)_old + (offset+raise*val)*(dx,dy,dz)
-
-  nb = List_Nbr(list) / nbElm;
-  for(i = 0; i < List_Nbr(list); i += nb) {
-    x = (double *)List_Pointer_Fast(list, i);
-    y = (double *)List_Pointer_Fast(list, i + nbNod);
-    z = (double *)List_Pointer_Fast(list, i + 2 * nbNod);
-    val = (double *)List_Pointer_Fast(list, i + 3 * nbNod);
-    for(j = 0; j < nbNod; j++) {
-      d[0] = x[j] - center[0];
-      d[1] = y[j] - center[1];
-      d[2] = z[j] - center[2];
-      norme(d);
-      coef = offset + raise * val[nbNod * timeStep + j];
-      x[j] += coef * d[0];
-      y[j] += coef * d[1];
-      z[j] += coef * d[2];
-    }
-  }
-}
-
 PView *GMSH_SphericalRaisePlugin::execute(PView *v)
 {
   double center[3];
@@ -144,17 +97,55 @@ PView *GMSH_SphericalRaisePlugin::execute(PView *v)
   PView *v1 = getView(iView, v);
   if(!v1) return v;
 
-  PViewDataList *data1 = getDataList(v1);
-  if(!data1) return v;
-
-  sphericalRaise(data1, data1->SP, data1->NbSP, 1, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SL, data1->NbSL, 2, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->ST, data1->NbST, 3, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SQ, data1->NbSQ, 4, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SS, data1->NbSS, 4, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SH, data1->NbSH, 8, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SI, data1->NbSI, 6, timeStep, center, raise, offset);
-  sphericalRaise(data1, data1->SY, data1->NbSY, 5, timeStep, center, raise, offset);
+  PViewData *data1 = v1->getData();
+
+  // sanity checks
+  if(timeStep < 0 || timeStep > data1->getNumTimeSteps() - 1){
+    Msg(GERROR, "Invalid TimeStep (%d) in view", timeStep);
+    return v;
+  }
+
+  // tag all the nodes with "0" (the default tag)
+  for(int step = 0; step < data1->getNumTimeSteps(); step++){
+    for(int ent = 0; ent < data1->getNumEntities(step); ent++){
+      for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
+	if(data1->skipElement(step, ent, ele)) continue;
+	int numNodes = data1->getNumNodes(step, ent, ele);
+	for(int nod = 0; nod < numNodes; nod++){
+	  double x, y, z;
+	  data1->getNode(step, ent, ele, nod, x, y, z);
+	  data1->setNode(step, ent, ele, nod, x, y, z, 0);
+	}
+      }
+    }
+  }
+
+  // transform all "0" nodes
+  for(int step = 0; step < data1->getNumTimeSteps(); step++){
+    for(int ent = 0; ent < data1->getNumEntities(step); ent++){
+      for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
+	if(data1->skipElement(step, ent, ele)) continue;
+	int numNodes = data1->getNumNodes(step, ent, ele);
+	for(int nod = 0; nod < numNodes; nod++){
+	  double x, y, z;
+	  int tag = data1->getNode(step, ent, ele, nod, x, y, z);
+	  if(!tag){
+	    double r[3], val;
+	    r[0] = x - center[0];
+	    r[1] = y - center[1];
+	    r[2] = z - center[2];
+	    norme(r);
+	    data1->getScalarValue(step, ent, ele, nod, val);
+	    double coef = offset + raise * val;
+	    x += coef * r[0];
+	    y += coef * r[1];
+	    z += coef * r[2];
+	    data1->setNode(step, ent, ele, nod, x, y, z, 1);
+	  }
+	}
+      }
+    }
+  }
 
   data1->finalize();
   v1->setChanged(true);
diff --git a/Plugin/SphericalRaise.h b/Plugin/SphericalRaise.h
index eb852caa19..9ed3720742 100644
--- a/Plugin/SphericalRaise.h
+++ b/Plugin/SphericalRaise.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_SphericalRaisePlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_SphericalRaisePlugin();
+  GMSH_SphericalRaisePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Transform.cpp b/Plugin/Transform.cpp
index ba3ec43753..38c413449e 100644
--- a/Plugin/Transform.cpp
+++ b/Plugin/Transform.cpp
@@ -1,4 +1,4 @@
-// $Id: Transform.cpp,v 1.39 2008-04-05 09:21:37 geuzaine Exp $
+// $Id: Transform.cpp,v 1.40 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -46,11 +46,6 @@ extern "C"
   }
 }
 
-GMSH_TransformPlugin::GMSH_TransformPlugin()
-{
-  ;
-}
-
 void GMSH_TransformPlugin::getName(char *name) const
 {
   strcpy(name, "Transform");
diff --git a/Plugin/Transform.h b/Plugin/Transform.h
index 7634e6effc..b4534ec55d 100644
--- a/Plugin/Transform.h
+++ b/Plugin/Transform.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_TransformPlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_TransformPlugin();
+  GMSH_TransformPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
diff --git a/Plugin/Triangulate.cpp b/Plugin/Triangulate.cpp
index 567a2ed789..9f977b6c33 100644
--- a/Plugin/Triangulate.cpp
+++ b/Plugin/Triangulate.cpp
@@ -1,4 +1,4 @@
-// $Id: Triangulate.cpp,v 1.47 2008-03-20 11:44:15 geuzaine Exp $
+// $Id: Triangulate.cpp,v 1.48 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -42,11 +42,6 @@ extern "C"
   }
 }
 
-GMSH_TriangulatePlugin::GMSH_TriangulatePlugin()
-{
-  ;
-}
-
 void GMSH_TriangulatePlugin::getName(char *name) const
 {
   strcpy(name, "Triangulate");
diff --git a/Plugin/Triangulate.h b/Plugin/Triangulate.h
index 7d01482bf4..b126a49e51 100644
--- a/Plugin/Triangulate.h
+++ b/Plugin/Triangulate.h
@@ -30,7 +30,7 @@ extern "C"
 class GMSH_TriangulatePlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_TriangulatePlugin();
+  GMSH_TriangulatePlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *helpText) const;
   void catchErrorMessage(char *errorMessage) const;
diff --git a/Plugin/Warp.cpp b/Plugin/Warp.cpp
index 01144819bb..e342ccca78 100644
--- a/Plugin/Warp.cpp
+++ b/Plugin/Warp.cpp
@@ -1,4 +1,4 @@
-// $Id: Warp.cpp,v 1.13 2008-03-20 11:44:15 geuzaine Exp $
+// $Id: Warp.cpp,v 1.14 2008-04-05 17:49:23 geuzaine Exp $
 //
 // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
 //
@@ -27,7 +27,6 @@ StringXNumber WarpOptions_Number[] = {
   {GMSH_FULLRC, "Factor", NULL, 1.},
   {GMSH_FULLRC, "TimeStep", NULL, 0.},
   {GMSH_FULLRC, "SmoothingAngle", NULL, 180.},
-  {GMSH_FULLRC, "Explode", NULL, 1.},
   {GMSH_FULLRC, "dView", NULL, -1.},
   {GMSH_FULLRC, "iView", NULL, -1.}
 };
@@ -40,19 +39,13 @@ extern "C"
   }
 }
 
-
-GMSH_WarpPlugin::GMSH_WarpPlugin()
-{
-  ;
-}
-
 void GMSH_WarpPlugin::getName(char *name) const
 {
   strcpy(name, "Warp");
 }
 
 void GMSH_WarpPlugin::getInfos(char *author, char *copyright,
-                                         char *help_text) const
+			       char *help_text) const
 {
   strcpy(author, "C. Geuzaine");
   strcpy(copyright, "DGR (www.multiphysics.com)");
@@ -86,174 +79,106 @@ void GMSH_WarpPlugin::catchErrorMessage(char *errorMessage) const
   strcpy(errorMessage, "Warp failed...");
 }
 
-static void addNormals(List_T *listElm, int nbElm, int nbNod, 
-                       smooth_normals *normals)
-{
-  if(!nbElm || nbNod < 3) return;
-  int nb = List_Nbr(listElm) / nbElm;
-  for(int i = 0; i < List_Nbr(listElm); i += nb) {
-    double *x = (double *)List_Pointer_Fast(listElm, i);
-    double *y = (double *)List_Pointer_Fast(listElm, i + nbNod);
-    double *z = (double *)List_Pointer_Fast(listElm, i + 2 * nbNod);
-    double nn[3];
-    normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], nn);
-    for(int k = 0; k < nbNod; k++)
-      normals->add(x[k], y[k], z[k], nn[0], nn[1], nn[2]);
-  }
-}
-
-static void warpList(List_T *iList, int iNbElm,
-                     List_T *dList, int dNbElm,
-                     int nbNod, double factor, int TimeStep,
-                     int nbComp, smooth_normals *normals, double explode)
-{
-  if(!iNbElm)
-    return;
-
-  if(!normals && (iNbElm != dNbElm)){
-    Msg(GERROR, "Views have a different number of elements (%d != %d)", 
-        iNbElm, dNbElm);
-    return;
-  }
-  
-  // for each element
-  //   for each node
-  //      (x,y,z) += factor * (valx,valy,valz)
-
-  int iNb = List_Nbr(iList) / iNbElm;
-  int dNb = normals ? 0 : List_Nbr(dList) / dNbElm;
-  for(int i = 0, j = 0; i < List_Nbr(iList); i += iNb, j += dNb) {
-    double *x = (double *)List_Pointer_Fast(iList, i);
-    double *y = (double *)List_Pointer_Fast(iList, i + nbNod);
-    double *z = (double *)List_Pointer_Fast(iList, i + 2 * nbNod);
-    double *val;
-    if(normals)
-      val = (double *)List_Pointer_Fast(iList, i + 3 * nbNod);
-    else
-      val = (double *)List_Pointer_Fast(dList, j + 3 * nbNod);
-
-    double nn[3] = {0., 0., 1.};
-    if(normals && nbNod > 2)
-      normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], nn);
-
-    for(int k = 0; k < nbNod; k++) {
-      if(normals){
-        double d = 1.;
-        if(TimeStep >= 0){
-          double *v = &val[nbComp * nbNod * TimeStep + nbComp * k];
-          if(nbComp == 1)
-            d = v[0];
-          else if(nbComp == 3)
-            d = sqrt(DSQR(v[0]) + DSQR(v[1]) + DSQR(v[2]));
-          else if(nbComp == 9)
-            d = ComputeVonMises(v);
-        }
-        normals->get(x[k], y[k], z[k], nn[0], nn[1], nn[2]);
-        x[k] += factor * d * nn[0];
-        y[k] += factor * d * nn[1];
-        z[k] += factor * d * nn[2];
-      }
-      else{
-        if(TimeStep < 0) TimeStep = 0;
-        x[k] += factor * val[3 * nbNod * TimeStep + 3 * k];
-        y[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 1];
-        z[k] += factor * val[3 * nbNod * TimeStep + 3 * k + 2];
-      }
-    }
-
-    if(explode != 1.){
-      double cg[3] = {0., 0., 0.};
-      for(int k = 0; k < nbNod; k++) {
-        cg[0] += x[k];
-        cg[1] += y[k];
-        cg[2] += z[k];
-      }
-      for(int k = 0; k < 3; k++) cg[k] /= (double)nbNod;
-      for(int k = 0; k < nbNod; k++) {
-        x[k] = cg[0] + explode * (x[k] - cg[0]);
-        y[k] = cg[1] + explode * (y[k] - cg[1]);
-        z[k] = cg[2] + explode * (z[k] - cg[2]);
-      }
-    }
-
-  }
-  
-}
-
-static void warp(PViewDataList *data1, PViewDataList *data2, double factor, 
-                 int ts, double tol, double e)
-{
-  smooth_normals *nn = 0;
-  if(WarpOptions_Number[4].def <  0){
-    nn = new smooth_normals(tol);
-    addNormals(data1->ST, data1->NbST, 3, nn);
-    addNormals(data1->VT, data1->NbVT, 3, nn);
-    addNormals(data1->TT, data1->NbTT, 3, nn);
-    addNormals(data1->SQ, data1->NbSQ, 4, nn);
-    addNormals(data1->VQ, data1->NbVQ, 4, nn);
-    addNormals(data1->TQ, data1->NbTQ, 4, nn);
-  }
-
-  warpList(data1->SP, data1->NbSP, data2->VP, data2->NbVP, 1, factor, ts, 1, nn, e);
-  warpList(data1->SL, data1->NbSL, data2->VL, data2->NbVL, 2, factor, ts, 1, nn, e);
-  warpList(data1->ST, data1->NbST, data2->VT, data2->NbVT, 3, factor, ts, 1, nn, e);
-  warpList(data1->SQ, data1->NbSQ, data2->VQ, data2->NbVQ, 4, factor, ts, 1, nn, e);
-  warpList(data1->SS, data1->NbSS, data2->VS, data2->NbVS, 4, factor, ts, 1, nn, e);
-  warpList(data1->SH, data1->NbSH, data2->VH, data2->NbVH, 8, factor, ts, 1, nn, e);
-  warpList(data1->SI, data1->NbSI, data2->VI, data2->NbVI, 6, factor, ts, 1, nn, e);
-  warpList(data1->SY, data1->NbSY, data2->VY, data2->NbVY, 5, factor, ts, 1, nn, e);
-                                                                    
-  warpList(data1->VP, data1->NbVP, data2->VP, data2->NbVP, 1, factor, ts, 3, nn, e);
-  warpList(data1->VL, data1->NbVL, data2->VL, data2->NbVL, 2, factor, ts, 3, nn, e);
-  warpList(data1->VT, data1->NbVT, data2->VT, data2->NbVT, 3, factor, ts, 3, nn, e);
-  warpList(data1->VQ, data1->NbVQ, data2->VQ, data2->NbVQ, 4, factor, ts, 3, nn, e);
-  warpList(data1->VS, data1->NbVS, data2->VS, data2->NbVS, 4, factor, ts, 3, nn, e);
-  warpList(data1->VH, data1->NbVH, data2->VH, data2->NbVH, 8, factor, ts, 3, nn, e);
-  warpList(data1->VI, data1->NbVI, data2->VI, data2->NbVI, 6, factor, ts, 3, nn, e);
-  warpList(data1->VY, data1->NbVY, data2->VY, data2->NbVY, 5, factor, ts, 3, nn, e);
-                                                                    
-  warpList(data1->TP, data1->NbTP, data2->VP, data2->NbVP, 1, factor, ts, 9, nn, e);
-  warpList(data1->TL, data1->NbTL, data2->VL, data2->NbVL, 2, factor, ts, 9, nn, e);
-  warpList(data1->TT, data1->NbTT, data2->VT, data2->NbVT, 3, factor, ts, 9, nn, e);
-  warpList(data1->TQ, data1->NbTQ, data2->VQ, data2->NbVQ, 4, factor, ts, 9, nn, e);
-  warpList(data1->TS, data1->NbTS, data2->VS, data2->NbVS, 4, factor, ts, 9, nn, e);
-  warpList(data1->TH, data1->NbTH, data2->VH, data2->NbVH, 8, factor, ts, 9, nn, e);
-  warpList(data1->TI, data1->NbTI, data2->VI, data2->NbVI, 6, factor, ts, 9, nn, e);
-  warpList(data1->TY, data1->NbTY, data2->VY, data2->NbVY, 5, factor, ts, 9, nn, e);
-
-  if(nn) delete nn;
-}
-
 PView *GMSH_WarpPlugin::execute(PView *v)
 {
   double factor = WarpOptions_Number[0].def;
   int TimeStep = (int)WarpOptions_Number[1].def;
   double AngleTol = WarpOptions_Number[2].def;
-  double Explode = WarpOptions_Number[3].def;
-  int dView = (int)WarpOptions_Number[4].def;
-  int iView = (int)WarpOptions_Number[5].def;
+  int dView = (int)WarpOptions_Number[3].def;
+  int iView = (int)WarpOptions_Number[4].def;
 
   PView *v1 = getView(iView, v);
   if(!v1) return v;
-
-  PViewDataList *data1 = getDataList(v1);
-  if(!data1) return v;
-
   if(dView < 0) dView = iView;
-
   PView *v2 = getView(dView, v);
   if(!v2) return v;
 
-  PViewDataList *data2 = getDataList(v2);
-  if(!data2) return v;
+  PViewData *data1 = v1->getData();
+  PViewData *data2 = v2->getData();
 
-  if(TimeStep > data2->getNumTimeSteps() - 1){
-    // we allow TimeStep < 0 (to apply fixed warps)
+  // sanity checks
+  if(data1->getNumEntities() != data2->getNumEntities() ||
+     data1->getNumElements() != data2->getNumElements()){
+    Msg(GERROR, "Incompatible views");
+    return v;
+  }
+  if(TimeStep < 0 || TimeStep > data2->getNumTimeSteps() - 1){
     Msg(GERROR, "Invalid TimeStep (%d) in View[%d]", TimeStep, v2->getIndex());
     return v;
   }
+  
+  // create smooth normal field if we don't have an explicit warp field
+  smooth_normals *normals = 0;
+  if(dView < 0){
+    normals = new smooth_normals(AngleTol);
+    for(int ent = 0; ent < data1->getNumEntities(0); ent++){
+      for(int ele = 0; ele < data1->getNumElements(0, ent); ele++){
+	if(data1->skipElement(0, ent, ele)) continue;
+	int numEdges = data1->getNumEdges(0, ent, ele);
+	if(numEdges == 3 || numEdges == 4){
+	  double x[4], y[4], z[4], n[4];
+	  for(int nod = 0; nod < numEdges; nod++)
+	    data1->getNode(0, ent, ele, nod, x[nod], y[nod], z[nod]);
+	  normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n);
+	  for(int nod = 0; nod < numEdges; nod++)
+	    normals->add(x[nod], y[nod], z[nod], n[0], n[1], n[2]);
+	}
+      }
+    }
+  }
+
+  // tag all the nodes with "0" (the default tag)
+  for(int step = 0; step < data1->getNumTimeSteps(); step++){
+    for(int ent = 0; ent < data1->getNumEntities(step); ent++){
+      for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
+	if(data1->skipElement(step, ent, ele)) continue;
+	int numNodes = data1->getNumNodes(step, ent, ele);
+	for(int nod = 0; nod < numNodes; nod++){
+	  double x, y, z;
+	  data1->getNode(step, ent, ele, nod, x, y, z);
+	  data1->setNode(step, ent, ele, nod, x, y, z, 0);
+	}
+      }
+    }
+  }
 
-  warp(data1, data2, factor, TimeStep, AngleTol, Explode);
+  // transform each "0" node: (x,y,z) += factor * mult * (valx, valy, valz)
+  for(int step = 0; step < data1->getNumTimeSteps(); step++){
+    for(int ent = 0; ent < data1->getNumEntities(step); ent++){
+      for(int ele = 0; ele < data1->getNumElements(step, ent); ele++){
+	if(data1->skipElement(step, ent, ele)) continue;
+	int numNodes = data1->getNumNodes(step, ent, ele);
+	double x[8], y[8], z[8], n[3] = {0., 0., 0.};
+	int tag[8];
+	for(int nod = 0; nod < numNodes; nod++)
+	  tag[nod] = data1->getNode(step, ent, ele, nod, x[nod], y[nod], z[nod]);
+	int dim = data1->getDimension(step, ent, ele);
+	if(normals && dim == 2)
+	  normal3points(x[0], y[0], z[0], x[1], y[1], z[1], x[2], y[2], z[2], n);
+	for(int nod = 0; nod < numNodes; nod++){
+	  if(tag[nod]) continue; // already transformed
+	  double mult = 1., val[3] = {n[0], n[1], n[2]};
+	  if(normals){
+	    if(dim == 2){
+	      normals->get(x[nod], y[nod], z[nod], val[0], val[1], val[2]);
+	      data1->getScalarValue(step, ent, ele, nod, mult);
+	    }
+	  }
+	  else if(data2->getNumComponents(TimeStep, ent, ele) == 3 &&
+		  data2->getNumNodes(TimeStep, ent, ele) == numNodes){
+	    for(int comp = 0; comp < 3; comp++)
+	      data2->getValue(TimeStep, ent, ele, nod, comp, val[comp]);
+	  }
+	  x[nod] += factor * mult * val[0];
+	  y[nod] += factor * mult * val[1];
+	  z[nod] += factor * mult * val[2];
+	  data1->setNode(step, ent, ele, nod, x[nod], y[nod], z[nod], 1);
+	}
+      }
+    }
+  }
+  
+  if(normals) delete normals;
 
   data1->finalize();
   v1->setChanged(true);
diff --git a/Plugin/Warp.h b/Plugin/Warp.h
index 81ca9c7f28..04f9272b2d 100644
--- a/Plugin/Warp.h
+++ b/Plugin/Warp.h
@@ -30,12 +30,12 @@ extern "C"
 class GMSH_WarpPlugin : public GMSH_Post_Plugin
 {
 public:
-  GMSH_WarpPlugin();
+  GMSH_WarpPlugin(){}
   void getName(char *name) const;
   void getInfos(char *author, char *copyright, char *help_text) const;
   void catchErrorMessage(char *errorMessage) const;
   int getNbOptions() const;
-  StringXNumber* getOption(int iopt);  
+  StringXNumber *getOption(int iopt);  
   PView *execute(PView *);
 };
 
-- 
GitLab