Browse Source

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

Former-commit-id: 430b736de96c1efa4621684a7d925977220f5d05
Daniele Panozzo 9 years ago
parent
commit
4fae662971
77 changed files with 501 additions and 162 deletions
  1. 2 0
      .gitignore
  2. 3 0
      include/igl/WindingNumberAABB.h
  3. 7 0
      include/igl/WindingNumberTree.h
  4. 1 1
      include/igl/boolean/mesh_boolean.cpp
  5. 2 2
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp
  6. 9 9
      include/igl/cgal/order_facets_around_edge.cpp
  7. 4 4
      include/igl/cgal/order_facets_around_edges.cpp
  8. 2 4
      include/igl/cgal/outer_hull.cpp
  9. 16 20
      include/igl/cgal/points_inside_component.cpp
  10. 2 2
      include/igl/cgal/projected_delaunay.cpp
  11. 0 10
      include/igl/cgal/remesh_intersections.cpp
  12. 2 3
      include/igl/decimate.cpp
  13. 5 1
      include/igl/doublearea.cpp
  14. 3 1
      include/igl/lim/lim.h
  15. 3 3
      include/igl/marching_cubes.cpp
  16. 3 3
      include/igl/marching_cubes_tables.h
  17. 16 0
      include/igl/matlab/requires_arg.cpp
  18. 29 0
      include/igl/matlab/requires_arg.h
  19. 43 0
      include/igl/matlab/validate_arg.cpp
  20. 36 0
      include/igl/matlab/validate_arg.h
  21. 10 2
      include/igl/png/texture_from_png.cpp
  22. 5 0
      include/igl/png/texture_from_png.h
  23. 80 26
      include/igl/pseudonormal_test.cpp
  24. 53 1
      include/igl/random_quaternion.cpp
  25. 2 0
      include/igl/slice.cpp
  26. 9 1
      scripts/clone-and-build.sh
  27. 2 1
      tutorial/101_FileIO/main.cpp
  28. 2 1
      tutorial/102_DrawMesh/main.cpp
  29. 3 2
      tutorial/103_Events/main.cpp
  30. 2 1
      tutorial/104_Colors/main.cpp
  31. 2 1
      tutorial/105_Overlays/main.cpp
  32. 2 1
      tutorial/106_ViewerMenu/main.cpp
  33. 2 1
      tutorial/201_Normals/main.cpp
  34. 2 1
      tutorial/202_GaussianCurvature/main.cpp
  35. 2 1
      tutorial/203_CurvatureDirections/main.cpp
  36. 3 2
      tutorial/204_Gradient/main.cpp
  37. 2 1
      tutorial/205_Laplacian/main.cpp
  38. 2 1
      tutorial/301_Slice/main.cpp
  39. 2 1
      tutorial/302_Sort/main.cpp
  40. 3 1
      tutorial/303_LaplaceEquation/main.cpp
  41. 3 1
      tutorial/304_LinearEqualityConstraints/main.cpp
  42. 2 2
      tutorial/305_QuadraticProgramming/main.cpp
  43. 2 1
      tutorial/306_EigenDecomposition/main.cpp
  44. 3 2
      tutorial/401_BiharmonicDeformation/main.cpp
  45. 2 1
      tutorial/402_PolyharmonicDeformation/main.cpp
  46. 5 3
      tutorial/403_BoundedBiharmonicWeights/main.cpp
  47. 5 3
      tutorial/404_DualQuaternionSkinning/main.cpp
  48. 4 2
      tutorial/405_AsRigidAsPossible/main.cpp
  49. 4 2
      tutorial/406_FastAutomaticSkinningTransformations/main.cpp
  50. 4 2
      tutorial/407_BiharmonicCoordinates/main.cpp
  51. 3 1
      tutorial/501_HarmonicParam/main.cpp
  52. 3 1
      tutorial/502_LSCMParam/main.cpp
  53. 3 1
      tutorial/503_ARAPParam/main.cpp
  54. 2 1
      tutorial/504_NRosyDesign/main.cpp
  55. 3 1
      tutorial/505_MIQ/main.cpp
  56. 4 2
      tutorial/506_FrameField/main.cpp
  57. 4 2
      tutorial/507_PolyVectorField/main.cpp
  58. 4 3
      tutorial/508_ConjugateField/main.cpp
  59. 3 1
      tutorial/509_Planarization/main.cpp
  60. 4 1
      tutorial/510_Integrable/main.cpp
  61. 3 1
      tutorial/601_Serialization/main.cpp
  62. 3 1
      tutorial/602_Matlab/main.cpp
  63. 3 1
      tutorial/605_Tetgen/main.cpp
  64. 2 1
      tutorial/606_AmbientOcclusion/main.cpp
  65. 3 1
      tutorial/607_Picking/main.cpp
  66. 2 1
      tutorial/608_LIM/main.cpp
  67. 4 2
      tutorial/609_Boolean/main.cpp
  68. 7 5
      tutorial/610_CSGTree/main.cpp
  69. 3 1
      tutorial/701_Statistics/main.cpp
  70. 3 1
      tutorial/702_WindingNumber/main.cpp
  71. 3 1
      tutorial/703_Decimation/main.cpp
  72. 3 1
      tutorial/704_SignedDistance/main.cpp
  73. 3 1
      tutorial/705_MarchingCubes/main.cpp
  74. 4 0
      tutorial/CMakeLists.txt
  75. 1 1
      tutorial/tutorial.html.REMOVED.git-id
  76. 1 1
      tutorial/tutorial.md.REMOVED.git-id
  77. 8 0
      tutorial/tutorial_shared_path.h

+ 2 - 0
.gitignore

@@ -21,6 +21,8 @@ example1
 external/yimg/.git*
 external/tinyxml2/CMakeFiles*
 external/tinyxml2/CMakeCache.txt
