Browse Source

Bug fix to handle vertex cone and query point all coplanar.

Former-commit-id: 87fdedac134229053ef56b6afbded8faf1e1d418
Qingnan Zhou 9 years ago
parent
commit
38b8e15f27
1 changed files with 10 additions and 3 deletions
  1. 10 3
      include/igl/copyleft/cgal/closest_facet.cpp

+ 10 - 3
include/igl/copyleft/cgal/closest_facet.cpp

@@ -290,9 +290,16 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
                 }
             }
             auto query_orientation = separator.oriented_side(query_point);
-            bool r = (positive == 0 && query_orientation == CGAL::POSITIVE)
-                || (negative == 0 && query_orientation == CGAL::NEGATIVE);
-            return r;
+            if (query_orientation == CGAL::ON_ORIENTED_BOUNDARY &&
+                    (positive == 0 || negative == 0)) {
+                // All adj vertices and query point are coplanar.
+                // In this case, all separators are equally valid.
+                return true;
+            } else {
+                bool r = (positive == 0 && query_orientation == CGAL::POSITIVE)
+                    || (negative == 0 && query_orientation == CGAL::NEGATIVE);
+                return r;
+            }
         };
 
         size_t d = std::numeric_limits<size_t>::max();