From c83d7cfe7ce2698a2392459702dd8fffebad6973 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 13 May 2013 20:03:53 +0000
Subject: [PATCH] allow s (time step) and t (time) in general raise expressions

---
 Common/Options.cpp         | 7 ++++---
 Post/PViewOptions.cpp      | 4 +++-
 Post/PViewOptions.h        | 1 +
 Post/PViewVertexArrays.cpp | 4 +++-
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/Common/Options.cpp b/Common/Options.cpp
index 4f2ed53567..e70b047927 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -3164,14 +3164,14 @@ double opt_general_stereo_mode(OPT_ARGS_NUM)
   if(action & GMSH_SET)
     CTX::instance()->stereo = (int)val;
   if (CTX::instance()->stereo)    opt_general_camera_mode(num, action, 1.);
-  
+
 #if defined(HAVE_FLTK)
   /*
   if(FlGui::available() && (action & GMSH_GUI))
   FlGui::instance()->options->general.butt[17]->value(CTX::instance()->stereo);
 */
 #endif
-  
+
   return CTX::instance()->stereo ;
 }
 
@@ -3223,7 +3223,7 @@ double opt_general_camera_mode(OPT_ARGS_NUM)
     FlGui::instance()->options->general.butt[18]->value
       (CTX::instance()->camera);
     FlGui::instance()->options->activate("general_camera");
-  
+
   }
   */
 #endif
@@ -6147,6 +6147,7 @@ double opt_view_timestep(OPT_ARGS_NUM)
       if(data->getAdaptiveData())
         data->getAdaptiveData()->changeResolution
           (opt->timeStep, opt->maxRecursionLevel, opt->targetError);
+      opt->currentTime = data->getTime(opt->timeStep);
     }
     if(view) view->setChanged(true);
   }
diff --git a/Post/PViewOptions.cpp b/Post/PViewOptions.cpp
index 01e97315b1..1ae82893fa 100644
--- a/Post/PViewOptions.cpp
+++ b/Post/PViewOptions.cpp
@@ -14,6 +14,7 @@ PViewOptions::PViewOptions() : genRaiseEvaluator(0)
 {
   ColorTable_InitParam(2, &colorTable);
   ColorTable_Recompute(&colorTable);
+  currentTime = 0.;
 }
 
 PViewOptions::~PViewOptions()
@@ -107,7 +108,8 @@ unsigned int PViewOptions::getColor(int i, int nb)
 void PViewOptions::createGeneralRaise()
 {
   const char *names[] =
-    { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8"};
+    { "x", "y", "z", "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8",
+      "s", "t"};
   unsigned int numVariables = sizeof(names) / sizeof(names[0]);
   std::vector<std::string> expressions(3), variables(numVariables);
   expressions[0] = genRaiseX;
diff --git a/Post/PViewOptions.h b/Post/PViewOptions.h
index e3de672298..7eaf1b5987 100644
--- a/Post/PViewOptions.h
+++ b/Post/PViewOptions.h
@@ -79,6 +79,7 @@ class PViewOptions {
   int scaleType, rangeType, abscissaRangeType;
   int vectorType, tensorType, glyphLocation, centerGlyphs;
   int timeStep;
+  double currentTime;
   int drawStrings;
   int drawPoints, drawLines, drawTriangles, drawQuadrangles, drawPolygons;
   int drawTetrahedra, drawHexahedra, drawPrisms, drawPyramids, drawPolyhedra;
diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp
index a9f9cecfd7..1358ead311 100644
--- a/Post/PViewVertexArrays.cpp
+++ b/Post/PViewVertexArrays.cpp
@@ -180,10 +180,12 @@ static void applyGeneralRaise(PView *p, int numNodes, int numComp,
   PViewOptions *opt = p->getOptions();
   if(!opt->genRaiseEvaluator) return;
 
-  std::vector<double> values(12, 0.), res(3);
+  std::vector<double> values(14, 0.), res(3);
   for(int k = 0; k < numNodes; k++) {
     for(int i = 0; i < 3; i++) values[i] = xyz[k][i];
     for(int i = 0; i < std::min(numComp, 9); i++) values[3 + i] = vals[k][i];
+    values[12] = p->getOptions()->timeStep;
+    values[13] = p->getOptions()->currentTime;
     if(opt->genRaiseEvaluator->eval(values, res))
       for(int i = 0; i < 3; i++)
         xyz[k][i] += opt->genRaiseFactor * res[i];
-- 
GitLab