[MOAB-dev] r3740 - MOAB/trunk/src

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Fri Apr 2 14:15:02 CDT 2010


Author: kraftche
Date: 2010-04-02 14:15:01 -0500 (Fri, 02 Apr 2010)
New Revision: 3740

Modified:
   MOAB/trunk/src/AdaptiveKDTree.cpp
Log:
o Rewrite ray/node intersection in KDTree to be a) correct, b) faster, 
  c) shorter and hopefully easier to understand, and d) better commented.

o Change odd tolerance stuff in tree construction that results in 
  invalid trees for cases where splits are parallel to triangles.



Modified: MOAB/trunk/src/AdaptiveKDTree.cpp
===================================================================
--- MOAB/trunk/src/AdaptiveKDTree.cpp	2010-04-01 22:14:56 UTC (rev 3739)
+++ MOAB/trunk/src/AdaptiveKDTree.cpp	2010-04-02 19:15:01 UTC (rev 3740)
@@ -23,6 +23,7 @@
 #include "moab/GeomUtil.hpp"
 #include "moab/Range.hpp"
 #include "Internals.hpp"
+#include <math.h>
 
 #include <assert.h>
 #include <algorithm>
@@ -796,7 +797,7 @@
   const CartVect left_dim = 0.5*(left_max - box_min);
   const CartVect right_cen = 0.5*(box_max + right_min);
   const CartVect right_dim = 0.5*(box_max - right_min);
-  const CartVect dim = box_max - box_min;
+  //const CartVect dim = box_max - box_min;
   
   
     // test each entity
@@ -850,18 +851,16 @@
         ro = true;
     }
     
-      // Triangle must be in at least one leaf.  If test against plain
+      // Triangle must be in at least one leaf.  If test against plane
       // identified that leaf, then we're done.  If triangle is on both
       // sides of plane, do more precise test to ensure that it is really
       // in both.
     if (lo && ro) {
-      lo = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i), left_cen, left_dim );
-      ro = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i),right_cen,right_dim );
-      double tol = std::numeric_limits<double>::epsilon();
-        // didn't intersect either - tolerance issue
-      while (!lo && !ro && tol < eps) {
-        lo = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i), left_cen,left_dim+tol*dim );
-        ro = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i),right_cen,right_dim+tol*dim );
+      double tol = eps/1000;
+      lo = ro = false;
+      while (!lo && !ro && tol <= eps) {
+        lo = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i), left_cen, left_dim+CartVect(tol) );
+        ro = GeomUtil::box_elem_overlap( coords, TYPE_FROM_HANDLE(*i),right_cen,right_dim+CartVect(tol) );
         tol *= 10.0;
       }
     }
@@ -1949,13 +1948,13 @@
 };
 
 ErrorCode AdaptiveKDTree::ray_intersect_triangles( EntityHandle root,
-                                                 const double tol,


More information about the moab-dev mailing list