소스 검색

birth indices in decimate

Former-commit-id: a43f889ea30bea622cf4299bd3fce361e77c8dbb
Alec Jacobson 8 년 전
부모
커밋
35e75d991c
2개의 변경된 파일45개의 추가작업 그리고 7개의 파일을 삭제
  1. 25 6
      include/igl/decimate.cpp
  2. 20 1
      include/igl/decimate.h

+ 25 - 6
include/igl/decimate.cpp

@@ -10,6 +10,7 @@
 #include "edge_flaps.h"
 #include "remove_unreferenced.h"
 #include "slice_mask.h"
+#include "slice.h"
 #include "connect_boundary_to_infinity.h"
 #include <iostream>
 
@@ -19,8 +20,10 @@ IGL_INLINE bool igl::decimate(
   const size_t max_m,
   Eigen::MatrixXd & U,
   Eigen::MatrixXi & G,
-  Eigen::VectorXi & J)
+  Eigen::VectorXi & J,
+  Eigen::VectorXi & I)
 {
+
   // Original number of faces
   const int orig_m = F.rows();
   // Tracking number of faces
@@ -73,15 +76,29 @@ IGL_INLINE bool igl::decimate(
     max_non_infinite_faces_stopping_condition,
     U,
     G,
-    J);
+    J,
+    I);
   const Eigen::Array<bool,Eigen::Dynamic,1> keep = (J.array()<orig_m);
   igl::slice_mask(Eigen::MatrixXi(G),keep,1,G);
   igl::slice_mask(Eigen::VectorXi(J),keep,1,J);
-  Eigen::VectorXi _1;
-  igl::remove_unreferenced(Eigen::MatrixXd(U),Eigen::MatrixXi(G),U,G,_1);
+  Eigen::VectorXi _1,I2;
+  igl::remove_unreferenced(Eigen::MatrixXd(U),Eigen::MatrixXi(G),U,G,_1,I2);
+  igl::slice(Eigen::VectorXi(I),I2,1,I);
   return ret;
 }
 
+IGL_INLINE bool igl::decimate(
+  const Eigen::MatrixXd & V,
+  const Eigen::MatrixXi & F,
+  const size_t max_m,
+  Eigen::MatrixXd & U,
+  Eigen::MatrixXi & G,
+  Eigen::VectorXi & J)
+{
+  Eigen::VectorXi I;
+  return igl::decimate(V,F,max_m,U,G,J,I);
+}
+
 IGL_INLINE bool igl::decimate(
   const Eigen::MatrixXd & OV,
   const Eigen::MatrixXi & OF,
@@ -112,7 +129,9 @@ IGL_INLINE bool igl::decimate(
       const int)> & stopping_condition,
   Eigen::MatrixXd & U,
   Eigen::MatrixXi & G,
-  Eigen::VectorXi & J)
+  Eigen::VectorXi & J,
+  Eigen::VectorXi & I
+  )
 {
   using namespace Eigen;
   using namespace std;
@@ -189,6 +208,6 @@ IGL_INLINE bool igl::decimate(
   F2.conservativeResize(m,F2.cols());
   J.conservativeResize(m);
   VectorXi _1;
-  remove_unreferenced(V,F2,U,G,_1);
+  remove_unreferenced(V,F2,U,G,_1,I);
   return clean_finish;
 }

+ 20 - 1
include/igl/decimate.h

@@ -25,6 +25,24 @@ namespace igl
   //   U  #U by dim list of output vertex posistions (can be same ref as V)
   //   G  #G by 3 list of output face indices into U (can be same ref as G)
   //   J  #G list of indices into F of birth face
+  //   I  #U list of indices into V of birth vertices
+  // Returns true if m was reached (otherwise #G > m)
+  IGL_INLINE bool decimate(
+    const Eigen::MatrixXd & V,
+    const Eigen::MatrixXi & F,
+    const size_t max_m,
+    Eigen::MatrixXd & U,
+    Eigen::MatrixXi & G,
+    Eigen::VectorXi & J,
+    Eigen::VectorXi & I);
+  // Inputs:
+  //   V  #V by dim list of vertex positions
+  //   F  #F by 3 list of face indices into V.
+  //   max_m  desired number of output faces
+  // Outputs:
+  //   U  #U by dim list of output vertex posistions (can be same ref as V)
+  //   G  #G by 3 list of output face indices into U (can be same ref as G)
+  //   J  #G list of indices into F of birth face
   // Returns true if m was reached (otherwise #G > m)
   IGL_INLINE bool decimate(
     const Eigen::MatrixXd & V,
@@ -79,7 +97,8 @@ namespace igl
       )> & stopping_condition,
     Eigen::MatrixXd & U,
     Eigen::MatrixXi & G,
-    Eigen::VectorXi & J);
+    Eigen::VectorXi & J,
+    Eigen::VectorXi & I);
 
 }