From 0c32a2924e8628c2408d60c02b96b8b1c1d4cf30 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Fri, 23 Jan 2009 07:32:55 +0000
Subject: [PATCH] use tol in octree search only for Field

---
 Mesh/Field.cpp      | 27 ++-------------------------
 Post/OctreePost.cpp | 25 ++++++++++++-------------
 Post/OctreePost.h   | 10 +++++-----
 doc/VERSIONS.txt    | 15 ++++++++-------
 doc/gmsh.html       |  2 +-
 5 files changed, 28 insertions(+), 51 deletions(-)

diff --git a/Mesh/Field.cpp b/Mesh/Field.cpp
index 39bc5d4967..f682470da5 100644
--- a/Mesh/Field.cpp
+++ b/Mesh/Field.cpp
@@ -965,31 +965,8 @@ class PostViewField : public Field
       update_needed = false;
     }
     double l = 0.;
-    if(!octree->searchScalar(x, y, z, &l, 0)) {
-      // try really hard to find an element around the point
-      /*
-      double fact[4] = {1.e-6, 1.e-5, 1.e-4, 1.e-2};
-      for(int i = 0; i < 4; i++){
-	double eps = CTX.lc * fact[i];
-	//	printf("approx search witg eps=%g\n", eps);
-	if(octree->searchScalar(x + eps, y, z, &l, 0)) break;
-	if(octree->searchScalar(x - eps, y, z, &l, 0)) break;
-	if(octree->searchScalar(x, y + eps, z, &l, 0)) break;
-	if(octree->searchScalar(x, y - eps, z, &l, 0)) break;
-	if(octree->searchScalar(x, y, z + eps, &l, 0)) break;
-	if(octree->searchScalar(x, y, z - eps, &l, 0)) break;
-	if(octree->searchScalar(x + eps, y - eps, z - eps, &l, 0)) break;
-	if(octree->searchScalar(x + eps, y + eps, z - eps, &l, 0)) break;
-	if(octree->searchScalar(x - eps, y - eps, z - eps, &l, 0)) break;
-	if(octree->searchScalar(x - eps, y + eps, z - eps, &l, 0)) break;
-	if(octree->searchScalar(x + eps, y - eps, z + eps, &l, 0)) break;
-	if(octree->searchScalar(x + eps, y + eps, z + eps, &l, 0)) break;
-	if(octree->searchScalar(x - eps, y - eps, z + eps, &l, 0)) break;
-	if(octree->searchScalar(x - eps, y + eps, z + eps, &l, 0)) break;
-      } 
-      */     
-      //      printf("oops\n");
-    }
+    if(!octree->searchScalarWithTol(x, y, z, &l, 0, 0, 10.))
+      Msg::Info("No element found containing point (%g,%g,%g)", x, y, z);
     if(l <= 0 && crop_negative_values) return MAX_LC;
     return l;
   }
diff --git a/Post/OctreePost.cpp b/Post/OctreePost.cpp
index a7731aa4af..11a8e2d48a 100644
--- a/Post/OctreePost.cpp
+++ b/Post/OctreePost.cpp
@@ -382,8 +382,8 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep,
   return true;
 } 
 
