فهرست منبع

fix bug where cost of collapsed edge was attempted (#2347)

Co-authored-by: Alec Jacobson <[email protected]>
Alec Jacobson 1 سال پیش
والد
کامیت
94c6afde11
2فایلهای تغییر یافته به همراه9 افزوده شده و 5 حذف شده
  1. 6 4
      include/igl/collapse_edge.cpp
  2. 3 1
      include/igl/infinite_cost_stopping_condition.cpp

+ 6 - 4
include/igl/collapse_edge.cpp

@@ -82,10 +82,10 @@ IGL_INLINE bool igl::collapse_edge(
   {
     E(e,0) = IGL_COLLAPSE_EDGE_NULL;
     E(e,1) = IGL_COLLAPSE_EDGE_NULL;
-    // Don't clear EF, EI in case post_collapse would like to access previous
-    // connectivity. It's questionable whether E should be cleared at all, but
-    // if the user is drawing things with E then it's convenient that it's
-    // mapped to "null" edges (similar to F).
+    EF(e,0) = IGL_COLLAPSE_EDGE_NULL;
+    EF(e,1) = IGL_COLLAPSE_EDGE_NULL;
+    EI(e,0) = IGL_COLLAPSE_EDGE_NULL;
+    EI(e,1) = IGL_COLLAPSE_EDGE_NULL;
   };
 
   // update edge info
@@ -311,6 +311,8 @@ IGL_INLINE bool igl::collapse_edge(
   post_collapse(V,F,E,EMAP,EF,EI,Q,EQ,C,e,e1,e2,f1,f2,collapsed);
   if(collapsed)
   {
+    // Erase the center edge, marking its timestamp as -1
+    EQ(e) = -1;
     // Erase the two, other collapsed edges by marking their timestamps as -1
     EQ(e1) = -1;
     EQ(e2) = -1;

+ 3 - 1
include/igl/infinite_cost_stopping_condition.cpp

@@ -21,7 +21,7 @@ IGL_INLINE void igl::infinite_cost_stopping_condition(
     const Eigen::MatrixXi & EF,
     const Eigen::MatrixXi & EI,
     const igl::min_heap< std::tuple<double,int,int> > & ,/*Q*/
-    const Eigen::VectorXi &                             ,/*EQ*/
+    const Eigen::VectorXi &                             EQ,
     const Eigen::MatrixXd & /*C*/,
     const int e,
     const int /*e1*/,
@@ -29,6 +29,8 @@ IGL_INLINE void igl::infinite_cost_stopping_condition(
     const int /*f1*/,
     const int /*f2*/)->bool
     {
+      // e was (just) collapsed.
+      if(EQ(e) == -1) { return false; }
       Eigen::RowVectorXd p;
       double cost;
       cost_and_placement(e,V,F,E,EMAP,EF,EI,cost,p);