From b6037bad08d857b07de13900cf5396d27a94964d Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Wed, 13 Dec 2000 20:21:48 +0000
Subject: [PATCH] Added tolerance in sys3x3 (it produces a message) -> to help
 in Plan_Moyen

---
 Mesh/2D_Mesh.cpp | 19 +++++++++++--------
 Mesh/Numeric.cpp |  9 ++++++++-
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/Mesh/2D_Mesh.cpp b/Mesh/2D_Mesh.cpp
index 14133accb6..d704da617c 100644
--- a/Mesh/2D_Mesh.cpp
+++ b/Mesh/2D_Mesh.cpp
@@ -1,4 +1,4 @@
-/* $Id: 2D_Mesh.cpp,v 1.11 2000-12-08 13:55:23 geuzaine Exp $ */
+/* $Id: 2D_Mesh.cpp,v 1.12 2000-12-13 20:21:48 geuzaine Exp $ */
 /*
    Maillage Delaunay d'une surface (Point insertion Technique)
 
@@ -73,6 +73,8 @@ void Plan_Moyen (void *data, void *dum){
     points = List_Create (10, 10, sizeof (Vertex *));
     deb = 0;
   }
+  else
+    List_Reset (points);
 
   switch (s->Typ){
   case MSH_SURF_PLAN:
@@ -143,7 +145,7 @@ void Plan_Moyen (void *data, void *dum){
     s->d = X;
     res[0] = 1.;
     res[1] = res[2] = 0.0;
-    Msg(DEBUG, "Plan Type x = c");
+    Msg(DEBUG, "Mean Plane of Type 'x = c'");
   }
 
   /* y = Y */
@@ -152,7 +154,7 @@ void Plan_Moyen (void *data, void *dum){
     s->d = Y;
     res[1] = 1.;
     res[0] = res[2] = 0.0;
-    Msg(DEBUG, "Plan Type y = c");
+    Msg(DEBUG, "Mean Plane of Type 'y = c'");
   }
 
   /* z = Z */
@@ -161,6 +163,7 @@ void Plan_Moyen (void *data, void *dum){
     s->d = Z;
     res[2] = 1.;
     res[1] = res[0] = 0.0;
+    Msg(DEBUG, "Mean Plane of Type 'y = c'");
   }
 
   /* by + cz = -x */
@@ -177,7 +180,7 @@ void Plan_Moyen (void *data, void *dum){
       res[0] = 1.;
       res[1] = r2[0];
       res[2] = r2[1];
-      Msg(DEBUG, "Plan Type by + cz = -x");
+      Msg(DEBUG, "Mean Plane of Type 'by + cz = -x'");
     }
 
     /* ax + cz = -y */
@@ -194,7 +197,7 @@ void Plan_Moyen (void *data, void *dum){
         res[0] = r2[0];
         res[1] = 1.;
         res[2] = r2[1];
-        Msg(DEBUG, "Plan Type ax + cz = -y");
+        Msg(DEBUG, "Mean Plane of Type 'ax + cz = -y'");
       }
       
       /* ax + by = -z */
@@ -211,10 +214,10 @@ void Plan_Moyen (void *data, void *dum){
           res[0] = r2[0];
           res[1] = r2[1];
           res[2] = 1.;
-          Msg(DEBUG, "Plan Type ax + by = -z");
+          Msg(DEBUG, "Mean Plane of Type 'ax + by = -z'");
         }
         else{
-          Msg(ERROR, "Mean Plane");
+          Msg(ERROR, "Problem in Mean Plane");
         }
       }
     }
@@ -282,7 +285,7 @@ void Plan_Moyen (void *data, void *dum){
       }
     }
   }
-  List_Reset (points);
+
 }
 
 
diff --git a/Mesh/Numeric.cpp b/Mesh/Numeric.cpp
index c51e4a4125..b319f7a77a 100644
--- a/Mesh/Numeric.cpp
+++ b/Mesh/Numeric.cpp
@@ -1,4 +1,4 @@
-/* $Id: Numeric.cpp,v 1.7 2000-11-28 11:28:32 geuzaine Exp $ */
+/* $Id: Numeric.cpp,v 1.8 2000-12-13 20:21:48 geuzaine Exp $ */
 
 #include "Gmsh.h"
 #include "Const.h"
@@ -94,6 +94,13 @@ int sys3x3 (double mat[3][3], double b[3], double res[3], double *det){
     return (0);
   }
 
+  // WARNING, WARNING
+  if (fabs(*det) < 1.e-12){
+    Msg(INFO, "Assuming Sys3x3 Matrix is Singular (Is this OK?)");
+    res[0] = res[1] = res[2] = 0.0 ;
+    return (0);
+  }
+
   ud = 1. / (*det);
 
   res[0] = b[0] * (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) -
-- 
GitLab