ソースを参照

edgetopology now sorts the EF relation

Former-commit-id: d85ca5c9a40896495854bd7da18b8cf2986daa7b
Daniele Panozzo 12 年 前
コミット
5d88fb8cc0
2 ファイル変更26 行追加3 行削除
  1. 25 2
      include/igl/edgetopology.cpp
  2. 1 1
      include/igl/edgetopology.h

+ 25 - 2
include/igl/edgetopology.cpp

@@ -37,7 +37,7 @@ IGL_INLINE void igl::edgetopology(
     if (!((ETT[i][0] == ETT[i+1][0]) && (ETT[i][1] == ETT[i+1][1])))
       ++En;
   
-  EV  = Eigen::MatrixXi::Constant((int)(En),2,-1);
+  EV = Eigen::MatrixXi::Constant((int)(En),2,-1);
   FE = Eigen::MatrixXi::Constant((int)(F.rows()),3,-1);
   EF = Eigen::MatrixXi::Constant((int)(En),2,-1);
   En = 0;
@@ -68,7 +68,30 @@ IGL_INLINE void igl::edgetopology(
       ++i; // skip the next one
     }
     ++En;
-  }    
+  }
+  
+  // Sort the relation EF, accordingly to EV
+  // the first one is the face on the left of the edge
+  
+  for(unsigned i=0; i<EF.rows(); ++i)
+  {
+    int fid = EF(i,0);
+    bool flip = true;
+    // search for edge EV.row(i)
+    for (unsigned j=0; j<3; ++j)
+    {
+      if ((F(fid,j) == EV(i,0)) && (F(fid,(j+1)%3) == EV(i,1)))
+        flip = false;
+    }
+    
+    if (flip)
+    {
+      int tmp = EF(i,0);
+      EF(i,0) = EF(i,1);
+      EF(i,1) = tmp;
+    }
+  }
+  
 }
 
 #ifndef IGL_HEADER_ONLY

+ 1 - 1
include/igl/edgetopology.h

@@ -18,7 +18,7 @@ namespace igl
   // Output:
   // EV  : #Ex2, Stores the edge description as pair of indices to vertices
   // FE : #Fx3, Stores the Triangle-Edge relation
-  // EF : #Ex2: Stores the Edge-Triangle relation (unsorted)
+  // EF : #Ex2: Stores the Edge-Triangle relation
   IGL_INLINE void edgetopology(
     const Eigen::MatrixXd& V, 
     const Eigen::MatrixXi& F,