Ver Fonte

circulation does not need F,E args + tests

Alec Jacobson há 6 anos atrás
pai
commit
be75695e02

+ 4 - 6
include/igl/circulation.cpp

@@ -7,12 +7,11 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "circulation.h"
 #include "circulation.h"
 #include "list_to_matrix.h"
 #include "list_to_matrix.h"
+#include <cassert>
 
 
 IGL_INLINE std::vector<int> igl::circulation(
 IGL_INLINE std::vector<int> igl::circulation(
   const int e,
   const int e,
   const bool ccw,
   const bool ccw,
-  const Eigen::MatrixXi & F,
-  const Eigen::MatrixXi & E,
   const Eigen::VectorXi & EMAP,
   const Eigen::VectorXi & EMAP,
   const Eigen::MatrixXi & EF,
   const Eigen::MatrixXi & EF,
   const Eigen::MatrixXi & EI)
   const Eigen::MatrixXi & EI)
@@ -20,7 +19,8 @@ IGL_INLINE std::vector<int> igl::circulation(
   // prepare output
   // prepare output
   std::vector<int> N;
   std::vector<int> N;
   N.reserve(6);
   N.reserve(6);
-  const int m = F.rows();
+  const int m = EMAP.size()/3;
+  assert(m*3 == EMAP.size());
   const auto & step = [&](
   const auto & step = [&](
     const int e, 
     const int e, 
     const int ff,
     const int ff,
@@ -59,13 +59,11 @@ IGL_INLINE std::vector<int> igl::circulation(
 IGL_INLINE void igl::circulation(
 IGL_INLINE void igl::circulation(
   const int e,
   const int e,
   const bool ccw,
   const bool ccw,
-  const Eigen::MatrixXi & F,
-  const Eigen::MatrixXi & E,
   const Eigen::VectorXi & EMAP,
   const Eigen::VectorXi & EMAP,
   const Eigen::MatrixXi & EF,
   const Eigen::MatrixXi & EF,
   const Eigen::MatrixXi & EI,
   const Eigen::MatrixXi & EI,
   Eigen::VectorXi & vN)
   Eigen::VectorXi & vN)
 {
 {
-  std::vector<int> N = circulation(e,ccw,F,E,EMAP,EF,EI);
+  std::vector<int> N = circulation(e,ccw,EMAP,EF,EI);
   igl::list_to_matrix(N,vN);
   igl::list_to_matrix(N,vN);
 }
 }

+ 1 - 6
include/igl/circulation.h

@@ -20,8 +20,6 @@ namespace igl
   //   e  index into E of edge to circulate
   //   e  index into E of edge to circulate
   //   ccw  whether to _continue_ in ccw direction of edge (circulate around
   //   ccw  whether to _continue_ in ccw direction of edge (circulate around
   //     E(e,1))
   //     E(e,1))
-  //   F  #F by 3 list of face indices
-  //   E  #E by 2 list of edge indices
   //   EMAP #F*3 list of indices into E, mapping each directed edge to unique
   //   EMAP #F*3 list of indices into E, mapping each directed edge to unique
   //     unique edge in E
   //     unique edge in E
   //   EF  #E by 2 list of edge flaps, EF(e,0)=f means e=(i-->j) is the edge of
   //   EF  #E by 2 list of edge flaps, EF(e,0)=f means e=(i-->j) is the edge of
@@ -30,11 +28,10 @@ namespace igl
   //   EI  #E by 2 list of edge flap corners (see above).
   //   EI  #E by 2 list of edge flap corners (see above).
   // Returns list of faces touched by circulation (in cyclically order).
   // Returns list of faces touched by circulation (in cyclically order).
   //   
   //   
+  // See also: edge_flaps
   IGL_INLINE std::vector<int> circulation(
   IGL_INLINE std::vector<int> circulation(
     const int e,
     const int e,
     const bool ccw,
     const bool ccw,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXi & E,
     const Eigen::VectorXi & EMAP,
     const Eigen::VectorXi & EMAP,
     const Eigen::MatrixXi & EF,
     const Eigen::MatrixXi & EF,
     const Eigen::MatrixXi & EI);
     const Eigen::MatrixXi & EI);
@@ -42,8 +39,6 @@ namespace igl
   IGL_INLINE void circulation(
   IGL_INLINE void circulation(
     const int e,
     const int e,
     const bool ccw,
     const bool ccw,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXi & E,
     const Eigen::VectorXi & EMAP,
     const Eigen::VectorXi & EMAP,
     const Eigen::MatrixXi & EF,
     const Eigen::MatrixXi & EF,
     const Eigen::MatrixXi & EI,
     const Eigen::MatrixXi & EI,

+ 3 - 3
include/igl/collapse_edge.cpp

@@ -40,7 +40,7 @@ IGL_INLINE bool igl::collapse_edge(
   }
   }
 
 
   // Important to grab neighbors of d before monkeying with edges
   // Important to grab neighbors of d before monkeying with edges
-  const std::vector<int> nV2Fd = circulation(e,!eflip,F,E,EMAP,EF,EI);
+  const std::vector<int> nV2Fd = circulation(e,!eflip,EMAP,EF,EI);
 
 
   // The following implementation strongly relies on s<d
   // The following implementation strongly relies on s<d
   assert(s<d && "s should be less than d");
   assert(s<d && "s should be less than d");
@@ -339,8 +339,8 @@ IGL_INLINE bool igl::collapse_edge(
   Q.erase(Q.begin());
   Q.erase(Q.begin());
   e = p.second;
   e = p.second;
   Qit[e] = Q.end();
   Qit[e] = Q.end();
-  std::vector<int> N  = circulation(e, true,F,E,EMAP,EF,EI);
-  std::vector<int> Nd = circulation(e,false,F,E,EMAP,EF,EI);
+  std::vector<int> N  = circulation(e, true,EMAP,EF,EI);
+  std::vector<int> Nd = circulation(e,false,EMAP,EF,EI);
   N.insert(N.begin(),Nd.begin(),Nd.end());
   N.insert(N.begin(),Nd.begin(),Nd.end());
   bool collapsed = true;
   bool collapsed = true;
   if(pre_collapse(V,F,E,EMAP,EF,EI,Q,Qit,C,e))
   if(pre_collapse(V,F,E,EMAP,EF,EI,Q,Qit,C,e))

+ 2 - 2
include/igl/copyleft/progressive_hulls_cost_and_placement.cpp

@@ -32,8 +32,8 @@ IGL_INLINE void igl::copyleft::progressive_hulls_cost_and_placement(
 
 
   assert(V.cols() == 3 && "V.cols() should be 3");
   assert(V.cols() == 3 && "V.cols() should be 3");
   // Gather list of unique face neighbors
   // Gather list of unique face neighbors
-  vector<int> Nall =  circulation(e, true,F,E,EMAP,EF,EI);
-  vector<int> Nother= circulation(e,false,F,E,EMAP,EF,EI);
+  vector<int> Nall =  circulation(e, true,EMAP,EF,EI);
+  vector<int> Nother= circulation(e,false,EMAP,EF,EI);
   Nall.insert(Nall.end(),Nother.begin(),Nother.end());
   Nall.insert(Nall.end(),Nother.begin(),Nother.end());
   vector<int> N;
   vector<int> N;
   igl::unique(Nall,N);
   igl::unique(Nall,N);

+ 1 - 1
include/igl/edge_collapse_is_valid.cpp

@@ -49,7 +49,7 @@ IGL_INLINE bool igl::edge_collapse_is_valid(
       const Eigen::MatrixXi & EI) 
       const Eigen::MatrixXi & EI) 
     {
     {
       vector<int> N,uN;
       vector<int> N,uN;
-      vector<int> V2Fe = circulation(e, ccw,F,E,EMAP,EF,EI);
+      vector<int> V2Fe = circulation(e, ccw,EMAP,EF,EI);
       for(auto f : V2Fe)
       for(auto f : V2Fe)
       {
       {
         N.push_back(F(f,0));
         N.push_back(F(f,0));

+ 1 - 1
include/igl/simplify_polyhedron.cpp

@@ -55,7 +55,7 @@ IGL_INLINE void igl::simplify_polyhedron(
       const auto vi = E(e,positive);
       const auto vi = E(e,positive);
       const auto vj = E(e,!positive);
       const auto vj = E(e,!positive);
       p = V.row(vj);
       p = V.row(vj);
-      std::vector<int> faces = igl::circulation(e,positive,F,E,EMAP,EF,EI);
+      std::vector<int> faces = igl::circulation(e,positive,EMAP,EF,EI);
       cost = 0;
       cost = 0;
       for(auto f : faces)
       for(auto f : faces)
       {
       {

+ 62 - 0
tests/include/igl/circulation.cpp

@@ -0,0 +1,62 @@
+#include <test_common.h>
+#include <igl/circulation.h>
+#include <igl/edge_flaps.h>
+#include <igl/unique_edge_map.h>
+#include <igl/matlab_format.h>
+
+TEST(circulation,single_edge)
+{
+  //       7    
+  //     /₆|₇\
+  //   4 - 5 - 6
+  //   |₂/₃|₄\₅|
+  //   1 - 2 - 3
+  //     \₀|₁/  
+  //       0     
+  const Eigen::MatrixXi F = (Eigen::MatrixXi(8,3)<<
+    0,2,1,
+    0,3,2,
+    1,5,4,
+    1,2,5,
+    2,3,5,
+    3,6,5,
+    4,5,7,
+    5,6,7).finished();
+  Eigen::MatrixXi E,uE;
+  Eigen::VectorXi EMAP;
+  std::vector<std::vector<int> > uE2E;
+  igl::unique_edge_map(F, E, uE, EMAP, uE2E);
+  Eigen::MatrixXi EI,EF;
+  {
+    const auto & cuE = uE;
+    const auto & cEMAP = EMAP;
+    igl::edge_flaps(F,cuE,cEMAP,EF,EI);
+  }
+  // Find (2,5) in uE
+  int ei = 0;
+  for(;ei<E.rows();ei++)
+  {
+    if(uE(ei,0) == 2 && uE(ei,1) == 5) break;
+    if(uE(ei,1) == 2 && uE(ei,0) == 5) break;
+  }
+  Eigen::VectorXi Nccw;
+  igl::circulation(ei,true,EMAP,EF,EI,Nccw);
+  const Eigen::VectorXi Nccwgt = 
+    (Eigen::VectorXi(6)<<
+     4,
+     5,
+     7,
+     6,
+     2,
+     3).finished();
+  test_common::assert_eq(Nccw,Nccwgt);
+  Eigen::VectorXi Ncw;
+  igl::circulation(ei,false,EMAP,EF,EI,Ncw);
+  const Eigen::VectorXi Ncwgt = 
+    (Eigen::VectorXi(4)<<
+     4,
+     1,
+     0,
+     3).finished();
+  test_common::assert_eq(Ncw,Ncwgt);
+}