瀏覽代碼

Merge branch 'master' of https://github.com/libigl/libigl

Former-commit-id: 59aeaacda5b67137acf9c92abd000f4ae510648b
schuellc 10 年之前
父節點
當前提交
f2d02ddeac

+ 1 - 0
RELEASE_HISTORY.txt

@@ -1,3 +1,4 @@
+1.1.3  Bug fixes in active set and boundary_conditions
 1.1.1  PLY file format support
 1.1.0  Mesh boolean operations using CGAL and cork, implementing [Attene 14]
 1.0.3  Bone heat method

+ 1 - 1
VERSION.txt

@@ -3,4 +3,4 @@
 # Anyone may increment Minor to indicate a small change.
 # Major indicates a large change or large number of changes (upload to website)
 # World indicates a substantial change or release
-1.1.2
+1.1.3

+ 39 - 22
include/igl/active_set.cpp

@@ -8,6 +8,7 @@
 #include "active_set.h"
 #include "min_quad_with_fixed.h"
 #include "slice.h"
+#include "slice_into.h"
 #include "cat.h"
 #include "matlab_format.h"
 
@@ -44,6 +45,9 @@ IGL_INLINE igl::SolverStatus igl::active_set(
   )
 {
 //#define ACTIVE_SET_CPP_DEBUG
+#ifdef ACTIVE_SET_CPP_DEBUG
+#  warning "ACTIVE_SET_CPP_DEBUG"
+#endif
   using namespace igl;
   using namespace Eigen;
   using namespace std;
@@ -259,39 +263,52 @@ IGL_INLINE igl::SolverStatus igl::active_set(
     }
 #endif
     
+    Eigen::PlainObjectBase<DerivedZ> sol;
+    if(known_i.size() == A.rows())
+    {
+      // Everything's fixed?
 #ifdef ACTIVE_SET_CPP_DEBUG
-    cout<<"  min_quad_with_fixed_precompute"<<endl;
+      cout<<"  everything's fixed."<<endl;
 #endif
-    if(!min_quad_with_fixed_precompute(A,known_i,Aeq_i,params.Auu_pd,data))
+      Z.resize(A.rows(),Y_i.cols());
+      slice_into(Y_i,known_i,1,Z);
+      sol.resize(0,Y_i.cols());
+      assert(Aeq_i.rows() == 0 && "All fixed but linearly constrained");
+    }else
     {
-      cerr<<"Error: min_quad_with_fixed precomputation failed."<<endl;
-      if(iter > 0 && Aeq_i.rows() > Aeq.rows())
+#ifdef ACTIVE_SET_CPP_DEBUG
+      cout<<"  min_quad_with_fixed_precompute"<<endl;
+#endif
+      if(!min_quad_with_fixed_precompute(A,known_i,Aeq_i,params.Auu_pd,data))
       {
-        cerr<<"  *Are you sure rows of [Aeq;Aieq] are linearly independent?*"<<
-          endl;
+        cerr<<"Error: min_quad_with_fixed precomputation failed."<<endl;
+        if(iter > 0 && Aeq_i.rows() > Aeq.rows())
+        {
+          cerr<<"  *Are you sure rows of [Aeq;Aieq] are linearly independent?*"<<
+            endl;
+        }
+        ret = SOLVER_STATUS_ERROR;
+        break;
       }
-      ret = SOLVER_STATUS_ERROR;
-      break;
-    }
 #ifdef ACTIVE_SET_CPP_DEBUG
-    cout<<"  min_quad_with_fixed_solve"<<endl;
+      cout<<"  min_quad_with_fixed_solve"<<endl;
 #endif
-    Eigen::PlainObjectBase<DerivedZ> sol;
-    if(!min_quad_with_fixed_solve(data,B,Y_i,Beq_i,Z,sol))
-    {
-      cerr<<"Error: min_quad_with_fixed solve failed."<<endl;
-      ret = SOLVER_STATUS_ERROR;
-      break;
-    }
-    //cout<<matlab_format((Aeq*Z-Beq).eval(),"cr")<<endl;
-    //cout<<matlab_format(Z,"Z")<<endl;
+      if(!min_quad_with_fixed_solve(data,B,Y_i,Beq_i,Z,sol))
+      {
+        cerr<<"Error: min_quad_with_fixed solve failed."<<endl;
+        ret = SOLVER_STATUS_ERROR;
+        break;
+      }
+      //cout<<matlab_format((Aeq*Z-Beq).eval(),"cr")<<endl;
+      //cout<<matlab_format(Z,"Z")<<endl;
 #ifdef ACTIVE_SET_CPP_DEBUG
-    cout<<"  post"<<endl;
+      cout<<"  post"<<endl;
 #endif
+      // Computing Lagrange multipliers needs to be adjusted slightly if A is not symmetric
+      assert(data.Auu_sym);
+    }
 
     // Compute Lagrange multiplier values for known_i
