From 912847edd422a66cfaecdd5a6a2420198d9b759f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 18 Oct 2009 19:33:05 +0000
Subject: [PATCH] Fix whole-element clipping for glyphs (thanks to Shahrokh
 Ghavamian for reporting the bug)

---
 Graphics/drawPost.cpp      | 1 +
 Post/PView.h               | 2 ++
 Post/PViewVertexArrays.cpp | 4 ++--
 doc/CREDITS.txt            | 2 +-
 4 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Graphics/drawPost.cpp b/Graphics/drawPost.cpp
index ff7f9b3add..50afbb9b27 100644
--- a/Graphics/drawPost.cpp
+++ b/Graphics/drawPost.cpp
@@ -256,6 +256,7 @@ static void drawGlyphs(drawContext *ctx, PView *p)
           data->getValue(opt->timeStep, ent, i, j, k, val[j][k]);
       }
       changeCoordinates(p, ent, i, numNodes, type, numComp, xyz, val);
+      if(!isElementVisible(opt, dim, numNodes, xyz)) continue;
       if(opt->intervalsType == PViewOptions::Numeric)
         drawNumberGlyphs(ctx, p, numNodes, numComp, xyz, val);
       if(dim == 2 && opt->normals)
diff --git a/Post/PView.h b/Post/PView.h
index c577b4c0c9..70a0259596 100644
--- a/Post/PView.h
+++ b/Post/PView.h
@@ -132,5 +132,7 @@ class PView{
 void changeCoordinates(PView *p, int ient, int iele,
                        int numNodes, int type, int numComp, 
                        double xyz[PVIEW_NMAX][3], double val[PVIEW_NMAX][9]);
+bool isElementVisible(PViewOptions *opt, int dim, int numNodes, 
+                      double xyz[PVIEW_NMAX][3]);
 
 #endif
diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp
index c212a9fa4b..567bd0fed6 100644
--- a/Post/PViewVertexArrays.cpp
+++ b/Post/PViewVertexArrays.cpp
@@ -265,8 +265,8 @@ static double intersectClipPlane(int clip, int numNodes, double xyz[PVIEW_NMAX][
   return val;
 }
 
-static bool isElementVisible(PViewOptions *opt, int dim, int numNodes, 
-                             double xyz[PVIEW_NMAX][3])
+bool isElementVisible(PViewOptions *opt, int dim, int numNodes, 
+                      double xyz[PVIEW_NMAX][3])
 {
   if(!CTX::instance()->clipWholeElements) return true;
   bool hidden = false;
diff --git a/doc/CREDITS.txt b/doc/CREDITS.txt
index b3b13dd941..fe44f64569 100644
--- a/doc/CREDITS.txt
+++ b/doc/CREDITS.txt
@@ -121,4 +121,4 @@ Michel Benhamou, Tom De Vuyst, Kris Van den Abeele, Simon Vun, Simon
 Corbin, Thomas De-Soza, Marcus Drosson, Antoine Dechaume, Jose Paulo
 Moitinho de Almeida, Thomas Pinchard, Corrado Chisari, Axel Hackbarth,
 Peter Wainwright, Jiri Hnidek, Thierry Thomas, Konstantinos Poulios,
-Laurent Van Miegroet.
+Laurent Van Miegroet, Shahrokh Ghavamian.
-- 
GitLab