+external/tinyxml2/cmake_install.cmake
+external/tinyxml2/Makefile
 external/embree/build/*
 external/embree/bin/*
 external/embree/bin

+ 3 - 0
include/igl/WindingNumberAABB.h

@@ -126,6 +126,9 @@ inline void igl::WindingNumberAABB<Point>::grow()
 {
   using namespace std;
   using namespace Eigen;
+  // Clear anything that already exists
+  this->delete_children();
+
   //cout<<"cap.rows(): "<<this->getcap().rows()<<endl;
   //cout<<"F.rows(): "<<this->getF().rows()<<endl;
 

+ 7 - 0
include/igl/WindingNumberTree.h

@@ -59,6 +59,7 @@ namespace igl
         const WindingNumberTree<Point> & parent,
         const Eigen::MatrixXi & F);
       inline virtual ~WindingNumberTree();
+      inline void delete_children();
       inline virtual void set_mesh(
         const Eigen::MatrixXd & V,
         const Eigen::MatrixXi & F);
@@ -207,6 +208,12 @@ inline igl::WindingNumberTree<Point>::WindingNumberTree(
 
 template <typename Point>
 inline igl::WindingNumberTree<Point>::~WindingNumberTree()
+{
+  delete_children();
+}
+
+template <typename Point>
+inline void igl::WindingNumberTree<Point>::delete_children()
 {
   using namespace std;
   // Delete children

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

@@ -237,7 +237,7 @@ IGL_INLINE void igl::boolean::mesh_boolean(
     for(Index g = 0;g<gm;g++)
     {
       const int ug = IC(g);
-      assert(ug < uG2G.size());
+      assert((size_t) ug < uG2G.size());
       uG2G[ug].push_back(g);
       // is uG(g,:) just a rotated version of G(g,:) ?
       const bool consistent =

+ 2 - 2
include/igl/cgal/mesh_to_cgal_triangle_list.cpp

@@ -58,6 +58,6 @@ template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, 3,
 template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
 template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
 template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epeck>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epick>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
+template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
+template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
 #endif

+ 9 - 9
include/igl/cgal/order_facets_around_edge.cpp

@@ -348,7 +348,7 @@ void igl::cgal::order_facets_around_edge(
     std::vector<int> adj_faces_with_pivot(num_faces);
     for (size_t i=0; i<num_faces; i++)
     {
-        if (faces(i,0) == N+1 && faces(i,1) == N+2)
+        if ((size_t)faces(i,0) == N+1 && (size_t)faces(i,1) == N+2)
         {
             adj_faces_with_pivot[i] = int(i+1) * -1;
         } else
@@ -362,12 +362,12 @@ void igl::cgal::order_facets_around_edge(
             vertices, faces, N+1, N+2,
             adj_faces_with_pivot, order_with_pivot);
 
-    assert(order_with_pivot.size() == num_faces);
+    assert((size_t)order_with_pivot.size() == num_faces);
     order.resize(N);
     size_t pivot_index = num_faces + 1;
     for (size_t i=0; i<num_faces; i++)
     {
-        if (order_with_pivot[i] == N)
+        if ((size_t)order_with_pivot[i] == N)
         {
             pivot_index = i;
             break;
@@ -384,10 +384,10 @@ void igl::cgal::order_facets_around_edge(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -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&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<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&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -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&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<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&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > 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::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -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&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::order_facets_around_edge<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&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -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&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::order_facets_around_edge<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&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 4 - 4
include/igl/cgal/order_facets_around_edges.cpp

@@ -304,7 +304,7 @@ IGL_INLINE void igl::cgal::order_facets_around_edges(
 
         Eigen::VectorXi order;
         order_facets_around_edge(V, F, s, d, adj_faces, order);
-        assert(order.size() == edge_valance);
+        assert((size_t)order.size() == edge_valance);
 
         auto& ordered_edges = uE2oE[ui];
         auto& consistency = uE2C[ui];
@@ -320,7 +320,7 @@ IGL_INLINE void igl::cgal::order_facets_around_edges(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > >&, std::__1::vector<std::__1::vector<bool, std::__1::allocator<bool> >, std::__1::allocator<std::__1::vector<bool, std::__1::allocator<bool> > > >&);
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(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<int, -1, 2, 0, -1, 2> > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > >&, std::__1::vector<std::__1::vector<bool, std::__1::allocator<bool> >, std::__1::allocator<std::__1::vector<bool, std::__1::allocator<bool> > > >&);
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(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, 2, 0, -1, 2> > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > > const&, std::__1::vector<std::__1::vector<long, std::__1::allocator<long> >, std::__1::allocator<std::__1::vector<long, std::__1::allocator<long> > > >&, std::__1::vector<std::__1::vector<bool, std::__1::allocator<bool> >, std::__1::allocator<std::__1::vector<bool, std::__1::allocator<bool> > > >&);
+template void igl::cgal::order_facets_around_edges<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
+template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(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<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
+template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(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, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
 #endif

+ 2 - 4
include/igl/cgal/outer_hull.cpp

@@ -329,9 +329,7 @@ IGL_INLINE void igl::cgal::outer_hull(
   // non-intersecting.
   const auto & has_overlapping_bbox = [](
     const Eigen::PlainObjectBase<DerivedV> & V,
-    const MatrixXV & BC,
     const MatrixXG & A,
-    const MatrixXJ & AJ,
     const MatrixXG & B)->bool
   {
     const auto & bounding_box = [](
@@ -387,7 +385,7 @@ IGL_INLINE void igl::cgal::outer_hull(
       {
         continue;
       }
-      if (has_overlapping_bbox(V, BC, vG[id], vJ[id], vG[oid])) {
+      if (has_overlapping_bbox(V, vG[id], vG[oid])) {
           unresolved.push_back(oid);
       }
     }
@@ -402,7 +400,7 @@ IGL_INLINE void igl::cgal::outer_hull(
     }
     Eigen::VectorXi inside;
     igl::cgal::points_inside_component(V, vG[id], query_points, inside);
-    assert(inside.size() == num_unresolved_components);
+    assert((size_t)inside.size() == num_unresolved_components);
     for (size_t i=0; i<num_unresolved_components; i++) {
         if (inside(i, 0)) {
             const size_t oid = unresolved[i];

+ 16 - 20
include/igl/cgal/points_inside_component.cpp

@@ -58,9 +58,8 @@ namespace igl {
                 return FACE;
             }
 
-            template<typename DerivedV, typename DerivedF, typename DerivedI>
+            template<typename DerivedF, typename DerivedI>
             void extract_adj_faces(
-                    const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const size_t s, const size_t d,
@@ -68,24 +67,23 @@ namespace igl {
                 const size_t num_faces = I.rows();
                 for (size_t i=0; i<num_faces; i++) {
                     Eigen::Vector3i f = F.row(I(i, 0));
-                    if ((f[0] == s && f[1] == d) ||
-                        (f[1] == s && f[2] == d) ||
-                        (f[2] == s && f[0] == d)) {
+                    if (((size_t)f[0] == s && (size_t)f[1] == d) ||
+                        ((size_t)f[1] == s && (size_t)f[2] == d) ||
+                        ((size_t)f[2] == s && (size_t)f[0] == d)) {
                         adj_faces.push_back((I(i, 0)+1) * -1);
                         continue;
                     }
-                    if ((f[0] == d && f[1] == s) ||
-                        (f[1] == d && f[2] == s) ||
-                        (f[2] == d && f[0] == s)) {
+                    if (((size_t)f[0] == d && (size_t)f[1] == s) ||
+                        ((size_t)f[1] == d && (size_t)f[2] == s) ||
+                        ((size_t)f[2] == d && (size_t)f[0] == s)) {
                         adj_faces.push_back(I(i, 0)+1);
                         continue;
                     }
                 }
             }
 
-            template<typename DerivedV, typename DerivedF, typename DerivedI>
+            template<typename DerivedF, typename DerivedI>
             void extract_adj_vertices(
-                    const Eigen::PlainObjectBase<DerivedV>& V,
                     const Eigen::PlainObjectBase<DerivedF>& F,
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const size_t v, std::vector<int>& adj_vertices) {
@@ -93,14 +91,13 @@ namespace igl {
                 const size_t num_faces = I.rows();
                 for (size_t i=0; i<num_faces; i++) {
                     Eigen::Vector3i f = F.row(I(i, 0));
-                    assert((f.array() < V.rows()).all());
-                    if (f[0] == v) {
+                    if ((size_t)f[0] == v) {
                         unique_adj_vertices.insert(f[1]);
                         unique_adj_vertices.insert(f[2]);
-                    } else if (f[1] == v) {
+                    } else if ((size_t)f[1] == v) {
                         unique_adj_vertices.insert(f[0]);
                         unique_adj_vertices.insert(f[2]);
-                    } else if (f[2] == v) {
+                    } else if ((size_t)f[2] == v) {
                         unique_adj_vertices.insert(f[0]);
                         unique_adj_vertices.insert(f[1]);
                     }
@@ -151,7 +148,7 @@ namespace igl {
                 // query point is outside.
 
                 std::vector<int> adj_faces;
-                extract_adj_faces(V, F, I, s, d, adj_faces);
+                extract_adj_faces(F, I, s, d, adj_faces);
                 const size_t num_adj_faces = adj_faces.size();
                 assert(num_adj_faces > 0);
 
@@ -162,7 +159,7 @@ namespace igl {
                 Eigen::VectorXi order;
                 order_facets_around_edge(V, F, s, d,
                         adj_faces, pivot_point, order);
-                assert(order.size() == num_adj_faces);
+                assert((size_t)order.size() == num_adj_faces);
                 if (adj_faces[order[0]] > 0 &&
                     adj_faces[order[num_adj_faces-1] < 0]) {
                     return true;
@@ -183,7 +180,7 @@ namespace igl {
                     const Eigen::PlainObjectBase<DerivedI>& I,
                     const Point_3& query, size_t s) {
                 std::vector<int> adj_vertices;
-                extract_adj_vertices(V, F, I, s, adj_vertices);
+                extract_adj_vertices(F, I, s, adj_vertices);
                 const size_t num_adj_vertices = adj_vertices.size();
 
                 std::vector<Point_3> adj_points;
@@ -226,7 +223,6 @@ namespace igl {
                 for (size_t i=0; i<num_adj_vertices; i++) {
                     const size_t vi = adj_vertices[i];
                     for (size_t j=i+1; j<num_adj_vertices; j++) {
-                        const size_t vj = adj_vertices[j];
                         Plane_3 separator(p, adj_points[i], adj_points[j]);
                         if (separator.is_degenerate()) {
                             throw "Input mesh contains degenerated faces";
@@ -237,9 +233,9 @@ namespace igl {
                             break;
                         }
                     }
-                    if (d < V.rows()) break;
+                    if (d < (size_t)V.rows()) break;
                 }
-                if (d > V.rows()) {
+                if (d > (size_t)V.rows()) {
                     // All adj faces are coplanar, use the first edge.
                     d = adj_vertices[0];
                 }

+ 2 - 2
include/igl/cgal/projected_delaunay.cpp

@@ -101,6 +101,6 @@ IGL_INLINE void igl::cgal::projected_delaunay(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::projected_delaunay<CGAL::Epeck>(CGAL::Triangle_3<CGAL::Epeck> const&, std::__1::vector<CGAL::Object, std::__1::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epeck, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epeck, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
-template void igl::cgal::projected_delaunay<CGAL::Epick>(CGAL::Triangle_3<CGAL::Epick> const&, std::__1::vector<CGAL::Object, std::__1::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
+template void igl::cgal::projected_delaunay<CGAL::Epeck>(CGAL::Triangle_3<CGAL::Epeck> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epeck, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epeck, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
+template void igl::cgal::projected_delaunay<CGAL::Epick>(CGAL::Triangle_3<CGAL::Epick> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
 #endif

File diff suppressed because it is too large
+ 0 - 10
include/igl/cgal/remesh_intersections.cpp


+ 2 - 3
include/igl/decimate.cpp

@@ -18,8 +18,9 @@ IGL_INLINE bool igl::decimate(
   Eigen::MatrixXd & U,
   Eigen::MatrixXi & G)
 {
+  int m = F.rows();
   const auto & max_m_faces = 
-    [&max_m,&F](
+    [&max_m,&m](
     const Eigen::MatrixXd &,
     const Eigen::MatrixXi &,
     const Eigen::MatrixXi &,
@@ -35,8 +36,6 @@ IGL_INLINE bool igl::decimate(
     const int,
     const int)->bool
     {
-      using namespace std;
-      static int m = F.rows();
       m-=2;
       return m<=(int)max_m;
     };

+ 5 - 1
include/igl/doublearea.cpp

@@ -104,6 +104,9 @@ IGL_INLINE typename DerivedA::Scalar igl::doublearea_single(
   const Eigen::PlainObjectBase<DerivedB> & B,
   const Eigen::PlainObjectBase<DerivedC> & C)
 {
+  assert(A.size() == 2 && "Vertices should be 2D");
+  assert(B.size() == 2 && "Vertices should be 2D");
+  assert(C.size() == 2 && "Vertices should be 2D");
   auto r = A-C;
   auto s = B-C;
   return r(0)*s(1) - r(1)*s(0);
@@ -126,7 +129,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((size_t)s.rows() == m);
+  assert((Index)s.rows() == m);
   // resize output
   dblA.resize(l.rows(),1);
   // Minimum number of iterms per openmp thread
@@ -196,4 +199,5 @@ template void igl::doublearea<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Mat
 template Eigen::Matrix<double, 2, 1, 0, 2, 1>::Scalar igl::doublearea_single<Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 1, 0, 2, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> > const&);
 template void igl::doublearea<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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<double, -1, -1, 0, -1, -1> >&);
 template void igl::doublearea<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::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> >&);
+template void igl::doublearea<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 1, 0, 1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 1, 0, 1, 1> >&);
 #endif

+ 3 - 1
include/igl/lim/lim.h

@@ -61,7 +61,9 @@ namespace igl
     //                   mesh
     //--------------------------------------------------------------------------
     // Return values:
-    //  1 : Successful optimization with fulfilled tolerance
+    //  1 : Optimization deemed successful because either (a) it stagnated
+    //    (very step size) or (b) positional constraints were satisfied. (re:
+    //    https://github.com/libigl/libigl/issues/79 )
     // -1 : Max iteration reached before tolerance was fulfilled
     // -2 : not feasible -> has inverted elements (may want to decrease eps?)
   

+ 3 - 3
include/igl/marching_cubes.cpp

@@ -27,9 +27,9 @@
 #include "marching_cubes_tables.h"
 #include <map>
 
-extern int edgeTable[256];
-extern int triTable[256][2][17];
-extern int polyTable[8][16];
+extern const int edgeTable[256];
+extern const int triTable[256][2][17];
+extern const int polyTable[8][16];
 
 class EdgeKey 
 {

+ 3 - 3
include/igl/marching_cubes_tables.h

@@ -33,7 +33,7 @@
 //int triTable[256][2][17];
 //int polyTable[8][16];
 
-int edgeTable[256]=
+const int edgeTable[256]=
 {
   0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
   0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
@@ -73,7 +73,7 @@ int edgeTable[256]=
 //-----------------------------------------------------------------------------
 
 
-int triTable[256][2][17] =
+const int triTable[256][2][17] =
 {{{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
   { 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}},
   
@@ -896,7 +896,7 @@ int triTable[256][2][17] =
 //-----------------------------------------------------------------------------
 
 
-int polyTable[8][16] =
+const int polyTable[8][16] =
 {
   {-1},
   {-1},

+ 16 - 0
include/igl/matlab/requires_arg.cpp

@@ -0,0 +1,16 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "requires_arg.h"
+#include "mexErrMsgTxt.h"
+#include "../C_STR.h"
+
+IGL_INLINE void igl::matlab::requires_arg(const int i, const int nrhs, const char *name)
+{
+  mexErrMsgTxt((i+1)<nrhs,
+      C_STR("Parameter '"<<name<<"' requires argument"));
+}

+ 29 - 0
include/igl/matlab/requires_arg.h

@@ -0,0 +1,29 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_REQUIRES_ARG_H
+#define IGL_REQUIRES_ARG_H
+#include "../igl_inline.h"
+#include <mex.h>
+namespace igl
+{
+  namespace matlab
+  {
+    // Simply throw an error if (i+1)<rhs 
+    //
+    // Input:
+    //   i  index of current arg
+    //   nrhs  total number of args
+    //   name of current arg
+    IGL_INLINE void requires_arg(const int i, const int nrhs, const char *name);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "requires_arg.cpp"
+#endif
+#endif
+

+ 43 - 0
include/igl/matlab/validate_arg.cpp

@@ -0,0 +1,43 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "validate_arg.h"
+#include "requires_arg.h"
+#include "mexErrMsgTxt.h"
+#include "../C_STR.h"
+
+IGL_INLINE void igl::matlab::validate_arg_scalar(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxGetN(prhs[i+1])==1 && mxGetM(prhs[i+1])==1,
+      C_STR("Parameter '"<<name<<"' requires scalar argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_logical(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsLogical(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires Logical argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_char(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsChar(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires char argument"));
+}
+
+IGL_INLINE void igl::matlab::validate_arg_double(
+    const int i, const int nrhs, const mxArray * prhs[], const char * name)
+{
+  requires_arg(i,nrhs,name);
+  mexErrMsgTxt(mxIsDouble(prhs[i+1]),
+    C_STR("Parameter '"<<name<<"' requires double argument"));
+}

+ 36 - 0
include/igl/matlab/validate_arg.h

@@ -0,0 +1,36 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_VALIDATE_ARG_H
+#define IGL_VALIDATE_ARG_H
+#include "../igl_inline.h"
+#include <mex.h>
+namespace igl
+{
+  namespace matlab
+  {
+    // Throw an error if arg i+1 is not a scalar
+    //
+    // Inputs:
+    //   i  index of current arguement
+    //   nrhs  total number of arguments
+    //   prhs  pointer to arguements array
+    //   name   name of current argument
+    IGL_INLINE void validate_arg_scalar(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_logical(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_char(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+    IGL_INLINE void validate_arg_double(
+      const int i, const int nrhs, const mxArray * prhs[], const char * name);
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "validate_arg.cpp"
+#endif
+#endif

+ 10 - 2
include/igl/png/texture_from_png.cpp

@@ -10,7 +10,7 @@
 #include "../opengl/report_gl_error.h"
 #include <YImage.hpp>
 
-IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint & id)
+IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, const bool flip, GLuint & id)
 {
   YImage yimg;
   if(!yimg.load(png_file.c_str()))
@@ -18,7 +18,10 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint &
     return false;
   }
   // Why do I need to flip?
-  //yimg.flip();
+  if(flip)
+  {
+    yimg.flip();
+  }
   glGenTextures(1, &id);
   glBindTexture(GL_TEXTURE_2D, id);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -32,6 +35,11 @@ IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint &
   return true;
 }
 
+IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint & id)
+{
+  return texture_from_png(png_file,false,id);
+}
+
 
 IGL_INLINE bool igl::png::texture_from_png(
   const std::string png_file,

+ 5 - 0
include/igl/png/texture_from_png.h

@@ -22,9 +22,11 @@ namespace igl
     //
     // Input:
     //  png_file  path to .png file
+    //  flip  whether to flip the image vertically (A --> ∀)
     // Output:
     //  id  of generated openGL texture
     // Returns true on success, false on failure
+    IGL_INLINE bool texture_from_png(const std::string png_file, const bool flip, GLuint & id);
     IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
   }
 }
@@ -40,6 +42,9 @@ namespace igl
     // Output:
     //  R,G,B,A texture channels
     // Returns true on success, false on failure
+    //
+    // Todo: this is an inappropriate function name. This is really just
+    // reading a png.... Not necessarily as a texture.
     IGL_INLINE bool texture_from_png(const std::string png_file,
     Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
     Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,

+ 80 - 26
include/igl/pseudonormal_test.cpp

@@ -7,6 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "pseudonormal_test.h"
 #include "AABB.h"
+#include "project_to_line_segment.h"
 #include <cassert>
 
 IGL_INLINE void igl::pseudonormal_test(
@@ -25,40 +26,93 @@ IGL_INLINE void igl::pseudonormal_test(
   using namespace Eigen;
   const auto & qc = q-c;
   RowVector3d b;
-  AABB<Eigen::MatrixXd,3>::barycentric_coordinates(
-    c,V.row(F(f,0)),V.row(F(f,1)),V.row(F(f,2)),b);
-  // Determine which normal to use
+  // Using barycentric coorindates to determine whether close to a vertex/edge
+  // seems prone to error when dealing with nearly degenerate triangles: Even
+  // the barycenter (1/3,1/3,1/3) can be made arbitrarily close to an
+  // edge/vertex
+  //
+  const RowVector3d A = V.row(F(f,0));
+  const RowVector3d B = V.row(F(f,1));
+  const RowVector3d C = V.row(F(f,2));
+
+  const double area = [&A,&B,&C]()
+  {
+    Matrix<double,1,1> area;
+    doublearea(A,B,C,area);
+    return area(0);
+  }();
+  // These were chosen arbitrarily. In a floating point scenario, I'm not sure
+  // the best way to determine if c is on a vertex/edge or in the middle of the
+  // face: specifically, I'm worrying about degenerate triangles where
+  // barycentric coordinates are error-prone.
+  const double MIN_DOUBLE_AREA = 1e-4;
   const double epsilon = 1e-12;
-  const int type = (b.array()<=epsilon).cast<int>().sum();
-  switch(type)
+  if(area>MIN_DOUBLE_AREA)
   {
-    case 2:
-      // Find vertex
-      for(int x = 0;x<3;x++)
-      {
-        if(b(x)>epsilon)
+    AABB<Eigen::MatrixXd,3>::barycentric_coordinates( c,A,B,C,b);
+    // Determine which normal to use
+    const int type = (b.array()<=epsilon).cast<int>().sum();
+    switch(type)
+    {
+      case 2:
+        // Find vertex
+        for(int x = 0;x<3;x++)
         {
-          n = VN.row(F(f,x));
-          break;
+          if(b(x)>epsilon)
+          {
+            n = VN.row(F(f,x));
+            break;
+          }
         }
-      }
-      break;
-    case 1:
-      // Find edge
-      for(int x = 0;x<3;x++)
-      {
-        if(b(x)<=epsilon)
+        break;
+      case 1:
+        // Find edge
+        for(int x = 0;x<3;x++)
         {
-          n = EN.row(EMAP(F.rows()*x+f));
-          break;
+          if(b(x)<=epsilon)
+          {
+            n = EN.row(EMAP(F.rows()*x+f));
+            break;
+          }
         }
+        break;
+      default:
+        assert(false && "all barycentric coords zero.");
+      case 0:
+        n = FN.row(f);
+        break;
+    }
+  }else
+  {
+    // Check each vertex
+    bool found = false;
+    for(int v = 0;v<3 && !found;v++)
+    {
+      if( (c-V.row(F(f,v))).norm() < epsilon)
+      {
+        found = true;
+        n = VN.row(F(f,v));
       }
-      break;
-    default:
-      assert(false && "all barycentric coords zero.");
-    case 0:
+    }
+    // Check each edge
+    for(int e = 0;e<3 && !found;e++)
+    {
+      const RowVector3d s = V.row(F(f,(e+1)%3));
+      const RowVector3d d = V.row(F(f,(e+2)%3));
+      Matrix<double,1,1> sqr_d_j_x(1,1);
+      Matrix<double,1,1> t(1,1);
+      project_to_line_segment(c,s,d,t,sqr_d_j_x);
+      if(sqrt(sqr_d_j_x(0)) < epsilon)
+      {
+        n = EN.row(EMAP(F.rows()*e+f));
+        found = true;
+      }
+    }
+    // Finally just use face
+    if(!found)
+    {
       n = FN.row(f);
-      break;
+    }
   }
   s = (qc.dot(n) >= 0 ? 1. : -1.);
 }

+ 53 - 1
include/igl/random_quaternion.cpp

@@ -10,11 +10,12 @@
 template <typename Scalar>
 IGL_INLINE Eigen::Quaternion<Scalar> igl::random_quaternion()
 {
-  // http://mathproofs.blogspot.com/2005/05/uniformly-distributed-random-unit.html
   const auto & unit_rand = []()->Scalar
   {
     return ((Scalar)rand() / (Scalar)RAND_MAX);
   };
+#ifdef false
+  // http://mathproofs.blogspot.com/2005/05/uniformly-distributed-random-unit.html
   const Scalar t0 = 2.*M_PI*unit_rand();
   const Scalar t1 = acos(1.-2.*unit_rand());
   const Scalar t2 = 0.5*(M_PI*unit_rand() + acos(unit_rand()));
@@ -23,6 +24,57 @@ IGL_INLINE Eigen::Quaternion<Scalar> igl::random_quaternion()
     1.*cos(t0)*sin(t1)*sin(t2),
     1.*cos(t1)*sin(t2),
     1.*cos(t2));
+#elif false
+  // "Uniform Random Rotations" [Shoemake 1992] method 1
+  const auto & uurand = [&unit_rand]()->Scalar
+  {
+    return unit_rand()*2.-1.; 
+  };
+  Scalar x = uurand();
+  Scalar y = uurand();
+  Scalar z = uurand();
+  Scalar w = uurand();
+  const auto & hype = [&uurand](Scalar & x, Scalar & y)->Scalar
+  {
+    Scalar s1;
+    while((s1 = x*x + y*y) > 1.0)
+    {
+      x = uurand();
+      y = uurand();
+    }
+    return s1;
+  };
+  Scalar s1 = hype(x,y);
+  Scalar s2 = hype(z,w);
+  Scalar num1 = -2.*log(s1);
+  Scalar num2 = -2.*log(s2);
+  Scalar r = num1 + num2;
+  Scalar root1 = sqrt((num1/s1)/r);
+  Scalar root2 = sqrt((num2/s2)/r);
+  return Eigen::Quaternion<Scalar>(
+    x*root1,
+    y*root1,
+    z*root2,
+    w*root2);
+#else
+  // Shoemake method 2
+  const Scalar x0 = unit_rand();
+  const Scalar x1 = unit_rand();
+  const Scalar x2 = unit_rand();
+  const Scalar r1 = sqrt(1.0 - x0);
+  const Scalar r2 = sqrt(x0);
+  const Scalar t1 = 2.*M_PI*x1;
+  const Scalar t2 = 2.*M_PI*x2;
+  const Scalar c1 = cos(t1);
+  const Scalar s1 = sin(t1);
+  const Scalar c2 = cos(t2);
+  const Scalar s2 = sin(t2);
+  return Eigen::Quaternion<Scalar>(
+    s1*r1,
+    c1*r1,
+    s2*r2,
+    c2*r2);
+#endif
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 2 - 0
include/igl/slice.cpp

@@ -264,4 +264,6 @@ template void igl::slice<Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0,
 template void igl::slice<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<double, -1, -1, 0, -1, -1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 template void igl::slice<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> >&);
 template void igl::slice<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<double, -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<double, -1, -1, 0, -1, -1> >&);
+template void igl::slice<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<double, -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<double, -1, -1, 0, -1, -1> >&);
+template void igl::slice<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::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
 #endif

+ 9 - 1
scripts/clone-and-build.sh

@@ -73,7 +73,6 @@ function guard {
   command="$@"
   pwd
   echo "$command"
-  sleep 2
   if ! output=$($command 2>&1) ;
   then
     report_error "$command" "$output"
@@ -82,6 +81,11 @@ function guard {
   fi
 }
 
+function grep_std_1
+{
+  (! grep -rI "std::__1" *)
+}
+
 set -o xtrace
 # Clone repo
 guard rm -rf /var/tmp/libigl
@@ -105,3 +109,7 @@ mkdir build-use-static
 cd build-use-static
 guard cmake -DCMAKE_BUILD_TYPE=Debug -DLIBIGL_USE_STATIC_LIBRARY=ON ../../tutorial/
 guard make -C ../../tutorial/build-use-static
+# check that no files contain `std::__1` often coming from templates copied
+# from clang output. These will fail on gcc
+cd ../../include/igl
+guard grep_std_1

+ 2 - 1
tutorial/101_FileIO/main.cpp

@@ -1,6 +1,7 @@
 #include <igl/readOFF.h>
 #include <igl/writeOBJ.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -8,7 +9,7 @@ Eigen::MatrixXi F;
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/cube.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH  "/cube.off", V, F);
 
   // Print the vertices and faces matrices
   std::cout << "Vertices: " << std::endl << V << std::endl;

+ 2 - 1
tutorial/102_DrawMesh/main.cpp

@@ -1,5 +1,6 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -7,7 +8,7 @@ Eigen::MatrixXi F;
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/bunny.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
 
   // Plot the mesh
   igl::viewer::Viewer viewer;

+ 3 - 2
tutorial/103_Events/main.cpp

@@ -1,6 +1,7 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V1,V2;
 Eigen::MatrixXi F1,F2;
@@ -33,8 +34,8 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
 int main(int argc, char *argv[])
 {
   // Load two meshes
-  igl::readOFF("../shared/bumpy.off", V1, F1);
-  igl::readOFF("../shared/fertility.off", V2, F2);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bumpy.off", V1, F1);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/fertility.off", V2, F2);
   std::cout<<R"(
 1 Switch to bump mesh
 2 Switch to fertility mesh

+ 2 - 1
tutorial/104_Colors/main.cpp

@@ -1,6 +1,7 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 #include <igl/jet.h>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -9,7 +10,7 @@ Eigen::MatrixXd C;
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/screwdriver.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/screwdriver.off", V, F);
 
   // Plot the mesh
   igl::viewer::Viewer viewer;

+ 2 - 1
tutorial/105_Overlays/main.cpp

@@ -1,6 +1,7 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 #include <sstream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -8,7 +9,7 @@ Eigen::MatrixXi F;
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/bunny.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
 
   // Find the bounding box
   Eigen::Vector3d m = V.colwise().minCoeff();

+ 2 - 1
tutorial/106_ViewerMenu/main.cpp

@@ -3,6 +3,7 @@
 #include <nanogui/formhelper.h>
 #include <nanogui/screen.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -13,7 +14,7 @@ float floatVariable = 0.1f;
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/bunny.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bunny.off", V, F);
 
   // Init the viewer
   igl::viewer::Viewer viewer;

+ 2 - 1
tutorial/201_Normals/main.cpp

@@ -4,6 +4,7 @@
 #include <igl/per_face_normals.h>
 #include <igl/per_corner_normals.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -35,7 +36,7 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/fandisk.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/fandisk.off", V, F);
 
   // Compute per-face normals
   igl::per_face_normals(V,F,N_faces);

+ 2 - 1
tutorial/202_GaussianCurvature/main.cpp

@@ -2,6 +2,7 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 #include <igl/jet.h>
+#include "tutorial_shared_path.h"
 
 int main(int argc, char *argv[])
 {
@@ -9,7 +10,7 @@ int main(int argc, char *argv[])
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/bumpy.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bumpy.off",V,F);
 
   VectorXd K;
   igl::gaussian_curvature(V,F,K);

+ 2 - 1
tutorial/203_CurvatureDirections/main.cpp

@@ -9,6 +9,7 @@
 #include <igl/principal_curvature.h>
 #include <igl/read_triangle_mesh.h>
 #include <igl/viewer/Viewer.h>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -16,7 +17,7 @@ Eigen::MatrixXi F;
 int main(int argc, char *argv[])
 {
   using namespace Eigen;
-  std::string filename = "../shared/fertility.off";
+  std::string filename = TUTORIAL_SHARED_PATH "/fertility.off";
   if(argc>1)
   {
     filename = argv[1];

+ 3 - 2
tutorial/204_Gradient/main.cpp

@@ -7,6 +7,7 @@
 #include <igl/viewer/Viewer.h>
 
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 int main(int argc, char *argv[])
 {
@@ -16,11 +17,11 @@ int main(int argc, char *argv[])
   MatrixXi F;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/cheburashka.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/cheburashka.off", V, F);
 
   // Read scalar function values from a file, U: #V by 1
   VectorXd U;
-  igl::readDMAT("../shared/cheburashka-scalar.dmat",U);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/cheburashka-scalar.dmat",U);
 
   // Compute gradient operator: #F*3 by #V
   SparseMatrix<double> G;

+ 2 - 1
tutorial/205_Laplacian/main.cpp

@@ -11,6 +11,7 @@
 #include <igl/viewer/Viewer.h>
 
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V,U;
 Eigen::MatrixXi F;
@@ -23,7 +24,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/cow.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/cow.off", V, F);
 
   // Compute Laplace-Beltrami operator: #V by #V
   igl::cotmatrix(V,F,L);

+ 2 - 1
tutorial/301_Slice/main.cpp

@@ -4,6 +4,7 @@
 #include <igl/slice_into.h>
 #include <igl/viewer/Viewer.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 int main(int argc, char *argv[])
 {
@@ -11,7 +12,7 @@ int main(int argc, char *argv[])
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/decimated-knight.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/decimated-knight.off",V,F);
 
   // 100 random indicies into rows of F
   VectorXi I;

+ 2 - 1
tutorial/302_Sort/main.cpp

@@ -6,6 +6,7 @@
 #include <igl/sortrows.h>
 #include <igl/viewer/Viewer.h>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 int main(int argc, char *argv[])
 {
@@ -13,7 +14,7 @@ int main(int argc, char *argv[])
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/decimated-knight.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/decimated-knight.off",V,F);
 
   // Sort barycenters lexicographically
   MatrixXd BC,sorted_BC;

+ 3 - 1
tutorial/303_LaplaceEquation/main.cpp

@@ -11,13 +11,15 @@
 #include <igl/viewer/Viewer.h>
 #include <Eigen/Sparse>
 #include <iostream>
+#include "tutorial_shared_path.h"
+
 int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/camelhead.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off",V,F);
   // Find boundary edges
   MatrixXi E;
   igl::boundary_facets(F,E);

+ 3 - 1
tutorial/304_LinearEqualityConstraints/main.cpp

@@ -8,13 +8,15 @@
 #include <igl/viewer/Viewer.h>
 #include <Eigen/Sparse>
 #include <iostream>
+#include "tutorial_shared_path.h"
+
 int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/cheburashka.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/cheburashka.off",V,F);
 
   // Two fixed points
   VectorXi b(2,1);

+ 2 - 2
tutorial/305_QuadraticProgramming/main.cpp

@@ -8,7 +8,7 @@
 #include <igl/viewer/Viewer.h>
 #include <Eigen/Sparse>
 #include <iostream>
-
+#include "tutorial_shared_path.h"
   
 Eigen::VectorXi b;
 Eigen::VectorXd B,bc,lx,ux,Beq,Bieq,Z;
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
   using namespace std;
   MatrixXd V;
   MatrixXi F;
-  igl::readOFF("../shared/cheburashka.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/cheburashka.off",V,F);
 
   // Plot the mesh
   igl::viewer::Viewer viewer;

+ 2 - 1
tutorial/306_EigenDecomposition/main.cpp

@@ -7,6 +7,7 @@
 #include <Eigen/Sparse>
 #include <iostream>
 #include <queue>
+#include "tutorial_shared_path.h"
 
 Eigen::MatrixXd V,U;
 Eigen::MatrixXi F;
@@ -19,7 +20,7 @@ int main(int argc, char * argv[])
   using namespace std;
   using namespace igl;
   VectorXd D;
-  if(!read_triangle_mesh("../shared/beetle.off",V,F))
+  if(!read_triangle_mesh(TUTORIAL_SHARED_PATH "/beetle.off",V,F))
   {
     cout<<"failed to load mesh"<<endl;
   }

+ 3 - 2
tutorial/401_BiharmonicDeformation/main.cpp

@@ -5,6 +5,7 @@
 #include <igl/viewer/Viewer.h>
 #include <algorithm>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 double bc_frac = 1.0;
 double bc_dir = -0.03;
@@ -59,11 +60,11 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOBJ("../shared/decimated-max.obj",V,F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/decimated-max.obj",V,F);
   U=V;
   // S(i) = j: j<0 (vertex i not in handle), j >= 0 (vertex i in handle j)
   VectorXi S;
-  igl::readDMAT("../shared/decimated-max-selection.dmat",S);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/decimated-max-selection.dmat",S);
   igl::colon<int>(0,V.rows()-1,b);
   b.conservativeResize(stable_partition( b.data(), b.data()+b.size(), 
    [&S](int i)->bool{return S(i)>=0;})-b.data());

+ 2 - 1
tutorial/402_PolyharmonicDeformation/main.cpp

@@ -4,6 +4,7 @@
 #include <igl/viewer/Viewer.h>
 #include <algorithm>
 #include <iostream>
+#include "tutorial_shared_path.h"
 
 double z_max = 1.0;
 double z_dir = -0.03;
@@ -59,7 +60,7 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOBJ("../shared/bump-domain.obj",V,F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/bump-domain.obj",V,F);
   U=V;
   // Find boundary vertices outside annulus
   typedef Matrix<bool,Dynamic,1> VectorXb;

+ 5 - 3
tutorial/403_BoundedBiharmonicWeights/main.cpp

@@ -30,6 +30,8 @@
 #include <algorithm>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 typedef 
   std::vector<Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> >
   RotationList;
@@ -118,15 +120,15 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readMESH("../shared/hand.mesh",V,T,F);
+  igl::readMESH(TUTORIAL_SHARED_PATH "/hand.mesh",V,T,F);
   U=V;
-  igl::readTGF("../shared/hand.tgf",C,BE);
+  igl::readTGF(TUTORIAL_SHARED_PATH "/hand.tgf",C,BE);
   // retrieve parents for forward kinematics
   igl::directed_edge_parents(BE,P);
 
   // Read pose as matrix of quaternions per row
   MatrixXd Q;
-  igl::readDMAT("../shared/hand-pose.dmat",Q);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/hand-pose.dmat",Q);
   igl::column_to_quats(Q,pose);
   assert(pose.size() == BE.rows());
 

+ 5 - 3
tutorial/404_DualQuaternionSkinning/main.cpp

@@ -16,6 +16,8 @@
 #include <algorithm>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 typedef 
   std::vector<Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> >
   RotationList;
@@ -110,9 +112,9 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOBJ("../shared/arm.obj",V,F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/arm.obj",V,F);
   U=V;
-  igl::readTGF("../shared/arm.tgf",C,BE);
+  igl::readTGF(TUTORIAL_SHARED_PATH "/arm.tgf",C,BE);
   // retrieve parents for forward kinematics
   igl::directed_edge_parents(BE,P);
   RotationList rest_pose;
@@ -124,7 +126,7 @@ int main(int argc, char *argv[])
   const Quaterniond bend(AngleAxisd(-igl::PI*0.7,Vector3d(0,0,1)));
   poses[3][2] = rest_pose[2]*bend*rest_pose[2].conjugate();
 
-  igl::readDMAT("../shared/arm-weights.dmat",W);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/arm-weights.dmat",W);
   igl::lbs_matrix(V,W,M);
 
   // Plot the mesh with pseudocolors

+ 4 - 2
tutorial/405_AsRigidAsPossible/main.cpp

@@ -17,6 +17,8 @@
 #include <algorithm>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 typedef 
   std::vector<Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> >
   RotationList;
@@ -90,9 +92,9 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOFF("../shared/decimated-knight.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/decimated-knight.off",V,F);
   U=V;
-  igl::readDMAT("../shared/decimated-knight-selection.dmat",S);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/decimated-knight-selection.dmat",S);
 
   // vertices in selection
   igl::colon<int>(0,V.rows()-1,b);

+ 4 - 2
tutorial/406_FastAutomaticSkinningTransformations/main.cpp

@@ -23,6 +23,8 @@
 #include <algorithm>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 typedef 
   std::vector<Eigen::Quaterniond,Eigen::aligned_allocator<Eigen::Quaterniond> >
   RotationList;
@@ -142,10 +144,10 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOBJ("../shared/armadillo.obj",V,F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/armadillo.obj",V,F);
   U=V;
   MatrixXd W;
-  igl::readDMAT("../shared/armadillo-weights.dmat",W);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/armadillo-weights.dmat",W);
   igl::lbs_matrix_column(V,W,M);
 
   // Cluster according to weights

+ 4 - 2
tutorial/407_BiharmonicCoordinates/main.cpp

@@ -16,6 +16,8 @@
 #include <iostream>
 #include <queue>
 
+#include "tutorial_shared_path.h"
+
 struct Mesh
 {
   Eigen::MatrixXd V,U;
@@ -30,11 +32,11 @@ int main(int argc, char * argv[])
   using namespace Eigen;
   using namespace std;
   using namespace igl;
-  if(!readMESH("../shared/octopus-low.mesh",low.V,low.T,low.F))
+  if(!readMESH(TUTORIAL_SHARED_PATH "/octopus-low.mesh",low.V,low.T,low.F))
   {
     cout<<"failed to load mesh"<<endl;
   }
-  if(!readMESH("../shared/octopus-high.mesh",high.V,high.T,high.F))
+  if(!readMESH(TUTORIAL_SHARED_PATH "/octopus-high.mesh",high.V,high.T,high.F))
   {
     cout<<"failed to load mesh"<<endl;
   }

+ 3 - 1
tutorial/501_HarmonicParam/main.cpp

@@ -4,6 +4,8 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 Eigen::MatrixXd V_uv;
@@ -31,7 +33,7 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/camelhead.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
 
   // Find the open boundary
   Eigen::VectorXi bnd;

+ 3 - 1
tutorial/502_LSCMParam/main.cpp

@@ -4,6 +4,8 @@
 
 #include <igl/lscm.h>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 Eigen::MatrixXd V_uv;
@@ -35,7 +37,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/camelhead.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
 
   // Fix two points on the boundary
   VectorXi bnd,b(2,1);

+ 3 - 1
tutorial/503_ARAPParam/main.cpp

@@ -5,6 +5,8 @@
 #include <igl/readOFF.h>
 #include <igl/viewer/Viewer.h>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 Eigen::MatrixXd V_uv;
@@ -42,7 +44,7 @@ int main(int argc, char *argv[])
 {
   using namespace std;
   // Load a mesh in OFF format
-  igl::readOFF("../shared/camelhead.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/camelhead.off", V, F);
 
   // Compute the initial solution for ARAP (harmonic parametrization)
   Eigen::VectorXi bnd;

+ 2 - 1
tutorial/504_NRosyDesign/main.cpp

@@ -5,6 +5,7 @@
 #include <igl/comiso/nrosy.h>
 #include <igl/viewer/Viewer.h>
 
+#include "tutorial_shared_path.h"
 
 // Mesh
 Eigen::MatrixXd V;
@@ -122,7 +123,7 @@ int main(int argc, char *argv[])
   using namespace Eigen;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/bumpy.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/bumpy.off", V, F);
 
   // Threshold faces with high anisotropy
   b.resize(1);

+ 3 - 1
tutorial/505_MIQ/main.cpp

@@ -14,6 +14,8 @@
 #include <igl/viewer/Viewer.h>
 #include <sstream>
 
+#include "tutorial_shared_path.h"
+
 // Input mesh
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -230,7 +232,7 @@ int main(int argc, char *argv[])
   using namespace Eigen;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/3holes.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/3holes.off", V, F);
 
   // Compute face barycenters
   igl::barycenter(V, F, B);

+ 4 - 2
tutorial/506_FrameField/main.cpp

@@ -12,6 +12,8 @@
 #include <igl/comiso/frame_field.h>
 #include <igl/viewer/Viewer.h>
 
+#include "tutorial_shared_path.h"
+
 // Input mesh
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -177,7 +179,7 @@ int main(int argc, char *argv[])
   using namespace Eigen;
 
   // Load a mesh in OBJ format
-  igl::readOBJ("../shared/bumpy-cube.obj", V, F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/bumpy-cube.obj", V, F);
 
   // Compute face barycenters
   igl::barycenter(V, F, B);
@@ -187,7 +189,7 @@ int main(int argc, char *argv[])
 
   // Load constraints
   MatrixXd temp;
-  igl::readDMAT("../shared/bumpy-cube.dmat",temp);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/bumpy-cube.dmat",temp);
 
   b   = temp.block(0,0,temp.rows(),1).cast<int>();
   bc1 = temp.block(0,1,temp.rows(),3);

+ 4 - 2
tutorial/507_PolyVectorField/main.cpp

@@ -10,6 +10,8 @@
 #include <iostream>
 #include <vector>
 
+#include "tutorial_shared_path.h"
+
 // Input mesh
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -127,8 +129,8 @@ int main(int argc, char *argv[])
   using namespace Eigen;
   using namespace std;
   // Load a mesh in OBJ format
-  igl::readOBJ("../shared/lilium.obj", V, F);
-  readSamples("../shared/lilium.samples.0.2", samples);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/lilium.obj", V, F);
+  readSamples(TUTORIAL_SHARED_PATH "/lilium.samples.0.2", samples);
 
   // Compute local basis for faces
   igl::local_basis(V,F,B1,B2,B3);

+ 4 - 3
tutorial/508_ConjugateField/main.cpp

@@ -12,6 +12,7 @@
 #include <vector>
 #include <cstdlib>
 
+#include "tutorial_shared_path.h"
 
 // Input mesh
 Eigen::MatrixXd V;
@@ -123,7 +124,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a mesh in OBJ format
-  igl::readOBJ("../shared/inspired_mesh.obj", V, F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/inspired_mesh.obj", V, F);
   // Compute face barycenters
   igl::barycenter(V, F, B);
 
@@ -135,8 +136,8 @@ int main(int argc, char *argv[])
   global_scale =  .4*igl::avg_edge_length(V, F);
 
   // Load constraints
-  igl::readDMAT("../shared/inspired_mesh_b.dmat",b);
-  igl::readDMAT("../shared/inspired_mesh_bc.dmat",bc);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/inspired_mesh_b.dmat",b);
+  igl::readDMAT(TUTORIAL_SHARED_PATH "/inspired_mesh_bc.dmat",bc);
 
   // Interpolate to get a smooth field
   igl::n_polyvector(V, F, b, bc, smooth_pvf);

+ 3 - 1
tutorial/509_Planarization/main.cpp

@@ -10,6 +10,8 @@
 #include <vector>
 #include <cstdlib>
 
+#include "tutorial_shared_path.h"
+
 // Quad mesh generated from conjugate field
 Eigen::MatrixXd VQC;
 Eigen::MatrixXi FQC;
@@ -84,7 +86,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a quad mesh generated by a conjugate field
-  igl::readOFF("../shared/inspired_mesh_quads_Conjugate.off", VQC, FQC);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/inspired_mesh_quads_Conjugate.off", VQC, FQC);
 
   // Convert it in a triangle mesh
   FQCtri.resize(2*FQC.rows(), 3);

+ 4 - 1
tutorial/510_Integrable/main.cpp

@@ -24,6 +24,9 @@
 #include <iostream>
 #include <fstream>
 #include <igl/matlab_format.h>
+
+#include "tutorial_shared_path.h"
+
 using namespace std;
 
 // Input mesh
@@ -624,7 +627,7 @@ int main(int argc, char *argv[])
 {
 
   // Load a mesh
-  igl::readOBJ("../shared/inspired_mesh.obj", V, F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/inspired_mesh.obj", V, F);
 
   printf("--Initialization--\n");
   V_border = igl::is_border_vertex(V,F);

+ 3 - 1
tutorial/601_Serialization/main.cpp

@@ -3,6 +3,8 @@
 #include <igl/xml/serialize_xml.h>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
 
@@ -62,7 +64,7 @@ int main(int argc, char *argv[])
   State stateIn, stateOut;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/2triangles.off",stateIn.V,stateIn.F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/2triangles.off",stateIn.V,stateIn.F);
 
   // Save some integers in a vector
   stateIn.ids.push_back(6);

+ 3 - 1
tutorial/602_Matlab/main.cpp

@@ -5,6 +5,8 @@
 #include <igl/viewer/Viewer.h>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 // Base mesh
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -45,7 +47,7 @@ bool key_down(igl::viewer::Viewer& viewer, unsigned char key, int modifier)
 int main(int argc, char *argv[])
 {
   // Load a mesh in OFF format
-  igl::readOFF("../shared/3holes.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/3holes.off", V, F);
 
   // Launch MATLAB
   igl::matlab::mlinit(&engine);

+ 3 - 1
tutorial/605_Tetgen/main.cpp

@@ -3,6 +3,8 @@
 #include <igl/readOFF.h>
 #include <igl/barycenter.h>
 
+#include "tutorial_shared_path.h"
+
 // Input polygon
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -62,7 +64,7 @@ int main(int argc, char *argv[])
   using namespace std;
 
   // Load a surface mesh
-  igl::readOFF("../shared/fertility.off",V,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/fertility.off",V,F);
 
   // Tetrahedralize the interior
   igl::tetgen::tetrahedralize(V,F,"pq1.414Y", TV,TT,TF);

+ 2 - 1
tutorial/606_AmbientOcclusion/main.cpp

@@ -5,6 +5,7 @@
 #include <igl/viewer/Viewer.h>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
 
 // Mesh
 Eigen::MatrixXd V;
@@ -58,7 +59,7 @@ int main(int argc, char *argv[])
     "Press , to turn down lighting"<<endl;
 
   // Load a mesh in OFF format
-  igl::readOFF("../shared/fertility.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/fertility.off", V, F);
 
   MatrixXd N;
   igl::per_vertex_normals(V,F,N);

+ 3 - 1
tutorial/607_Picking/main.cpp

@@ -5,6 +5,8 @@
 
 #include <algorithm>
 
+#include "tutorial_shared_path.h"
+
 // Mesh
 Eigen::MatrixXd V;
 Eigen::MatrixXi F;
@@ -54,7 +56,7 @@ int main(int argc, char *argv[])
   using namespace Eigen;
   using namespace std;
   // Load a mesh in OFF format
-  igl::readOFF("../shared/fertility.off", V, F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/fertility.off", V, F);
 
   // Create a BVH for raycasting
   ei = new igl::embree::EmbreeIntersector();

+ 2 - 1
tutorial/608_LIM/main.cpp

@@ -5,6 +5,7 @@
 #include <igl/viewer/Viewer.h>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
 
 // Mesh
 Eigen::MatrixX3d V0;
@@ -65,7 +66,7 @@ int main(int argc, char *argv[])
   barriersEnabled = true;
 
   // load a mesh in OFF format
-  igl::readOFF("../shared/grid.off",V0,F);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/grid.off",V0,F);
   V1 = V0;
 
   // find bottom and left boundary vertices

+ 4 - 2
tutorial/609_Boolean/main.cpp

@@ -7,6 +7,8 @@
 #include <Eigen/Core>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd VA,VB,VC;
 Eigen::VectorXi J,I;
 Eigen::MatrixXi FA,FB,FC;
@@ -75,8 +77,8 @@ int main(int argc, char *argv[])
 {
   using namespace Eigen;
   using namespace std;
-  igl::readOFF("../shared/cheburashka.off",VA,FA);
-  igl::readOFF("../shared/decimated-knight.off",VB,FB);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/cheburashka.off",VA,FA);
+  igl::readOFF(TUTORIAL_SHARED_PATH "/decimated-knight.off",VB,FB);
   // Plot the mesh with pseudocolors
   igl::viewer::Viewer viewer;
 

+ 7 - 5
tutorial/610_CSGTree/main.cpp

@@ -4,6 +4,8 @@
 #include <igl/jet.h>
 #include <Eigen/Core>
 
+#include "tutorial_shared_path.h"
+
 int main(int argc, char * argv[])
 {
   using namespace Eigen;
@@ -13,11 +15,11 @@ int main(int argc, char * argv[])
   MatrixXi FA,FB,FC,FD,FE;
   MatrixXd VA,VB,VC,VD,VE;
   // Read in inputs as double precision floating point meshes
-  read_triangle_mesh("../shared/cube.obj"     ,VA,FA);
-  read_triangle_mesh("../shared/sphere.obj"   ,VB,FB);
-  read_triangle_mesh("../shared/xcylinder.obj",VC,FC);
-  read_triangle_mesh("../shared/ycylinder.obj",VD,FD);
-  read_triangle_mesh("../shared/zcylinder.obj",VE,FE);
+  read_triangle_mesh(TUTORIAL_SHARED_PATH "/cube.obj"     ,VA,FA);
+  read_triangle_mesh(TUTORIAL_SHARED_PATH "/sphere.obj"   ,VB,FB);
+  read_triangle_mesh(TUTORIAL_SHARED_PATH "/xcylinder.obj",VC,FC);
+  read_triangle_mesh(TUTORIAL_SHARED_PATH "/ycylinder.obj",VD,FD);
+  read_triangle_mesh(TUTORIAL_SHARED_PATH "/zcylinder.obj",VE,FE);
   igl::viewer::Viewer viewer;
 
   int num_views = 5+4;

+ 3 - 1
tutorial/701_Statistics/main.cpp

@@ -5,6 +5,8 @@
 #include <Eigen/Core>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 int main(int argc, char *argv[])
 {
   using namespace Eigen;
@@ -13,7 +15,7 @@ int main(int argc, char *argv[])
   MatrixXd V;
   MatrixXi F;
 
-  igl::readOBJ("../shared/horse_quad.obj",V,F);
+  igl::readOBJ(TUTORIAL_SHARED_PATH "/horse_quad.obj",V,F);
 
   // Count the number of irregular vertices, the border is ignored
   vector<bool> irregular = igl::is_irregular_vertex(V,F);

+ 3 - 1
tutorial/702_WindingNumber/main.cpp

@@ -9,6 +9,8 @@
 #include <Eigen/Sparse>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V,BC;
 Eigen::VectorXd W;
 Eigen::MatrixXi T,F,G;
@@ -101,7 +103,7 @@ int main(int argc, char *argv[])
 
   // Load mesh: (V,T) tet-mesh of convex hull, F contains facets of input
   // surface mesh _after_ self-intersection resolution
-  igl::readMESH("../shared/big-sigcat.mesh",V,T,F);
+  igl::readMESH(TUTORIAL_SHARED_PATH "/big-sigcat.mesh",V,T,F);
 
   // Compute barycenters of all tets
   igl::barycenter(V,T,BC);

+ 3 - 1
tutorial/703_Decimation/main.cpp

@@ -7,6 +7,8 @@
 #include <iostream>
 #include <set>
 
+#include "tutorial_shared_path.h"
+
 int main(int argc, char * argv[])
 {
   using namespace std;
@@ -16,7 +18,7 @@ int main(int argc, char * argv[])
   cout<<"  [space]  toggle animation."<<endl;
   cout<<"  'r'  reset."<<endl;
   // Load a closed manifold mesh
-  string filename("../shared/fertility.off");
+  string filename(TUTORIAL_SHARED_PATH "/fertility.off");
   if(argc>=2)
   {
     filename = argv[1];

+ 3 - 1
tutorial/704_SignedDistance/main.cpp

@@ -14,6 +14,8 @@
 #include <Eigen/Sparse>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 Eigen::MatrixXd V;
 Eigen::MatrixXi T,F;
 igl::AABB<Eigen::MatrixXd,3> tree;
@@ -127,7 +129,7 @@ int main(int argc, char *argv[])
 
   // Load mesh: (V,T) tet-mesh of convex hull, F contains original surface
   // triangles
-  igl::readMESH("../shared/bunny.mesh",V,T,F);
+  igl::readMESH(TUTORIAL_SHARED_PATH "/bunny.mesh",V,T,F);
 
 
   // Encapsulated call to point_mesh_squared_distance to determine bounds

+ 3 - 1
tutorial/705_MarchingCubes/main.cpp

@@ -5,6 +5,8 @@
 #include <Eigen/Core>
 #include <iostream>
 
+#include "tutorial_shared_path.h"
+
 int main(int argc, char * argv[])
 {
   using namespace Eigen;
@@ -14,7 +16,7 @@ int main(int argc, char * argv[])
   MatrixXd V;
   // Read in inputs as double precision floating point meshes
   read_triangle_mesh(
-      "../shared/armadillo.obj",V,F);
+      TUTORIAL_SHARED_PATH "/armadillo.obj",V,F);
   // number of vertices on the largest side
   const int s = 50;
   const RowVector3d Vmin = V.colwise().minCoeff();

+ 4 - 0
tutorial/CMakeLists.txt

@@ -134,6 +134,10 @@ endif(UNIX AND NOT APPLE)
 
 #message(FATAL_ERROR ${SHARED_LIBRARIES})
 
+# Store location of tutorial/shared directory 
+set(TUTORIAL_SHARED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/shared CACHE PATH "location of shared tutorial resources")
+add_definitions("-DTUTORIAL_SHARED_PATH=\"${TUTORIAL_SHARED_PATH}\"")
+
 # Chapter 1
 add_subdirectory("101_FileIO")
 add_subdirectory("102_DrawMesh")

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

@@ -1 +1 @@
-f76a0af84c248418b4ca59f42fdff9b8985a68f6
+5d18dcc0e2feb40028d7020f495e49d98bc1c2ad

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

@@ -1 +1 @@
-2db6de1eea7e06a20786a45f0120ff3a977a625f
+fbaf1dfab928d1ccc131e1283f7692ecd5e54c47

+ 8 - 0
tutorial/tutorial_shared_path.h

@@ -0,0 +1,8 @@
+#ifndef tutorial_shared_path_h_included
+#define tutorial_shared_path_h_included
+
+#ifndef TUTORIAL_SHARED_PATH
+#define TUTORIAL_SHARED_PATH "../shared"
+#endif
+
+#endif

Some files were not shown because too many files changed in this diff