-bool OctreePost::_searchScalar(double x, double y, double z, double *values, 
-                               int step, double *size)
+bool OctreePost::searchScalar(double x, double y, double z, double *values, 
+                              int step, double *size)
 {
   double P[3] = {x, y, z};
 
@@ -413,20 +413,19 @@ bool OctreePost::_searchScalar(double x, double y, double z, double *values,
   return false;
 }
 
-bool OctreePost::searchScalar(double x, double y, double z, double *values, 
-                              int step, double *size)
+bool OctreePost::searchScalarWithTol(double x, double y, double z, double *values, 
+                                     int step, double *size, double tol)
 {
-  bool a = _searchScalar(x, y, z, values, step, size);
+  bool a = searchScalar(x, y, z, values, step, size);
   if(!a){
-    double oldeps1 = element::getTolerance();
-    double oldeps2 = MElement::getTolerance();
-    element::setTolerance(10.);
-    MElement::setTolerance(10.);
-    a = _searchScalar(x, y, z, values, step, size);
-    element::setTolerance(oldeps1);
-    MElement::setTolerance(oldeps2);
+    double oldtol1 = element::getTolerance();
+    double oldtol2 = MElement::getTolerance();
+    element::setTolerance(tol);
+    MElement::setTolerance(tol);
+    a = searchScalar(x, y, z, values, step, size);
+    element::setTolerance(oldtol1);
+    MElement::setTolerance(oldtol2);
   }    
-  if (!a) Msg::Debug("No element found containing point (%g,%g,%g)", x, y, z);
   return a;
 }
 
diff --git a/Post/OctreePost.h b/Post/OctreePost.h
index bd6770d517..7c033c23c6 100644
--- a/Post/OctreePost.h
+++ b/Post/OctreePost.h
@@ -30,8 +30,6 @@ class OctreePost
                  double *elementSize);
   bool _getValue(void *in, int nbComp, double P[3], int step, 
                  double *values, double *elementSize);
-  bool _searchScalar(double x, double y, double z, double *values, 
-                     int step = -1, double *size = 0);
  public :
   OctreePost(PView *);
   ~OctreePost();
@@ -41,11 +39,13 @@ class OctreePost
   // interpolated unless time step is set to a different value than
   // -1.
   bool searchScalar(double x, double y, double z, double *values, 
-                    int step = -1, double *size = 0);
+                    int step=-1, double *size=0);
+  bool searchScalarWithTol(double x, double y, double z, double *values, 
+                           int step=-1, double *size=0, double tol=1.e-2);
   bool searchVector(double x, double y, double z, double *values, 
-                    int step = -1, double *size = 0);
+                    int step=-1, double *size=0);
   bool searchTensor(double x, double y, double z, double *values, 
-                    int step = -1, double *size = 0);
+                    int step=-1, double *size=0);
 };
 
 #endif
diff --git a/doc/VERSIONS.txt b/doc/VERSIONS.txt
index 0f456b4fe2..4013f0972d 100644
--- a/doc/VERSIONS.txt
+++ b/doc/VERSIONS.txt
@@ -1,10 +1,11 @@
-$Id: VERSIONS.txt,v 1.31 2009-01-15 00:45:11 geuzaine Exp $
-
-2.3.0 (?): major graphics and GUI code refactoring; new full-quad/hexa
-subdivision algorithm (removed Mesh.RecombineAlgo); improved automatic
-transfinite corner selection (now also for volumes); improved
-visibility browser; modified arrow size, clipping planes and transform
-options; many small improvements and bug fixes all over the place.
+$Id: VERSIONS.txt,v 1.32 2009-01-23 07:32:54 geuzaine Exp $
+
+2.3.0 (Jan 23, 2009): major graphics and GUI code refactoring; new
+full-quad/hexa subdivision algorithm (removed Mesh.RecombineAlgo);
+improved automatic transfinite corner selection (now also for
+volumes); improved visibility browser; modified arrow size, clipping
+planes and transform options; many small improvements and bug fixes
+all over the place.
 
 2.2.6 (Nov 21, 2008): better transfinite smoothing and automatic
 corner selection; fixed high order meshing crashes on Windows and
diff --git a/doc/gmsh.html b/doc/gmsh.html
index 4e13244bc5..f48bc5bea6 100644
--- a/doc/gmsh.html
+++ b/doc/gmsh.html
@@ -25,7 +25,7 @@ generator with built-in pre- and post-processing facilities</h1>
 <p>
 <h3 align="center">Christophe Geuzaine and Jean-François Remacle</h3>
 <p>
-<h3 align=center>Version 2.3.0, ?? 2008</h3>
+<h3 align=center>Version 2.3.0, January 23 2009</h3>
 <p>
 <center>
   <a href="#Description">Description</a> |
-- 
GitLab