From 87a823f63f1c755cedb3b23f0cbfc2359dac435e Mon Sep 17 00:00:00 2001
From: Jonathan Lambrechts <jonathan.lambrechts@uclouvain.be>
Date: Mon, 10 Jun 2013 14:40:08 +0000
Subject: [PATCH] visualization of High order 1D mesh elements (not postpro)

---
 Geo/MLine.cpp | 34 ++++++++++++++++++++++++++++++++++
 Geo/MLine.h   | 19 ++++---------------
 2 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/Geo/MLine.cpp b/Geo/MLine.cpp
index 7b33b69a68..42766c6031 100644
--- a/Geo/MLine.cpp
+++ b/Geo/MLine.cpp
@@ -72,3 +72,37 @@ double MLine::getVolume()
 {
   return getLength();
 }
+
+int MLine3::getNumEdgesRep() 
+{
+  return  CTX::instance()->mesh.numSubEdges;
+}
+
+void MLine3::getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n)
+{
+  int numSubEdges = CTX::instance()->mesh.numSubEdges;
+  SPoint3 pnt1, pnt2;
+  pnt(-1. + 2 * (double)num / numSubEdges, 0., 0., pnt1);
+  pnt(-1. + 2 * (double)(num + 1) / numSubEdges, 0., 0, pnt2);
+  x[0] = pnt1.x(); x[1] = pnt2.x();
+  y[0] = pnt1.y(); y[1] = pnt2.y();
+  z[0] = pnt1.z(); z[1] = pnt2.z();
+  n[0] = n[1] = MEdge(_v[0], _v[1]).normal();
+}
+
+int MLineN::getNumEdgesRep() 
+{
+  return  CTX::instance()->mesh.numSubEdges;
+}
+
+void MLineN::getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n)
+{
+  int numSubEdges = CTX::instance()->mesh.numSubEdges;
+  SPoint3 pnt1, pnt2;
+  pnt(-1. + 2 * (double)num / numSubEdges, 0., 0., pnt1);
+  pnt(-1. + 2 * (double)(num + 1) / numSubEdges, 0., 0, pnt2);
+  x[0] = pnt1.x(); x[1] = pnt2.x();
+  y[0] = pnt1.y(); y[1] = pnt2.y();
+  z[0] = pnt1.z(); z[1] = pnt2.z();
+  n[0] = n[1] = MEdge(_v[0], _v[1]).normal();
+}
diff --git a/Geo/MLine.h b/Geo/MLine.h
index d4ebc09a9b..1cb90314eb 100644
--- a/Geo/MLine.h
+++ b/Geo/MLine.h
@@ -133,14 +133,8 @@ class MLine3 : public MLine {
   }
   virtual MVertex *getVertexINP(int num){ return getVertexUNV(num); }
   virtual int getNumEdgeVertices() const { return 1; }
-  virtual int getNumEdgesRep(){ return 2; }
-  virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n)
-  {
-    static const int e[2][2] = {
-      {0, 2}, {2, 1}
-    };
-    _getEdgeRep(getVertex(e[num][0]), getVertex(e[num][1]), x, y, z, n);
-  }
+  virtual int getNumEdgesRep();
+  virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n);
   virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
   {
     v.resize(3);
@@ -188,13 +182,8 @@ class MLineN : public MLine {
   virtual MVertex *getVertex(int num){ return num < 2 ? _v[num] : _vs[num - 2]; }
   virtual const MVertex *getVertex(int num) const{ return num < 2 ? _v[num] : _vs[num - 2]; }
   virtual int getNumEdgeVertices() const { return _vs.size(); }
-  virtual int getNumEdgesRep(){ return _vs.size() + 1; }
-  virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n)
-  {
-    _getEdgeRep(getVertex((num == 0) ? 0 : num + 1),
-                getVertex((num == getNumEdgesRep() - 1) ? 1 : num + 2),
-                x, y, z, n);
-  }
+  virtual int getNumEdgesRep();
+  virtual void getEdgeRep(int num, double *x, double *y, double *z, SVector3 *n);
   virtual void getEdgeVertices(const int num, std::vector<MVertex*> &v) const
   {
     v.resize(2 + _vs.size());
-- 
GitLab