-    // This needs to be adjusted slightly if A is not symmetric
-    assert(data.Auu_sym);
     SparseMatrix<AT> Ak;
     // Slow
     slice(A,known_i,1,Ak);

+ 4 - 4
include/igl/bbw/bbw.cpp

@@ -104,11 +104,11 @@ IGL_INLINE bool igl::bbw(
     {
       case QP_SOLVER_IGL_ACTIVE_SET:
       {
-        //if(data.verbosity >= 1)
-        //{
+        if(data.verbosity >= 1)
+        {
           cout<<"BBW: max_iter: "<<data.active_set_params.max_iter<<endl;
-          cout<<"BBW: max_iter: "<<eff_params.max_iter<<endl;
-        //}
+          cout<<"BBW: eff_max_iter: "<<eff_params.max_iter<<endl;
+        }
         if(data.verbosity >= 1)
         {
           cout<<"BBW: Computing initial weights for "<<m<<" handle"<<

+ 4 - 4
include/igl/boolean/mesh_boolean.cpp

@@ -1,5 +1,5 @@
 #include "mesh_boolean.h"
-#include <igl/peal_outer_hull_layers.h>
+#include <igl/peel_outer_hull_layers.h>
 #include <igl/cgal/remesh_self_intersections.h>
 #include <igl/remove_unreferenced.h>
 #include <igl/unique_simplices.h>
@@ -169,13 +169,13 @@ IGL_INLINE void igl::mesh_boolean(
   }
 
 #ifdef IGL_MESH_BOOLEAN_DEBUG
-  cout<<"peal..."<<endl;
+  cout<<"peel..."<<endl;
 #endif
   Matrix<bool,Dynamic,1> from_A(CF.rows());
-  // Peal layers keeping track of odd and even flips
+  // peel layers keeping track of odd and even flips
   Matrix<bool,Dynamic,1> odd;
   Matrix<bool,Dynamic,1> flip;
-  peal_outer_hull_layers(CV,CF,odd,flip);
+  peel_outer_hull_layers(CV,CF,odd,flip);
 
 #ifdef IGL_MESH_BOOLEAN_DEBUG
   cout<<"categorize..."<<endl;

+ 2 - 4
include/igl/boundary_conditions.cpp

@@ -35,10 +35,9 @@ IGL_INLINE bool igl::boundary_conditions(
     return false;
   }
 
-
   vector<int> bci;
   vector<int> bcj;
-  vector<int> bcv;
+  vector<double> bcv;
 
   // loop over points
   for(int p = 0;p<P.size();p++)
@@ -95,7 +94,6 @@ IGL_INLINE bool igl::boundary_conditions(
     }
   }
 
-  // Cage edges are not considered yet
   // loop over cage edges
   for(int e = 0;e<CE.rows();e++)
   {
@@ -153,7 +151,7 @@ IGL_INLINE bool igl::boundary_conditions(
   for(i = 0;i<bc.rows();i++)
   {
     double sum = bc.row(i).sum();
-    assert(sum != 0);
+    assert(sum != 0 && "Some boundary vertex getting all zero BCs");
     bc.row(i).array() /= sum;
   }
 

+ 1 - 1
include/igl/doublearea.cpp

@@ -124,7 +124,7 @@ IGL_INLINE void igl::doublearea(
   sort(ul,2,false,l,_);
   // semiperimeters
   Matrix<typename Derivedl::Scalar,Dynamic,1> s = l.rowwise().sum()*0.5;
-  assert(s.rows() == m);
+  assert((size_t)s.rows() == m);
   // resize output
   dblA.resize(l.rows(),1);
   // Minimum number of iterms per openmp thread

+ 4 - 3
include/igl/facet_components.cpp

@@ -13,7 +13,8 @@ IGL_INLINE void igl::facet_components(
   vector<vector<vector<Index > > > TT;
   vector<vector<vector<Index > > > TTi;
   triangle_triangle_adjacency(F,TT,TTi);
-  return facet_components(TT,C);
+  Eigen::VectorXi counts;
+  return facet_components(TT,C,counts);
 }
 
 template <
@@ -68,9 +69,9 @@ IGL_INLINE void igl::facet_components(
     }
     id++;
   }
-  assert(id == vcounts.size());
+  assert((size_t) id == vcounts.size());
   const size_t ncc = vcounts.size();
-  assert(C.maxCoeff()+1 == ncc);
+  assert((size_t)C.maxCoeff()+1 == ncc);
   counts.resize(ncc,1);
   for(size_t i = 0;i<ncc;i++)
   {

+ 1 - 0
include/igl/min_quad_with_fixed.cpp

@@ -96,6 +96,7 @@ IGL_INLINE bool igl::min_quad_with_fixed_precompute(
 
   SparseMatrix<T> Auu;
   slice(A,data.unknown,data.unknown,Auu);
+  assert(Auu.size() > 0 && "All DOFs seem to be fixed.");
 
   // Positive definiteness is *not* determined, rather it is given as a
   // parameter

+ 15 - 10
include/igl/peal_outer_hull_layers.cpp → include/igl/peel_outer_hull_layers.cpp

@@ -1,16 +1,19 @@
-#include "peal_outer_hull_layers.h"
+#include "peel_outer_hull_layers.h"
 #include "outer_hull.h"
 #include "writePLY.h"
 #include <vector>
 #include <iostream>
-//#define IGL_PEAL_OUTER_HULL_LAYERS_DEBUG
+//#define IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
+#ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
+#include "STR.h"
+#endif
 
 template <
   typename DerivedV,
   typename DerivedF,
   typename Derivedodd,
   typename Derivedflip>
-IGL_INLINE void igl::peal_outer_hull_layers(
+IGL_INLINE size_t igl::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   Eigen::PlainObjectBase<Derivedodd > & odd,
@@ -23,11 +26,11 @@ IGL_INLINE void igl::peal_outer_hull_layers(
   typedef Matrix<Index,Dynamic,1> MatrixXI;
   typedef Matrix<typename Derivedflip::Scalar,Dynamic,Derivedflip::ColsAtCompileTime> MatrixXflip;
   const Index m = F.rows();
-#ifdef IGL_PEAL_OUTER_HULL_LAYERS_DEBUG
-  cout<<"peal outer hull layers..."<<endl;
+#ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
+  cout<<"peel outer hull layers..."<<endl;
 #endif
 
-#ifdef IGL_PEAL_OUTER_HULL_LAYERS_DEBUG
+#ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
   cout<<"resize output ..."<<endl;
 #endif
   // keep track of iteration parity and whether flipped in hull
@@ -47,12 +50,13 @@ IGL_INLINE void igl::peal_outer_hull_layers(
     MatrixXF Fo;
     MatrixXI Jo;
     MatrixXflip flipr;
-#ifdef IGL_PEAL_OUTER_HULL_LAYERS_DEBUG
+#ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
   cout<<"calling outer hull..."<<endl;
-  writePLY("outer-hull-input.ply",V,Fr);
+  writePLY(STR("outer-hull-input-"<<iter<<".ply"),V,Fr);
 #endif
     outer_hull(V,Fr,Fo,Jo,flipr);
-#ifdef IGL_PEAL_OUTER_HULL_LAYERS_DEBUG
+#ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
+  writePLY(STR("outer-hull-output-"<<iter<<".ply"),V,Fo);
   cout<<"reindex, flip..."<<endl;
 #endif
     assert(Fo.rows() == Jo.rows());
@@ -86,10 +90,11 @@ IGL_INLINE void igl::peal_outer_hull_layers(
     odd_iter = !odd_iter;
     iter++;
   }
+  return iter;
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::peal_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template size_t igl::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 #endif

+ 9 - 8
include/igl/peal_outer_hull_layers.h → include/igl/peel_outer_hull_layers.h

@@ -1,27 +1,28 @@
-#ifndef PEAL_OUTER_HULL_LAYERS_H
-#define PEAL_OUTER_HULL_LAYERS_H
+#ifndef PEEL_OUTER_HULL_LAYERS_H
+#define PEEL_OUTER_HULL_LAYERS_H
 #include "igl_inline.h"
 #include <Eigen/Core>
 namespace igl
 {
   // Computes necessary generic information for boolean operations by
-  // successively "pealing" off the "outer hull" of a mesh (V,F) resulting from
+  // successively "peeling" off the "outer hull" of a mesh (V,F) resulting from
   // "resolving" all (self-)intersections.
   //
   // Inputs:
   //   V  #V by 3 list of vertex positions
   //   F  #F by 3 list of triangle indices into V
   // Outputs:
-  //   odd  #F list of whether facet belongs to an odd iteration peal (otherwise
-  //     an even iteration peal)
+  //   odd  #F list of whether facet belongs to an odd iteration peel (otherwise
+  //     an even iteration peel)
   //   flip  #F list of whether a facet's orientation was flipped when facet
-  //     "pealed" into its associated outer hull layer.
+  //     "peeled" into its associated outer hull layer.
+  // Returns number of peels
   template <
     typename DerivedV,
     typename DerivedF,
     typename Derivedodd,
     typename Derivedflip>
-  IGL_INLINE void peal_outer_hull_layers(
+  IGL_INLINE size_t peel_outer_hull_layers(
     const Eigen::PlainObjectBase<DerivedV > & V,
     const Eigen::PlainObjectBase<DerivedF > & F,
     Eigen::PlainObjectBase<Derivedodd > & odd,
@@ -29,6 +30,6 @@ namespace igl
 }
 
 #ifndef IGL_STATIC_LIBRARY
-#  include "peal_outer_hull_layers.cpp"
+#  include "peel_outer_hull_layers.cpp"
 #endif
 #endif

+ 1 - 1
tutorial/tutorial.md.REMOVED.git-id

@@ -1 +1 @@
-65f03843aee5fa051933483e51bc0a045058efeb
+fa0e428fe664733ee1a4465d21cdc6d0ab1b5c82