Browse Source

missing commits

Alec Jacobson 4 years ago
parent
commit
01086ed865
2 changed files with 19 additions and 7 deletions
  1. 13 6
      include/igl/dual_contouring.cpp
  2. 6 1
      include/igl/min_quad_with_fixed.cpp

+ 13 - 6
include/igl/dual_contouring.cpp

@@ -39,10 +39,9 @@ namespace igl
       using Matrix3S = Eigen::Matrix<Scalar,3,3>;
       using Matrix3S = Eigen::Matrix<Scalar,3,3>;
       using Vector3S = Eigen::Matrix<Scalar,3,1>;
       using Vector3S = Eigen::Matrix<Scalar,3,1>;
       using KeyTriplet = std::tuple<int,int,int>;
       using KeyTriplet = std::tuple<int,int,int>;
-    // helper function
-    public:
-    // Working variables
     public: 
     public: 
+    // Working variables
+    // see dual_contouring.h
       // f(x) returns >0 outside, <0 inside, and =0 on the surface
       // f(x) returns >0 outside, <0 inside, and =0 on the surface
       std::function<Scalar(const RowVector3S &)> f;
       std::function<Scalar(const RowVector3S &)> f;
       // f_grad(x) returns (df/dx)/‖df/dx‖ (normalization only important when
       // f_grad(x) returns (df/dx)/‖df/dx‖ (normalization only important when
@@ -54,15 +53,26 @@ namespace igl
       RowVector3S min_corner;
       RowVector3S min_corner;
       RowVector3S step;
       RowVector3S step;
       Eigen::Matrix<Scalar,Eigen::Dynamic,3> V;
       Eigen::Matrix<Scalar,Eigen::Dynamic,3> V;
+    // Internal variables
       // Running number of vertices added during contouring
       // Running number of vertices added during contouring
       typename decltype(V)::Index n;
       typename decltype(V)::Index n;
+      // map from cell subscript to index in V
       std::unordered_map< KeyTriplet, typename decltype(V)::Index, Hash > C2V;
       std::unordered_map< KeyTriplet, typename decltype(V)::Index, Hash > C2V;
+      // running list of aggregate vertex positions (used for spring
+      // regularization term)
       std::vector<RowVector3S,Eigen::aligned_allocator<RowVector3S>> vV;
       std::vector<RowVector3S,Eigen::aligned_allocator<RowVector3S>> vV;
+      // running list of subscripts corresponding to vertices
       std::vector<Eigen::RowVector3i,Eigen::aligned_allocator<Eigen::RowVector3i>> vI;
       std::vector<Eigen::RowVector3i,Eigen::aligned_allocator<Eigen::RowVector3i>> vI;
+      // running list of quadric matrices corresponding to inserted vertices
       std::vector<Matrix4S,Eigen::aligned_allocator<Matrix4S>> vH;
       std::vector<Matrix4S,Eigen::aligned_allocator<Matrix4S>> vH;
+      // running list of number of faces incident on this vertex (used to
+      // normalize spring regulatization term)
       std::vector<int> vcount;
       std::vector<int> vcount;
+      // running list of output quad faces
       Eigen::Matrix<Eigen::Index,Eigen::Dynamic,Eigen::Dynamic> Q;
       Eigen::Matrix<Eigen::Index,Eigen::Dynamic,Eigen::Dynamic> Q;
+      // running number of real quads in Q (used for dynamic array allocation)
       typename decltype(Q)::Index m;
       typename decltype(Q)::Index m;
+      // mutexes used to insert into Q and (vV,vI,vH,vcount) 
       std::mutex Qmut;
       std::mutex Qmut;
       std::mutex Vmut;
       std::mutex Vmut;
     public:
     public:
@@ -279,7 +289,6 @@ namespace igl
       {
       {
         Q.conservativeResize(m,Q.cols());
         Q.conservativeResize(m,Q.cols());
         V.resize(n,3);
         V.resize(n,3);
-        //for(int v = 0;v<n;v++)
         igl::parallel_for(n,[&](const Eigen::Index v)
         igl::parallel_for(n,[&](const Eigen::Index v)
         {
         {
           RowVector3S mid = vV[v] / Scalar(vcount[v]);
           RowVector3S mid = vV[v] / Scalar(vcount[v]);
@@ -325,7 +334,6 @@ namespace igl
         // Should do some reasonable reserves for C2V,vV,vI,vH,vcount
         // Should do some reasonable reserves for C2V,vV,vI,vH,vcount
         Q.resize(std::pow(nx*ny*nz,2./3.),triangles?3:4);
         Q.resize(std::pow(nx*ny*nz,2./3.),triangles?3:4);
         // loop over grid
         // loop over grid
-        //for(int x = 1;x<nx;x++)
         igl::parallel_for(nx,[&](const int x)
         igl::parallel_for(nx,[&](const int x)
         {
         {
           for(int y = 0;y<ny;y++)
           for(int y = 0;y<ny;y++)
@@ -369,7 +377,6 @@ namespace igl
         };
         };
 
 
         // loop over grid
         // loop over grid
-        //for(int z = 0;z<nz;z++)
         igl::parallel_for(nz,[&](const int z)
         igl::parallel_for(nz,[&](const int z)
         {
         {
           for(int y = 0;y<ny;y++)
           for(int y = 0;y<ny;y++)

+ 6 - 1
include/igl/min_quad_with_fixed.cpp

@@ -694,10 +694,15 @@ IGL_INLINE Eigen::Matrix<Scalar,n,1> igl::min_quad_with_fixed(
     x(u) /= H(u,u);
     x(u) /= H(u,u);
     return x;
     return x;
   }
   }
-  // Is there a smart template way to do this?
+  // Alec: Is there a smart template way to do this?
+  // jdumas: I guess you could do a templated for-loop starting from 16, and
+  // dispatching to the appropriate templated function when the argument matches
+  // (with a fallback to the dynamic version). Cf this example:
+  // https://gist.github.com/disconnect3d/13c2d035bb31b244df14
   switch(kcount)
   switch(kcount)
   {
   {
     case 0: assert(false && "Handled above."); return Eigen::Matrix<Scalar,n,1>();
     case 0: assert(false && "Handled above."); return Eigen::Matrix<Scalar,n,1>();
+    // % Matlibberish for generating these case statements:
     // maxi=16;for i=1:maxi;fprintf('    case %d:\n    {\n     const bool D = (n-%d<=0)||(%d>=n)||(n>%d);\n     return min_quad_with_fixed<Scalar,D?Eigen::Dynamic:n,D?Eigen::Dynamic:%d,Hpd>(H,f,k,bc);\n    }\n',[i i i maxi i]);end
     // maxi=16;for i=1:maxi;fprintf('    case %d:\n    {\n     const bool D = (n-%d<=0)||(%d>=n)||(n>%d);\n     return min_quad_with_fixed<Scalar,D?Eigen::Dynamic:n,D?Eigen::Dynamic:%d,Hpd>(H,f,k,bc);\n    }\n',[i i i maxi i]);end
     case 1:
     case 1:
     {
     {