ソースを参照

Handle degenerated triangles in SelfIntersectMesh and remesh_intersections.

Bug fix for closest_facet to handle coplanar cases.


Former-commit-id: c14e18366cd4a75bf971d7cfa2e9dec43bbfbeca
Qingnan Zhou 9 年 前
コミット
b711d2511d

+ 8 - 5
include/igl/copyleft/cgal/SelfIntersectMesh.h

@@ -354,7 +354,10 @@ inline igl::copyleft::cgal::SelfIntersectMesh<
     tit != T.end(); 
     ++tit)
   {
-    boxes.push_back(Box(tit->bbox(), tit));
+    if (!tit->is_degenerate())
+    {
+      boxes.push_back(Box(tit->bbox(), tit));
+    }
   }
   // Leapfrog callback
   std::function<void(const Box &a,const Box &b)> cb = 
@@ -831,10 +834,10 @@ inline void igl::copyleft::cgal::SelfIntersectMesh<
   Index fb = b.handle()-T.begin();
   const Triangle_3 & A = *a.handle();
   const Triangle_3 & B = *b.handle();
-  // I'm not going to deal with degenerate triangles, though at some point we
-  // should
-  assert(!a.handle()->is_degenerate());
-  assert(!b.handle()->is_degenerate());
+  //// I'm not going to deal with degenerate triangles, though at some point we
+  //// should
+  //assert(!a.handle()->is_degenerate());
+  //assert(!b.handle()->is_degenerate());
   // Number of combinatorially shared vertices
   Index comb_shared_vertices = 0;
   // Number of geometrically shared vertices (*not* including combinatorially

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

@@ -20,6 +20,7 @@
 
 #include "order_facets_around_edge.h"
 #include "../../vertex_triangle_adjacency.h"
+#include "../../writePLY.h"
 
 template<
     typename DerivedV,
@@ -158,7 +159,7 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
             corner_idx = 0;
         } else {
             std::cerr << "s: " << s << "\t d:" << d << std::endl;
-            std::cout << F.row(preferred_facet) << std::endl;
+            std::cerr << F.row(preferred_facet) << std::endl;
             throw std::runtime_error(
                     "Invalid connectivity, edge does not belong to facet");
         }
@@ -291,7 +292,7 @@ IGL_INLINE void igl::copyleft::cgal::closest_facet(
             }
             auto query_orientation = separator.oriented_side(query_point);
             if (query_orientation == CGAL::ON_ORIENTED_BOUNDARY &&
-                    (positive == 0 || negative == 0)) {
+                    (positive == 0 && negative == 0)) {
                 // All adj vertices and query point are coplanar.
                 // In this case, all separators are equally valid.
                 return true;

+ 3 - 1
include/igl/copyleft/cgal/propagate_winding_numbers.cpp

@@ -83,7 +83,9 @@ IGL_INLINE void igl::copyleft::cgal::propagate_winding_numbers(
   Eigen::VectorXi EMAP;
   std::vector<std::vector<size_t> > uE2E;
   igl::unique_edge_map(F, E, uE, EMAP, uE2E);
-  assert(propagate_winding_numbers_helper::is_orientable(F, uE, uE2E));
+  if (!propagate_winding_numbers_helper::is_orientable(F, uE, uE2E)) {
+      std::cerr << "Input mesh is not orientable!" << std::endl;
+  }
 
   Eigen::VectorXi P;
   const size_t num_patches = igl::extract_manifold_patches(F, EMAP, uE2E, P);

+ 1 - 1
include/igl/copyleft/cgal/remesh_intersections.cpp

@@ -272,7 +272,7 @@ IGL_INLINE void igl::copyleft::cgal::remesh_intersections(
 
     // Process un-touched faces.
     for (size_t i=0; i<num_faces; i++) {
-        if (!is_offending[i]) {
+        if (!is_offending[i] && !T[i].is_degenerate()) {
             resolved_faces.push_back(
                     { F(i,0), F(i,1), F(i,2) } );
             source_faces.push_back(i);