Эх сурвалжийг харах

also return list of original faces for submeshed faces at intersections

Former-commit-id: 44ec6539ab05c007aaa8743ac4625e111db3cd17
Alec Jacobson 11 жил өмнө
parent
commit
4c5a6407f9

+ 9 - 3
include/igl/cgal/SelfIntersectMesh.h

@@ -91,7 +91,8 @@ namespace igl
         const SelfintersectParam & params,
         Eigen::MatrixXd & VV,
         Eigen::MatrixXi & FF,
-        Eigen::MatrixXi & IF);
+        Eigen::MatrixXi & IF,
+        Eigen::VectorXi & J);
     private:
       // Helper function to mark a face as offensive
       //
@@ -250,7 +251,8 @@ inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
   const SelfintersectParam & params,
   Eigen::MatrixXd & VV,
   Eigen::MatrixXi & FF,
-  Eigen::MatrixXi & IF):
+  Eigen::MatrixXi & IF,
+  Eigen::VectorXi & J):
   V(V),
   F(F),
   count(0),
@@ -449,6 +451,7 @@ inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
 #endif
   // Append faces
   FF.resize(F.rows()-offending.size()+NF_count,3);
+  J.resize(FF.rows());
   // First append non-offending original faces
   // There's an Eigen way to do this in one line but I forget
   int off = 0;
@@ -456,7 +459,9 @@ inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
   {
     if(!offensive[f])
     {
-      FF.row(off++) = F.row(f);
+      FF.row(off) = F.row(f);
+      J(off) = f;
+      off++;
     }
   }
   assert(off == (int)(F.rows()-offending.size()));
@@ -464,6 +469,7 @@ inline igl::SelfIntersectMesh<Kernel>::SelfIntersectMesh(
   for(int o = 0;o<(int)offending.size();o++)
   {
     FF.block(off,0,NF[o].rows(),3) = NF[o];
+    J.block(off,0,NF[o].rows(),1).setConstant(offending[o]);
     off += NF[o].rows();
   }
   // Append vertices

+ 4 - 3
include/igl/cgal/selfintersect.cpp

@@ -16,7 +16,8 @@ IGL_INLINE void igl::selfintersect(
   const SelfintersectParam & params,
   Eigen::MatrixXd & VV,
   Eigen::MatrixXi & FF,
-  Eigen::MatrixXi & IF)
+  Eigen::MatrixXi & IF,
+  Eigen::VectorXi & J)
 {
   using namespace std;
   if(params.detect_only)
@@ -34,7 +35,7 @@ IGL_INLINE void igl::selfintersect(
 //#endif
 
     typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
-    SelfIntersectMesh<Kernel> SIM = SelfIntersectMesh<Kernel>(V,F,params,VV,FF,IF);
+    SelfIntersectMesh<Kernel> SIM = SelfIntersectMesh<Kernel>(V,F,params,VV,FF,IF,J);
 
 //#ifdef __APPLE__
 //    signal(SIGFPE,SIG_DFL);
@@ -43,6 +44,6 @@ IGL_INLINE void igl::selfintersect(
   }else
   {
     typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
-    SelfIntersectMesh<Kernel> SIM = SelfIntersectMesh<Kernel>(V,F,params,VV,FF,IF);
+    SelfIntersectMesh<Kernel> SIM = SelfIntersectMesh<Kernel>(V,F,params,VV,FF,IF,J);
   }
 }

+ 3 - 1
include/igl/cgal/selfintersect.h

@@ -46,13 +46,15 @@ namespace igl
   //   FF  #FF by 3 list of triangle indices into V
   //   IF  #intersecting face pairs by 2  list of intersecting face pairs,
   //     indexing F
+  //   J  #FF list of indices into F denoting birth triangle
   IGL_INLINE void selfintersect(
     const Eigen::MatrixXd & V,
     const Eigen::MatrixXi & F,
     const SelfintersectParam & params,
     Eigen::MatrixXd & VV,
     Eigen::MatrixXi & FF,
-    Eigen::MatrixXi & IF);
+    Eigen::MatrixXi & IF,
+    Eigen::VectorXi & J);
 }
 
 #ifdef IGL_HEADER_ONLY