瀏覽代碼

fix remesh_intersections

Previously if a new vtx is visited when stitch_all==false, it does
not check whether the vtx is in the interior of a face. This commit
fixes that.


Former-commit-id: 453a011c58e4d657a7bdcc357d3cb58f118a5e2d
Yijing Li 7 年之前
父節點
當前提交
9c0bdb15e4
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      include/igl/copyleft/cgal/remesh_intersections.cpp

+ 9 - 0
include/igl/copyleft/cgal/remesh_intersections.cpp

@@ -148,6 +148,8 @@ IGL_INLINE void igl::copyleft::cgal::remesh_intersections(
     std::vector<Index> source_faces;
     std::vector<Index> source_faces;
     std::vector<Point_3> new_vertices;
     std::vector<Point_3> new_vertices;
     EdgeMap edge_vertices;
     EdgeMap edge_vertices;
+    // face_vertices: Given a face Index, find vertices inside the face
+    std::unordered_map<Index, std::vector<Index>> face_vertices;
 
 
     // Run constraint Delaunay triangulation on the plane.
     // Run constraint Delaunay triangulation on the plane.
     // 
     // 
@@ -252,8 +254,15 @@ IGL_INLINE void igl::copyleft::cgal::remesh_intersections(
         }
         }
 
 
         // p must be in the middle of the triangle.
         // p must be in the middle of the triangle.
+        auto & existing_face_vertices = face_vertices[ori_f];
+        for(const auto vid : existing_face_vertices) {
+          if (p == new_vertices[vid - num_base_vertices]) {
+            return vid;
+          }
+        }
         const size_t index = num_base_vertices + new_vertices.size();
         const size_t index = num_base_vertices + new_vertices.size();
         new_vertices.push_back(p);
         new_vertices.push_back(p);
+        existing_face_vertices.push_back(index);
         return index;
         return index;
       }
       }
     };
     };