From 46b1c140e2ccb00eb6ba36491a688f500695711f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 22 Sep 2007 18:19:29 +0000
Subject: [PATCH] - don't force show geom surf/vol if we have a mesh - removed
 unused stuff in VertexArray before moving to set<ElementData> for   auto
 boundary creation

---
 Common/VertexArray.cpp | 28 +++-------------------------
 Common/VertexArray.h   |  7 +++----
 Fltk/Callbacks.cpp     | 14 +++++++++-----
 Graphics/Post.cpp      | 31 ++++++++++++++++++-------------
 4 files changed, 33 insertions(+), 47 deletions(-)

diff --git a/Common/VertexArray.cpp b/Common/VertexArray.cpp
index 4319cd3f0e..018ba35dd8 100644
--- a/Common/VertexArray.cpp
+++ b/Common/VertexArray.cpp
@@ -1,4 +1,4 @@
-// $Id: VertexArray.cpp,v 1.24 2007-09-18 16:26:01 geuzaine Exp $
+// $Id: VertexArray.cpp,v 1.25 2007-09-22 18:19:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -63,24 +63,6 @@ void VertexArray::add(float x, float y, float z, float n0, float n1, float n2,
   if(ele && CTX.pick_elements) _elements.push_back(ele);
 }
 
-void VertexArray::add(float x, float y, float z, unsigned int col, MElement *ele)
-{
-  _vertices.push_back(x);
-  _vertices.push_back(y);
-  _vertices.push_back(z);
-
-  unsigned char r = CTX.UNPACK_RED(col);
-  unsigned char g = CTX.UNPACK_GREEN(col);
-  unsigned char b = CTX.UNPACK_BLUE(col);
-  unsigned char a = CTX.UNPACK_ALPHA(col);
-  _colors.push_back(r);
-  _colors.push_back(g);
-  _colors.push_back(b);
-  _colors.push_back(a);
-
-  if(ele && CTX.pick_elements) _elements.push_back(ele);
-}
-
 float BarycenterLessThan::tolerance = 0.;
 
 void VertexArray::add(double *x, double *y, double *z, SVector3 *n,
@@ -96,12 +78,8 @@ void VertexArray::add(double *x, double *y, double *z, SVector3 *n,
     _barycenters.insert(pc);
   }
 
-  for(int i = 0; i < npe; i++){
-    if(n) 
-      add(x[i], y[i], z[i], n[i].x(), n[i].y(), n[i].z(), col[i], ele);
-    else
-      add(x[i], y[i], z[i], 0., 0., 1., col[i], ele);
-  }
+  for(int i = 0; i < npe; i++)
+    add(x[i], y[i], z[i], n[i].x(), n[i].y(), n[i].z(), col[i], ele);
 }
 
 class AlphaElement {
diff --git a/Common/VertexArray.h b/Common/VertexArray.h
index 018222deb9..4c675e4cf2 100644
--- a/Common/VertexArray.h
+++ b/Common/VertexArray.h
@@ -79,10 +79,9 @@ class VertexArray{
   // adds a vertex in the arrays
   void add(float x, float y, float z, float n0, float n1, float n2, 
 	   unsigned int col, MElement *ele=0);
-  void add(float x, float y, float z, unsigned int col, MElement *ele=0);
-  // add a complete element in the arrays (if unique is set, only add
-  // the element if another one with the same barycenter is not
-  // already present)
+  // add an element in the arrays (if unique is set, only add the
+  // element if another one with the same barycenter is not already
+  // present)
   void add(double *x, double *y, double *z, SVector3 *n, unsigned int *col,
 	   MElement *ele=0, bool unique=true);
   // sorts the elements back to front wrt the eye position
diff --git a/Fltk/Callbacks.cpp b/Fltk/Callbacks.cpp
index 44048fa35c..ddd29fde9e 100644
--- a/Fltk/Callbacks.cpp
+++ b/Fltk/Callbacks.cpp
@@ -1,4 +1,4 @@
-// $Id: Callbacks.cpp,v 1.546 2007-09-15 17:11:50 geuzaine Exp $
+// $Id: Callbacks.cpp,v 1.547 2007-09-22 18:19:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -2164,14 +2164,16 @@ void visibility_interactive_cb(CALLBACK_ARGS)
     what = ENT_SURFACE;
     mode = 0;
     help = "surfaces to hide";
-    opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1);
+    if(GModel::current()->getMeshStatus() < 2)
+      opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1);
   }
   else if(!strcmp(str, "hide_volumes")){
     CTX.pick_elements = 0;
     what = ENT_VOLUME;
     mode = 0;
     help = "volumes to hide";
-    opt_geometry_volumes(0, GMSH_SET | GMSH_GUI, 1);
+    if(GModel::current()->getMeshStatus() < 3)
+      opt_geometry_volumes(0, GMSH_SET | GMSH_GUI, 1);
   }
   else if(!strcmp(str, "show_elements")){
     CTX.pick_elements = 1;
@@ -2198,14 +2200,16 @@ void visibility_interactive_cb(CALLBACK_ARGS)
     what = ENT_SURFACE;
     mode = 1;
     help = "surfaces to show";
-    opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1);
+    if(GModel::current()->getMeshStatus() < 2)
+      opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1);
   }
   else if(!strcmp(str, "show_volumes")){
     CTX.pick_elements = 0;
     what = ENT_VOLUME;
     mode = 1;
     help = "volumes to show";
-    opt_geometry_volumes(0, GMSH_SET | GMSH_GUI, 1);
+    if(GModel::current()->getMeshStatus() < 3)
+      opt_geometry_volumes(0, GMSH_SET | GMSH_GUI, 1);
   }
   else if(!strcmp(str, "show_all")){
     for(int i = 1; i <= 5; i++) // elements, points, lines, surfaces, volumes
diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp
index 4c23b55bd8..0b73f86c43 100644
--- a/Graphics/Post.cpp
+++ b/Graphics/Post.cpp
@@ -1,4 +1,4 @@
-// $Id: Post.cpp,v 1.135 2007-09-20 10:03:48 geuzaine Exp $
+// $Id: Post.cpp,v 1.136 2007-09-22 18:19:29 geuzaine Exp $
 //
 // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 //
@@ -1195,18 +1195,6 @@ class initPView {
 
     if(!opt->Visible || opt->Type != PViewOptions::Plot3D) return;
 
-    if(p->va_points) delete p->va_points;
-    p->va_points = new VertexArray(1, _estimateNumPoints(p));
-    if(p->va_lines) delete p->va_lines;
-    p->va_lines = new VertexArray(2, _estimateNumLines(p));
-    if(p->va_triangles) delete p->va_triangles;
-    p->va_triangles = new VertexArray(3, _estimateNumTriangles(p));
-    if(p->va_vectors) delete p->va_vectors;
-    p->va_vectors = new VertexArray(2, _estimateNumVectors(p));
-
-    if(p->normals) delete p->normals;
-    p->normals = new smooth_normals(opt->AngleSmoothNormals);
-
     if(opt->UseGenRaise) opt->createGeneralRaise();
 
     if(opt->RangeType == PViewOptions::Custom){
@@ -1222,9 +1210,26 @@ class initPView {
       opt->TmpMax = data->getMax();
     }
 
+    if(p->va_points) delete p->va_points;
+    p->va_points = new VertexArray(1, _estimateNumPoints(p));
+    if(p->va_lines) delete p->va_lines;
+    p->va_lines = new VertexArray(2, _estimateNumLines(p));
+    if(p->va_triangles) delete p->va_triangles;
+    p->va_triangles = new VertexArray(3, _estimateNumTriangles(p));
+    if(p->va_vectors) delete p->va_vectors;
+    p->va_vectors = new VertexArray(2, _estimateNumVectors(p));
+
+    if(p->normals) delete p->normals;
+    p->normals = new smooth_normals(opt->AngleSmoothNormals);
+
     if(opt->SmoothNormals) addElementsInArrays(p, true);
     addElementsInArrays(p, false);
 
+    p->va_points->finalize();
+    p->va_lines->finalize();
+    p->va_triangles->finalize();
+    p->va_vectors->finalize();
+
     Msg(INFO, "Rendering %d vertices", p->va_points->getNumVertices() + 
 	p->va_lines->getNumVertices() + p->va_triangles->getNumVertices() + 
 	p->va_vectors->getNumVertices());
-- 
GitLab