From ad7895b07791042141c7efa43e2aeda3ef0b2a9f Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 4 May 2014 05:57:06 +0000
Subject: [PATCH] coverity fixes

---
 Mesh/meshGRegionLocalMeshMod.cpp | 7 ++++---
 Post/PViewVertexArrays.cpp       | 7 +++++--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Mesh/meshGRegionLocalMeshMod.cpp b/Mesh/meshGRegionLocalMeshMod.cpp
index d21ec6d089..a89b892eba 100644
--- a/Mesh/meshGRegionLocalMeshMod.cpp
+++ b/Mesh/meshGRegionLocalMeshMod.cpp
@@ -107,7 +107,7 @@ bool buildEdgeCavity(MTet4 *t, int iLocalEdge, MVertex **v1, MVertex **v2,
       return false;
     }
     // FIXME when hybrid mesh, this loops for ever
-    if (cavity.size() > 1000)return false;
+    if (cavity.size() > 1000) return false;
     //    printf("%d %d\n",ITER++, cavity.size());
   }
   computeNeighboringTetsOfACavity (cavity,outside);
@@ -453,8 +453,9 @@ void buildVertexCavity_recur(MTet4 *t, MVertex *v, std::vector<MTet4*> &cavity)
     }
   }
   if (iV == -1){
-    Msg::Fatal("trying to build a cavity of tets for a vertex that does not "
-        "belong to this tet");
+    Msg::Error("Trying to build a cavity of tets for a vertex that does not "
+               "belong to this tet");
+    return;
   }
   for (int i = 0; i < 3; i++){
     MTet4 *neigh = t->getNeigh(vFac[iV][i]);
diff --git a/Post/PViewVertexArrays.cpp b/Post/PViewVertexArrays.cpp
index c6305ce718..d26d909fe4 100644
--- a/Post/PViewVertexArrays.cpp
+++ b/Post/PViewVertexArrays.cpp
@@ -677,7 +677,8 @@ static void addScalarPolygon(PView *p, double **xyz,
         ite != edges.end(); ite++){
       int i = (int) (*ite).second / 100;
       int j = (*ite).second % 100;
-      addScalarLine(p, xyz, val, pre, 3*i+il[j][0], 3*i+il[j][0], true);
+      if(j < 3)
+        addScalarLine(p, xyz, val, pre, 3*i+il[j][0], 3*i+il[j][0], true);
     }
     opt->boundary++;
 
@@ -858,6 +859,7 @@ static void addScalarPyramid(PView *p, double **xyz,
 static void addOutlinePolyhedron(PView *p, double **xyz,
                                  unsigned int color, bool pre, int numNodes)
 {
+  // FIXME: this code is horribly slow
   const int it[4][3] = {{0, 2, 1}, {0, 1, 3}, {0, 3, 2}, {3, 1, 2}};
   std::map<MFace, int, Less_Face> triFaces;
   std::vector<MVertex *> verts;
@@ -878,7 +880,8 @@ static void addOutlinePolyhedron(PView *p, double **xyz,
       ite != triFaces.end(); ite++){
     int i = (int) (*ite).second / 100;
     int j = (*ite).second % 100;
-    addOutlineTriangle(p, xyz, color, pre, 4*i+it[j][0], 4*i+it[j][1], 4*i+it[j][2]);
+    if(j < 4)
+      addOutlineTriangle(p, xyz, color, pre, 4*i+it[j][0], 4*i+it[j][1], 4*i+it[j][2]);
   }
   for(int i = 0; i < numNodes; i++)
     delete verts[i];
-- 
GitLab