From 6fbc222d0ebb53c7fc7f3644459a9e51faa878b4 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Tue, 13 Dec 2011 11:23:26 +0000
Subject: [PATCH] better curvilinear coordinate computation

---
 Fltk/statisticsWindow.cpp | 20 ++++++++++++++++----
 Graphics/drawGraph2d.cpp  |  6 ++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/Fltk/statisticsWindow.cpp b/Fltk/statisticsWindow.cpp
index b164f0b365..9b214a6600 100644
--- a/Fltk/statisticsWindow.cpp
+++ b/Fltk/statisticsWindow.cpp
@@ -35,19 +35,31 @@ static void statistics_histogram_cb(Fl_Widget *w, void *data)
   std::vector<double> x, y;
 
   if(name == "Gamma2D"){
-    for(int i = 0; i < 100; i++) y.push_back(FlGui::instance()->stats->quality[0][i]);
+    for(int i = 0; i < 100; i++){
+      x.push_back((double)i / 99);
+      y.push_back(FlGui::instance()->stats->quality[0][i]);
+    }
     new PView("Gamma", "# Elements", x, y);
   }
   else if(name == "Eta2D"){
-    for(int i = 0; i < 100; i++) y.push_back(FlGui::instance()->stats->quality[1][i]);
+    for(int i = 0; i < 100; i++){
+      x.push_back((double)i / 99);
+      y.push_back(FlGui::instance()->stats->quality[1][i]);
+    }
     new PView("Eta", "# Elements", x, y);
   }
   else if(name == "Rho2D"){
-    for(int i = 0; i < 100; i++) y.push_back(FlGui::instance()->stats->quality[2][i]);
+    for(int i = 0; i < 100; i++){
+      x.push_back((double)i / 99);
+      y.push_back(FlGui::instance()->stats->quality[2][i]);
+    }
     new PView("Rho", "# Elements", x, y);
   }
   else if(name == "Disto2D"){
-    for(int i = 0; i < 100; i++) y.push_back(FlGui::instance()->stats->quality[3][i]);
+    for(int i = 0; i < 100; i++){
+      x.push_back((double)i / 99);
+      y.push_back(FlGui::instance()->stats->quality[3][i]);
+    }
     new PView("Disto", "# Elements", x, y);
   }
   else{
diff --git a/Graphics/drawGraph2d.cpp b/Graphics/drawGraph2d.cpp
index c2051f4a69..39a61f9a5e 100644
--- a/Graphics/drawGraph2d.cpp
+++ b/Graphics/drawGraph2d.cpp
@@ -117,13 +117,15 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
             y[0].push_back(vy);
           }
           else if(opt->type == PViewOptions::Plot2DSpace){
-            // store offset to origin + distance to first point
+            // compute curvilinear coordinate
             if(x.empty()){
               p0 = SPoint3(xyz[0], xyz[1], xyz[2]);
               x.push_back(ComputeScalarRep(3, xyz));
             }
             else{
-              x.push_back(x[0] + p0.distance(SPoint3(xyz[0], xyz[1], xyz[2])));
+              SPoint3 p1(xyz[0], xyz[1], xyz[2]);
+              x.push_back(x.back() + p0.distance(p1));
+              p0 = p1;
             }
             y[0].push_back(vy);
           }
-- 
GitLab