浏览代码

fixed memory error hidden by const& in miq-related functions

Former-commit-id: 104299c1452332593bf2bdd37558b209ebd2ec5f
Daniele Panozzo 8 年之前
父节点
当前提交
8aaab1ecd9

+ 2 - 0
.gitignore

@@ -96,3 +96,5 @@ python/build4
 python/scripts/generated
 python/builddebug
 tutorial/.idea
+python/buildstatic
+tutorial/cmake-build-debug

+ 3 - 3
include/igl/HalfEdgeIterator.h

@@ -100,9 +100,9 @@ namespace igl
     bool reverse;
 
     // All the same type? This is likely to break.
-    const DerivedF & F;
-    const DerivedFF & FF;
-    const DerivedFFi & FFi;
+    const Eigen::PlainObjectBase<DerivedF> & F;
+    const Eigen::PlainObjectBase<DerivedFF> & FF;
+    const Eigen::PlainObjectBase<DerivedFFi> & FFi;
   };
 
 }

+ 5 - 5
include/igl/cut_mesh.cpp

@@ -23,16 +23,16 @@ namespace igl {
   public:
     // Input
     //mesh
-    const DerivedV &V;
-    const DerivedF &F;
+    const Eigen::PlainObjectBase<DerivedV> &V;
+    const Eigen::PlainObjectBase<DerivedF> &F;
     // TT is the same type as TTi? This is likely to break at some point
-    const DerivedTT &TT;
-    const DerivedTT &TTi;
+    const Eigen::PlainObjectBase<DerivedTT> &TT;
+    const Eigen::PlainObjectBase<DerivedTT> &TTi;
     const std::vector<std::vector<VFType> >& VF;
     const std::vector<std::vector<VFType> >& VFi;
     const std::vector<bool> &V_border; // bool
     //edges to cut
-    const DerivedC &Handle_Seams; // 3 bool
+    const Eigen::PlainObjectBase<DerivedC> &Handle_Seams; // 3 bool
 
     // total number of scalar variables
     int num_scalar_variables;

+ 1 - 0
include/igl/cut_mesh_from_singularities.cpp

@@ -201,4 +201,5 @@ template void igl::cut_mesh_from_singularities<Eigen::Matrix<double, -1, 3, 0, -
 template void igl::cut_mesh_from_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::cut_mesh_from_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 template void igl::cut_mesh_from_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template void igl::cut_mesh_from_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 #endif

+ 1 - 0
include/igl/find_cross_field_singularities.cpp

@@ -82,4 +82,5 @@ Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, bool);
 template void igl::find_cross_field_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 template void igl::find_cross_field_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, bool);
 template void igl::find_cross_field_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::find_cross_field_singularities<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 34 - 33
tutorial/505_MIQ/main.cpp

@@ -15,6 +15,7 @@
 #include <sstream>
 
 #include "tutorial_shared_path.h"
+#include <igl/serialize.h>
 
 // Input mesh
 Eigen::MatrixXd V;
@@ -38,13 +39,13 @@ Eigen::MatrixXd BIS1, BIS2;
 Eigen::MatrixXd BIS1_combed, BIS2_combed;
 
 // Per-corner, integer mismatches
-Eigen::MatrixXi MMatch;
+Eigen::Matrix<int, Eigen::Dynamic, 3> MMatch;
 
 // Field singularities
-Eigen::VectorXi isSingularity, singularityIndex;
+Eigen::Matrix<int, Eigen::Dynamic, 1> isSingularity, singularityIndex;
 
 // Per corner seams
-Eigen::MatrixXi Seams;
+Eigen::Matrix<int, Eigen::Dynamic, 3> Seams;
 
 // Combed field
 Eigen::MatrixXd X1_combed, X2_combed;
@@ -234,50 +235,50 @@ int main(int argc, char *argv[])
   // Load a mesh in OFF format
   igl::readOFF(TUTORIAL_SHARED_PATH "/3holes.off", V, F);
 
+  double gradient_size = 50;
+  double iter = 0;
+  double stiffness = 5.0;
+  bool direct_round = 0;
+  std::string filename = "/Users/daniele/x.dat";
+
   // Compute face barycenters
   igl::barycenter(V, F, B);
 
   // Compute scale for visualizing fields
   global_scale =  .5*igl::avg_edge_length(V, F);
 
+    // Contrain one face
+    VectorXi b(1);
+    b << 0;
+    MatrixXd bc(1, 3);
+    bc << 1, 0, 0;
 
-  // Contrain one face
-  VectorXi b(1);
-  b << 0;
-  MatrixXd bc(1,3);
-  bc << 1, 0, 0;
-
-  // Create a smooth 4-RoSy field
-  VectorXd S;
-  igl::copyleft::comiso::nrosy(V,F,b,bc,VectorXi(),VectorXd(),MatrixXd(),4,0.5,X1,S);
+    // Create a smooth 4-RoSy field
+    VectorXd S;
+    igl::copyleft::comiso::nrosy(V, F, b, bc, VectorXi(), VectorXd(), MatrixXd(), 4, 0.5, X1, S);
 
-  // Find the the orthogonal vector
-  MatrixXd B1,B2,B3;
-  igl::local_basis(V,F,B1,B2,B3);
-  X2 = igl::rotate_vectors(X1, VectorXd::Constant(1,M_PI/2), B1, B2);
-
-  double gradient_size = 50;
-  double iter = 0;
-  double stiffness = 5.0;
-  bool direct_round = 0;
+    // Find the the orthogonal vector
+    MatrixXd B1, B2, B3;
+    igl::local_basis(V, F, B1, B2, B3);
+    X2 = igl::rotate_vectors(X1, VectorXd::Constant(1, M_PI / 2), B1, B2);
 
-  // Always work on the bisectors, it is more general
-  igl::compute_frame_field_bisectors(V, F, X1, X2, BIS1, BIS2);
+    // Always work on the bisectors, it is more general
+    igl::compute_frame_field_bisectors(V, F, X1, X2, BIS1, BIS2);
 
-  // Comb the field, implicitly defining the seams
-  igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
+    // Comb the field, implicitly defining the seams
+    igl::comb_cross_field(V, F, BIS1, BIS2, BIS1_combed, BIS2_combed);
 
-  // Find the integer mismatches
-  igl::cross_field_missmatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
+    // Find the integer mismatches
+    igl::cross_field_missmatch(V, F, BIS1_combed, BIS2_combed, true, MMatch);
 
-  // Find the singularities
-  igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);
+    // Find the singularities
+    igl::find_cross_field_singularities(V, F, MMatch, isSingularity, singularityIndex);
 
-  // Cut the mesh, duplicating all vertices on the seams
-  igl::cut_mesh_from_singularities(V, F, MMatch, Seams);
+    // Cut the mesh, duplicating all vertices on the seams
+    igl::cut_mesh_from_singularities(V, F, MMatch, Seams);
 
-  // Comb the frame-field accordingly
-  igl::comb_frame_field(V, F, X1, X2, BIS1_combed, BIS2_combed, X1_combed, X2_combed);
+    // Comb the frame-field accordingly
+    igl::comb_frame_field(V, F, X1, X2, BIS1_combed, BIS2_combed, X1_combed, X2_combed);
 
   // Global parametrization
   igl::copyleft::comiso::miq(V,