From fefc09bdd9f299e228953dec3db7d611e20c8465 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 14 Sep 2007 18:51:37 +0000
Subject: [PATCH] tweak 2d graph + other small fixes

---
 Common/VertexArray.cpp |  5 ++---
 Common/VertexArray.h   |  2 --
 Geo/Makefile           |  5 +++--
 Graphics/Graph2D.cpp   | 14 +++++++++++---
 Post/PView.cpp         | 22 ++++++++++++++--------
 doc/VERSIONS           |  4 ++--
 6 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp
index 3c8b72f249..46b17c71f2 100644
--- a/Common/VertexArray.cpp
+++ b/Common/VertexArray.cpp
@@ -1,4 +1,4 @@
-// $Id: VertexArray.cpp,v 1.22 2007-08-27 23:33:48 geuzaine Exp $
+// $Id: VertexArray.cpp,v 1.23 2007-09-14 18:51:37 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -27,7 +27,7 @@
 extern Context_T CTX;
 
 VertexArray::VertexArray(int numVerticesPerElement, int numElements) 
-  : fill(0), _numVerticesPerElement(numVerticesPerElement)
+  : _numVerticesPerElement(numVerticesPerElement)
 {
   int nb = (numElements ? numElements : 1) * numVerticesPerElement;
   _vertices.reserve(nb * 3);
@@ -192,4 +192,3 @@ void VertexArray::sort(double x, double y, double z)
   _normals = sortedNormals;
   _colors = sortedColors;
 }
-
diff --git a/Common/VertexArray.h b/Common/VertexArray.h
index e99b87eb91..8d1e6772e9 100644
--- a/Common/VertexArray.h
+++ b/Common/VertexArray.h
@@ -52,8 +52,6 @@ class BarycenterLessThan{
 };
 
 class VertexArray{
- public:
-  int fill; // this must/will be removed
  private:
   int _numVerticesPerElement;
   std::vector<float> _vertices;
diff --git a/Geo/Makefile b/Geo/Makefile
index 7de66d24d7..a3d360eea2 100644
--- a/Geo/Makefile
+++ b/Geo/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.163 2007-09-12 20:14:34 geuzaine Exp $
+# $Id: Makefile,v 1.164 2007-09-14 18:51:37 geuzaine Exp $
 #
 # Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 #
@@ -205,7 +205,8 @@ GModel.o: GModel.cpp GModel.h GVertex.h GEntity.h Range.h SPoint3.h \
   ../Post/ColorTable.h ../Geo/Geo.h ../Geo/gmshSurface.h \
   ../DataStr/Tree.h ../DataStr/avl.h ../Geo/SPoint2.h \
   ../Geo/ExtrudeParams.h ../Geo/GEdge.h ../Post/OctreePost.h \
-  ../Common/Octree.h ../Common/OctreeInternals.h ../Mesh/BackgroundMesh.h
+  ../Common/Octree.h ../Common/OctreeInternals.h ../Mesh/BackgroundMesh.h \
+  ../Common/Message.h
 GModelIO_Geo.o: GModelIO_Geo.cpp GModel.h GVertex.h GEntity.h Range.h \
   SPoint3.h SBoundingBox3d.h ../Common/VertexArray.h ../Geo/SVector3.h \
   ../Geo/SPoint3.h ../Common/GmshDefines.h MVertex.h GPoint.h SPoint2.h \
diff --git a/Graphics/Graph2D.cpp b/Graphics/Graph2D.cpp
index 093e26001f..20abe72d15 100644
--- a/Graphics/Graph2D.cpp
+++ b/Graphics/Graph2D.cpp
@@ -1,4 +1,4 @@
-// $Id: Graph2D.cpp,v 1.67 2007-09-12 05:08:12 geuzaine Exp $
+// $Id: Graph2D.cpp,v 1.68 2007-09-14 18:51:37 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -85,6 +85,8 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
 
   bool space = (opt->Type == PViewOptions::Plot2DSpace);
 
+  SPoint3 p0;
+
   numy = 0;
   for(int i = 0; i < data->getNumElements(); i++){
     int dim = data->getDimension(i);
@@ -97,10 +99,16 @@ static bool getGraphData(PView *p, std::vector<double> &x, double &xmin,
 	  data->getNode(i, j, xyz[0], xyz[1], xyz[2]);
 	  for(int k = 0; k < numComp; k++)
 	    data->getValue(i, j, k, ts, val[k]);
-	  double vx = ComputeScalarRep(3, xyz);
 	  double vy = ComputeScalarRep(numComp, val);
 	  if(space){
-	    x.push_back(vx);
+	    // store offset to origin + distance to first point
+	    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])));
+	    }
 	    y[0].push_back(vy);
 	  }
 	  else{
diff --git a/Post/PView.cpp b/Post/PView.cpp
index b6b5e4ba32..f02ef9bfb8 100644
--- a/Post/PView.cpp
+++ b/Post/PView.cpp
@@ -1,4 +1,4 @@
-// $Id: PView.cpp,v 1.8 2007-09-10 04:47:08 geuzaine Exp $
+// $Id: PView.cpp,v 1.9 2007-09-14 18:51:37 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -301,13 +301,19 @@ void PView::combine(bool time, int how, bool remove)
 
 bool PView::write(std::string filename, int format, bool append)
 {
+  Msg(STATUS2, "Writing '%s'", filename.c_str());
+
+  bool ret;
   switch(format){
-  case 0: return _data->writePOS(filename, false, false, append); // ASCII
-  case 1: return _data->writePOS(filename, true, false, append); // binary
-  case 2: return _data->writePOS(filename, false, true, append); // parsed
-  case 3: return _data->writeSTL(filename); 
-  case 4: return _data->writeTXT(filename);
-  case 5: return _data->writeMSH(filename);
-  default: Msg(GERROR, "Unknown view format %d", format); return false;
+  case 0: ret = _data->writePOS(filename, false, false, append); break; // ASCII
+  case 1: ret = _data->writePOS(filename, true, false, append); break; // binary
+  case 2: ret = _data->writePOS(filename, false, true, append); break; // parsed
+  case 3: ret = _data->writeSTL(filename); break;
+  case 4: ret = _data->writeTXT(filename); break;
+  case 5: ret = _data->writeMSH(filename); break;
+  default: ret = false; Msg(GERROR, "Unknown view format %d", format); break;
   }
+
+  Msg(STATUS2, "Wrote '%s'", filename.c_str());
+  return ret;
 }
diff --git a/doc/VERSIONS b/doc/VERSIONS
index 448af73e7f..d8043e8804 100644
--- a/doc/VERSIONS
+++ b/doc/VERSIONS
@@ -1,7 +1,7 @@
-$Id: VERSIONS,v 1.391 2007-09-10 04:47:09 geuzaine Exp $
+$Id: VERSIONS,v 1.392 2007-09-14 18:51:37 geuzaine Exp $
 
 2.1.0 (XX): new post-processing database; complete rewrite of
-post-processing draing code; improved 2D mesh algorithms; fix for
+post-processing drawing code; improved 2D mesh algorithms; fix for
 'could not find extruded vertex' bug;
 
 2.0.8 (Jul 13, 2007): unused vertices are not saved in mesh files
-- 
GitLab