Browse Source

dependency extras are each in there own namespace (examples/tutorials probably broken

Former-commit-id: a0243ce5d50aa5d86a61c407ab71b15921d45923
Alec Jacobson 10 years ago
parent
commit
c15a158a2c
100 changed files with 2407 additions and 2262 deletions
  1. 5 5
      include/igl/bbw/bbw.cpp
  2. 68 65
      include/igl/bbw/bbw.h
  3. 11 8
      include/igl/boolean/MeshBooleanType.h
  4. 3 3
      include/igl/boolean/from_cork_mesh.cpp
  5. 17 14
      include/igl/boolean/from_cork_mesh.h
  6. 8 7
      include/igl/boolean/mesh_boolean.cpp
  7. 83 75
      include/igl/boolean/mesh_boolean.h
  8. 3 3
      include/igl/boolean/mesh_boolean_cork.cpp
  9. 29 26
      include/igl/boolean/mesh_boolean_cork.h
  10. 3 3
      include/igl/boolean/to_cork_mesh.cpp
  11. 17 14
      include/igl/boolean/to_cork_mesh.h
  12. 10 7
      include/igl/cgal/RemeshSelfIntersectionsParam.h
  13. 211 208
      include/igl/cgal/SelfIntersectMesh.h
  14. 2 2
      include/igl/cgal/complex_to_mesh.cpp
  15. 20 17
      include/igl/cgal/complex_to_mesh.h
  16. 1 1
      include/igl/cgal/intersect_other.cpp
  17. 26 23
      include/igl/cgal/intersect_other.h
  18. 5 5
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp
  19. 21 18
      include/igl/cgal/mesh_to_cgal_triangle_list.h
  20. 2 2
      include/igl/cgal/mesh_to_polyhedron.cpp
  21. 19 16
      include/igl/cgal/mesh_to_polyhedron.h
  22. 2 2
      include/igl/cgal/order_facets_around_edges.cpp
  23. 5 1
      include/igl/cgal/order_facets_around_edges.h
  24. 5 5
      include/igl/cgal/outer_hull.cpp
  25. 47 44
      include/igl/cgal/outer_hull.h
  26. 4 4
      include/igl/cgal/peel_outer_hull_layers.cpp
  27. 39 36
      include/igl/cgal/peel_outer_hull_layers.h
  28. 2 2
      include/igl/cgal/polyhedron_to_mesh.cpp
  29. 17 14
      include/igl/cgal/polyhedron_to_mesh.h
  30. 4 4
      include/igl/cgal/remesh_self_intersections.cpp
  31. 55 52
      include/igl/cgal/remesh_self_intersections.h
  32. 2 2
      include/igl/cgal/signed_distance_isosurface.cpp
  33. 29 26
      include/igl/cgal/signed_distance_isosurface.h
  34. 5 1
      include/igl/comiso/frame_field.cpp
  35. 3 0
      include/igl/comiso/frame_field.h
  36. 1 1
      include/igl/comiso/miq.cpp.REMOVED.git-id
  37. 78 74
      include/igl/comiso/miq.h
  38. 38 35
      include/igl/comiso/nrosy.cpp
  39. 43 42
      include/igl/comiso/nrosy.h
  40. 169 163
      include/igl/embree/EmbreeIntersector.h
  41. 10 7
      include/igl/embree/Hit.h
  42. 8 8
      include/igl/embree/ambient_occlusion.cpp
  43. 40 37
      include/igl/embree/ambient_occlusion.h
  44. 1 1
      include/igl/embree/bone_heat.cpp
  45. 26 23
      include/igl/embree/bone_heat.h
  46. 6 6
      include/igl/embree/bone_visible.cpp
  47. 49 46
      include/igl/embree/bone_visible.h
  48. 3 18
      include/igl/embree/line_mesh_intersection.cpp
  49. 28 52
      include/igl/embree/line_mesh_intersection.h
  50. 3 3
      include/igl/embree/reorient_facets_raycast.cpp
  51. 51 48
      include/igl/embree/reorient_facets_raycast.h
  52. 14 14
      include/igl/embree/unproject_in_mesh.cpp
  53. 54 52
      include/igl/embree/unproject_in_mesh.h
  54. 5 5
      include/igl/embree/unproject_onto_mesh.cpp
  55. 52 50
      include/igl/embree/unproject_onto_mesh.h
  56. 1 1
      include/igl/lim/lim.cpp
  57. 110 95
      include/igl/lim/lim.h
  58. 152 149
      include/igl/matlab/MatlabWorkspace.h
  59. 23 20
      include/igl/matlab/MexStream.h
  60. 14 14
      include/igl/matlab/matlabinterface.cpp
  61. 46 43
      include/igl/matlab/matlabinterface.h
  62. 1 1
      include/igl/matlab/mexErrMsgTxt.cpp
  63. 5 2
      include/igl/matlab/mexErrMsgTxt.h
  64. 5 5
      include/igl/matlab/parse_rhs.cpp
  65. 18 15
      include/igl/matlab/parse_rhs.h
  66. 9 9
      include/igl/matlab/prepare_lhs.cpp
  67. 24 21
      include/igl/matlab/prepare_lhs.h
  68. 1 1
      include/igl/mosek/mosek_guarded.cpp
  69. 9 6
      include/igl/mosek/mosek_guarded.h
  70. 2 2
      include/igl/mosek/mosek_linprog.cpp
  71. 38 35
      include/igl/mosek/mosek_linprog.h
  72. 3 3
      include/igl/mosek/mosek_quadprog.cpp
  73. 100 97
      include/igl/mosek/mosek_quadprog.h
  74. 2 2
      include/igl/png/render_to_png.cpp
  75. 20 17
      include/igl/png/render_to_png.h
  76. 1 1
      include/igl/png/render_to_png_async.cpp
  77. 22 19
      include/igl/png/render_to_png_async.h
  78. 1 1
      include/igl/png/texture_from_file.cpp
  79. 13 10
      include/igl/png/texture_from_file.h
  80. 2 2
      include/igl/png/texture_from_png.cpp
  81. 27 21
      include/igl/png/texture_from_png.h
  82. 2 2
      include/igl/tetgen/cdt.cpp
  83. 38 35
      include/igl/tetgen/cdt.h
  84. 3 3
      include/igl/tetgen/mesh_to_tetgenio.cpp
  85. 24 21
      include/igl/tetgen/mesh_to_tetgenio.h
  86. 3 3
      include/igl/tetgen/mesh_with_skeleton.cpp
  87. 46 43
      include/igl/tetgen/mesh_with_skeleton.h
  88. 1 1
      include/igl/tetgen/read_into_tetgenio.cpp
  89. 30 27
      include/igl/tetgen/read_into_tetgenio.h
  90. 6 6
      include/igl/tetgen/tetgenio_to_tetmesh.cpp
  91. 36 33
      include/igl/tetgen/tetgenio_to_tetmesh.h
  92. 3 3
      include/igl/tetgen/tetrahedralize.cpp
  93. 47 44
      include/igl/tetgen/tetrahedralize.h
  94. 1 1
      include/igl/triangle/triangulate.cpp
  95. 23 21
      include/igl/triangle/triangulate.h
  96. 8 8
      include/igl/viewer/OpenGL_shader.cpp
  97. 3 0
      include/igl/viewer/OpenGL_shader.h
  98. 11 11
      include/igl/viewer/OpenGL_state.cpp
  99. 5 2
      include/igl/viewer/OpenGL_state.h
  100. 6 6
      include/igl/viewer/TextRenderer.cpp

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

@@ -21,7 +21,7 @@
 #include <cstdio>
 
 
-igl::BBWData::BBWData():
+igl::bbw::BBWData::BBWData():
   partition_unity(false),
   W0(),
 #ifndef IGL_NO_MOSEK
@@ -35,7 +35,7 @@ igl::BBWData::BBWData():
   active_set_params.Auu_pd = true;
 }
 
-void igl::BBWData::print()
+void igl::bbw::BBWData::print()
 {
   using namespace std;
   cout<<"partition_unity: "<<partition_unity<<endl;
@@ -50,12 +50,12 @@ template <
   typename Derivedb,
   typename Derivedbc, 
   typename DerivedW>
-IGL_INLINE bool igl::bbw(
+IGL_INLINE bool igl::bbw::bbw(
   const Eigen::PlainObjectBase<DerivedV> & V, 
   const Eigen::PlainObjectBase<DerivedEle> & Ele, 
   const Eigen::PlainObjectBase<Derivedb> & b, 
   const Eigen::PlainObjectBase<Derivedbc> & bc, 
-  igl::BBWData & data,
+  igl::bbw::BBWData & data,
   Eigen::PlainObjectBase<DerivedW> & W
   )
 {
@@ -212,5 +212,5 @@ IGL_INLINE bool igl::bbw(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template bool igl::bbw<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::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> > const&, igl::BBWData&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template bool igl::bbw::bbw<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::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> > const&, igl::bbw::BBWData&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 68 - 65
include/igl/bbw/bbw.h

@@ -17,75 +17,78 @@
 
 namespace igl
 {
-  enum QPSolver
+  namespace bbw
   {
-    QP_SOLVER_IGL_ACTIVE_SET = 0,
-    QP_SOLVER_MOSEK = 1,
-    NUM_QP_SOLVERS = 2
-  };
-  const char * const QPSolverNames[NUM_QP_SOLVERS] =
-  {
-    "QP_SOLVER_IGL_ACTIVE_SET",
-    "QP_SOLVER_MOSEK"
-  };
-  // Container for BBW computation related data and flags
-  class BBWData
-  {
-    public:
-      // Enforce partition of unity during optimization (optimize all weight
-      // simultaneously)
-      bool partition_unity;
-      // Initial guess
-      Eigen::MatrixXd W0;
+    enum QPSolver
+    {
+      QP_SOLVER_IGL_ACTIVE_SET = 0,
+      QP_SOLVER_MOSEK = 1,
+      NUM_QP_SOLVERS = 2
+    };
+    const char * const QPSolverNames[NUM_QP_SOLVERS] =
+    {
+      "QP_SOLVER_IGL_ACTIVE_SET",
+      "QP_SOLVER_MOSEK"
+    };
+    // Container for BBW computation related data and flags
+    class BBWData
+    {
+      public:
+        // Enforce partition of unity during optimization (optimize all weight
+        // simultaneously)
+        bool partition_unity;
+        // Initial guess
+        Eigen::MatrixXd W0;
 #ifndef IGL_NO_MOSEK
-      igl::MosekData mosek_data;
+        igl::mosek::MosekData mosek_data;
 #endif
-      igl::active_set_params active_set_params;
-      // Which solver
-      QPSolver qp_solver;
-      // Verbosity level
-      // 0: quiet
-      // 1: loud
-      // 2: louder
-      int verbosity;
-    public:
-      BBWData();
-      // Print current state of object
-      void print();
-  };
+        igl::active_set_params active_set_params;
+        // Which solver
+        QPSolver qp_solver;
+        // Verbosity level
+        // 0: quiet
+        // 1: loud
+        // 2: louder
+        int verbosity;
+      public:
+        BBWData();
+        // Print current state of object
+        void print();
+    };
 
-  // Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
-  // set of boundary conditions
-  //
-  // Templates
-  //   DerivedV  derived type of eigen matrix for V (e.g. MatrixXd)
-  //   DerivedF  derived type of eigen matrix for F (e.g. MatrixXi)
-  //   Derivedb  derived type of eigen matrix for b (e.g. VectorXi)
-  //   Derivedbc  derived type of eigen matrix for bc (e.g. MatrixXd)
-  //   DerivedW  derived type of eigen matrix for W (e.g. MatrixXd)
-  // Inputs:
-  //   V  #V by dim vertex positions
-  //   Ele  #Elements by simplex-size list of element indices
-  //   b  #b boundary indices into V
-  //   bc #b by #W list of boundary values
-  //   data  object containing options, intial guess --> solution and results
-  // Outputs:
-  //   W  #V by #W list of *unnormalized* weights to normalize use 
-  //    igl::normalize_row_sums(W,W); 
-  // Returns true on success, false on failure
-  template <
-    typename DerivedV, 
-    typename DerivedEle, 
-    typename Derivedb,
-    typename Derivedbc, 
-    typename DerivedW>
-  IGL_INLINE bool bbw(
-    const Eigen::PlainObjectBase<DerivedV> & V, 
-    const Eigen::PlainObjectBase<DerivedEle> & Ele, 
-    const Eigen::PlainObjectBase<Derivedb> & b, 
-    const Eigen::PlainObjectBase<Derivedbc> & bc, 
-    BBWData & data,
-    Eigen::PlainObjectBase<DerivedW> & W);
+    // Compute Bounded Biharmonic Weights on a given domain (V,Ele) with a given
+    // set of boundary conditions
+    //
+    // Templates
+    //   DerivedV  derived type of eigen matrix for V (e.g. MatrixXd)
+    //   DerivedF  derived type of eigen matrix for F (e.g. MatrixXi)
+    //   Derivedb  derived type of eigen matrix for b (e.g. VectorXi)
+    //   Derivedbc  derived type of eigen matrix for bc (e.g. MatrixXd)
+    //   DerivedW  derived type of eigen matrix for W (e.g. MatrixXd)
+    // Inputs:
+    //   V  #V by dim vertex positions
+    //   Ele  #Elements by simplex-size list of element indices
+    //   b  #b boundary indices into V
+    //   bc #b by #W list of boundary values
+    //   data  object containing options, intial guess --> solution and results
+    // Outputs:
+    //   W  #V by #W list of *unnormalized* weights to normalize use 
+    //    igl::normalize_row_sums(W,W); 
+    // Returns true on success, false on failure
+    template <
+      typename DerivedV, 
+               typename DerivedEle, 
+               typename Derivedb,
+               typename Derivedbc, 
+               typename DerivedW>
+                 IGL_INLINE bool bbw(
+                     const Eigen::PlainObjectBase<DerivedV> & V, 
+                     const Eigen::PlainObjectBase<DerivedEle> & Ele, 
+                     const Eigen::PlainObjectBase<Derivedb> & b, 
+                     const Eigen::PlainObjectBase<Derivedbc> & bc, 
+                     BBWData & data,
+                     Eigen::PlainObjectBase<DerivedW> & W);
+  }
 }
   
 #ifndef IGL_STATIC_LIBRARY

+ 11 - 8
include/igl/boolean/MeshBooleanType.h

@@ -3,15 +3,18 @@
 
 namespace igl
 {
-  enum MeshBooleanType
+  namespace boolean
   {
-    MESH_BOOLEAN_TYPE_UNION = 0,
-    MESH_BOOLEAN_TYPE_INTERSECT = 1,
-    MESH_BOOLEAN_TYPE_MINUS = 2,
-    MESH_BOOLEAN_TYPE_XOR = 3,
-    MESH_BOOLEAN_TYPE_RESOLVE = 4,
-    NUM_MESH_BOOLEAN_TYPES = 5
-  };
+    enum MeshBooleanType
+    {
+      MESH_BOOLEAN_TYPE_UNION = 0,
+      MESH_BOOLEAN_TYPE_INTERSECT = 1,
+      MESH_BOOLEAN_TYPE_MINUS = 2,
+      MESH_BOOLEAN_TYPE_XOR = 3,
+      MESH_BOOLEAN_TYPE_RESOLVE = 4,
+      NUM_MESH_BOOLEAN_TYPES = 5
+    };
+  }
 };
 
 #endif

+ 3 - 3
include/igl/boolean/from_cork_mesh.cpp

@@ -4,7 +4,7 @@
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::from_cork_mesh(
+IGL_INLINE void igl::boolean::from_cork_mesh(
   const CorkTriMesh & mesh,
   Eigen::PlainObjectBase<DerivedV > & V,
   Eigen::PlainObjectBase<DerivedF > & F)
@@ -30,8 +30,8 @@ IGL_INLINE void igl::from_cork_mesh(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::from_cork_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::from_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template void igl::boolean::from_cork_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::boolean::from_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(CorkTriMesh const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 #endif
 
 #endif

+ 17 - 14
include/igl/boolean/from_cork_mesh.h

@@ -6,20 +6,23 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Convert cork's triangle mesh representation to a (V,F) mesh.
-  //
-  // Inputs:
-  //   mesh  cork representation of mesh
-  // Outputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  template <
-    typename DerivedV,
-    typename DerivedF>
-  IGL_INLINE void from_cork_mesh(
-    const CorkTriMesh & mesh,
-    Eigen::PlainObjectBase<DerivedV > & V,
-    Eigen::PlainObjectBase<DerivedF > & F);
+  namespace boolean
+  {
+    // Convert cork's triangle mesh representation to a (V,F) mesh.
+    //
+    // Inputs:
+    //   mesh  cork representation of mesh
+    // Outputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    template <
+      typename DerivedV,
+      typename DerivedF>
+    IGL_INLINE void from_cork_mesh(
+      const CorkTriMesh & mesh,
+      Eigen::PlainObjectBase<DerivedV > & V,
+      Eigen::PlainObjectBase<DerivedF > & F);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "from_cork_mesh.cpp"

+ 8 - 7
include/igl/boolean/mesh_boolean.cpp

@@ -18,7 +18,7 @@ template <
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedJ>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -45,7 +45,7 @@ template <
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedFC>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -73,7 +73,7 @@ template <
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedJ>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -93,6 +93,7 @@ IGL_INLINE void igl::mesh_boolean(
   using namespace Eigen;
   using namespace std;
   using namespace igl;
+  using namespace igl::cgal;
   MeshBooleanType eff_type = type;
   // Concatenate A and B into a single mesh
   typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
@@ -311,12 +312,12 @@ IGL_INLINE void igl::mesh_boolean(
 template void igl::remove_unreferenced<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, 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&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 
 #include <igl/cgal/peel_outer_hull_layers.cpp>
-template unsigned long igl::peel_outer_hull_layers<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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<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<double, -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 unsigned long igl::cgal::peel_outer_hull_layers<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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<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<double, -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> >&);
 
 #include <igl/cgal/outer_hull.cpp>
-template void igl::outer_hull<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::outer_hull<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 
 // Explicit template specialization
-template void igl::mesh_boolean<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::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> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::mesh_boolean<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::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<int, -1, -1, 0, -1, -1> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::boolean::mesh_boolean<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::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> > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::boolean::mesh_boolean<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::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<int, -1, -1, 0, -1, -1> > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 83 - 75
include/igl/boolean/mesh_boolean.h

@@ -8,81 +8,89 @@
 
 namespace igl
 {
-  //  MESH_BOOLEAN Compute boolean csg operations on "solid", consistently oriented
-  //  meshes.
-  // 
-  //  Inputs:
-  //    V  #V by 3 list of vertex positions of first mesh
-  //    F  #F by 3 list of triangle indices into V
-  //    U  #U by 3 list of vertex positions of second mesh
-  //    G  #G by 3 list of triangle indices into U
-  //    type  type of boolean operation
-  //  Outputs:
-  //    W  #W by 3 list of vertex positions of boolean result mesh
-  //    H  #H by 3 list of triangle indices into W
-  //    J  #H list of indices into [FA;FB] revealing "birth" facet
-  //  
-  //  See also: self_intersect
-  //     
-  template <
-    typename DerivedVA,
-    typename DerivedFA,
-    typename DerivedVB,
-    typename DerivedFB,
-    typename DerivedVC,
-    typename DerivedFC,
-    typename DerivedJ>
-  IGL_INLINE void mesh_boolean(
-    const Eigen::PlainObjectBase<DerivedVA > & VA,
-    const Eigen::PlainObjectBase<DerivedFA > & FA,
-    const Eigen::PlainObjectBase<DerivedVB > & VB,
-    const Eigen::PlainObjectBase<DerivedFB > & FB,
-    const MeshBooleanType & type,
-    Eigen::PlainObjectBase<DerivedVC > & VC,
-    Eigen::PlainObjectBase<DerivedFC > & FC,
-    Eigen::PlainObjectBase<DerivedJ > & J);
-  template <
-    typename DerivedVA,
-    typename DerivedFA,
-    typename DerivedVB,
-    typename DerivedFB,
-    typename DerivedVC,
-    typename DerivedFC>
-  IGL_INLINE void mesh_boolean(
-    const Eigen::PlainObjectBase<DerivedVA > & VA,
-    const Eigen::PlainObjectBase<DerivedFA > & FA,
-    const Eigen::PlainObjectBase<DerivedVB > & VB,
-    const Eigen::PlainObjectBase<DerivedFB > & FB,
-    const MeshBooleanType & type,
-    Eigen::PlainObjectBase<DerivedVC > & VC,
-    Eigen::PlainObjectBase<DerivedFC > & FC);
-  // Inputs:
-  //   resolve_fun  function handle for computing resolve of a
-  //     self-intersections of a mesh and outputting the new mesh.
-  template <
-    typename DerivedVA,
-    typename DerivedFA,
-    typename DerivedVB,
-    typename DerivedFB,
-    typename DerivedVC,
-    typename DerivedFC,
-    typename DerivedJ>
-  IGL_INLINE void mesh_boolean(
-    const Eigen::PlainObjectBase<DerivedVA > & VA,
-    const Eigen::PlainObjectBase<DerivedFA > & FA,
-    const Eigen::PlainObjectBase<DerivedVB > & VB,
-    const Eigen::PlainObjectBase<DerivedFB > & FB,
-    const MeshBooleanType & type,
-    const std::function<void(
-      const Eigen::Matrix<typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
-      const Eigen::Matrix<typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
-            Eigen::Matrix<typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
-            Eigen::Matrix<typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
-            Eigen::Matrix<typename  DerivedJ::Scalar,Eigen::Dynamic,1>&)> 
-      & resolve_fun,
-    Eigen::PlainObjectBase<DerivedVC > & VC,
-    Eigen::PlainObjectBase<DerivedFC > & FC,
-    Eigen::PlainObjectBase<DerivedJ > & J);
+  namespace boolean
+  {
+    //  MESH_BOOLEAN Compute boolean csg operations on "solid", consistently
+    //  oriented meshes.
+    // 
+    //  Inputs:
+    //    V  #V by 3 list of vertex positions of first mesh
+    //    F  #F by 3 list of triangle indices into V
+    //    U  #U by 3 list of vertex positions of second mesh
+    //    G  #G by 3 list of triangle indices into U
+    //    type  type of boolean operation
+    //  Outputs:
+    //    W  #W by 3 list of vertex positions of boolean result mesh
+    //    H  #H by 3 list of triangle indices into W
+    //    J  #H list of indices into [FA;FB] revealing "birth" facet
+    //  
+    //  See also: self_intersect
+    //     
+    template <
+      typename DerivedVA,
+               typename DerivedFA,
+               typename DerivedVB,
+               typename DerivedFB,
+               typename DerivedVC,
+               typename DerivedFC,
+               typename DerivedJ>
+                 IGL_INLINE void mesh_boolean(
+                     const Eigen::PlainObjectBase<DerivedVA > & VA,
+                     const Eigen::PlainObjectBase<DerivedFA > & FA,
+                     const Eigen::PlainObjectBase<DerivedVB > & VB,
+                     const Eigen::PlainObjectBase<DerivedFB > & FB,
+                     const MeshBooleanType & type,
+                     Eigen::PlainObjectBase<DerivedVC > & VC,
+                     Eigen::PlainObjectBase<DerivedFC > & FC,
+                     Eigen::PlainObjectBase<DerivedJ > & J);
+    template <
+      typename DerivedVA,
+               typename DerivedFA,
+               typename DerivedVB,
+               typename DerivedFB,
+               typename DerivedVC,
+               typename DerivedFC>
+                 IGL_INLINE void mesh_boolean(
+                     const Eigen::PlainObjectBase<DerivedVA > & VA,
+                     const Eigen::PlainObjectBase<DerivedFA > & FA,
+                     const Eigen::PlainObjectBase<DerivedVB > & VB,
+                     const Eigen::PlainObjectBase<DerivedFB > & FB,
+                     const MeshBooleanType & type,
+                     Eigen::PlainObjectBase<DerivedVC > & VC,
+                     Eigen::PlainObjectBase<DerivedFC > & FC);
+    // Inputs:
+    //   resolve_fun  function handle for computing resolve of a
+    //     self-intersections of a mesh and outputting the new mesh.
+    template <
+      typename DerivedVA,
+               typename DerivedFA,
+               typename DerivedVB,
+               typename DerivedFB,
+               typename DerivedVC,
+               typename DerivedFC,
+               typename DerivedJ>
+                 IGL_INLINE void mesh_boolean(
+                     const Eigen::PlainObjectBase<DerivedVA > & VA,
+                     const Eigen::PlainObjectBase<DerivedFA > & FA,
+                     const Eigen::PlainObjectBase<DerivedVB > & VB,
+                     const Eigen::PlainObjectBase<DerivedFB > & FB,
+                     const MeshBooleanType & type,
+                     const std::function<void(
+                       const Eigen::Matrix<
+                         typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
+                       const Eigen::Matrix<
+                         typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
+                       Eigen::Matrix<
+                         typename DerivedVC::Scalar,Eigen::Dynamic,3> &,
+                       Eigen::Matrix<
+                         typename DerivedFC::Scalar,Eigen::Dynamic,3> &,
+                       Eigen::Matrix<
+                         typename  DerivedJ::Scalar,Eigen::Dynamic,1>&)> 
+                     & resolve_fun,
+                     Eigen::PlainObjectBase<DerivedVC > & VC,
+                     Eigen::PlainObjectBase<DerivedFC > & FC,
+                     Eigen::PlainObjectBase<DerivedJ > & J);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 3 - 3
include/igl/boolean/mesh_boolean_cork.cpp

@@ -10,7 +10,7 @@ template <
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedFC>
-IGL_INLINE void igl::mesh_boolean_cork(
+IGL_INLINE void igl::boolean::mesh_boolean_cork(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -87,8 +87,8 @@ IGL_INLINE void igl::mesh_boolean_cork(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::mesh_boolean_cork<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::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> > const&, MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::mesh_boolean_cork<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template void igl::boolean::mesh_boolean_cork<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::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> > const&, MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::boolean::mesh_boolean_cork<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 #endif
 
 #endif

+ 29 - 26
include/igl/boolean/mesh_boolean_cork.h

@@ -8,32 +8,35 @@
 
 namespace igl
 {
-  // Compute a boolean operation on two input meshes using the cork library.
-  //
-  // Inputs:
-  //   VA  #VA by 3 list of vertex positions of first mesh
-  //   FA  #FA by 3 list of triangle indices into VA
-  //   VB  #VB by 3 list of vertex positions of second mesh
-  //   FB  #FB by 3 list of triangle indices into VB
-  //   type  of boolean operation see MeshBooleanType.h
-  // Outputs:
-  //   VC  #VC by 3 list of vertex positions of output mesh
-  //   FC  #FC by 3 list of triangle indices into VC
-  template <
-    typename DerivedVA,
-    typename DerivedFA,
-    typename DerivedVB,
-    typename DerivedFB,
-    typename DerivedVC,
-    typename DerivedFC>
-  IGL_INLINE void mesh_boolean_cork(
-    const Eigen::PlainObjectBase<DerivedVA > & VA,
-    const Eigen::PlainObjectBase<DerivedFA > & FA,
-    const Eigen::PlainObjectBase<DerivedVB > & VB,
-    const Eigen::PlainObjectBase<DerivedFB > & FB,
-    const MeshBooleanType & type,
-    Eigen::PlainObjectBase<DerivedVC > & VC,
-    Eigen::PlainObjectBase<DerivedFC > & FC);
+  namespace boolean
+  {
+    // Compute a boolean operation on two input meshes using the cork library.
+    //
+    // Inputs:
+    //   VA  #VA by 3 list of vertex positions of first mesh
+    //   FA  #FA by 3 list of triangle indices into VA
+    //   VB  #VB by 3 list of vertex positions of second mesh
+    //   FB  #FB by 3 list of triangle indices into VB
+    //   type  of boolean operation see MeshBooleanType.h
+    // Outputs:
+    //   VC  #VC by 3 list of vertex positions of output mesh
+    //   FC  #FC by 3 list of triangle indices into VC
+    template <
+      typename DerivedVA,
+      typename DerivedFA,
+      typename DerivedVB,
+      typename DerivedFB,
+      typename DerivedVC,
+      typename DerivedFC>
+    IGL_INLINE void mesh_boolean_cork(
+      const Eigen::PlainObjectBase<DerivedVA > & VA,
+      const Eigen::PlainObjectBase<DerivedFA > & FA,
+      const Eigen::PlainObjectBase<DerivedVB > & VB,
+      const Eigen::PlainObjectBase<DerivedFB > & FB,
+      const MeshBooleanType & type,
+      Eigen::PlainObjectBase<DerivedVC > & VC,
+      Eigen::PlainObjectBase<DerivedFC > & FC);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 3 - 3
include/igl/boolean/to_cork_mesh.cpp

@@ -3,7 +3,7 @@
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::to_cork_mesh(
+IGL_INLINE void igl::boolean::to_cork_mesh(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   CorkTriMesh & mesh)
@@ -32,7 +32,7 @@ IGL_INLINE void igl::to_cork_mesh(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::to_cork_mesh<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&, CorkTriMesh&);
-template void igl::to_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, CorkTriMesh&);
+template void igl::boolean::to_cork_mesh<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&, CorkTriMesh&);
+template void igl::boolean::to_cork_mesh<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, CorkTriMesh&);
 #endif
 #endif

+ 17 - 14
include/igl/boolean/to_cork_mesh.h

@@ -6,20 +6,23 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Convert a (V,F) mesh to a cork's triangle mesh representation.
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  // Outputs:
-  //   mesh  cork representation of mesh
-  template <
-    typename DerivedV,
-    typename DerivedF>
-  IGL_INLINE void to_cork_mesh(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    CorkTriMesh & mesh);
+  namespace boolean
+  {
+    // Convert a (V,F) mesh to a cork's triangle mesh representation.
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    // Outputs:
+    //   mesh  cork representation of mesh
+    template <
+      typename DerivedV,
+      typename DerivedF>
+    IGL_INLINE void to_cork_mesh(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      CorkTriMesh & mesh);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "to_cork_mesh.cpp"

+ 10 - 7
include/igl/cgal/RemeshSelfIntersectionsParam.h

@@ -10,14 +10,17 @@
 
 namespace igl
 {
-  // Optional Parameters
-  //   DetectOnly  Only compute IF, leave VV and FF alone
-  struct RemeshSelfIntersectionsParam
+  namespace cgal
   {
-    bool detect_only;
-    bool first_only;
-    RemeshSelfIntersectionsParam():detect_only(false),first_only(false){};
-  };
+    // Optional Parameters
+    //   DetectOnly  Only compute IF, leave VV and FF alone
+    struct RemeshSelfIntersectionsParam
+    {
+      bool detect_only;
+      bool first_only;
+      RemeshSelfIntersectionsParam():detect_only(false),first_only(false){};
+    };
+  }
 }
 
 #endif

+ 211 - 208
include/igl/cgal/SelfIntersectMesh.h

@@ -25,204 +25,207 @@
 
 namespace igl
 {
-  // Kernel is a CGAL kernel like:
-  //     CGAL::Exact_predicates_inexact_constructions_kernel
-  // or 
-  //     CGAL::Exact_predicates_exact_constructions_kernel
-
-  template <
-    typename Kernel,
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedVV,
-    typename DerivedFF,
-    typename DerivedIF,
-    typename DerivedJ,
-    typename DerivedIM>
-  class SelfIntersectMesh
+  namespace cgal
   {
-    typedef 
-      SelfIntersectMesh<
-      Kernel,
-      DerivedV,
-      DerivedF,
-      DerivedVV,
-      DerivedFF,
-      DerivedIF,
-      DerivedJ,
-      DerivedIM> Self;
-    public:
-      // 3D Primitives
-      typedef CGAL::Point_3<Kernel>    Point_3;
-      typedef CGAL::Segment_3<Kernel>  Segment_3; 
-      typedef CGAL::Triangle_3<Kernel> Triangle_3; 
-      typedef CGAL::Plane_3<Kernel>    Plane_3;
-      typedef CGAL::Tetrahedron_3<Kernel> Tetrahedron_3; 
-      //typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3; 
-      //typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron_3; 
-      // 2D Primitives
-      typedef CGAL::Point_2<Kernel>    Point_2;
-      typedef CGAL::Segment_2<Kernel>  Segment_2; 
-      typedef CGAL::Triangle_2<Kernel> Triangle_2; 
-      // 2D Constrained Delaunay Triangulation types
-      typedef CGAL::Triangulation_vertex_base_2<Kernel>  TVB_2;
-      typedef CGAL::Constrained_triangulation_face_base_2<Kernel> CTFB_2;
-      typedef CGAL::Triangulation_data_structure_2<TVB_2,CTFB_2> TDS_2;
-      typedef CGAL::Exact_intersections_tag Itag;
-      typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel,TDS_2,Itag> 
-        CDT_2;
-      typedef CGAL::Constrained_triangulation_plus_2<CDT_2> CDT_plus_2;
-      // Axis-align boxes for all-pairs self-intersection detection
-      typedef std::vector<Triangle_3> Triangles;
-      typedef typename Triangles::iterator TrianglesIterator;
-      typedef typename Triangles::const_iterator TrianglesConstIterator;
+    // Kernel is a CGAL kernel like:
+    //     CGAL::Exact_predicates_inexact_constructions_kernel
+    // or 
+    //     CGAL::Exact_predicates_exact_constructions_kernel
+  
+    template <
+      typename Kernel,
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedVV,
+      typename DerivedFF,
+      typename DerivedIF,
+      typename DerivedJ,
+      typename DerivedIM>
+    class SelfIntersectMesh
+    {
       typedef 
-        CGAL::Box_intersection_d::Box_with_handle_d<double,3,TrianglesIterator> 
-        Box;
-
-      // Input mesh
-      const Eigen::PlainObjectBase<DerivedV> & V;
-      const Eigen::PlainObjectBase<DerivedF> & F;
-      // Number of self-intersecting triangle pairs
-      typedef typename DerivedF::Index Index;
-      Index count;
-      typedef std::vector<CGAL::Object> ObjectList;
-      std::vector<ObjectList > F_objects;
-      Triangles T;
-      typedef std::vector<Index> IndexList;
-      IndexList lIF;
-      std::vector<bool> offensive;
-      std::vector<Index> offending_index;
-      std::vector<Index> offending;
-      // Make a short name for the edge map's key
-      typedef std::pair<Index,Index> EMK;
-      // Make a short name for the type stored at each edge, the edge map's
-      // value
-      typedef std::vector<Index> EMV;
-      // Make a short name for the edge map
-      typedef std::map<EMK,EMV> EdgeMap;
-      EdgeMap edge2faces;
-    public:
-      RemeshSelfIntersectionsParam params;
-    public:
-      // Constructs (VV,FF) a new mesh with self-intersections of (V,F)
-      // subdivided
-      //
-      // See also: remesh_self_intersections.h
-      inline SelfIntersectMesh(
-          const Eigen::PlainObjectBase<DerivedV> & V,
-          const Eigen::PlainObjectBase<DerivedF> & F,
-          const RemeshSelfIntersectionsParam & params,
-          Eigen::PlainObjectBase<DerivedVV> & VV,
-          Eigen::PlainObjectBase<DerivedFF> & FF,
-          Eigen::PlainObjectBase<DerivedIF> & IF,
-          Eigen::PlainObjectBase<DerivedJ> & J,
-          Eigen::PlainObjectBase<DerivedIM> & IM);
-    private:
-      // Helper function to mark a face as offensive
-      //
-      // Inputs:
-      //   f  index of face in F
-      inline void mark_offensive(const Index f);
-      // Helper function to count intersections between faces
-      //
-      // Input:
-      //   fa  index of face A in F
-      //   fb  index of face B in F
-      inline void count_intersection( const Index fa, const Index fb);
-      // Helper function for box_intersect. Intersect two triangles A and B,
-      // append the intersection object (point,segment,triangle) to a running
-      // list for A and B
-      //
-      // Inputs:
-      //   A  triangle in 3D
-      //   B  triangle in 3D
-      //   fa  index of A in F (and F_objects)
-      //   fb  index of A in F (and F_objects)
-      // Returns true only if A intersects B
-      //
-      inline bool intersect(
-          const Triangle_3 & A, 
-          const Triangle_3 & B, 
-          const Index fa,
-          const Index fb);
-      // Helper function for box_intersect. In the case where A and B have
-      // already been identified to share a vertex, then we only want to add
-      // possible segment intersections. Assumes truly duplicate triangles are
-      // not given as input
-      //
-      // Inputs:
-      //   A  triangle in 3D
-      //   B  triangle in 3D
-      //   fa  index of A in F (and F_objects)
-      //   fb  index of B in F (and F_objects)
-      //   va  index of shared vertex in A (and F_objects)
-      //   vb  index of shared vertex in B (and F_objects)
-      //// Returns object of intersection (should be Segment or point)
-      //   Returns true if intersection (besides shared point)
-      //
-      inline bool single_shared_vertex(
-          const Triangle_3 & A,
-          const Triangle_3 & B,
-          const Index fa,
-          const Index fb,
-          const Index va,
-          const Index vb);
-      // Helper handling one direction
-      inline bool single_shared_vertex(
-          const Triangle_3 & A,
-          const Triangle_3 & B,
-          const Index fa,
-          const Index fb,
-          const Index va);
-      // Helper function for box_intersect. In the case where A and B have
-      // already been identified to share two vertices, then we only want to add
-      // a possible coplanar (Triangle) intersection. Assumes truly degenerate
-      // facets are not givin as input.
-      inline bool double_shared_vertex(
-          const Triangle_3 & A,
-          const Triangle_3 & B,
-          const Index fa,
-          const Index fb);
-
-    public:
-      // Callback function called during box self intersections test. Means
-      // boxes a and b intersect. This method then checks if the triangles in
-      // each box intersect and if so, then processes the intersections
-      //
-      // Inputs:
-      //   a  box containing a triangle
-      //   b  box containing a triangle
-      inline void box_intersect(const Box& a, const Box& b);
-    private:
-      // Compute 2D delaunay triangulation of a given 3d triangle and a list of
-      // intersection objects (points,segments,triangles). CGAL uses an affine
-      // projection rather than an isometric projection, so we're not
-      // guaranteed that the 2D delaunay triangulation here will be a delaunay
-      // triangulation in 3D.
-      //
-      // Inputs:
-      //   A  triangle in 3D
-      //   A_objects_3  updated list of intersection objects for A
-      // Outputs:
-      //   cdt  Contrained delaunay triangulation in projected 2D plane
-      inline void projected_delaunay(
-          const Triangle_3 & A,
-          const ObjectList & A_objects_3,
-          CDT_plus_2 & cdt);
-      // Getters:
-    public:
-      //const IndexList& get_lIF() const{ return lIF;}
-      static inline void box_intersect_static(
-        SelfIntersectMesh * SIM, 
-        const Box &a, 
-        const Box &b);
-      // Annoying wrappers to conver from cgal to double or cgal
-      static inline void to_output_type(const typename Kernel::FT & cgal,double & d);
-      static inline void to_output_type(
-        const typename CGAL::Epeck::FT & cgal,
-        CGAL::Epeck::FT & d);
-  };
+        SelfIntersectMesh<
+        Kernel,
+        DerivedV,
+        DerivedF,
+        DerivedVV,
+        DerivedFF,
+        DerivedIF,
+        DerivedJ,
+        DerivedIM> Self;
+      public:
+        // 3D Primitives
+        typedef CGAL::Point_3<Kernel>    Point_3;
+        typedef CGAL::Segment_3<Kernel>  Segment_3; 
+        typedef CGAL::Triangle_3<Kernel> Triangle_3; 
+        typedef CGAL::Plane_3<Kernel>    Plane_3;
+        typedef CGAL::Tetrahedron_3<Kernel> Tetrahedron_3; 
+        //typedef CGAL::Polyhedron_3<Kernel> Polyhedron_3; 
+        //typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron_3; 
+        // 2D Primitives
+        typedef CGAL::Point_2<Kernel>    Point_2;
+        typedef CGAL::Segment_2<Kernel>  Segment_2; 
+        typedef CGAL::Triangle_2<Kernel> Triangle_2; 
+        // 2D Constrained Delaunay Triangulation types
+        typedef CGAL::Triangulation_vertex_base_2<Kernel>  TVB_2;
+        typedef CGAL::Constrained_triangulation_face_base_2<Kernel> CTFB_2;
+        typedef CGAL::Triangulation_data_structure_2<TVB_2,CTFB_2> TDS_2;
+        typedef CGAL::Exact_intersections_tag Itag;
+        typedef CGAL::Constrained_Delaunay_triangulation_2<Kernel,TDS_2,Itag> 
+          CDT_2;
+        typedef CGAL::Constrained_triangulation_plus_2<CDT_2> CDT_plus_2;
+        // Axis-align boxes for all-pairs self-intersection detection
+        typedef std::vector<Triangle_3> Triangles;
+        typedef typename Triangles::iterator TrianglesIterator;
+        typedef typename Triangles::const_iterator TrianglesConstIterator;
+        typedef 
+          CGAL::Box_intersection_d::Box_with_handle_d<double,3,TrianglesIterator> 
+          Box;
+  
+        // Input mesh
+        const Eigen::PlainObjectBase<DerivedV> & V;
+        const Eigen::PlainObjectBase<DerivedF> & F;
+        // Number of self-intersecting triangle pairs
+        typedef typename DerivedF::Index Index;
+        Index count;
+        typedef std::vector<CGAL::Object> ObjectList;
+        std::vector<ObjectList > F_objects;
+        Triangles T;
+        typedef std::vector<Index> IndexList;
+        IndexList lIF;
+        std::vector<bool> offensive;
+        std::vector<Index> offending_index;
+        std::vector<Index> offending;
+        // Make a short name for the edge map's key
+        typedef std::pair<Index,Index> EMK;
+        // Make a short name for the type stored at each edge, the edge map's
+        // value
+        typedef std::vector<Index> EMV;
+        // Make a short name for the edge map
+        typedef std::map<EMK,EMV> EdgeMap;
+        EdgeMap edge2faces;
+      public:
+        RemeshSelfIntersectionsParam params;
+      public:
+        // Constructs (VV,FF) a new mesh with self-intersections of (V,F)
+        // subdivided
+        //
+        // See also: remesh_self_intersections.h
+        inline SelfIntersectMesh(
+            const Eigen::PlainObjectBase<DerivedV> & V,
+            const Eigen::PlainObjectBase<DerivedF> & F,
+            const RemeshSelfIntersectionsParam & params,
+            Eigen::PlainObjectBase<DerivedVV> & VV,
+            Eigen::PlainObjectBase<DerivedFF> & FF,
+            Eigen::PlainObjectBase<DerivedIF> & IF,
+            Eigen::PlainObjectBase<DerivedJ> & J,
+            Eigen::PlainObjectBase<DerivedIM> & IM);
+      private:
+        // Helper function to mark a face as offensive
+        //
+        // Inputs:
+        //   f  index of face in F
+        inline void mark_offensive(const Index f);
+        // Helper function to count intersections between faces
+        //
+        // Input:
+        //   fa  index of face A in F
+        //   fb  index of face B in F
+        inline void count_intersection( const Index fa, const Index fb);
+        // Helper function for box_intersect. Intersect two triangles A and B,
+        // append the intersection object (point,segment,triangle) to a running
+        // list for A and B
+        //
+        // Inputs:
+        //   A  triangle in 3D
+        //   B  triangle in 3D
+        //   fa  index of A in F (and F_objects)
+        //   fb  index of A in F (and F_objects)
+        // Returns true only if A intersects B
+        //
+        inline bool intersect(
+            const Triangle_3 & A, 
+            const Triangle_3 & B, 
+            const Index fa,
+            const Index fb);
+        // Helper function for box_intersect. In the case where A and B have
+        // already been identified to share a vertex, then we only want to add
+        // possible segment intersections. Assumes truly duplicate triangles are
+        // not given as input
+        //
+        // Inputs:
+        //   A  triangle in 3D
+        //   B  triangle in 3D
+        //   fa  index of A in F (and F_objects)
+        //   fb  index of B in F (and F_objects)
+        //   va  index of shared vertex in A (and F_objects)
+        //   vb  index of shared vertex in B (and F_objects)
+        //// Returns object of intersection (should be Segment or point)
+        //   Returns true if intersection (besides shared point)
+        //
+        inline bool single_shared_vertex(
+            const Triangle_3 & A,
+            const Triangle_3 & B,
+            const Index fa,
+            const Index fb,
+            const Index va,
+            const Index vb);
+        // Helper handling one direction
+        inline bool single_shared_vertex(
+            const Triangle_3 & A,
+            const Triangle_3 & B,
+            const Index fa,
+            const Index fb,
+            const Index va);
+        // Helper function for box_intersect. In the case where A and B have
+        // already been identified to share two vertices, then we only want to add
+        // a possible coplanar (Triangle) intersection. Assumes truly degenerate
+        // facets are not givin as input.
+        inline bool double_shared_vertex(
+            const Triangle_3 & A,
+            const Triangle_3 & B,
+            const Index fa,
+            const Index fb);
+  
+      public:
+        // Callback function called during box self intersections test. Means
+        // boxes a and b intersect. This method then checks if the triangles in
+        // each box intersect and if so, then processes the intersections
+        //
+        // Inputs:
+        //   a  box containing a triangle
+        //   b  box containing a triangle
+        inline void box_intersect(const Box& a, const Box& b);
+      private:
+        // Compute 2D delaunay triangulation of a given 3d triangle and a list of
+        // intersection objects (points,segments,triangles). CGAL uses an affine
+        // projection rather than an isometric projection, so we're not
+        // guaranteed that the 2D delaunay triangulation here will be a delaunay
+        // triangulation in 3D.
+        //
+        // Inputs:
+        //   A  triangle in 3D
+        //   A_objects_3  updated list of intersection objects for A
+        // Outputs:
+        //   cdt  Contrained delaunay triangulation in projected 2D plane
+        inline void projected_delaunay(
+            const Triangle_3 & A,
+            const ObjectList & A_objects_3,
+            CDT_plus_2 & cdt);
+        // Getters:
+      public:
+        //const IndexList& get_lIF() const{ return lIF;}
+        static inline void box_intersect_static(
+          SelfIntersectMesh * SIM, 
+          const Box &a, 
+          const Box &b);
+        // Annoying wrappers to conver from cgal to double or cgal
+        static inline void to_output_type(const typename Kernel::FT & cgal,double & d);
+        static inline void to_output_type(
+          const typename CGAL::Epeck::FT & cgal,
+          CGAL::Epeck::FT & d);
+    };
+  }
 }
 
 // Implementation
@@ -274,7 +277,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -299,7 +302,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline igl::SelfIntersectMesh<
+inline igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -668,7 +671,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -716,7 +719,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -747,7 +750,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -786,7 +789,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -832,7 +835,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -913,7 +916,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -993,7 +996,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -1147,7 +1150,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -1223,7 +1226,7 @@ template <
   typename DerivedIM>
 inline 
 void 
-igl::SelfIntersectMesh<
+igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -1249,7 +1252,7 @@ template <
   typename DerivedIM>
 inline 
 void 
-igl::SelfIntersectMesh<
+igl::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,

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

@@ -16,7 +16,7 @@
 #include <stack>
 
 template <typename Tr, typename DerivedV, typename DerivedF>
-IGL_INLINE bool igl::complex_to_mesh(
+IGL_INLINE bool igl::cgal::complex_to_mesh(
   const CGAL::Complex_2_in_triangulation_3<Tr> & c2t3,
   Eigen::PlainObjectBase<DerivedV> & V, 
   Eigen::PlainObjectBase<DerivedF> & F)
@@ -147,5 +147,5 @@ IGL_INLINE bool igl::complex_to_mesh(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-template bool igl::complex_to_mesh<CGAL::Delaunay_triangulation_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_data_structure_3<CGAL::Surface_mesh_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Surface_mesh_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_cell_base_3<void> > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(CGAL::Complex_2_in_triangulation_3<CGAL::Delaunay_triangulation_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_data_structure_3<CGAL::Surface_mesh_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Surface_mesh_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_cell_base_3<void> > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, void> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::cgal::complex_to_mesh<CGAL::Delaunay_triangulation_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_data_structure_3<CGAL::Surface_mesh_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Surface_mesh_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_cell_base_3<void> > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(CGAL::Complex_2_in_triangulation_3<CGAL::Delaunay_triangulation_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_data_structure_3<CGAL::Surface_mesh_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_vertex_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_vertex_base_3<void> > >, CGAL::Delaunay_triangulation_cell_base_with_circumcenter_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Surface_mesh_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_cell_base_3<CGAL::Robust_circumcenter_traits_3<CGAL::Epick>, CGAL::Triangulation_ds_cell_base_3<void> > > >, CGAL::Sequential_tag>, CGAL::Default, CGAL::Default>, void> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 20 - 17
include/igl/cgal/complex_to_mesh.h

@@ -14,23 +14,26 @@
 
 namespace igl 
 {
-  // Templates:
-  //   Tr  CGAL triangulation type, e.g.
-  //     CGAL::Surface_mesh_default_triangulation_3
-  // Inputs
-  //   c2t3  2-complex (surface) living in a 3d triangulation (e.g. result of
-  //     CGAL::make_surface_mesh)
-  // Outputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices
-  // Returns true iff conversion was successful, failure can ok if CGAL code
-  // can't figure out ordering.
-  //
-  template <typename Tr, typename DerivedV, typename DerivedF>
-  IGL_INLINE bool complex_to_mesh(
-    const CGAL::Complex_2_in_triangulation_3<Tr> & c2t3,
-    Eigen::PlainObjectBase<DerivedV> & V, 
-    Eigen::PlainObjectBase<DerivedF> & F);
+  namespace cgal
+  {
+    // Templates:
+    //   Tr  CGAL triangulation type, e.g.
+    //     CGAL::Surface_mesh_default_triangulation_3
+    // Inputs
+    //   c2t3  2-complex (surface) living in a 3d triangulation (e.g. result of
+    //     CGAL::make_surface_mesh)
+    // Outputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices
+    // Returns true iff conversion was successful, failure can ok if CGAL code
+    // can't figure out ordering.
+    //
+    template <typename Tr, typename DerivedV, typename DerivedF>
+    IGL_INLINE bool complex_to_mesh(
+      const CGAL::Complex_2_in_triangulation_3<Tr> & c2t3,
+      Eigen::PlainObjectBase<DerivedV> & V, 
+      Eigen::PlainObjectBase<DerivedF> & F);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 1 - 1
include/igl/cgal/intersect_other.cpp

@@ -13,7 +13,7 @@
 #define IGL_FIRST_HIT_EXCEPTION 10
 #endif
 
-IGL_INLINE void igl::intersect_other(
+IGL_INLINE void igl::cgal::intersect_other(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & U,

+ 26 - 23
include/igl/cgal/intersect_other.h

@@ -20,29 +20,32 @@
 
 namespace igl
 {
-  // INTERSECT Given a triangle mesh (V,F) and another mesh (U,G) find all pairs
-  // of intersecting faces. Note that self-intersections are ignored.
-  // 
-  // [VV,FF,IF] = selfintersect(V,F,'ParameterName',ParameterValue, ...)
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  //   U  #U by 3 list of vertex positions
-  //   G  #G by 3 list of triangle indices into U
-  //   first_only  whether to only detect the first intersection.
-  // Outputs:
-  //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
-  //     indexing F and G
-  //
-  // See also: selfintersect
-  IGL_INLINE void intersect_other(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & U,
-    const Eigen::MatrixXi & G,
-    const bool first_only,
-    Eigen::MatrixXi & IF);
+  namespace cgal
+  {
+    // INTERSECT Given a triangle mesh (V,F) and another mesh (U,G) find all pairs
+    // of intersecting faces. Note that self-intersections are ignored.
+    // 
+    // [VV,FF,IF] = selfintersect(V,F,'ParameterName',ParameterValue, ...)
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    //   U  #U by 3 list of vertex positions
+    //   G  #G by 3 list of triangle indices into U
+    //   first_only  whether to only detect the first intersection.
+    // Outputs:
+    //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
+    //     indexing F and G
+    //
+    // See also: selfintersect
+    IGL_INLINE void intersect_other(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      const Eigen::MatrixXd & U,
+      const Eigen::MatrixXi & G,
+      const bool first_only,
+      Eigen::MatrixXi & IF);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

@@ -13,7 +13,7 @@ template <
   typename DerivedV,
   typename DerivedF,
   typename Kernel>
-IGL_INLINE void igl::mesh_to_cgal_triangle_list(
+IGL_INLINE void igl::cgal::mesh_to_cgal_triangle_list(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   std::vector<CGAL::Triangle_3<Kernel> > & T)
@@ -38,8 +38,8 @@ IGL_INLINE void igl::mesh_to_cgal_triangle_list(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(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::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
-template void igl::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::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::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<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(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::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
+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> > >&);
 #endif

+ 21 - 18
include/igl/cgal/mesh_to_cgal_triangle_list.h

@@ -12,24 +12,27 @@
 #include "CGAL_includes.hpp"
 namespace igl
 {
-  // Convert a mesh (V,F) to a list of CGAL triangles
-  //
-  // Templates:
-  //   Kernal  CGAL computation and construction kernel (e.g.
-  //     CGAL::Exact_predicates_exact_constructions_kernel)
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices
-  // Outputs:
-  //   T  #F list of CGAL triangles
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename Kernel>
-  IGL_INLINE void mesh_to_cgal_triangle_list(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    std::vector<CGAL::Triangle_3<Kernel> > & T);
+  namespace cgal
+  {
+    // Convert a mesh (V,F) to a list of CGAL triangles
+    //
+    // Templates:
+    //   Kernal  CGAL computation and construction kernel (e.g.
+    //     CGAL::Exact_predicates_exact_constructions_kernel)
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices
+    // Outputs:
+    //   T  #F list of CGAL triangles
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename Kernel>
+    IGL_INLINE void mesh_to_cgal_triangle_list(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      std::vector<CGAL::Triangle_3<Kernel> > & T);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "mesh_to_cgal_triangle_list.cpp"

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

@@ -11,7 +11,7 @@
 
 
 template <typename Polyhedron>
-IGL_INLINE bool igl::mesh_to_polyhedron(
+IGL_INLINE bool igl::cgal::mesh_to_polyhedron(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   Polyhedron & poly)
@@ -50,5 +50,5 @@ IGL_INLINE bool igl::mesh_to_polyhedron(
 // Explicit template instanciation
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.h>
-template bool igl::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
+template bool igl::cgal::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
 #endif

+ 19 - 16
include/igl/cgal/mesh_to_polyhedron.h

@@ -12,22 +12,25 @@
 
 namespace igl
 {
-  // Convert a mesh (V,F) to a CGAL Polyhedron
-  //
-  // Templates:
-  //   Polyhedron  CGAL Polyhedron type (e.g. Polyhedron_3)
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices
-  // Outputs:
-  //   poly  cgal polyhedron
-  // Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if
-  // (V,F) is vertex and edge manifold).
-  template <typename Polyhedron>
-  IGL_INLINE bool mesh_to_polyhedron(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    Polyhedron & poly);
+  namespace cgal
+  {
+    // Convert a mesh (V,F) to a CGAL Polyhedron
+    //
+    // Templates:
+    //   Polyhedron  CGAL Polyhedron type (e.g. Polyhedron_3)
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices
+    // Outputs:
+    //   poly  cgal polyhedron
+    // Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if
+    // (V,F) is vertex and edge manifold).
+    template <typename Polyhedron>
+    IGL_INLINE bool mesh_to_polyhedron(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      Polyhedron & poly);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "mesh_to_polyhedron.cpp"

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

@@ -16,7 +16,7 @@ template<
 IGL_INLINE
 typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
 typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
-igl::order_facets_around_edges(
+igl::cgal::order_facets_around_edges(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,
@@ -160,7 +160,7 @@ template<
 IGL_INLINE 
 typename std::enable_if<std::is_same<typename DerivedV::Scalar,
 typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
-igl::order_facets_around_edges(
+igl::cgal::order_facets_around_edges(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,

+ 5 - 1
include/igl/cgal/order_facets_around_edges.h

@@ -5,7 +5,10 @@
 #include <Eigen/Core>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
-namespace igl {
+namespace igl
+{
+  namespace cgal
+  {
     // For each undirected edge, sort its adjacent faces.
     //
     // Inputs:
@@ -70,6 +73,7 @@ namespace igl {
             const std::vector<std::vector<uE2EType> >& uE2E,
             std::vector<std::vector<uE2oEType> >& uE2oE,
             std::vector<std::vector<uE2CType > >& uE2C );
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 5 - 5
include/igl/cgal/outer_hull.cpp

@@ -27,7 +27,7 @@ template <
   typename DerivedG,
   typename DerivedJ,
   typename Derivedflip>
-IGL_INLINE void igl::outer_hull(
+IGL_INLINE void igl::cgal::outer_hull(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedN> & N,
@@ -512,7 +512,7 @@ template <
   typename DerivedG,
   typename DerivedJ,
   typename Derivedflip>
-IGL_INLINE void igl::outer_hull(
+IGL_INLINE void igl::cgal::outer_hull(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedG> & G,
@@ -532,7 +532,7 @@ IGL_INLINE void igl::outer_hull(
 #include <igl/outer_facet.cpp>
 #include <igl/cgal/order_facets_around_edges.cpp>
 #define IGL_STATIC_LIBRARY
-template void igl::outer_hull<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -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<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
-template void igl::outer_hull<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::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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::outer_hull<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::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::outer_hull<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -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<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::outer_hull<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::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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::outer_hull<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::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 #endif

+ 47 - 44
include/igl/cgal/outer_hull.h

@@ -4,50 +4,53 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Compute the "outer hull" of a potentially non-manifold mesh (V,F) whose
-  // intersections have been "resolved" (e.g. using `cork` or
-  // `igl::selfintersect`). The outer hull is defined to be all facets
-  // (regardless of orientation) for which there exists some path from infinity
-  // to the face without intersecting any other facets. For solids, this is the
-  // surface of the solid. In general this includes any thin "wings" or "flaps".
-  // This implementation largely follows Section 3.6 of "Direct repair of
-  // self-intersecting meshes" [Attene 2014].
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  //   N  #F by 3 list of per-face normals
-  // Outputs:
-  //   G  #G by 3 list of output triangle indices into V
-  //   J  #G list of indices into F
-  //   flip  #F list of whether facet was added to G **and** flipped orientation
-  //     (false for faces not added to G)
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedN,
-    typename DerivedG,
-    typename DerivedJ,
-    typename Derivedflip>
-  IGL_INLINE void outer_hull(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    const Eigen::PlainObjectBase<DerivedN> & N,
-    Eigen::PlainObjectBase<DerivedG> & G,
-    Eigen::PlainObjectBase<DerivedJ> & J,
-    Eigen::PlainObjectBase<Derivedflip> & flip);
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedG,
-    typename DerivedJ,
-    typename Derivedflip>
-  IGL_INLINE void outer_hull(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    Eigen::PlainObjectBase<DerivedG> & G,
-    Eigen::PlainObjectBase<DerivedJ> & J,
-    Eigen::PlainObjectBase<Derivedflip> & flip);
+  namespace cgal
+  {
+    // Compute the "outer hull" of a potentially non-manifold mesh (V,F) whose
+    // intersections have been "resolved" (e.g. using `cork` or
+    // `igl::cgal::selfintersect`). The outer hull is defined to be all facets
+    // (regardless of orientation) for which there exists some path from infinity
+    // to the face without intersecting any other facets. For solids, this is the
+    // surface of the solid. In general this includes any thin "wings" or
+    // "flaps".  This implementation largely follows Section 3.6 of "Direct
+    // repair of self-intersecting meshes" [Attene 2014].
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    //   N  #F by 3 list of per-face normals
+    // Outputs:
+    //   G  #G by 3 list of output triangle indices into V
+    //   J  #G list of indices into F
+    //   flip  #F list of whether facet was added to G **and** flipped orientation
+    //     (false for faces not added to G)
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedN,
+      typename DerivedG,
+      typename DerivedJ,
+      typename Derivedflip>
+    IGL_INLINE void outer_hull(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      const Eigen::PlainObjectBase<DerivedN> & N,
+      Eigen::PlainObjectBase<DerivedG> & G,
+      Eigen::PlainObjectBase<DerivedJ> & J,
+      Eigen::PlainObjectBase<Derivedflip> & flip);
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedG,
+      typename DerivedJ,
+      typename Derivedflip>
+    IGL_INLINE void outer_hull(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      Eigen::PlainObjectBase<DerivedG> & G,
+      Eigen::PlainObjectBase<DerivedJ> & J,
+      Eigen::PlainObjectBase<Derivedflip> & flip);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

@@ -17,7 +17,7 @@ template <
   typename DerivedN,
   typename Derivedodd,
   typename Derivedflip>
-IGL_INLINE size_t igl::peel_outer_hull_layers(
+IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedN > & N,
@@ -113,7 +113,7 @@ template <
   typename DerivedF,
   typename Derivedodd,
   typename Derivedflip>
-IGL_INLINE size_t igl::peel_outer_hull_layers(
+IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   Eigen::PlainObjectBase<Derivedodd > & odd,
@@ -127,6 +127,6 @@ IGL_INLINE size_t igl::peel_outer_hull_layers(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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> >&);
-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<double, -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<double, -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::cgal::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> >&);
+template size_t igl::cgal::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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<double, -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

+ 39 - 36
include/igl/cgal/peel_outer_hull_layers.h

@@ -4,42 +4,45 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Computes necessary generic information for boolean operations by
-  // 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
-  //   N  #F by 3 list of per-face normals
-  // Outputs:
-  //   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
-  //     "peeled" into its associated outer hull layer.
-  // Returns number of peels
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedN,
-    typename Derivedodd,
-    typename Derivedflip>
-  IGL_INLINE size_t peel_outer_hull_layers(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    const Eigen::PlainObjectBase<DerivedN > & N,
-    Eigen::PlainObjectBase<Derivedodd > & odd,
-    Eigen::PlainObjectBase<Derivedflip > & flip);
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename Derivedodd,
-    typename Derivedflip>
-  IGL_INLINE size_t peel_outer_hull_layers(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    Eigen::PlainObjectBase<Derivedodd > & odd,
-    Eigen::PlainObjectBase<Derivedflip > & flip);
+  namespace cgal
+  {
+    // Computes necessary generic information for boolean operations by
+    // 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
+    //   N  #F by 3 list of per-face normals
+    // Outputs:
+    //   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
+    //     "peeled" into its associated outer hull layer.
+    // Returns number of peels
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedN,
+      typename Derivedodd,
+      typename Derivedflip>
+    IGL_INLINE size_t peel_outer_hull_layers(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      const Eigen::PlainObjectBase<DerivedN > & N,
+      Eigen::PlainObjectBase<Derivedodd > & odd,
+      Eigen::PlainObjectBase<Derivedflip > & flip);
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename Derivedodd,
+      typename Derivedflip>
+    IGL_INLINE size_t peel_outer_hull_layers(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      Eigen::PlainObjectBase<Derivedodd > & odd,
+      Eigen::PlainObjectBase<Derivedflip > & flip);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

@@ -9,7 +9,7 @@
 #include <CGAL/Polyhedron_3.h>
 
 template <typename Polyhedron>
-IGL_INLINE void igl::polyhedron_to_mesh(
+IGL_INLINE void igl::cgal::polyhedron_to_mesh(
   const Polyhedron & poly,
   Eigen::MatrixXd & V,
   Eigen::MatrixXi & F)
@@ -60,5 +60,5 @@ IGL_INLINE void igl::polyhedron_to_mesh(
 // Explicit template instanciation
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.h>
-template void igl::polyhedron_to_mesh<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
+template void igl::cgal::polyhedron_to_mesh<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
 #endif

+ 17 - 14
include/igl/cgal/polyhedron_to_mesh.h

@@ -12,20 +12,23 @@
 
 namespace igl
 {
-  // Convert a CGAL Polyhedron to a mesh (V,F)
-  //
-  // Templates:
-  //   Polyhedron  CGAL Polyhedron type (e.g. Polyhedron_3)
-  // Inputs:
-  //   poly  cgal polyhedron
-  // Outputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices
-  template <typename Polyhedron>
-  IGL_INLINE void polyhedron_to_mesh(
-    const Polyhedron & poly,
-    Eigen::MatrixXd & V,
-    Eigen::MatrixXi & F);
+  namespace cgal
+  {
+    // Convert a CGAL Polyhedron to a mesh (V,F)
+    //
+    // Templates:
+    //   Polyhedron  CGAL Polyhedron type (e.g. Polyhedron_3)
+    // Inputs:
+    //   poly  cgal polyhedron
+    // Outputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices
+    template <typename Polyhedron>
+    IGL_INLINE void polyhedron_to_mesh(
+      const Polyhedron & poly,
+      Eigen::MatrixXd & V,
+      Eigen::MatrixXi & F);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "polyhedron_to_mesh.cpp"

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

@@ -19,7 +19,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-IGL_INLINE void igl::remesh_self_intersections(
+IGL_INLINE void igl::cgal::remesh_self_intersections(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const RemeshSelfIntersectionsParam & params,
@@ -82,7 +82,7 @@ IGL_INLINE void igl::remesh_self_intersections(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::remesh_self_intersections<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::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&, igl::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, 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&, igl::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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&, igl::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::remesh_self_intersections<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::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&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, 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&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 55 - 52
include/igl/cgal/remesh_self_intersections.h

@@ -21,58 +21,61 @@
   
 namespace igl
 {
-  // Given a triangle mesh (V,F) compute a new mesh (VV,FF) which is the same
-  // as (V,F) except that any self-intersecting triangles in (V,F) have been
-  // subdivided (new vertices and face created) so that the self-intersection
-  // contour lies exactly on edges in (VV,FF). New vertices will appear in
-  // original faces or on original edges. New vertices on edges are "merged"
-  // only across original faces sharing that edge. This means that if the input
-  // triangle mesh is a closed manifold the output will be too.
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  //   params  struct of optional parameters
-  // Outputs:
-  //   VV  #VV by 3 list of vertex positions
-  //   FF  #FF by 3 list of triangle indices into V
-  //   IF  #intersecting face pairs by 2  list of intersecting face pairs,
-  //     indexing F
-  //   J  #FF list of indices into F denoting birth triangle
-  //   IM  #VV list of indices into VV of unique vertices.
-  //
-  // Known bugs: If an existing edge in (V,F) lies exactly on another face then
-  // any resulting additional vertices along that edge may not get properly
-  // connected so that the output mesh has the same global topology. This is
-  // because 
-  //
-  // Example:
-  //     // resolve intersections
-  //     igl::remesh_self_intersections(V,F,params,VV,FF,IF,J,IM);
-  //     // _apply_ duplicate vertex mapping IM to FF
-  //     for_each(FF.data(),FF.data()+FF.size(),[&IM](int & a){a=IM(a);});
-  //     // remove any vertices now unreferenced after duplicate mapping.
-  //     igl::remove_unreferenced(VV,FF,SV,SF,UIM);
-  //     // Now (SV,SF) is ready to extract outer hull
-  //     igl::outer_hull(SV,SF,G,J,flip);
-  //
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedVV,
-    typename DerivedFF,
-    typename DerivedIF,
-    typename DerivedJ,
-    typename DerivedIM>
-  IGL_INLINE void remesh_self_intersections(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    const RemeshSelfIntersectionsParam & params,
-    Eigen::PlainObjectBase<DerivedVV> & VV,
-    Eigen::PlainObjectBase<DerivedFF> & FF,
-    Eigen::PlainObjectBase<DerivedIF> & IF,
-    Eigen::PlainObjectBase<DerivedJ> & J,
-    Eigen::PlainObjectBase<DerivedIM> & IM);
+  namespace cgal
+  {
+    // Given a triangle mesh (V,F) compute a new mesh (VV,FF) which is the same
+    // as (V,F) except that any self-intersecting triangles in (V,F) have been
+    // subdivided (new vertices and face created) so that the self-intersection
+    // contour lies exactly on edges in (VV,FF). New vertices will appear in
+    // original faces or on original edges. New vertices on edges are "merged"
+    // only across original faces sharing that edge. This means that if the input
+    // triangle mesh is a closed manifold the output will be too.
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    //   params  struct of optional parameters
+    // Outputs:
+    //   VV  #VV by 3 list of vertex positions
+    //   FF  #FF by 3 list of triangle indices into V
+    //   IF  #intersecting face pairs by 2  list of intersecting face pairs,
+    //     indexing F
+    //   J  #FF list of indices into F denoting birth triangle
+    //   IM  #VV list of indices into VV of unique vertices.
+    //
+    // Known bugs: If an existing edge in (V,F) lies exactly on another face then
+    // any resulting additional vertices along that edge may not get properly
+    // connected so that the output mesh has the same global topology. This is
+    // because 
+    //
+    // Example:
+    //     // resolve intersections
+    //     igl::cgal::remesh_self_intersections(V,F,params,VV,FF,IF,J,IM);
+    //     // _apply_ duplicate vertex mapping IM to FF
+    //     for_each(FF.data(),FF.data()+FF.size(),[&IM](int & a){a=IM(a);});
+    //     // remove any vertices now unreferenced after duplicate mapping.
+    //     igl::remove_unreferenced(VV,FF,SV,SF,UIM);
+    //     // Now (SV,SF) is ready to extract outer hull
+    //     igl::cgal::outer_hull(SV,SF,G,J,flip);
+    //
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedVV,
+      typename DerivedFF,
+      typename DerivedIF,
+      typename DerivedJ,
+      typename DerivedIM>
+    IGL_INLINE void remesh_self_intersections(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      const RemeshSelfIntersectionsParam & params,
+      Eigen::PlainObjectBase<DerivedVV> & VV,
+      Eigen::PlainObjectBase<DerivedFF> & FF,
+      Eigen::PlainObjectBase<DerivedIF> & IF,
+      Eigen::PlainObjectBase<DerivedJ> & J,
+      Eigen::PlainObjectBase<DerivedIM> & IM);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

@@ -29,7 +29,7 @@
 #include <CGAL/AABB_triangle_primitive.h>
 #include <vector>
 
-IGL_INLINE bool igl::signed_distance_isosurface(
+IGL_INLINE bool igl::cgal::signed_distance_isosurface(
   const Eigen::MatrixXd & IV,
   const Eigen::MatrixXi & IF,
   const double level,
@@ -136,5 +136,5 @@ IGL_INLINE bool igl::signed_distance_isosurface(
   // meshing surface
   CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Manifold_tag());
   // complex to (V,F)
-  return igl::complex_to_mesh(c2t3,V,F);
+  return igl::cgal::complex_to_mesh(c2t3,V,F);
 }

+ 29 - 26
include/igl/cgal/signed_distance_isosurface.h

@@ -12,32 +12,35 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // SIGNED_DISTANCE_ISOSURFACE Compute the contour of an iso-level of the
-  // signed distance field to a given mesh.
-  //
-  // Inputs:
-  //   IV  #IV by 3 list of input mesh vertex positions
-  //   IF  #IF by 3 list of input triangle indices
-  //   level  iso-level to contour in world coords, negative is inside.
-  //   angle_bound  lower bound on triangle angles (mesh quality) (e.g. 28)
-  //   radius_bound  upper bound on triangle size (mesh density?) (e.g. 0.02)
-  //   distance_bound  cgal mysterious parameter (mesh density?) (e.g. 0.01)
-  //   sign_type  method for computing distance _sign_ (see
-  //     ../signed_distance.h)
-  // Outputs:
-  //   V  #V by 3 list of input mesh vertex positions
-  //   F  #F by 3 list of input triangle indices
-  //  
-  IGL_INLINE bool signed_distance_isosurface(
-    const Eigen::MatrixXd & IV,
-    const Eigen::MatrixXi & IF,
-    const double level,
-    const double angle_bound,
-    const double radius_bound,
-    const double distance_bound,
-    const SignedDistanceType sign_type,
-    Eigen::MatrixXd & V,
-    Eigen::MatrixXi & F);
+  namespace cgal
+  {
+    // SIGNED_DISTANCE_ISOSURFACE Compute the contour of an iso-level of the
+    // signed distance field to a given mesh.
+    //
+    // Inputs:
+    //   IV  #IV by 3 list of input mesh vertex positions
+    //   IF  #IF by 3 list of input triangle indices
+    //   level  iso-level to contour in world coords, negative is inside.
+    //   angle_bound  lower bound on triangle angles (mesh quality) (e.g. 28)
+    //   radius_bound  upper bound on triangle size (mesh density?) (e.g. 0.02)
+    //   distance_bound  cgal mysterious parameter (mesh density?) (e.g. 0.01)
+    //   sign_type  method for computing distance _sign_ (see
+    //     ../signed_distance.h)
+    // Outputs:
+    //   V  #V by 3 list of input mesh vertex positions
+    //   F  #F by 3 list of input triangle indices
+    //  
+    IGL_INLINE bool signed_distance_isosurface(
+      const Eigen::MatrixXd & IV,
+      const Eigen::MatrixXi & IF,
+      const double level,
+      const double angle_bound,
+      const double radius_bound,
+      const double distance_bound,
+      const SignedDistanceType sign_type,
+      Eigen::MatrixXd & V,
+      Eigen::MatrixXi & F);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 5 - 1
include/igl/comiso/frame_field.cpp

@@ -8,6 +8,8 @@
 
 namespace igl
 {
+namespace comiso
+{
 
 class FrameInterpolator
 {
@@ -642,9 +644,11 @@ Eigen::MatrixXd FrameInterpolator::getFieldPerFace()
 }
 
 }
+namespace igl
+{
 
 
-IGL_INLINE void igl::frame_field(
+IGL_INLINE void igl::comiso::frame_field(
                                  const Eigen::MatrixXd& V,
                                  const Eigen::MatrixXi& F,
                                  const Eigen::VectorXi& b,

+ 3 - 0
include/igl/comiso/frame_field.h

@@ -14,6 +14,8 @@
 
 namespace igl
 {
+namespace comiso
+{
 // Generate a piecewise-constant frame-field field from a sparse set of constraints on faces
 // using the algorithm proposed in:
 // Frame Fields: Anisotropic and Non-Orthogonal Cross Fields
@@ -42,6 +44,7 @@ IGL_INLINE void frame_field(
   Eigen::MatrixXd& FF2
   );
 }
+}
 
 #ifndef IGL_STATIC_LIBRARY
 #  include "frame_field.cpp"

+ 1 - 1
include/igl/comiso/miq.cpp.REMOVED.git-id

@@ -1 +1 @@
-53de49ce1ce4a0b841b852e3e973c71387a7bcae
+16464c7ad8917249fdb40e5b2be12ab61090ce28

+ 78 - 74
include/igl/comiso/miq.h

@@ -13,80 +13,84 @@
 
 namespace igl
 {
-  // Global seamless parametrization aligned with a given per-face jacobian (PD1,PD2).
-  // The algorithm is based on
-  // "Mixed-Integer Quadrangulation" by D. Bommes, H. Zimmer, L. Kobbelt
-  // ACM SIGGRAPH 2009, Article No. 77 (http://dl.acm.org/citation.cfm?id=1531383)
-  // We thank Nico Pietroni for providing a reference implementation of MIQ
-  // on which our code is based.
-
-  // Inputs:
-  //   V              #V by 3 list of mesh vertex 3D positions
-  //   F              #F by 3 list of faces indices in V
-  //   PD1            #V by 3 first line of the Jacobian per triangle
-  //   PD2            #V by 3 second line of the Jacobian per triangle
-  //                  (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
-  //   scale          global scaling for the gradient (controls the quads resolution)
-  //   stiffness      weight for the stiffness iterations
-  //   direct_round   greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
-  //   iter           stiffness iterations (0 = no stiffness)
-  //   local_iter     number of local iterations for the integer rounding
-  //   do_round       enables the integer rounding (disabling it could be useful for debugging)
-  //   round_vertices id of additional vertices that should be snapped to integer coordinates
-  //   hard_features  #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
-  //
-  // Output:
-  //   UV             #UV by 2 list of vertices in 2D
-  //   FUV            #FUV by 3 list of face indices in UV
-  //
-  // TODO: rename the parameters name in the cpp consistenly
-  //       improve the handling of hard_features, right now it might fail in difficult cases
-
-  template <typename DerivedV, typename DerivedF, typename DerivedU>
-  IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
-                                              const Eigen::PlainObjectBase<DerivedF> &F,
-                                              const Eigen::PlainObjectBase<DerivedV> &PD1,
-                                              const Eigen::PlainObjectBase<DerivedV> &PD2,
-                                              Eigen::PlainObjectBase<DerivedU> &UV,
-                                              Eigen::PlainObjectBase<DerivedF> &FUV,
-                                              double scale = 30.0,
-                                              double stiffness = 5.0,
-                                              bool direct_round = false,
-                                              int iter = 5,
-                                              int local_iter = 5,
-                                              bool DoRound = true,bool SingularityRound=true,
-                                              std::vector<int> round_vertices = std::vector<int>(),
-                                              std::vector<std::vector<int> > hard_features = std::vector<std::vector<int> >());
-
-  // Helper function that allows to directly provided pre-combed bisectors for an already cut mesh
-  // Additional input:
-  // PD1_combed, PD2_combed  :   #F by 3 combed jacobian
-  // BIS1_combed, BIS2_combed:   #F by 3 pre combed bi-sectors
-  // MMatch:                     #F by 3 list of per-corner integer PI/2 rotations
-  // Singular:                   #V list of flag that denotes if a vertex is singular or not
-  // SingularDegree:             #V list of flag that denotes the degree of the singularity
-  // Seams:                      #F by 3 list of per-corner flag that denotes seams
-
-  template <typename DerivedV, typename DerivedF, typename DerivedU>
-  IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
-                                              const Eigen::PlainObjectBase<DerivedF> &F,
-                                              const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
-                                              const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
-                                              // const Eigen::PlainObjectBase<DerivedV> &BIS1_combed,
-                                              // const Eigen::PlainObjectBase<DerivedV> &BIS2_combed,
-                                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &MMatch,
-                                              const Eigen::Matrix<int, Eigen::Dynamic, 1> &Singular,
-                                              // const Eigen::Matrix<int, Eigen::Dynamic, 1> &SingularDegree,
-                                              const Eigen::Matrix<int, Eigen::Dynamic, 3> &Seams,
-                                              Eigen::PlainObjectBase<DerivedU> &UV,
-                                              Eigen::PlainObjectBase<DerivedF> &FUV,
-                                              double GradientSize = 30.0,
-                                              double Stiffness = 5.0,
-                                              bool DirectRound = false,
-                                              int iter = 5,
-                                              int localIter = 5, bool DoRound = true,bool SingularityRound=true,
-                                              std::vector<int> roundVertices = std::vector<int>(),
-                                              std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
+  namespace comiso
+  {
+    // Global seamless parametrization aligned with a given per-face jacobian (PD1,PD2).
+    // The algorithm is based on
+    // "Mixed-Integer Quadrangulation" by D. Bommes, H. Zimmer, L. Kobbelt
+    // ACM SIGGRAPH 2009, Article No. 77 (http://dl.acm.org/citation.cfm?id=1531383)
+    // We thank Nico Pietroni for providing a reference implementation of MIQ
+    // on which our code is based.
+  
+    // Inputs:
+    //   V              #V by 3 list of mesh vertex 3D positions
+    //   F              #F by 3 list of faces indices in V
+    //   PD1            #V by 3 first line of the Jacobian per triangle
+    //   PD2            #V by 3 second line of the Jacobian per triangle
+    //                  (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
+    //   scale          global scaling for the gradient (controls the quads resolution)
+    //   stiffness      weight for the stiffness iterations
+    //   direct_round   greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
+    //   iter           stiffness iterations (0 = no stiffness)
+    //   local_iter     number of local iterations for the integer rounding
+    //   do_round       enables the integer rounding (disabling it could be useful for debugging)
+    //   round_vertices id of additional vertices that should be snapped to integer coordinates
+    //   hard_features  #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
+    //
+    // Output:
+    //   UV             #UV by 2 list of vertices in 2D
+    //   FUV            #FUV by 3 list of face indices in UV
+    //
+    // TODO: rename the parameters name in the cpp consistenly
+    //       improve the handling of hard_features, right now it might fail in difficult cases
+  
+    template <typename DerivedV, typename DerivedF, typename DerivedU>
+    IGL_INLINE void miq(
+      const Eigen::PlainObjectBase<DerivedV> &V,
+      const Eigen::PlainObjectBase<DerivedF> &F,
+      const Eigen::PlainObjectBase<DerivedV> &PD1,
+      const Eigen::PlainObjectBase<DerivedV> &PD2,
+      Eigen::PlainObjectBase<DerivedU> &UV,
+      Eigen::PlainObjectBase<DerivedF> &FUV,
+      double scale = 30.0,
+      double stiffness = 5.0,
+      bool direct_round = false,
+      int iter = 5,
+      int local_iter = 5,
+      bool DoRound = true,bool SingularityRound=true,
+      std::vector<int> round_vertices = std::vector<int>(),
+      std::vector<std::vector<int> > hard_features = std::vector<std::vector<int> >());
+  
+    // Helper function that allows to directly provided pre-combed bisectors for an already cut mesh
+    // Additional input:
+    // PD1_combed, PD2_combed  :   #F by 3 combed jacobian
+    // BIS1_combed, BIS2_combed:   #F by 3 pre combed bi-sectors
+    // MMatch:                     #F by 3 list of per-corner integer PI/2 rotations
+    // Singular:                   #V list of flag that denotes if a vertex is singular or not
+    // SingularDegree:             #V list of flag that denotes the degree of the singularity
+    // Seams:                      #F by 3 list of per-corner flag that denotes seams
+  
+    template <typename DerivedV, typename DerivedF, typename DerivedU>
+    IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
+      const Eigen::PlainObjectBase<DerivedF> &F,
+      const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
+      const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
+      // const Eigen::PlainObjectBase<DerivedV> &BIS1_combed,
+      // const Eigen::PlainObjectBase<DerivedV> &BIS2_combed,
+      const Eigen::Matrix<int, Eigen::Dynamic, 3> &MMatch,
+      const Eigen::Matrix<int, Eigen::Dynamic, 1> &Singular,
+      // const Eigen::Matrix<int, Eigen::Dynamic, 1> &SingularDegree,
+      const Eigen::Matrix<int, Eigen::Dynamic, 3> &Seams,
+      Eigen::PlainObjectBase<DerivedU> &UV,
+      Eigen::PlainObjectBase<DerivedF> &FUV,
+      double GradientSize = 30.0,
+      double Stiffness = 5.0,
+      bool DirectRound = false,
+      int iter = 5,
+      int localIter = 5, bool DoRound = true,bool SingularityRound=true,
+      std::vector<int> roundVertices = std::vector<int>(),
+      std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
+  };
 };
 #ifndef IGL_STATIC_LIBRARY
 #include "miq.cpp"

+ 38 - 35
include/igl/comiso/nrosy.cpp

@@ -27,6 +27,8 @@
 
 namespace igl
 {
+namespace comiso
+{
 class NRosyField
 {
 public:
@@ -147,9 +149,10 @@ private:
 
 };
 
+} // NAMESPACE COMISO
 } // NAMESPACE IGL
 
-igl::NRosyField::NRosyField(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
+igl::comiso::NRosyField::NRosyField(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
 {
   using namespace std;
   using namespace Eigen;
@@ -204,14 +207,14 @@ igl::NRosyField::NRosyField(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F
   softAlpha = 0.5;
 }
 
-void igl::NRosyField::setSoftAlpha(double alpha)
+void igl::comiso::NRosyField::setSoftAlpha(double alpha)
 {
   assert(alpha >= 0 && alpha < 1);
   softAlpha = alpha;
 }
 
 
-void igl::NRosyField::prepareSystemMatrix(const int N)
+void igl::comiso::NRosyField::prepareSystemMatrix(const int N)
 {
   using namespace std;
   using namespace Eigen;
@@ -392,7 +395,7 @@ void igl::NRosyField::prepareSystemMatrix(const int N)
 //  s2.close();
 }
 
-void igl::NRosyField::solveNoRoundings()
+void igl::comiso::NRosyField::solveNoRoundings()
 {
   using namespace std;
   using namespace Eigen;
@@ -414,7 +417,7 @@ void igl::NRosyField::solveNoRoundings()
       p[i] = roundl(x[tag_p[i]]);
 }
 
-void igl::NRosyField::solveRoundings()
+void igl::comiso::NRosyField::solveRoundings()
 {
   using namespace std;
   using namespace Eigen;
@@ -468,13 +471,13 @@ void igl::NRosyField::solveRoundings()
 }
 
 
-void igl::NRosyField::roundAndFix()
+void igl::comiso::NRosyField::roundAndFix()
 {
   for(unsigned i=0; i<p.rows(); ++i)
     pFixed[i] = true;
 }
 
-void igl::NRosyField::roundAndFixToZero()
+void igl::comiso::NRosyField::roundAndFixToZero()
 {
   for(unsigned i=0; i<p.rows(); ++i)
   {
@@ -483,7 +486,7 @@ void igl::NRosyField::roundAndFixToZero()
   }
 }
 
-void igl::NRosyField::solve(const int N)
+void igl::comiso::NRosyField::solve(const int N)
 {
   // Reduce the search space by fixing matchings
   reduceSpace();
@@ -511,19 +514,19 @@ void igl::NRosyField::solve(const int N)
   findCones(N);
 }
 
-void igl::NRosyField::setConstraintHard(const int fid, const Eigen::Vector3d& v)
+void igl::comiso::NRosyField::setConstraintHard(const int fid, const Eigen::Vector3d& v)
 {
   isHard[fid] = true;
   hard(fid) = convert3DtoLocal(fid, v);
 }
 
-void igl::NRosyField::setConstraintSoft(const int fid, const double w, const Eigen::Vector3d& v)
+void igl::comiso::NRosyField::setConstraintSoft(const int fid, const double w, const Eigen::Vector3d& v)
 {
   wSoft(fid) = w;
   soft(fid) = convert3DtoLocal(fid, v);
 }
 
-void igl::NRosyField::resetConstraints()
+void igl::comiso::NRosyField::resetConstraints()
 {
   using namespace std;
   using namespace Eigen;
@@ -537,7 +540,7 @@ void igl::NRosyField::resetConstraints()
   soft   = VectorXd::Zero(F.rows());
 }
 
-Eigen::MatrixXd igl::NRosyField::getFieldPerFace()
+Eigen::MatrixXd igl::comiso::NRosyField::getFieldPerFace()
 {
   using namespace std;
   using namespace Eigen;
@@ -548,7 +551,7 @@ Eigen::MatrixXd igl::NRosyField::getFieldPerFace()
   return result;
 }
 
-Eigen::MatrixXd igl::NRosyField::getFFieldPerFace()
+Eigen::MatrixXd igl::comiso::NRosyField::getFFieldPerFace()
 {
   using namespace std;
   using namespace Eigen;
@@ -569,7 +572,7 @@ Eigen::MatrixXd igl::NRosyField::getFFieldPerFace()
 }
 
 
-void igl::NRosyField::computek()
+void igl::comiso::NRosyField::computek()
 {
   using namespace std;
   using namespace Eigen;
@@ -668,7 +671,7 @@ void igl::NRosyField::computek()
 
 }
 
-void igl::NRosyField::reduceSpace()
+void igl::comiso::NRosyField::reduceSpace()
 {
   using namespace std;
   using namespace Eigen;
@@ -765,7 +768,7 @@ void igl::NRosyField::reduceSpace()
 
 }
 
-double igl::NRosyField::convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v)
+double igl::comiso::NRosyField::convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v)
 {
   using namespace std;
   using namespace Eigen;
@@ -777,7 +780,7 @@ double igl::NRosyField::convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v)
   return atan2(vp(1),vp(0));
 }
 
-Eigen::Vector3d igl::NRosyField::convertLocalto3D(unsigned fid, double a)
+Eigen::Vector3d igl::comiso::NRosyField::convertLocalto3D(unsigned fid, double a)
 {
   using namespace std;
   using namespace Eigen;
@@ -786,7 +789,7 @@ Eigen::Vector3d igl::NRosyField::convertLocalto3D(unsigned fid, double a)
   return vp.transpose() * TPs[fid];
 }
 
-Eigen::VectorXd igl::NRosyField::angleDefect()
+Eigen::VectorXd igl::comiso::NRosyField::angleDefect()
 {
   Eigen::VectorXd A = Eigen::VectorXd::Constant(V.rows(),-2*M_PI);
 
@@ -805,7 +808,7 @@ Eigen::VectorXd igl::NRosyField::angleDefect()
   return A;
 }
 
-void igl::NRosyField::findCones(int N)
+void igl::comiso::NRosyField::findCones(int N)
 {
   // Compute I0, see http://www.graphics.rwth-aachen.de/media/papers/bommes_zimmer_2009_siggraph_011.pdf for details
 
@@ -862,27 +865,27 @@ void igl::NRosyField::findCones(int N)
   singularityIndex = I;
 }
 
-Eigen::VectorXd igl::NRosyField::getSingularityIndexPerVertex()
+Eigen::VectorXd igl::comiso::NRosyField::getSingularityIndexPerVertex()
 {
   return singularityIndex;
 }
 
-IGL_INLINE void igl::nrosy(
-                           const Eigen::MatrixXd& V,
-                           const Eigen::MatrixXi& F,
-                           const Eigen::VectorXi& b,
-                           const Eigen::MatrixXd& bc,
-                           const Eigen::VectorXi& b_soft,
-                           const Eigen::VectorXd& w_soft,
-                           const Eigen::MatrixXd& bc_soft,
-                           const int N,
-                           const double soft,
-                           Eigen::MatrixXd& R,
-                           Eigen::VectorXd& S
-                           )
+IGL_INLINE void igl::comiso::nrosy(
+  const Eigen::MatrixXd& V,
+  const Eigen::MatrixXi& F,
+  const Eigen::VectorXi& b,
+  const Eigen::MatrixXd& bc,
+  const Eigen::VectorXi& b_soft,
+  const Eigen::VectorXd& w_soft,
+  const Eigen::MatrixXd& bc_soft,
+  const int N,
+  const double soft,
+  Eigen::MatrixXd& R,
+  Eigen::VectorXd& S
+  )
 {
   // Init solver
-  igl::NRosyField solver(V,F);
+  igl::comiso::NRosyField solver(V,F);
 
   // Add hard constraints
   for (unsigned i=0; i<b.size();++i)
@@ -917,7 +920,7 @@ IGL_INLINE void igl::nrosy(
                            )
 {
   // Init solver
-  igl::NRosyField solver(V,F);
+  igl::comiso::NRosyField solver(V,F);
 
   // Add hard constraints
   for (unsigned i=0; i<b.size();++i)

+ 43 - 42
include/igl/comiso/nrosy.h

@@ -16,49 +16,50 @@
 
 namespace igl
 {
-// Generate a N-RoSy field from a sparse set of constraints
-//
-// Inputs:
-//   V       #V by 3 list of mesh vertex coordinates
-//   F       #F by 3 list of mesh faces (must be triangles)
-//   b       #B by 1 list of constrained face indices
-//   bc      #B by 3 list of representative vectors for the constrained faces
-//   b_soft  #S by 1 b for soft constraints
-//   w_soft  #S by 1 weight for the soft constraints (0-1)
-//   bc_soft #S by 3 bc for soft constraints
-//   N       the degree of the N-RoSy vector field
-//   soft    the strenght of the soft contraints w.r.t. smoothness
-//           (0 -> smoothness only, 1->constraints only)
-
-// Outputs:
-//   R       #F by 3 the representative vectors of the interpolated field
-//   S       #V by 1 the singularity index for each vertex (0 = regular)
-
-IGL_INLINE void nrosy(
-  const Eigen::MatrixXd& V,
-  const Eigen::MatrixXi& F,
-  const Eigen::VectorXi& b,
-  const Eigen::MatrixXd& bc,
-  const Eigen::VectorXi& b_soft,
-  const Eigen::VectorXd& w_soft,
-  const Eigen::MatrixXd& bc_soft,
-  const int N,
-  const double soft,
-  Eigen::MatrixXd& R,
-  Eigen::VectorXd& S
-  );
-
-//wrapper for the case without soft constraints
-IGL_INLINE void nrosy(
- const Eigen::MatrixXd& V,
- const Eigen::MatrixXi& F,
- const Eigen::VectorXi& b,
- const Eigen::MatrixXd& bc,
- const int N,
- Eigen::MatrixXd& R,
- Eigen::VectorXd& S
-  );
+  namespace comiso
+  {
+    // Generate a N-RoSy field from a sparse set of constraints
+    //
+    // Inputs:
+    //   V       #V by 3 list of mesh vertex coordinates
+    //   F       #F by 3 list of mesh faces (must be triangles)
+    //   b       #B by 1 list of constrained face indices
+    //   bc      #B by 3 list of representative vectors for the constrained
+    //     faces
+    //   b_soft  #S by 1 b for soft constraints
+    //   w_soft  #S by 1 weight for the soft constraints (0-1)
+    //   bc_soft #S by 3 bc for soft constraints
+    //   N       the degree of the N-RoSy vector field
+    //   soft    the strenght of the soft contraints w.r.t. smoothness
+    //           (0 -> smoothness only, 1->constraints only)
+    // Outputs:
+    //   R       #F by 3 the representative vectors of the interpolated field
+    //   S       #V by 1 the singularity index for each vertex (0 = regular)
+    IGL_INLINE void nrosy(
+      const Eigen::MatrixXd& V,
+      const Eigen::MatrixXi& F,
+      const Eigen::VectorXi& b,
+      const Eigen::MatrixXd& bc,
+      const Eigen::VectorXi& b_soft,
+      const Eigen::VectorXd& w_soft,
+      const Eigen::MatrixXd& bc_soft,
+      const int N,
+      const double soft,
+      Eigen::MatrixXd& R,
+      Eigen::VectorXd& S
+      );
+    //wrapper for the case without soft constraints
+    IGL_INLINE void nrosy(
+     const Eigen::MatrixXd& V,
+     const Eigen::MatrixXi& F,
+     const Eigen::VectorXi& b,
+     const Eigen::MatrixXd& bc,
+     const int N,
+     Eigen::MatrixXd& R,
+     Eigen::VectorXd& S
+      );
 
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 169 - 163
include/igl/embree/EmbreeIntersector.h

@@ -28,155 +28,158 @@
 
 namespace igl
 {
-  class EmbreeIntersector
+  namespace embree
   {
-  public:
-    // Initialize embree engine. This will be called on instance `init()`
-    // calls. If already inited then this function does nothing: it is harmless
-    // to call more than once.
-    static inline void global_init();
-  private:
-    // Deinitialize the embree engine.
-    static inline void global_deinit();
-  public:
-    typedef Eigen::Matrix<float,Eigen::Dynamic,3> PointMatrixType;
-    typedef Eigen::Matrix<int,Eigen::Dynamic,3> FaceMatrixType;
-  public: 
-    inline EmbreeIntersector();
-  private:
-    // Copying and assignment are not allowed.
-    inline EmbreeIntersector(const EmbreeIntersector & that);
-    inline EmbreeIntersector & operator=(const EmbreeIntersector &);
-  public:
-    virtual inline ~EmbreeIntersector();
-    
-    // Initialize with a given mesh.
-    //
-    // Inputs:
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of Oriented triangles
-    // Side effects:
-    //   The first time this is ever called the embree engine is initialized.
-    inline void init(
-      const PointMatrixType& V,
-      const FaceMatrixType& F);
-
-    // Initialize with a given mesh.
-    //
-    // Inputs:
-    //   V  vector of #V by 3 list of vertex positions for each geometry
-    //   F  vector of #F by 3 list of Oriented triangles for each geometry
-    //   masks  a 32 bit mask to identify active geometries.
-    // Side effects:
-    //   The first time this is ever called the embree engine is initialized.
-    inline void init(
-      const std::vector<const PointMatrixType*>& V,
-      const std::vector<const FaceMatrixType*>& F,
-      const std::vector<int>& masks);
-
-    // Deinitialize embree datasctructures for current mesh.  Also called on
-    // destruction: no need to call if you just want to init() once and
-    // destroy.
-    inline void deinit();
+    class EmbreeIntersector
+    {
+    public:
+      // Initialize embree engine. This will be called on instance `init()`
+      // calls. If already inited then this function does nothing: it is harmless
+      // to call more than once.
+      static inline void global_init();
+    private:
+      // Deinitialize the embree engine.
+      static inline void global_deinit();
+    public:
+      typedef Eigen::Matrix<float,Eigen::Dynamic,3> PointMatrixType;
+      typedef Eigen::Matrix<int,Eigen::Dynamic,3> FaceMatrixType;
+    public: 
+      inline EmbreeIntersector();
+    private:
+      // Copying and assignment are not allowed.
+      inline EmbreeIntersector(const EmbreeIntersector & that);
+      inline EmbreeIntersector & operator=(const EmbreeIntersector &);
+    public:
+      virtual inline ~EmbreeIntersector();
+      
+      // Initialize with a given mesh.
+      //
+      // Inputs:
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of Oriented triangles
+      // Side effects:
+      //   The first time this is ever called the embree engine is initialized.
+      inline void init(
+        const PointMatrixType& V,
+        const FaceMatrixType& F);
   
-    // Given a ray find the first hit
-    // 
-    // Inputs:
-    //   origin     3d origin point of ray
-    //   direction  3d (not necessarily normalized) direction vector of ray
-    //   tnear      start of ray segment
-    //   tfar       end of ray segment
-    //   masks      a 32 bit mask to identify active geometries.
-    // Output:
-    //   hit        information about hit
-    // Returns true if and only if there was a hit
-    inline bool intersectRay(
-      const Eigen::RowVector3f& origin, 
-      const Eigen::RowVector3f& direction,
-      Hit& hit,
-      float tnear = 0,
-      float tfar = std::numeric_limits<float>::infinity(),
-      int mask = 0xFFFFFFFF) const;
-
-    // Given a ray find the first hit
-    // This is a conservative hit test where multiple rays within a small radius
-    // will be tested and only the closesest hit is returned.
-    // 
-    // Inputs:
-    //   origin     3d origin point of ray
-    //   direction  3d (not necessarily normalized) direction vector of ray
-    //   tnear      start of ray segment
-    //   tfar       end of ray segment
-    //   masks      a 32 bit mask to identify active geometries.
-    //   geoId      id of geometry mask (default -1 if no: no masking)
-    //   closestHit true for gets closest hit, false for furthest hit
-    // Output:
-    //   hit        information about hit
-    // Returns true if and only if there was a hit
-    inline bool intersectBeam(
-      const Eigen::RowVector3f& origin,
-      const Eigen::RowVector3f& direction,
-      Hit& hit,
-      float tnear = 0,
-      float tfar = -1,
-      int mask = 0xFFFFFFFF,
-      int geoId = -1,
-      bool closestHit = true) const;
-
-    // Given a ray find all hits in order
-    // 
-    // Inputs:
-    //   origin     3d origin point of ray
-    //   direction  3d (not necessarily normalized) direction vector of ray
-    //   tnear      start of ray segment
-    //   tfar       end of ray segment
-    //   masks      a 32 bit mask to identify active geometries.
-    // Output:
-    //   hit        information about hit
-    //   num_rays   number of rays shot (at least one)
-    // Returns true if and only if there was a hit
-    inline bool intersectRay(
-      const Eigen::RowVector3f& origin,
-      const Eigen::RowVector3f& direction,
-      std::vector<Hit > &hits,
-      int& num_rays,
-      float tnear = 0,
-      float tfar = std::numeric_limits<float>::infinity(),
-      int mask = 0xFFFFFFFF) const;
-
-    // Given a ray find the first hit
-    // 
-    // Inputs:
-    //   a    3d first end point of segment
-    //   ab   3d vector from a to other endpoint b
-    // Output:
-    //   hit  information about hit
-    // Returns true if and only if there was a hit
-    inline bool intersectSegment(
-      const Eigen::RowVector3f& a,
-      const Eigen::RowVector3f& ab,
-      Hit &hit,
-      int mask = 0xFFFFFFFF) const;
+      // Initialize with a given mesh.
+      //
+      // Inputs:
+      //   V  vector of #V by 3 list of vertex positions for each geometry
+      //   F  vector of #F by 3 list of Oriented triangles for each geometry
+      //   masks  a 32 bit mask to identify active geometries.
+      // Side effects:
+      //   The first time this is ever called the embree engine is initialized.
+      inline void init(
+        const std::vector<const PointMatrixType*>& V,
+        const std::vector<const FaceMatrixType*>& F,
+        const std::vector<int>& masks);
+  
+      // Deinitialize embree datasctructures for current mesh.  Also called on
+      // destruction: no need to call if you just want to init() once and
+      // destroy.
+      inline void deinit();
     
-  private:
-
-    struct Vertex   {float x,y,z,a;};
-    struct Triangle {int v0, v1, v2;};
-
-    RTCScene scene;
-    unsigned geomID;
-    Vertex* vertices;
-    Triangle* triangles;
-    bool initialized;
-
-    inline void createRay(
-      RTCRay& ray,
-      const Eigen::RowVector3f& origin,
-      const Eigen::RowVector3f& direction,
-      float tnear,
-      float tfar,
-      int mask) const;
-  };
+      // Given a ray find the first hit
+      // 
+      // Inputs:
+      //   origin     3d origin point of ray
+      //   direction  3d (not necessarily normalized) direction vector of ray
+      //   tnear      start of ray segment
+      //   tfar       end of ray segment
+      //   masks      a 32 bit mask to identify active geometries.
+      // Output:
+      //   hit        information about hit
+      // Returns true if and only if there was a hit
+      inline bool intersectRay(
+        const Eigen::RowVector3f& origin, 
+        const Eigen::RowVector3f& direction,
+        Hit& hit,
+        float tnear = 0,
+        float tfar = std::numeric_limits<float>::infinity(),
+        int mask = 0xFFFFFFFF) const;
+  
+      // Given a ray find the first hit
+      // This is a conservative hit test where multiple rays within a small radius
+      // will be tested and only the closesest hit is returned.
+      // 
+      // Inputs:
+      //   origin     3d origin point of ray
+      //   direction  3d (not necessarily normalized) direction vector of ray
+      //   tnear      start of ray segment
+      //   tfar       end of ray segment
+      //   masks      a 32 bit mask to identify active geometries.
+      //   geoId      id of geometry mask (default -1 if no: no masking)
+      //   closestHit true for gets closest hit, false for furthest hit
+      // Output:
+      //   hit        information about hit
+      // Returns true if and only if there was a hit
+      inline bool intersectBeam(
+        const Eigen::RowVector3f& origin,
+        const Eigen::RowVector3f& direction,
+        Hit& hit,
+        float tnear = 0,
+        float tfar = -1,
+        int mask = 0xFFFFFFFF,
+        int geoId = -1,
+        bool closestHit = true) const;
+  
+      // Given a ray find all hits in order
+      // 
+      // Inputs:
+      //   origin     3d origin point of ray
+      //   direction  3d (not necessarily normalized) direction vector of ray
+      //   tnear      start of ray segment
+      //   tfar       end of ray segment
+      //   masks      a 32 bit mask to identify active geometries.
+      // Output:
+      //   hit        information about hit
+      //   num_rays   number of rays shot (at least one)
+      // Returns true if and only if there was a hit
+      inline bool intersectRay(
+        const Eigen::RowVector3f& origin,
+        const Eigen::RowVector3f& direction,
+        std::vector<Hit > &hits,
+        int& num_rays,
+        float tnear = 0,
+        float tfar = std::numeric_limits<float>::infinity(),
+        int mask = 0xFFFFFFFF) const;
+  
+      // Given a ray find the first hit
+      // 
+      // Inputs:
+      //   a    3d first end point of segment
+      //   ab   3d vector from a to other endpoint b
+      // Output:
+      //   hit  information about hit
+      // Returns true if and only if there was a hit
+      inline bool intersectSegment(
+        const Eigen::RowVector3f& a,
+        const Eigen::RowVector3f& ab,
+        Hit &hit,
+        int mask = 0xFFFFFFFF) const;
+      
+    private:
+  
+      struct Vertex   {float x,y,z,a;};
+      struct Triangle {int v0, v1, v2;};
+  
+      RTCScene scene;
+      unsigned geomID;
+      Vertex* vertices;
+      Triangle* triangles;
+      bool initialized;
+  
+      inline void createRay(
+        RTCRay& ray,
+        const Eigen::RowVector3f& origin,
+        const Eigen::RowVector3f& direction,
+        float tnear,
+        float tfar,
+        int mask) const;
+    };
+  }
 }
 
 // Implementation
@@ -187,12 +190,15 @@ namespace igl
 // initialized...
 namespace igl
 {
-  // Keeps track of whether the **Global** Embree intersector has been
-  // initialized. This should never been done at the global scope.
-  static bool EmbreeIntersector_inited = false;
+  namespace embree
+  {
+    // Keeps track of whether the **Global** Embree intersector has been
+    // initialized. This should never been done at the global scope.
+    static bool EmbreeIntersector_inited = false;
+  }
 }
 
-inline void igl::EmbreeIntersector::global_init()
+inline void igl::embree::EmbreeIntersector::global_init()
 {
   if(!EmbreeIntersector_inited)
   {
@@ -207,13 +213,13 @@ inline void igl::EmbreeIntersector::global_init()
   }
 }
 
-inline void igl::EmbreeIntersector::global_deinit()
+inline void igl::embree::EmbreeIntersector::global_deinit()
 {
   EmbreeIntersector_inited = false;
   rtcExit();
 }
 
-inline igl::EmbreeIntersector::EmbreeIntersector()
+inline igl::embree::EmbreeIntersector::EmbreeIntersector()
   :
   //scene(NULL),
   geomID(0),
@@ -223,7 +229,7 @@ inline igl::EmbreeIntersector::EmbreeIntersector()
 {
 }
 
-inline igl::EmbreeIntersector::EmbreeIntersector(
+inline igl::embree::EmbreeIntersector::EmbreeIntersector(
   const EmbreeIntersector &)
   :// To make -Weffc++ happy
   //scene(NULL),
@@ -235,7 +241,7 @@ inline igl::EmbreeIntersector::EmbreeIntersector(
   assert(false && "Embree: Copying EmbreeIntersector is not allowed");
 }
 
-inline igl::EmbreeIntersector & igl::EmbreeIntersector::operator=(
+inline igl::embree::EmbreeIntersector & igl::embree::EmbreeIntersector::operator=(
   const EmbreeIntersector &)
 {
   assert(false && "Embree: Assigning an EmbreeIntersector is not allowed");
@@ -243,7 +249,7 @@ inline igl::EmbreeIntersector & igl::EmbreeIntersector::operator=(
 }
 
 
-inline void igl::EmbreeIntersector::init(
+inline void igl::embree::EmbreeIntersector::init(
   const PointMatrixType& V,
   const FaceMatrixType& F)
 {
@@ -256,7 +262,7 @@ inline void igl::EmbreeIntersector::init(
   init(Vtemp,Ftemp,masks);
 }
 
-inline void igl::EmbreeIntersector::init(
+inline void igl::embree::EmbreeIntersector::init(
   const std::vector<const PointMatrixType*>& V,
   const std::vector<const FaceMatrixType*>& F,
   const std::vector<int>& masks)
@@ -317,14 +323,14 @@ inline void igl::EmbreeIntersector::init(
   initialized = true;
 }
 
-igl::EmbreeIntersector
+igl::embree::EmbreeIntersector
 ::~EmbreeIntersector()
 {
   if(initialized)
     deinit();
 }
 
-void igl::EmbreeIntersector::deinit()
+void igl::embree::EmbreeIntersector::deinit()
 {
   if(scene)
   {
@@ -343,7 +349,7 @@ void igl::EmbreeIntersector::deinit()
   }
 }
 
-inline bool igl::EmbreeIntersector::intersectRay(
+inline bool igl::embree::EmbreeIntersector::intersectRay(
   const Eigen::RowVector3f& origin,
   const Eigen::RowVector3f& direction,
   Hit& hit,
@@ -374,7 +380,7 @@ inline bool igl::EmbreeIntersector::intersectRay(
   return false;
 }
 
-inline bool igl::EmbreeIntersector::intersectBeam(
+inline bool igl::embree::EmbreeIntersector::intersectBeam(
       const Eigen::RowVector3f& origin, 
       const Eigen::RowVector3f& direction,
       Hit& hit,
@@ -419,7 +425,7 @@ inline bool igl::EmbreeIntersector::intersectBeam(
 }
 
 inline bool 
-igl::EmbreeIntersector
+igl::embree::EmbreeIntersector
 ::intersectRay(
   const Eigen::RowVector3f& origin, 
   const Eigen::RowVector3f& direction,
@@ -519,7 +525,7 @@ igl::EmbreeIntersector
 }
 
 inline bool 
-igl::EmbreeIntersector
+igl::embree::EmbreeIntersector
 ::intersectSegment(const Eigen::RowVector3f& a, const Eigen::RowVector3f& ab, Hit &hit, int mask) const
 {
   RTCRay ray;
@@ -541,7 +547,7 @@ igl::EmbreeIntersector
 }
 
 inline void
-igl::EmbreeIntersector
+igl::embree::EmbreeIntersector
 ::createRay(RTCRay& ray, const Eigen::RowVector3f& origin, const Eigen::RowVector3f& direction, float tnear, float tfar, int mask) const
 {
   ray.org[0] = origin[0];

+ 10 - 7
include/igl/embree/Hit.h

@@ -11,13 +11,16 @@
 
 namespace igl
 {
-  // Reimplementation of the embree::Hit struct from embree1.0
-  struct Hit
+  namespace embree
   {
-    int id; // primitive id
-    int gid; // geometry id
-    float u,v; // barycentric coordinates
-    float t; // distance = direction*t to intersection
-  };
+    // Reimplementation of the embree::Hit struct from embree1.0
+    struct Hit
+    {
+      int id; // primitive id
+      int gid; // geometry id
+      float u,v; // barycentric coordinates
+      float t; // distance = direction*t to intersection
+    };
+  }
 }
 #endif 

+ 8 - 8
include/igl/embree/ambient_occlusion.cpp

@@ -14,8 +14,8 @@ template <
   typename DerivedP,
   typename DerivedN,
   typename DerivedS >
-IGL_INLINE void igl::ambient_occlusion(
-  const igl::EmbreeIntersector & ei,
+IGL_INLINE void igl::embree::ambient_occlusion(
+  const igl::embree::EmbreeIntersector & ei,
   const Eigen::PlainObjectBase<DerivedP> & P,
   const Eigen::PlainObjectBase<DerivedN> & N,
   const int num_samples,
@@ -44,7 +44,7 @@ IGL_INLINE void igl::ambient_occlusion(
         // reverse ray
         d *= -1;
       }
-      igl::Hit hit;
+      igl::embree::Hit hit;
       const float tnear = 1e-4f;
       if(ei.intersectRay(origin,d,hit,tnear))
       {
@@ -61,7 +61,7 @@ template <
   typename DerivedP,
   typename DerivedN,
   typename DerivedS >
-IGL_INLINE void igl::ambient_occlusion(
+IGL_INLINE void igl::embree::ambient_occlusion(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedP> & P,
@@ -78,8 +78,8 @@ IGL_INLINE void igl::ambient_occlusion(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instanciation
-template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
-template void igl::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
-template void igl::ambient_occlusion<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>, 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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
-template void igl::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::embree::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::embree::ambient_occlusion<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>, 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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+template void igl::embree::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 #endif

+ 40 - 37
include/igl/embree/ambient_occlusion.h

@@ -11,43 +11,46 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Forward define
-  class EmbreeIntersector;
-  // Compute ambient occlusion per given point
-  //
-  // Inputs:
-  //    ei  EmbreeIntersector containing (V,F)
-  //    P  #P by 3 list of origin points
-  //    N  #P by 3 list of origin normals
-  // Outputs:
-  //    S  #P list of ambient occlusion values between 1 (fully occluded) and 0
-  //      (not occluded)
-  //
-  template <
-    typename DerivedP,
-    typename DerivedN,
-    typename DerivedS >
-  IGL_INLINE void ambient_occlusion(
-    const igl::EmbreeIntersector & ei,
-    const Eigen::PlainObjectBase<DerivedP> & P,
-    const Eigen::PlainObjectBase<DerivedN> & N,
-    const int num_samples,
-    Eigen::PlainObjectBase<DerivedS> & S);
-  // Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
-  // avoid this if repeatedly calling.
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedP,
-    typename DerivedN,
-    typename DerivedS >
-  IGL_INLINE void ambient_occlusion(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    const Eigen::PlainObjectBase<DerivedP> & P,
-    const Eigen::PlainObjectBase<DerivedN> & N,
-    const int num_samples,
-    Eigen::PlainObjectBase<DerivedS> & S);
+  namespace embree
+  {
+    // Forward define
+    class EmbreeIntersector;
+    // Compute ambient occlusion per given point
+    //
+    // Inputs:
+    //    ei  EmbreeIntersector containing (V,F)
+    //    P  #P by 3 list of origin points
+    //    N  #P by 3 list of origin normals
+    // Outputs:
+    //    S  #P list of ambient occlusion values between 1 (fully occluded) and
+    //      0 (not occluded)
+    //
+    template <
+      typename DerivedP,
+      typename DerivedN,
+      typename DerivedS >
+    IGL_INLINE void ambient_occlusion(
+      const EmbreeIntersector & ei,
+      const Eigen::PlainObjectBase<DerivedP> & P,
+      const Eigen::PlainObjectBase<DerivedN> & N,
+      const int num_samples,
+      Eigen::PlainObjectBase<DerivedS> & S);
+    // Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
+    // avoid this if repeatedly calling.
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedP,
+      typename DerivedN,
+      typename DerivedS >
+    IGL_INLINE void ambient_occlusion(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      const Eigen::PlainObjectBase<DerivedP> & P,
+      const Eigen::PlainObjectBase<DerivedN> & N,
+      const int num_samples,
+      Eigen::PlainObjectBase<DerivedS> & S);
+  }
 };
 #ifndef IGL_STATIC_LIBRARY
 #  include "ambient_occlusion.cpp"

+ 1 - 1
include/igl/embree/bone_heat.cpp

@@ -14,7 +14,7 @@
 #include "../mat_min.h"
 #include <Eigen/Sparse>
 
-bool igl::bone_heat(
+bool igl::embree::bone_heat(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & C,

+ 26 - 23
include/igl/embree/bone_heat.h

@@ -12,29 +12,32 @@
 
 namespace igl
 {
-  // BONE_HEAT  Compute skinning weights W given a surface mesh (V,F) and an
-  // internal skeleton (C,BE) according to "Automatic Rigging" [Baran and
-  // Popovic 2007].
-  //
-  // Inputs:
-  //   V  #V by 3 list of mesh vertex positions
-  //   F  #F by 3 list of mesh corner indices into V
-  //   C  #C by 3 list of joint locations
-  //   P  #P list of point handle indices into C
-  //   BE  #BE by 2 list of bone edge indices into C
-  //   CE  #CE by 2 list of cage edge indices into **P**
-  // Outputs:
-  //   W  #V by #P+#BE matrix of weights.
-  // Returns true only on success.
-  //
-  IGL_INLINE bool bone_heat(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & C,
-    const Eigen::VectorXi & P,
-    const Eigen::MatrixXi & BE,
-    const Eigen::MatrixXi & CE,
-    Eigen::MatrixXd & W);
+  namespace embree
+  {
+    // BONE_HEAT  Compute skinning weights W given a surface mesh (V,F) and an
+    // internal skeleton (C,BE) according to "Automatic Rigging" [Baran and
+    // Popovic 2007].
+    //
+    // Inputs:
+    //   V  #V by 3 list of mesh vertex positions
+    //   F  #F by 3 list of mesh corner indices into V
+    //   C  #C by 3 list of joint locations
+    //   P  #P list of point handle indices into C
+    //   BE  #BE by 2 list of bone edge indices into C
+    //   CE  #CE by 2 list of cage edge indices into **P**
+    // Outputs:
+    //   W  #V by #P+#BE matrix of weights.
+    // Returns true only on success.
+    //
+    IGL_INLINE bool bone_heat(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      const Eigen::MatrixXd & C,
+      const Eigen::VectorXi & P,
+      const Eigen::MatrixXi & BE,
+      const Eigen::MatrixXi & CE,
+      Eigen::MatrixXd & W);
+  }
 };
 
 #ifndef IGL_STATIC_LIBRARY

+ 6 - 6
include/igl/embree/bone_visible.cpp

@@ -16,7 +16,7 @@ template <
   typename DerivedF, 
   typename DerivedSD,
   typename Derivedflag>
-IGL_INLINE void igl::bone_visible(
+IGL_INLINE void igl::embree::bone_visible(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedSD> & s,
@@ -38,10 +38,10 @@ template <
   typename DerivedF, 
   typename DerivedSD,
   typename Derivedflag>
-IGL_INLINE void igl::bone_visible(
+IGL_INLINE void igl::embree::bone_visible(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   const Eigen::PlainObjectBase<DerivedSD> & s,
   const Eigen::PlainObjectBase<DerivedSD> & d,
   Eigen::PlainObjectBase<Derivedflag>  & flag)
@@ -86,7 +86,7 @@ IGL_INLINE void igl::bone_visible(
         projv = d;
       }
     }
-    igl::Hit hit;
+    igl::embree::Hit hit;
     // perhaps 1.0 should be 1.0-epsilon, or actually since we checking the
     // incident face, perhaps 1.0 should be 1.0+eps
     const Vector3d dir = (Vv-projv)*1.0;
@@ -140,6 +140,6 @@ IGL_INLINE void igl::bone_visible(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instanciation
-template void igl::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<bool, -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, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
-template void igl::bone_visible<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<bool, -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<bool, -1, 1, 0, -1, 1> >&);
+template void igl::embree::bone_visible<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<bool, -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, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template void igl::embree::bone_visible<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<bool, -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<bool, -1, 1, 0, -1, 1> >&);
 #endif

+ 49 - 46
include/igl/embree/bone_visible.h

@@ -12,52 +12,55 @@
 #include "EmbreeIntersector.h"
 namespace igl
 {
-  //
-  // BONE_VISIBLE  test whether vertices of mesh are "visible" to a given bone,
-  // where "visible" is defined as in [Baran & Popovic 07]. Instead of checking
-  // whether each point can see *any* of the bone, we just check if each point
-  // can see its own projection onto the bone segment. In other words, we project
-  // each vertex v onto the bone, projv. Then we check if there are any
-  // intersections between the line segment (projv-->v) and the mesh.
-  //
-  // [flag] = bone_visible(V,F,s,d);
-  //
-  // Input:
-  //    V  #V by 3 list of vertex positions
-  //    F  #F by 3 list of triangle indices
-  //    s  row vector of position of start end point of bone
-  //    d  row vector of position of dest end point of bone
-  // Output:
-  //    flag  #V by 1 list of bools (true) visible, (false) obstructed
-  //
-  // Note: This checks for hits along the segment which are facing in *any*
-  // direction from the ray.
-  //
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedSD,
-    typename Derivedflag>
-  IGL_INLINE void bone_visible(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    const Eigen::PlainObjectBase<DerivedSD> & s,
-    const Eigen::PlainObjectBase<DerivedSD> & d,
-    Eigen::PlainObjectBase<Derivedflag>  & flag);
-  // Inputs:
-  //  ei  EmbreeIntersector for mesh (V,F) should be double sided
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedSD,
-    typename Derivedflag>
-  IGL_INLINE void bone_visible(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    const igl::EmbreeIntersector & ei,
-    const Eigen::PlainObjectBase<DerivedSD> & s,
-    const Eigen::PlainObjectBase<DerivedSD> & d,
-    Eigen::PlainObjectBase<Derivedflag>  & flag);
+  namespace embree
+  {
+    //
+    // BONE_VISIBLE  test whether vertices of mesh are "visible" to a given bone,
+    // where "visible" is defined as in [Baran & Popovic 07]. Instead of checking
+    // whether each point can see *any* of the bone, we just check if each point
+    // can see its own projection onto the bone segment. In other words, we project
+    // each vertex v onto the bone, projv. Then we check if there are any
+    // intersections between the line segment (projv-->v) and the mesh.
+    //
+    // [flag] = bone_visible(V,F,s,d);
+    //
+    // Input:
+    //    V  #V by 3 list of vertex positions
+    //    F  #F by 3 list of triangle indices
+    //    s  row vector of position of start end point of bone
+    //    d  row vector of position of dest end point of bone
+    // Output:
+    //    flag  #V by 1 list of bools (true) visible, (false) obstructed
+    //
+    // Note: This checks for hits along the segment which are facing in *any*
+    // direction from the ray.
+    //
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedSD,
+      typename Derivedflag>
+    IGL_INLINE void bone_visible(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      const Eigen::PlainObjectBase<DerivedSD> & s,
+      const Eigen::PlainObjectBase<DerivedSD> & d,
+      Eigen::PlainObjectBase<Derivedflag>  & flag);
+    // Inputs:
+    //  ei  EmbreeIntersector for mesh (V,F) should be double sided
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedSD,
+      typename Derivedflag>
+    IGL_INLINE void bone_visible(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      const EmbreeIntersector & ei,
+      const Eigen::PlainObjectBase<DerivedSD> & s,
+      const Eigen::PlainObjectBase<DerivedSD> & d,
+      Eigen::PlainObjectBase<Derivedflag>  & flag);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "bone_visible.cpp"

+ 3 - 18
include/igl/embree/line_mesh_intersection.cpp

@@ -14,23 +14,8 @@
 #include <igl/per_vertex_normals.h>
 #include <igl/embree/EmbreeIntersector.h>
 
-//template <typename ScalarMatrix, typename IndexMatrix>
-//IGL_INLINE ScalarMatrix igl::line_mesh_intersection(
-//   const ScalarMatrix & V_source,
-//   const IndexMatrix  & F_source,
-//   const ScalarMatrix & V_target,
-//   const IndexMatrix  & F_target
-//)
-//{
-//  // Compute normals for the tri
-//  Eigen::MatrixXd ray_dir;
-//  igl::per_vertex_normals(V_source, F_source, ray_dir);
-//
-//  return line_mesh_intersection(V_source,ray_dir,V_target,F_target);
-//}
-
 template <typename ScalarMatrix, typename IndexMatrix>
-IGL_INLINE ScalarMatrix igl::line_mesh_intersection
+IGL_INLINE ScalarMatrix igl::embree::line_mesh_intersection
 (
  const ScalarMatrix & V_source,
  const ScalarMatrix  & N_source,
@@ -49,13 +34,13 @@ IGL_INLINE ScalarMatrix igl::line_mesh_intersection
   R.resize(V_source.rows(), 3);
   
   // Initialize embree
-  igl::EmbreeIntersector embree;
+  EmbreeIntersector embree;
   embree.init(V_target.template cast<float>(),F_target.template cast<int>());
 
   // Shoot rays from the source to the target
   for (unsigned i=0; i<ray_pos.rows(); ++i)
   {
-    igl::Hit A,B;
+    igl::embree::Hit A,B;
     
     // Shoot ray A
     Eigen::RowVector3d A_pos = ray_pos.row(i) + tol * ray_dir.row(i);

+ 28 - 52
include/igl/embree/line_mesh_intersection.h

@@ -15,58 +15,34 @@
 
 namespace igl 
 {
-
-  //// Project the triangle mesh V_source, F_source onto the triangle mesh
-  //// V_target,F_target.
-  //// A ray is casted for every vertex in the normal direction and its opposite.
-  ////
-  //// Input:
-  //// V_source: #Vx3 Vertices of the source mesh
-  //// F_source: #Fx3 Faces of the source mesh
-  //// V_target: #V2x3 Vertices of the target mesh
-  //// F_target: #F2x3 Faces of the target mesh
-  ////
-  //// Output:
-  //// #Vx3 matrix of baricentric coordinate. Each row corresponds to 
-  //// a vertex of the projected mesh and it has the following format:
-  //// id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
-  //// the barycentric coordinates wrt the first two edges of the triangle
-  //// To convert to standard global coordinates, see barycentric_to_global.h
-  //template <typename ScalarMatrix, typename IndexMatrix>
-  //IGL_INLINE ScalarMatrix line_mesh_intersection
-  //(
-	//	const ScalarMatrix & V_source,
-  //	const IndexMatrix  & F_source,
-  //  const ScalarMatrix & V_target,
-  //  const IndexMatrix  & F_target
-	//);
-
-  // Project the point cloud V_source onto the triangle mesh
-  // V_target,F_target. 
-  // A ray is casted for every vertex in the direction specified by 
-  // N_source and its opposite.
-  //
-  // Input:
-  // V_source: #Vx3 Vertices of the source mesh
-  // N_source: #Vx3 Normals of the point cloud
-  // V_target: #V2x3 Vertices of the target mesh
-  // F_target: #F2x3 Faces of the target mesh
-  //
-  // Output:
-  // #Vx3 matrix of baricentric coordinate. Each row corresponds to 
-  // a vertex of the projected mesh and it has the following format:
-  // id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
-  // the barycentric coordinates wrt the first two edges of the triangle
-  // To convert to standard global coordinates, see barycentric_to_global.h
-  template <typename ScalarMatrix, typename IndexMatrix>
-  IGL_INLINE ScalarMatrix line_mesh_intersection
-  (
-   const ScalarMatrix & V_source,
-   const ScalarMatrix  & N_source,
-   const ScalarMatrix & V_target,
-   const IndexMatrix  & F_target
-   );
-
+  namespace embree
+  {
+    // Project the point cloud V_source onto the triangle mesh
+    // V_target,F_target. 
+    // A ray is casted for every vertex in the direction specified by 
+    // N_source and its opposite.
+    //
+    // Input:
+    // V_source: #Vx3 Vertices of the source mesh
+    // N_source: #Vx3 Normals of the point cloud
+    // V_target: #V2x3 Vertices of the target mesh
+    // F_target: #F2x3 Faces of the target mesh
+    //
+    // Output:
+    // #Vx3 matrix of baricentric coordinate. Each row corresponds to 
+    // a vertex of the projected mesh and it has the following format:
+    // id b1 b2. id is the id of a face of the source mesh. b1 and b2 are 
+    // the barycentric coordinates wrt the first two edges of the triangle
+    // To convert to standard global coordinates, see barycentric_to_global.h
+    template <typename ScalarMatrix, typename IndexMatrix>
+    IGL_INLINE ScalarMatrix line_mesh_intersection
+    (
+     const ScalarMatrix & V_source,
+     const ScalarMatrix  & N_source,
+     const ScalarMatrix & V_target,
+     const IndexMatrix  & F_target
+     );
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "line_mesh_intersection.cpp"

+ 3 - 3
include/igl/embree/reorient_facets_raycast.cpp

@@ -21,7 +21,7 @@ template <
   typename DerivedF, 
   typename DerivedI,
   typename DerivedC>
-IGL_INLINE void igl::reorient_facets_raycast(
+IGL_INLINE void igl::embree::reorient_facets_raycast(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   int rays_total,
@@ -223,7 +223,7 @@ template <
   typename DerivedF, 
   typename DerivedFF,
   typename DerivedI>
-IGL_INLINE void igl::reorient_facets_raycast(
+IGL_INLINE void igl::embree::reorient_facets_raycast(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedFF> & FF,
@@ -253,5 +253,5 @@ IGL_INLINE void igl::reorient_facets_raycast(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::reorient_facets_raycast<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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::embree::reorient_facets_raycast<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> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 51 - 48
include/igl/embree/reorient_facets_raycast.h

@@ -11,54 +11,57 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Orient each component (identified by C) of a mesh (V,F) using ambient
-  // occlusion such that the front side is less occluded than back side
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices
-  //   rays_total  Total number of rays that will be shot
-  //   rays_minimum  Minimum number of rays that each patch should receive
-  //   facet_wise  Decision made for each face independently, no use of patches
-  //     (i.e., each face is treated as a patch)
-  //   use_parity  Use parity mode
-  //   is_verbose  Verbose output to cout
-  // Outputs:
-  //   I  #F list of whether face has been flipped
-  //   C  #F list of patch ID (output of bfs_orient > manifold patches)
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedI,
-    typename DerivedC>
-  IGL_INLINE void reorient_facets_raycast(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    int rays_total,
-    int rays_minimum,
-    bool facet_wise,
-    bool use_parity,
-    bool is_verbose,
-    Eigen::PlainObjectBase<DerivedI> & I,
-    Eigen::PlainObjectBase<DerivedC> & C);
-  // Outputs:
-  //   FF  #F by 3 list of reoriented faces
-  // Defaults:
-  //   rays_total = F.rows()*100;
-  //   rays_minimum = 10;
-  //   facet_wise = false;
-  //   use_parity = false;
-  //   is_verbose = false;
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedFF,
-    typename DerivedI>
-  IGL_INLINE void reorient_facets_raycast(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    const Eigen::PlainObjectBase<DerivedF> & F,
-    Eigen::PlainObjectBase<DerivedFF> & FF,
-    Eigen::PlainObjectBase<DerivedI> & I);
+  namespace embree
+  {
+    // Orient each component (identified by C) of a mesh (V,F) using ambient
+    // occlusion such that the front side is less occluded than back side
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices
+    //   rays_total  Total number of rays that will be shot
+    //   rays_minimum  Minimum number of rays that each patch should receive
+    //   facet_wise  Decision made for each face independently, no use of patches
+    //     (i.e., each face is treated as a patch)
+    //   use_parity  Use parity mode
+    //   is_verbose  Verbose output to cout
+    // Outputs:
+    //   I  #F list of whether face has been flipped
+    //   C  #F list of patch ID (output of bfs_orient > manifold patches)
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedI,
+      typename DerivedC>
+    IGL_INLINE void reorient_facets_raycast(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      int rays_total,
+      int rays_minimum,
+      bool facet_wise,
+      bool use_parity,
+      bool is_verbose,
+      Eigen::PlainObjectBase<DerivedI> & I,
+      Eigen::PlainObjectBase<DerivedC> & C);
+    // Outputs:
+    //   FF  #F by 3 list of reoriented faces
+    // Defaults:
+    //   rays_total = F.rows()*100;
+    //   rays_minimum = 10;
+    //   facet_wise = false;
+    //   use_parity = false;
+    //   is_verbose = false;
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedFF,
+      typename DerivedI>
+    IGL_INLINE void reorient_facets_raycast(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      const Eigen::PlainObjectBase<DerivedF> & F,
+      Eigen::PlainObjectBase<DerivedFF> & FF,
+      Eigen::PlainObjectBase<DerivedI> & I);
+  }
 };
 
 #ifndef IGL_STATIC_LIBRARY

+ 14 - 14
include/igl/embree/unproject_in_mesh.cpp

@@ -13,24 +13,24 @@
 #ifndef IGL_OPENGL_4
 template <
   typename Derivedobj>
-IGL_INLINE int igl::unproject_in_mesh(
+IGL_INLINE int igl::embree::unproject_in_mesh(
   const double x,
   const double y,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   Eigen::PlainObjectBase<Derivedobj> & obj)
 {
-  std::vector<igl::Hit> hits;
-  return igl::unproject_in_mesh(x,y,ei,obj,hits);
+  std::vector<igl::embree::Hit> hits;
+  return unproject_in_mesh(x,y,ei,obj,hits);
 }
 
 template <
   typename Derivedobj>
-IGL_INLINE int igl::unproject_in_mesh(
+IGL_INLINE int igl::embree::unproject_in_mesh(
   const double x,
   const double y,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   Eigen::PlainObjectBase<Derivedobj> & obj,
-  std::vector<igl::Hit > & hits)
+  std::vector<igl::embree::Hit > & hits)
 {
   using namespace igl;
   using namespace std;
@@ -68,14 +68,14 @@ IGL_INLINE int igl::unproject_in_mesh(
 #endif
 
 template <typename Derivedobj>
-IGL_INLINE int igl::unproject_in_mesh(
+IGL_INLINE int igl::embree::unproject_in_mesh(
   const Eigen::Vector2f& pos,
   const Eigen::Matrix4f& model,
   const Eigen::Matrix4f& proj,
   const Eigen::Vector4f& viewport,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   Eigen::PlainObjectBase<Derivedobj> & obj,
-  std::vector<igl::Hit > & hits)
+  std::vector<igl::embree::Hit > & hits)
 {
   using namespace igl;
   using namespace std;
@@ -115,9 +115,9 @@ IGL_INLINE int igl::unproject_in_mesh(
 
 #ifdef IGL_STATIC_LIBRARY
 #  ifndef IGL_OPENLGL_4
-template int igl::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&, std::vector<igl::Hit, std::allocator<igl::Hit> >&);
-template int igl::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
+template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
+template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 3, 1, 0, 3, 1> >(double, double, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
 #  endif
-template int igl::unproject_in_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<igl::Hit, std::allocator<igl::Hit> >&);
-template int igl::unproject_in_mesh<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&, std::vector<igl::Hit, std::allocator<igl::Hit> >&);
+template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
+template int igl::embree::unproject_in_mesh<Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::Matrix<float, 2, 1, 0, 2, 1> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 4, 0, 4, 4> const&, Eigen::Matrix<float, 4, 1, 0, 4, 1> const&, igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&, std::vector<igl::embree::Hit, std::allocator<igl::embree::Hit> >&);
 #endif

+ 54 - 52
include/igl/embree/unproject_in_mesh.h

@@ -15,66 +15,68 @@
 
 namespace igl
 {
-  // Forward define
-  class EmbreeIntersector;
-
-  #ifndef IGL_OPENGL_4
-  // Unproject a screen location (using current opengl viewport, projection, and
-  // model view) to a 3D position _inside_ a given mesh. If the ray through the
-  // given screen location (x,y) _hits_ the mesh more than twice then the 3D
-  // midpoint between the first two hits is return. If it hits once, then that
-  // point is return. If it does not hit the mesh then obj is not set.
+  namespace embree
+  {
+    // Forward define
+    class EmbreeIntersector;
+  
+    #ifndef IGL_OPENGL_4
+    // Unproject a screen location (using current opengl viewport, projection, and
+    // model view) to a 3D position _inside_ a given mesh. If the ray through the
+    // given screen location (x,y) _hits_ the mesh more than twice then the 3D
+    // midpoint between the first two hits is return. If it hits once, then that
+    // point is return. If it does not hit the mesh then obj is not set.
+    //
+    // Inputs:
+    //    x  x-coordinate of mouse location
+    //    y  y-coordinate of mouse location
+    //    ei  EmbreeIntersector containing (V,F)
+    // Outputs:
+    //    obj  3d unprojected mouse point in mesh
+    // Returns number of hits
+    //
+    template <
+      typename Derivedobj>
+    IGL_INLINE int unproject_in_mesh(
+      const double x,
+      const double y,
+      const EmbreeIntersector & ei,
+      Eigen::PlainObjectBase<Derivedobj> & obj);
+  
+    template <
+      typename Derivedobj>
+    IGL_INLINE int unproject_in_mesh(
+      const double x,
+      const double y,
+      const EmbreeIntersector & ei,
+      Eigen::PlainObjectBase<Derivedobj> & obj,
+      std::vector<igl::embree::Hit > & hits);
+    #endif
+  
+  // Unproject a screen location (using the given model, proj and viewewport) to a 3D position
+  // and a set of hits
   //
   // Inputs:
-  //    x  x-coordinate of mouse location
-  //    y  y-coordinate of mouse location
-  //    ei  EmbreeIntersector containing (V,F)
+  //    pos        screen space coordinates
+  //    model      model matrix
+  //    proj       projection matrix
+  //    viewport   vieweport vector
+  //    ei         EmbreeIntersector containing (V,F)
   // Outputs:
-  //    obj  3d unprojected mouse point in mesh
+  //    obj        3d unprojected mouse point in mesh
+  //    hits       vector of embree hits
   // Returns number of hits
-  //
   template <
     typename Derivedobj>
   IGL_INLINE int unproject_in_mesh(
-    const double x,
-    const double y,
-    const igl::EmbreeIntersector & ei,
-    Eigen::PlainObjectBase<Derivedobj> & obj);
-
-  template <
-    typename Derivedobj>
-  IGL_INLINE int unproject_in_mesh(
-    const double x,
-    const double y,
-    const igl::EmbreeIntersector & ei,
+    const Eigen::Vector2f& pos,
+    const Eigen::Matrix4f& model,
+    const Eigen::Matrix4f& proj,
+    const Eigen::Vector4f& viewport,
+    const EmbreeIntersector & ei,
     Eigen::PlainObjectBase<Derivedobj> & obj,
-    std::vector<igl::Hit > & hits);
-  #endif
-
-// Unproject a screen location (using the given model, proj and viewewport) to a 3D position
-// and a set of hits
-//
-// Inputs:
-//    pos        screen space coordinates
-//    model      model matrix
-//    proj       projection matrix
-//    viewport   vieweport vector
-//    ei         EmbreeIntersector containing (V,F)
-// Outputs:
-//    obj        3d unprojected mouse point in mesh
-//    hits       vector of embree hits
-// Returns number of hits
-template <
-  typename Derivedobj>
-IGL_INLINE int unproject_in_mesh(
-  const Eigen::Vector2f& pos,
-  const Eigen::Matrix4f& model,
-  const Eigen::Matrix4f& proj,
-  const Eigen::Vector4f& viewport,
-  const igl::EmbreeIntersector & ei,
-  Eigen::PlainObjectBase<Derivedobj> & obj,
-  std::vector<igl::Hit > & hits);
-
+    std::vector<igl::embree::Hit > & hits);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "unproject_in_mesh.cpp"

+ 5 - 5
include/igl/embree/unproject_onto_mesh.cpp

@@ -11,20 +11,20 @@
 #include <igl/embree/unproject_in_mesh.h>
 #include <vector>
 
-IGL_INLINE bool igl::unproject_onto_mesh(
+IGL_INLINE bool igl::embree::unproject_onto_mesh(
   const Eigen::Vector2f& pos,
   const Eigen::MatrixXi& F,
   const Eigen::Matrix4f& model,
   const Eigen::Matrix4f& proj,
   const Eigen::Vector4f& viewport,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   int& fid,
   Eigen::Vector3f& bc)
 {
   using namespace std;
   using namespace Eigen;
   MatrixXd obj;
-  vector<igl::Hit> hits;
+  vector<igl::embree::Hit> hits;
 
   // This is lazy, it will find more than just the first hit
   unproject_in_mesh(pos,model,proj,viewport,ei,obj,hits);
@@ -39,13 +39,13 @@ IGL_INLINE bool igl::unproject_onto_mesh(
   return false;
 }
 
-IGL_INLINE bool igl::unproject_onto_mesh(
+IGL_INLINE bool igl::embree::unproject_onto_mesh(
   const Eigen::Vector2f& pos,
   const Eigen::MatrixXi& F,
   const Eigen::Matrix4f& model,
   const Eigen::Matrix4f& proj,
   const Eigen::Vector4f& viewport,
-  const igl::EmbreeIntersector & ei,
+  const EmbreeIntersector & ei,
   int& fid,
   int& vid)
 {

+ 52 - 50
include/igl/embree/unproject_onto_mesh.h

@@ -15,56 +15,58 @@
 
 namespace igl
 {
-  // Forward define
-  class EmbreeIntersector;
-  // Unproject a screen location (using the given model, proj and viewport) to find
-  // the first hit on a mesh.
-  //
-  // Inputs:
-  //    pos        screen space coordinates
-  //    F          #F by 3 face matrix
-  //    model      model matrix
-  //    proj       projection matrix
-  //    viewport   vieweport vector
-  //    ei         EmbreeIntersector containing (V,F)
-  // Outputs:
-  //    fid        id of the first face hit
-  //    bc         barycentric coordinates of hit
-  // Returns true if there is a hit
-  IGL_INLINE bool unproject_onto_mesh(
-    const Eigen::Vector2f& pos,
-    const Eigen::MatrixXi& F,
-    const Eigen::Matrix4f& model,
-    const Eigen::Matrix4f& proj,
-    const Eigen::Vector4f& viewport,
-    const igl::EmbreeIntersector & ei,
-    int& fid,
-    Eigen::Vector3f& bc);
-  
-  // Unproject a screen location (using the given model, proj and viewport) to find
-  // the first face on the mesh and the closest vertex
-  //
-  // Inputs:
-  //    pos        screen space coordinates
-  //    F          #F by 3 face matrix
-  //    model      model matrix
-  //    proj       projection matrix
-  //    viewport   vieweport vector
-  //    ei         EmbreeIntersector containing (V,F)
-  // Outputs:
-  //    fid        id of the first face hit
-  //    vid        vertex id of the closest vertex hit
-  // Returns true if there is a hit
-  IGL_INLINE bool unproject_onto_mesh(
-    const Eigen::Vector2f& pos,
-    const Eigen::MatrixXi& F,
-    const Eigen::Matrix4f& model,
-    const Eigen::Matrix4f& proj,
-    const Eigen::Vector4f& viewport,
-    const igl::EmbreeIntersector & ei,
-    int& fid,
-    int& vid);
-
+  namespace embree
+  {
+    // Forward define
+    class EmbreeIntersector;
+    // Unproject a screen location (using the given model, proj and viewport) to find
+    // the first hit on a mesh.
+    //
+    // Inputs:
+    //    pos        screen space coordinates
+    //    F          #F by 3 face matrix
+    //    model      model matrix
+    //    proj       projection matrix
+    //    viewport   vieweport vector
+    //    ei         EmbreeIntersector containing (V,F)
+    // Outputs:
+    //    fid        id of the first face hit
+    //    bc         barycentric coordinates of hit
+    // Returns true if there is a hit
+    IGL_INLINE bool unproject_onto_mesh(
+      const Eigen::Vector2f& pos,
+      const Eigen::MatrixXi& F,
+      const Eigen::Matrix4f& model,
+      const Eigen::Matrix4f& proj,
+      const Eigen::Vector4f& viewport,
+      const EmbreeIntersector & ei,
+      int& fid,
+      Eigen::Vector3f& bc);
+    
+    // Unproject a screen location (using the given model, proj and viewport) to find
+    // the first face on the mesh and the closest vertex
+    //
+    // Inputs:
+    //    pos        screen space coordinates
+    //    F          #F by 3 face matrix
+    //    model      model matrix
+    //    proj       projection matrix
+    //    viewport   vieweport vector
+    //    ei         EmbreeIntersector containing (V,F)
+    // Outputs:
+    //    fid        id of the first face hit
+    //    vid        vertex id of the closest vertex hit
+    // Returns true if there is a hit
+    IGL_INLINE bool unproject_onto_mesh(
+      const Eigen::Vector2f& pos,
+      const Eigen::MatrixXi& F,
+      const Eigen::Matrix4f& model,
+      const Eigen::Matrix4f& proj,
+      const Eigen::Vector4f& viewport,
+      const EmbreeIntersector & ei,
+      int& fid,
+      int& vid);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "unproject_onto_mesh.cpp"

+ 1 - 1
include/igl/lim/lim.cpp

@@ -8,7 +8,7 @@
 #include "lim.h"
 #include <LIMSolverInterface.h>
 
-IGL_INLINE int igl::lim(
+IGL_INLINE int igl::lim::lim(
   Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
   const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
   const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,

+ 110 - 95
include/igl/lim/lim.h

@@ -13,101 +13,116 @@
 
 namespace igl
 {
-  // Known issues: energy type should be a readable enum rather than magic
-  // ints.
-  //
-  // Computes a locally injective mapping of a triangle or tet-mesh based on a deformation energy
-  // subject to some provided linear positional constraints Cv-d.
-  //
-  // Inputs:
-  //   vertices          vx3 matrix containing vertex position of the mesh
-  //   initialVertices   vx3 matrix containing vertex position of initial rest pose mesh
-  //   elements          exd matrix containing vertex indices of all elements
-  //   borderVertices    (only needed for 2D LSCM) vector containing indices of border vertices
-  //   gradients         (only needed for 2D Poisson) vector containing partial derivatives of target element gradients (structure is: [xx_0, xy_0, xx_1, xy_1, ..., xx_v, xy_v, yx_0, yy_0, yx_1, yy_1, ..., yx_v, yy_v]')
-  //   constraintMatrix  C: (c)x(v*(d-1)) sparse linear positional constraint matrix. X an Y-coordinates are alternatingly stacked per row (structure for triangles: [x_1, y_1, x_2, y_2, ..., x_v,y_v])
-  //   constraintTargets d: c vector target positions
-  //   energyType        type of used energy: 0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM
-  //   tolerance         max squared positional constraints error
-  //   maxIteration      max number of iterations
-  //   findLocalMinima   iterating until a local minima is found. If not enabled only tolerance must be fulfilled.
-  //   enableOutput      (optional) enables the output (#itaration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true)
-  //   enableBarriers    (optional) enables the non-flip constraints (default = true)
-  //   enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
-  //   beta              (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
-  //   eps               (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
-  //
-  // where:
-  //   v : # vertices
-  //   c : # linear constraints
-  //   e : # elements of mesh
-  //   d : # vertices per element (triangle = 3, tet = 4)
-  //----------------------------------------------------------------------------------------
-  // Output:
-  // vertices          vx3 matrix containing resulting vertex position of the mesh
-  //----------------------------------------------------------------------------------------
-  // Return values:
-  //  1 : Successful optimization with fulfilled tolerance
-  // -1 : Max iteration reached before tolerance was fulfilled
-  // -2 : not feasible -> has inverted elements (may want to decrease eps?)
-
-  int lim(
-    Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
-    const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
-    const Eigen::SparseMatrix<double>& constraintMatrix,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-    int energyType,
-    double tolerance,
-    int maxIteration,
-    bool findLocalMinima);
-
-  int lim(
-    Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
-    const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
-    const Eigen::SparseMatrix<double>& constraintMatrix,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-    int energyType,
-    double tolerance,
-    int maxIteration,
-    bool findLocalMinima,
-    bool enableOuput,
-    bool enableBarriers,
-    bool enableAlphaUpdate,
-    double beta,
-    double eps);
-
-  int lim(
-    Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
-    const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
-    const std::vector<int>& borderVertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
-    const Eigen::SparseMatrix<double>& constraintMatrix,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-    int energyType,
-    double tolerance,
-    int maxIteration,
-    bool findLocalMinima);
-
-  int lim(
-    Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
-    const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
-    const std::vector<int>& borderVertices,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
-    const Eigen::SparseMatrix<double>& constraintMatrix,
-    const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
-    int energyType,
-    double tolerance,
-    int maxIteration,
-    bool findLocalMinima,
-    bool enableOuput,
-    bool enableBarriers,
-    bool enableAlphaUpdate,
-    double beta,
-    double eps);
+  namespace lim
+  {
+    // Known issues: energy type should be a readable enum rather than magic
+    // ints.
+    //
+    // Computes a locally injective mapping of a triangle or tet-mesh based on
+    // a deformation energy subject to some provided linear positional
+    // constraints Cv-d.
+    //
+    // Inputs:
+    //   vertices          vx3 matrix containing vertex position of the mesh
+    //   initialVertices   vx3 matrix containing vertex position of initial
+    //                     rest pose mesh
+    //   elements          exd matrix containing vertex indices of all elements
+    //   borderVertices    (only needed for 2D LSCM) vector containing indices
+    //                     of border vertices
+    //   gradients         (only needed for 2D Poisson) vector containing
+    //                     partial derivatives of target element gradients
+    //                     (structure is: [xx_0, xy_0, xx_1, xy_1, ..., xx_v,
+    //                     xy_v, yx_0, yy_0, yx_1, yy_1, ..., yx_v, yy_v]')
+    //   constraintMatrix  C: (c)x(v*(d-1)) sparse linear positional constraint
+    //                     matrix. X an Y-coordinates are alternatingly stacked
+    //                     per row (structure for triangles: [x_1, y_1, x_2,
+    //                     y_2, ..., x_v,y_v])
+    //   constraintTargets d: c vector target positions
+    //   energyType        type of used energy:
+    //                     0=Dirichlet,1=Laplacian,2=Green,3=ARAP,4=LSCM
+    //   tolerance         max squared positional constraints error
+    //   maxIteration      max number of iterations
+    //   findLocalMinima   iterating until a local minima is found. If not
+    //                     enabled only tolerance must be fulfilled.
+    //   enableOutput      (optional) enables the output (#iteration / hessian correction / step size / positional constraints / barrier constraints / deformation energy) (default : true)
+    //   enableBarriers    (optional) enables the non-flip constraints (default = true)
+    //   enableAlphaUpdate (optional) enables dynamic alpha weight adjustment (default = true)
+    //   beta              (optional) steepness factor of barrier slopes (default: ARAP/LSCM = 0.01, Green = 1)
+    //   eps               (optional) smallest valid triangle area (default: 1e-5 * smallest triangle)
+    //
+    // where:
+    //   v : # vertices
+    //   c : # linear constraints
+    //   e : # elements of mesh
+    //   d : # vertices per element (triangle = 3, tet = 4)
+    //--------------------------------------------------------------------------
+    // Output:
+    // vertices          vx3 matrix containing resulting vertex position of the
+    //                   mesh
+    //--------------------------------------------------------------------------
+    // Return values:
+    //  1 : Successful optimization with fulfilled tolerance
+    // -1 : Max iteration reached before tolerance was fulfilled
+    // -2 : not feasible -> has inverted elements (may want to decrease eps?)
+  
+    int lim(
+      Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
+      const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
+      const Eigen::SparseMatrix<double>& constraintMatrix,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
+      int energyType,
+      double tolerance,
+      int maxIteration,
+      bool findLocalMinima);
+  
+    int lim(
+      Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
+      const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
+      const Eigen::SparseMatrix<double>& constraintMatrix,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
+      int energyType,
+      double tolerance,
+      int maxIteration,
+      bool findLocalMinima,
+      bool enableOuput,
+      bool enableBarriers,
+      bool enableAlphaUpdate,
+      double beta,
+      double eps);
+  
+    int lim(
+      Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
+      const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
+      const std::vector<int>& borderVertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
+      const Eigen::SparseMatrix<double>& constraintMatrix,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
+      int energyType,
+      double tolerance,
+      int maxIteration,
+      bool findLocalMinima);
+  
+    int lim(
+      Eigen::Matrix<double,Eigen::Dynamic,3>& vertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,3>& initialVertices,
+      const Eigen::Matrix<int,Eigen::Dynamic,Eigen::Dynamic>& elements,
+      const std::vector<int>& borderVertices,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& gradients,
+      const Eigen::SparseMatrix<double>& constraintMatrix,
+      const Eigen::Matrix<double,Eigen::Dynamic,1>& constraintTargets,
+      int energyType,
+      double tolerance,
+      int maxIteration,
+      bool findLocalMinima,
+      bool enableOuput,
+      bool enableBarriers,
+      bool enableAlphaUpdate,
+      double beta,
+      double eps);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 152 - 149
include/igl/matlab/MatlabWorkspace.h

@@ -18,135 +18,138 @@
 
 namespace igl
 {
-  // It would be really great to replicate this for a simple XML-based
-  // workspace.
-  //
-  // Class which contains data of a matlab workspace which can be written to a
-  // .mat file and loaded from matlab
-  // 
-  // This depends on matlab at compile time (though it shouldn't necessarily
-  // have to) but it does not depend on running the matlab engine at run-time.
-  //
-  // Known bugs: Treats all matrices as doubles (this may actually be desired
-  // for some "index" matrices since matlab's sparse command takes doubles
-  // rather than int class matrices). It is of course not desired when dealing
-  // with logicals or uint's for images.
-  class MatlabWorkspace
+  namespace matlab
   {
-    private:
-      // KNOWN BUG: Why not use a map? Any reason to allow duplicate names?
-      //
-      // List of names
-      std::vector<std::string> names;
-      // List of data pointers
-      std::vector<mxArray*> data;
-    public:
-      MatlabWorkspace();
-      ~MatlabWorkspace();
-      // Clear names and data of variables in workspace
-      inline void clear();
-      // Save current list of variables
-      //
-      // Inputs:
-      //   path  path to .mat file
-      // Returns true on success, false on failure
-      inline bool write(const std::string & path) const;
-      // Load list of variables from .mat file
-      //
-      // Inputs:
-      //   path  path to .mat file
-      // Returns true on success, false on failure
-      inline bool read(const std::string & path);
-      // Assign data to a variable name in the workspace
-      //
-      // Template: 
-      //   DerivedM  eigen matrix (e.g. MatrixXd)
-      // Inputs:
-      //   M  data (usually a matrix)
-      //   name  variable name to save into work space
-      // Returns true on success, false on failure
-      //
-      // Known Bugs: Assumes Eigen is using column major ordering
-      template <typename DerivedM>
-      inline MatlabWorkspace& save(
-        const Eigen::PlainObjectBase<DerivedM>& M,
-        const std::string & name);
-      // Template:
-      //   MT  sparse matrix type (e.g. double)
-      template <typename MT>
-      inline MatlabWorkspace& save(
-        const Eigen::SparseMatrix<MT>& M,
-        const std::string & name);
-      // Templates:
-      //   ScalarM  scalar type, e.g. double
-      template <typename ScalarM>
-      inline MatlabWorkspace& save(
-        const std::vector<std::vector<ScalarM> > & vM,
-        const std::string & name);
-      // Templates:
-      //   ScalarV  scalar type, e.g. double
-      template <typename ScalarV>
-      inline MatlabWorkspace& save(
-        const std::vector<ScalarV> & vV,
-        const std::string & name);
-      // NOTE: Eigen stores quaternions coefficients as (i,j,k,1), but most of
-      // our matlab code stores them as (1,i,j,k) This takes a quaternion and
-      // saves it as a (1,i,j,k) row vector
-      //
-      // Templates:
-      //   Q  quaternion type
-      template <typename Q>
-      inline MatlabWorkspace& save(
-        const Eigen::Quaternion<Q> & q,
-        const std::string & name);
-      inline MatlabWorkspace& save(
-        const double d,
-        const std::string & name);
-      // Same as save() but adds 1 to each element, useful for saving "index"
-      // matrices like lists of faces or elements
-      template <typename DerivedM>
-      inline MatlabWorkspace& save_index(
-        const Eigen::PlainObjectBase<DerivedM>& M,
-        const std::string & name);
-      template <typename ScalarM>
-      inline MatlabWorkspace& save_index(
-        const std::vector<std::vector<ScalarM> > & vM,
-        const std::string & name);
-      template <typename ScalarV>
-      inline MatlabWorkspace& save_index(
-        const std::vector<ScalarV> & vV,
-        const std::string & name);
-      // Find a certain matrix by name.
-      //
-      // KNOWN BUG: Outputs the first found (not necessarily unique lists).
-      //
-      // Template: 
-      //   DerivedM  eigen matrix (e.g. MatrixXd)
-      // Inputs:
-      //   name  exact name of matrix as string
-      // Outputs:
-      //   M  matrix
-      // Returns true only if found.
-      template <typename DerivedM>
-      inline bool find( 
-        const std::string & name,
-        Eigen::PlainObjectBase<DerivedM>& M);
-      template <typename MT>
-      inline bool find( 
-        const std::string & name,
-        Eigen::SparseMatrix<MT>& M);
-      inline bool find( 
-        const std::string & name,
-        double & d);
-      inline bool find( 
-        const std::string & name,
-        int & v);
-      // Subtracts 1 from all entries
-      template <typename DerivedM>
-      inline bool find_index( 
-        const std::string & name,
-        Eigen::PlainObjectBase<DerivedM>& M);
-  };
+    // It would be really great to replicate this for a simple XML-based
+    // workspace.
+    //
+    // Class which contains data of a matlab workspace which can be written to a
+    // .mat file and loaded from matlab
+    // 
+    // This depends on matlab at compile time (though it shouldn't necessarily
+    // have to) but it does not depend on running the matlab engine at run-time.
+    //
+    // Known bugs: Treats all matrices as doubles (this may actually be desired
+    // for some "index" matrices since matlab's sparse command takes doubles
+    // rather than int class matrices). It is of course not desired when dealing
+    // with logicals or uint's for images.
+    class MatlabWorkspace
+    {
+      private:
+        // KNOWN BUG: Why not use a map? Any reason to allow duplicate names?
+        //
+        // List of names
+        std::vector<std::string> names;
+        // List of data pointers
+        std::vector<mxArray*> data;
+      public:
+        MatlabWorkspace();
+        ~MatlabWorkspace();
+        // Clear names and data of variables in workspace
+        inline void clear();
+        // Save current list of variables
+        //
+        // Inputs:
+        //   path  path to .mat file
+        // Returns true on success, false on failure
+        inline bool write(const std::string & path) const;
+        // Load list of variables from .mat file
+        //
+        // Inputs:
+        //   path  path to .mat file
+        // Returns true on success, false on failure
+        inline bool read(const std::string & path);
+        // Assign data to a variable name in the workspace
+        //
+        // Template: 
+        //   DerivedM  eigen matrix (e.g. MatrixXd)
+        // Inputs:
+        //   M  data (usually a matrix)
+        //   name  variable name to save into work space
+        // Returns true on success, false on failure
+        //
+        // Known Bugs: Assumes Eigen is using column major ordering
+        template <typename DerivedM>
+        inline MatlabWorkspace& save(
+          const Eigen::PlainObjectBase<DerivedM>& M,
+          const std::string & name);
+        // Template:
+        //   MT  sparse matrix type (e.g. double)
+        template <typename MT>
+        inline MatlabWorkspace& save(
+          const Eigen::SparseMatrix<MT>& M,
+          const std::string & name);
+        // Templates:
+        //   ScalarM  scalar type, e.g. double
+        template <typename ScalarM>
+        inline MatlabWorkspace& save(
+          const std::vector<std::vector<ScalarM> > & vM,
+          const std::string & name);
+        // Templates:
+        //   ScalarV  scalar type, e.g. double
+        template <typename ScalarV>
+        inline MatlabWorkspace& save(
+          const std::vector<ScalarV> & vV,
+          const std::string & name);
+        // NOTE: Eigen stores quaternions coefficients as (i,j,k,1), but most of
+        // our matlab code stores them as (1,i,j,k) This takes a quaternion and
+        // saves it as a (1,i,j,k) row vector
+        //
+        // Templates:
+        //   Q  quaternion type
+        template <typename Q>
+        inline MatlabWorkspace& save(
+          const Eigen::Quaternion<Q> & q,
+          const std::string & name);
+        inline MatlabWorkspace& save(
+          const double d,
+          const std::string & name);
+        // Same as save() but adds 1 to each element, useful for saving "index"
+        // matrices like lists of faces or elements
+        template <typename DerivedM>
+        inline MatlabWorkspace& save_index(
+          const Eigen::PlainObjectBase<DerivedM>& M,
+          const std::string & name);
+        template <typename ScalarM>
+        inline MatlabWorkspace& save_index(
+          const std::vector<std::vector<ScalarM> > & vM,
+          const std::string & name);
+        template <typename ScalarV>
+        inline MatlabWorkspace& save_index(
+          const std::vector<ScalarV> & vV,
+          const std::string & name);
+        // Find a certain matrix by name.
+        //
+        // KNOWN BUG: Outputs the first found (not necessarily unique lists).
+        //
+        // Template: 
+        //   DerivedM  eigen matrix (e.g. MatrixXd)
+        // Inputs:
+        //   name  exact name of matrix as string
+        // Outputs:
+        //   M  matrix
+        // Returns true only if found.
+        template <typename DerivedM>
+        inline bool find( 
+          const std::string & name,
+          Eigen::PlainObjectBase<DerivedM>& M);
+        template <typename MT>
+        inline bool find( 
+          const std::string & name,
+          Eigen::SparseMatrix<MT>& M);
+        inline bool find( 
+          const std::string & name,
+          double & d);
+        inline bool find( 
+          const std::string & name,
+          int & v);
+        // Subtracts 1 from all entries
+        template <typename DerivedM>
+        inline bool find_index( 
+          const std::string & name,
+          Eigen::PlainObjectBase<DerivedM>& M);
+    };
+  }
 }
 
 // Implementation
@@ -165,26 +168,26 @@ namespace igl
 #include <algorithm>
 #include <vector>
 
-inline igl::MatlabWorkspace::MatlabWorkspace():
+inline igl::matlab::MatlabWorkspace::MatlabWorkspace():
   names(),
   data()
 {
 }
 
-inline igl::MatlabWorkspace::~MatlabWorkspace()
+inline igl::matlab::MatlabWorkspace::~MatlabWorkspace()
 {
   // clean up data
   clear();
 }
 
-inline void igl::MatlabWorkspace::clear()
+inline void igl::matlab::MatlabWorkspace::clear()
 {
   for_each(data.begin(),data.end(),&mxDestroyArray);
   data.clear();
   names.clear();
 }
 
-inline bool igl::MatlabWorkspace::write(const std::string & path) const
+inline bool igl::matlab::MatlabWorkspace::write(const std::string & path) const
 {
   using namespace std;
   MATFile * mat_file = matOpen(path.c_str(), "w");
@@ -214,7 +217,7 @@ inline bool igl::MatlabWorkspace::write(const std::string & path) const
   return true;
 }
 
-inline bool igl::MatlabWorkspace::read(const std::string & path)
+inline bool igl::matlab::MatlabWorkspace::read(const std::string & path)
 {
   using namespace std;
 
@@ -284,7 +287,7 @@ inline bool igl::MatlabWorkspace::read(const std::string & path)
 
 // Treat everything as a double
 template <typename DerivedM>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const Eigen::PlainObjectBase<DerivedM>& M,
   const std::string & name)
 {
@@ -302,7 +305,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
 
 // Treat everything as a double
 template <typename MT>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const Eigen::SparseMatrix<MT>& M,
   const std::string & name)
 {
@@ -339,7 +342,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
 }
 
 template <typename ScalarM>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const std::vector<std::vector<ScalarM> > & vM,
   const std::string & name)
 {
@@ -349,7 +352,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
 }
 
 template <typename ScalarV>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const std::vector<ScalarV> & vV,
   const std::string & name)
 {
@@ -359,7 +362,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
 }
 
 template <typename Q>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const Eigen::Quaternion<Q> & q,
   const std::string & name)
 {
@@ -371,7 +374,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
   return save(qm,name);
 }
 
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save(
   const double d,
   const std::string & name)
 {
@@ -381,8 +384,8 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save(
 }
 
 template <typename DerivedM>
-inline igl::MatlabWorkspace& 
-  igl::MatlabWorkspace::save_index(
+inline igl::matlab::MatlabWorkspace& 
+  igl::matlab::MatlabWorkspace::save_index(
     const Eigen::PlainObjectBase<DerivedM>& M,
     const std::string & name)
 {
@@ -392,7 +395,7 @@ inline igl::MatlabWorkspace&
 }
 
 template <typename ScalarM>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save_index(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save_index(
   const std::vector<std::vector<ScalarM> > & vM,
   const std::string & name)
 {
@@ -402,7 +405,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save_index(
 }
 
 template <typename ScalarV>
-inline igl::MatlabWorkspace& igl::MatlabWorkspace::save_index(
+inline igl::matlab::MatlabWorkspace& igl::matlab::MatlabWorkspace::save_index(
   const std::vector<ScalarV> & vV,
   const std::string & name)
 {
@@ -412,7 +415,7 @@ inline igl::MatlabWorkspace& igl::MatlabWorkspace::save_index(
 }
 
 template <typename DerivedM>
-inline bool igl::MatlabWorkspace::find( 
+inline bool igl::matlab::MatlabWorkspace::find( 
   const std::string & name,
   Eigen::PlainObjectBase<DerivedM>& M)
 {
@@ -446,7 +449,7 @@ inline bool igl::MatlabWorkspace::find(
 }
 
 template <typename MT>
-inline bool igl::MatlabWorkspace::find( 
+inline bool igl::matlab::MatlabWorkspace::find( 
   const std::string & name,
   Eigen::SparseMatrix<MT>& M)
 {
@@ -499,7 +502,7 @@ inline bool igl::MatlabWorkspace::find(
 
 }
 
-inline bool igl::MatlabWorkspace::find( 
+inline bool igl::matlab::MatlabWorkspace::find( 
   const std::string & name,
   int & v)
 {
@@ -522,7 +525,7 @@ inline bool igl::MatlabWorkspace::find(
   return true;
 }
 
-inline bool igl::MatlabWorkspace::find( 
+inline bool igl::matlab::MatlabWorkspace::find( 
   const std::string & name,
   double & d)
 {
@@ -546,7 +549,7 @@ inline bool igl::MatlabWorkspace::find(
 }
 
 template <typename DerivedM>
-inline bool igl::MatlabWorkspace::find_index( 
+inline bool igl::matlab::MatlabWorkspace::find_index( 
   const std::string & name,
   Eigen::PlainObjectBase<DerivedM>& M)
 {
@@ -560,7 +563,7 @@ inline bool igl::MatlabWorkspace::find_index(
 
 
 //template <typename Data>
-//bool igl::MatlabWorkspace::save(const Data & M, const std::string & name)
+//bool igl::matlab::MatlabWorkspace::save(const Data & M, const std::string & name)
 //{
 //  using namespace std;
 //  // If I don't know the type then I can't save it

+ 23 - 20
include/igl/matlab/MexStream.h

@@ -10,30 +10,33 @@
 #include <iostream>
 namespace igl
 {
-  // http://stackoverflow.com/a/249008/148668
-  
-  // Class to implement "cout" for mex files to print to the matlab terminal
-  // window.
-  //
-  // Insert at the beginning of mexFunction():
-  //  MexStream mout;
-  //  std::streambuf *outbuf = std::cout.rdbuf(&mout); 
-  //  ...
-  //  ALWAYS restore original buffer to avoid memory leak problems in matlab
-  //  std::cout.rdbuf(outbuf);
-  //
-  class MexStream : public std::streambuf
+  namespace matlab
   {
-    public:
-    protected:
-      inline virtual std::streamsize xsputn(const char *s, std::streamsize n); 
-      inline virtual int overflow(int c = EOF);
-  }; 
+    // http://stackoverflow.com/a/249008/148668
+    
+    // Class to implement "cout" for mex files to print to the matlab terminal
+    // window.
+    //
+    // Insert at the beginning of mexFunction():
+    //  MexStream mout;
+    //  std::streambuf *outbuf = std::cout.rdbuf(&mout); 
+    //  ...
+    //  ALWAYS restore original buffer to avoid memory leak problems in matlab
+    //  std::cout.rdbuf(outbuf);
+    //
+    class MexStream : public std::streambuf
+    {
+      public:
+      protected:
+        inline virtual std::streamsize xsputn(const char *s, std::streamsize n); 
+        inline virtual int overflow(int c = EOF);
+    }; 
+  }
 }
 
 // Implementation 
 #include <mex.h>
-inline std::streamsize igl::MexStream::xsputn(
+inline std::streamsize igl::matlab::MexStream::xsputn(
   const char *s, 
   std::streamsize n) 
 {
@@ -42,7 +45,7 @@ inline std::streamsize igl::MexStream::xsputn(
   return n;
 }
 
-inline int igl::MexStream::overflow(int c) 
+inline int igl::matlab::MexStream::overflow(int c) 
 {
     if (c != EOF) {
       mexPrintf("%.1s",&c);

+ 14 - 14
include/igl/matlab/matlabinterface.cpp

@@ -11,20 +11,20 @@
 
 // Init the MATLAB engine
 // (no need to call it directly since it is automatically invoked by any other command)
-IGL_INLINE void igl::mlinit(Engine** mlengine)
+IGL_INLINE void igl::matlab::mlinit(Engine** mlengine)
 {
   *mlengine = engOpen("\0");
 }
 
 // Closes the MATLAB engine
-IGL_INLINE void igl::mlclose(Engine** mlengine)
+IGL_INLINE void igl::matlab::mlclose(Engine** mlengine)
 {
   engClose(*mlengine);
   *mlengine = 0;
 }
 
 // Send a matrix to MATLAB
-IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXd& M)
+IGL_INLINE void igl::matlab::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXd& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -42,7 +42,7 @@ IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eige
 }
 
 // Send a matrix to MATLAB
-IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXf& M)
+IGL_INLINE void igl::matlab::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXf& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -60,7 +60,7 @@ IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eige
 }
 
 // Send a matrix to MATLAB
-IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXi& M)
+IGL_INLINE void igl::matlab::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::MatrixXi& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -78,7 +78,7 @@ IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eige
 }
 
 // Send a matrix to MATLAB
-IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M)
+IGL_INLINE void igl::matlab::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -96,7 +96,7 @@ IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eige
 }
 
 // Receive a matrix from MATLAB
-IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXd& M)
+IGL_INLINE void igl::matlab::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXd& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -129,7 +129,7 @@ IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Mat
   mxDestroyArray(ary);
 }
 
-IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXf& M)
+IGL_INLINE void igl::matlab::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXf& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -163,7 +163,7 @@ IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Mat
 }
 
 // Receive a matrix from MATLAB
-IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXi& M)
+IGL_INLINE void igl::matlab::mlgetmatrix(Engine** mlengine, std::string name, Eigen::MatrixXi& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -197,7 +197,7 @@ IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Mat
 }
 
 // Receive a matrix from MATLAB
-IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M)
+IGL_INLINE void igl::matlab::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -232,7 +232,7 @@ IGL_INLINE void igl::mlgetmatrix(Engine** mlengine, std::string name, Eigen::Mat
 
 
 // Send a single scalar to MATLAB
-IGL_INLINE void igl::mlsetscalar(Engine** mlengine, std::string name, double s)
+IGL_INLINE void igl::matlab::mlsetscalar(Engine** mlengine, std::string name, double s)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -243,7 +243,7 @@ IGL_INLINE void igl::mlsetscalar(Engine** mlengine, std::string name, double s)
 }
 
 // Receive a single scalar from MATLAB
-IGL_INLINE double igl::mlgetscalar(Engine** mlengine, std::string name)
+IGL_INLINE double igl::matlab::mlgetscalar(Engine** mlengine, std::string name)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -254,7 +254,7 @@ IGL_INLINE double igl::mlgetscalar(Engine** mlengine, std::string name)
 }
 
 // Execute arbitrary MATLAB code and return the MATLAB output
-IGL_INLINE std::string igl::mleval(Engine** mlengine, std::string code)
+IGL_INLINE std::string igl::matlab::mleval(Engine** mlengine, std::string code)
 {
   if (*mlengine == 0)
     mlinit(mlengine);
@@ -295,7 +295,7 @@ IGL_INLINE std::string igl::mleval(Engine** mlengine, std::string code)
 }
 
 // Send a sparse matrix
-IGL_INLINE void igl::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::SparseMatrix<double>& M)
+IGL_INLINE void igl::matlab::mlsetmatrix(Engine** mlengine, std::string name, const Eigen::SparseMatrix<double>& M)
 {
   int count = 0;
 //  // Count non-zero

+ 46 - 43
include/igl/matlab/matlabinterface.h

@@ -34,49 +34,52 @@
 
 namespace igl
 {
-  // Init the MATLAB engine
-  // (no need to call it directly since it is automatically invoked by any other command)
-  IGL_INLINE void mlinit(Engine** engine);
-
-  // Closes the MATLAB engine
-  IGL_INLINE void mlclose(Engine** engine);
-
-  // Send a matrix to MATLAB
-  IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXd& M);
-
-  // Send a matrix to MATLAB
-  IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXf& M);
-
-  // Send a matrix to MATLAB
-  IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXi& M);
-
-  // Send a matrix to MATLAB
-  IGL_INLINE void mlsetmatrix(Engine** mlengine, std::string name, const Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
-
-  // Receive a matrix from MATLAB
-  IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXd& M);
-
-  // Receive a matrix from MATLAB
-  IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXf& M);
-
-  // Receive a matrix from MATLAB
-  IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXi& M);
-
-  // Receive a matrix from MATLAB
-  IGL_INLINE void mlgetmatrix(Engine** mlengine, std::string name, Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
-
-  // Send a single scalar to MATLAB
-  IGL_INLINE void mlsetscalar(Engine** engine, std::string name, double s);
-
-  // Receive a single scalar from MATLAB
-  IGL_INLINE double mlgetscalar(Engine** engine, std::string name);
-
-  // Execute arbitrary MATLAB code and return the MATLAB output
-  IGL_INLINE std::string mleval(Engine** engine, std::string code);
-
-  // Send a sparse matrix to MATLAB
-  IGL_INLINE void mlsetmatrix(Engine** mlengine, std::string name, const Eigen::SparseMatrix<double>& M);
-
+  namespace matlab
+  {
+    // Init the MATLAB engine
+    // (no need to call it directly since it is automatically invoked by any other command)
+    IGL_INLINE void mlinit(Engine** engine);
+  
+    // Closes the MATLAB engine
+    IGL_INLINE void mlclose(Engine** engine);
+  
+    // Send a matrix to MATLAB
+    IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXd& M);
+  
+    // Send a matrix to MATLAB
+    IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXf& M);
+  
+    // Send a matrix to MATLAB
+    IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXi& M);
+  
+    // Send a matrix to MATLAB
+    IGL_INLINE void mlsetmatrix(Engine** mlengine, std::string name, const Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
+  
+    // Receive a matrix from MATLAB
+    IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXd& M);
+  
+    // Receive a matrix from MATLAB
+    IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXf& M);
+  
+    // Receive a matrix from MATLAB
+    IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXi& M);
+  
+    // Receive a matrix from MATLAB
+    IGL_INLINE void mlgetmatrix(Engine** mlengine, std::string name, Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
+  
+    // Send a single scalar to MATLAB
+    IGL_INLINE void mlsetscalar(Engine** engine, std::string name, double s);
+  
+    // Receive a single scalar from MATLAB
+    IGL_INLINE double mlgetscalar(Engine** engine, std::string name);
+  
+    // Execute arbitrary MATLAB code and return the MATLAB output
+    IGL_INLINE std::string mleval(Engine** engine, std::string code);
+  
+    // Send a sparse matrix to MATLAB
+    IGL_INLINE void mlsetmatrix(Engine** mlengine, std::string name, const Eigen::SparseMatrix<double>& M);
+  
+  }
 }
 
 // Be sure that this is not compiled into libigl.a

+ 1 - 1
include/igl/matlab/mexErrMsgTxt.cpp

@@ -10,7 +10,7 @@
 // Overload mexErrMsgTxt to check an assertion then print text only if
 // assertion fails
 #include "mex.h"
-IGL_INLINE void igl::mexErrMsgTxt(bool assertion, const char * text)
+IGL_INLINE void igl::matlab::mexErrMsgTxt(bool assertion, const char * text)
 {
   if(!assertion)
   {

+ 5 - 2
include/igl/matlab/mexErrMsgTxt.h

@@ -10,8 +10,11 @@
 #include "../igl_inline.h"
 namespace igl
 {
-  // Wrapper for mexErrMsgTxt that only calls error if test fails
-  IGL_INLINE void mexErrMsgTxt(bool test, const char * message);
+  namespace matlab
+  {
+    // Wrapper for mexErrMsgTxt that only calls error if test fails
+    IGL_INLINE void mexErrMsgTxt(bool test, const char * message);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "mexErrMsgTxt.cpp"

+ 5 - 5
include/igl/matlab/parse_rhs.cpp

@@ -2,7 +2,7 @@
 #include <algorithm>
 
 template <typename DerivedV>
-IGL_INLINE void igl::parse_rhs_double(
+IGL_INLINE void igl::matlab::parse_rhs_double(
     const mxArray *prhs[], 
     Eigen::PlainObjectBase<DerivedV> & V)
 {
@@ -34,7 +34,7 @@ IGL_INLINE void igl::parse_rhs_double(
 }
 
 template <typename DerivedV>
-IGL_INLINE void igl::parse_rhs_index(
+IGL_INLINE void igl::matlab::parse_rhs_index(
     const mxArray *prhs[], 
     Eigen::PlainObjectBase<DerivedV> & V)
 {
@@ -43,7 +43,7 @@ IGL_INLINE void igl::parse_rhs_index(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::parse_rhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::parse_rhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
-template void igl::parse_rhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
+template void igl::matlab::parse_rhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::matlab::parse_rhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::matlab::parse_rhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(mxArray_tag const**, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 #endif

+ 18 - 15
include/igl/matlab/parse_rhs.h

@@ -5,21 +5,24 @@
 #include <Eigen/Dense>
 namespace igl
 {
-  // Reads in a matrix as a double
-  //
-  // Inputs:
-  //   prhs  points to rhs argument
-  // Outputs:
-  //   V  M by N matrix 
-  template <typename DerivedV>
-  IGL_INLINE void parse_rhs_double(
-    const mxArray *prhs[], 
-    Eigen::PlainObjectBase<DerivedV> & V);
-  // Reads in a matrix and subtracts 1
-  template <typename DerivedV>
-  IGL_INLINE void parse_rhs_index(
-    const mxArray *prhs[], 
-    Eigen::PlainObjectBase<DerivedV> & V);
+  namespace matlab
+  {
+    // Reads in a matrix as a double
+    //
+    // Inputs:
+    //   prhs  points to rhs argument
+    // Outputs:
+    //   V  M by N matrix 
+    template <typename DerivedV>
+    IGL_INLINE void parse_rhs_double(
+      const mxArray *prhs[], 
+      Eigen::PlainObjectBase<DerivedV> & V);
+    // Reads in a matrix and subtracts 1
+    template <typename DerivedV>
+    IGL_INLINE void parse_rhs_index(
+      const mxArray *prhs[], 
+      Eigen::PlainObjectBase<DerivedV> & V);
+  }
 };
 #ifndef IGL_STATIC_LIBRARY
 #  include "parse_rhs.cpp"

+ 9 - 9
include/igl/matlab/prepare_lhs.cpp

@@ -1,7 +1,7 @@
 #include "prepare_lhs.h"
 #include <algorithm>
 template <typename DerivedV>
-IGL_INLINE void igl::prepare_lhs_double(
+IGL_INLINE void igl::matlab::prepare_lhs_double(
   const Eigen::PlainObjectBase<DerivedV> & V,
   mxArray *plhs[])
 {
@@ -26,7 +26,7 @@ IGL_INLINE void igl::prepare_lhs_double(
 }
 
 template <typename DerivedV>
-IGL_INLINE void igl::prepare_lhs_logical(
+IGL_INLINE void igl::matlab::prepare_lhs_logical(
   const Eigen::PlainObjectBase<DerivedV> & V,
   mxArray *plhs[])
 {
@@ -51,7 +51,7 @@ IGL_INLINE void igl::prepare_lhs_logical(
 }
 
 template <typename DerivedV>
-IGL_INLINE void igl::prepare_lhs_index(
+IGL_INLINE void igl::matlab::prepare_lhs_index(
   const Eigen::PlainObjectBase<DerivedV> & V,
   mxArray *plhs[])
 {
@@ -62,10 +62,10 @@ IGL_INLINE void igl::prepare_lhs_index(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::prepare_lhs_index<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
-template void igl::prepare_lhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
-template void igl::prepare_lhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, mxArray_tag**);
-template void igl::prepare_lhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, mxArray_tag**);
-template void igl::prepare_lhs_logical<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
-template void igl::prepare_lhs_double<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_index<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_index<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_double<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_index<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_logical<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
+template void igl::matlab::prepare_lhs_double<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, mxArray_tag**);
 #endif

+ 24 - 21
include/igl/matlab/prepare_lhs.h

@@ -5,27 +5,30 @@
 #include <Eigen/Dense>
 namespace igl
 {
-  // Writes out a matrix as a double
-  //
-  // Inputs:
-  //   prhs  points to rhs argument
-  // Outputs:
-  //   V  M by N matrix 
-  template <typename DerivedV>
-  IGL_INLINE void prepare_lhs_double(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    mxArray *plhs[]);
-  // Casts to logical
-  template <typename DerivedV>
-  IGL_INLINE void prepare_lhs_logical(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    mxArray *plhs[]);
-  // Writes out a matrix and adds 1
-  template <typename DerivedV>
-  IGL_INLINE void prepare_lhs_index(
-    const Eigen::PlainObjectBase<DerivedV> & V,
-    mxArray *plhs[]);
-};
+  namespace matlab
+  {
+    // Writes out a matrix as a double
+    //
+    // Inputs:
+    //   prhs  points to rhs argument
+    // Outputs:
+    //   V  M by N matrix 
+    template <typename DerivedV>
+    IGL_INLINE void prepare_lhs_double(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      mxArray *plhs[]);
+    // Casts to logical
+    template <typename DerivedV>
+    IGL_INLINE void prepare_lhs_logical(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      mxArray *plhs[]);
+    // Writes out a matrix and adds 1
+    template <typename DerivedV>
+    IGL_INLINE void prepare_lhs_index(
+      const Eigen::PlainObjectBase<DerivedV> & V,
+      mxArray *plhs[]);
+  };
+}
 #ifndef IGL_STATIC_LIBRARY
 #  include "prepare_lhs.cpp"
 #endif

+ 1 - 1
include/igl/mosek/mosek_guarded.cpp

@@ -8,7 +8,7 @@
 #include "mosek_guarded.h"
 #include <iostream>
 
-IGL_INLINE MSKrescodee igl::mosek_guarded(const MSKrescodee r)
+IGL_INLINE MSKrescodee igl::mosek::mosek_guarded(const MSKrescodee r)
 {
   using namespace std;
   if(r != MSK_RES_OK)

+ 9 - 6
include/igl/mosek/mosek_guarded.h

@@ -12,12 +12,15 @@
 #include "mosek.h"
 namespace igl
 {
-  // Little function to wrap around mosek call to handle errors
-  // 
-  // Inputs:
-  //   r  mosek error code returned from mosek call
-  // Returns r untouched
-  IGL_INLINE MSKrescodee mosek_guarded(const MSKrescodee r);
+  namespace mosek
+  {
+    // Little function to wrap around mosek call to handle errors
+    // 
+    // Inputs:
+    //   r  mosek error code returned from mosek call
+    // Returns r untouched
+    IGL_INLINE MSKrescodee mosek_guarded(const MSKrescodee r);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 2 - 2
include/igl/mosek/mosek_linprog.cpp

@@ -12,7 +12,7 @@
 #include <cmath>
 #include <vector>
 
-IGL_INLINE bool igl::mosek_linprog(
+IGL_INLINE bool igl::mosek::mosek_linprog(
   const Eigen::VectorXd & c,
   const Eigen::SparseMatrix<double> & A,
   const Eigen::VectorXd & lc,
@@ -32,7 +32,7 @@ IGL_INLINE bool igl::mosek_linprog(
   return ret;
 }
 
-IGL_INLINE bool igl::mosek_linprog(
+IGL_INLINE bool igl::mosek::mosek_linprog(
   const Eigen::VectorXd & c,
   const Eigen::SparseMatrix<double> & A,
   const Eigen::VectorXd & lc,

+ 38 - 35
include/igl/mosek/mosek_linprog.h

@@ -13,41 +13,44 @@
 #include <mosek.h>
 namespace igl
 {
-  // Solve a linear program using mosek:
-  // 
-  // min c'x
-  // s.t. lc <= A x <= uc
-  //      lx <= x <= ux
-  //
-  // Inputs:
-  //   c  #x list of linear objective coefficients
-  //   A  #A by #x matrix of linear inequality constraint coefficients
-  //   lc  #A list of lower constraint bounds
-  //   uc  #A list of upper constraint bounds
-  //   lx  #x list of lower variable bounds
-  //   ux  #x list of upper variable bounds
-  // Outputs:
-  //   x  #x list of solution values
-  // Returns true iff success.
-  IGL_INLINE bool mosek_linprog(
-    const Eigen::VectorXd & c,
-    const Eigen::SparseMatrix<double> & A,
-    const Eigen::VectorXd & lc,
-    const Eigen::VectorXd & uc,
-    const Eigen::VectorXd & lx,
-    const Eigen::VectorXd & ux,
-    Eigen::VectorXd & x);
-  // Wrapper that keeps mosek environment alive (if licence checking is
-  // becoming a bottleneck)
-  IGL_INLINE bool mosek_linprog(
-    const Eigen::VectorXd & c,
-    const Eigen::SparseMatrix<double> & A,
-    const Eigen::VectorXd & lc,
-    const Eigen::VectorXd & uc,
-    const Eigen::VectorXd & lx,
-    const Eigen::VectorXd & ux,
-    const MSKenv_t & env,
-    Eigen::VectorXd & x);
+  namespace mosek
+  {
+    // Solve a linear program using mosek:
+    // 
+    // min c'x
+    // s.t. lc <= A x <= uc
+    //      lx <= x <= ux
+    //
+    // Inputs:
+    //   c  #x list of linear objective coefficients
+    //   A  #A by #x matrix of linear inequality constraint coefficients
+    //   lc  #A list of lower constraint bounds
+    //   uc  #A list of upper constraint bounds
+    //   lx  #x list of lower variable bounds
+    //   ux  #x list of upper variable bounds
+    // Outputs:
+    //   x  #x list of solution values
+    // Returns true iff success.
+    IGL_INLINE bool mosek_linprog(
+        const Eigen::VectorXd & c,
+        const Eigen::SparseMatrix<double> & A,
+        const Eigen::VectorXd & lc,
+        const Eigen::VectorXd & uc,
+        const Eigen::VectorXd & lx,
+        const Eigen::VectorXd & ux,
+        Eigen::VectorXd & x);
+    // Wrapper that keeps mosek environment alive (if licence checking is
+    // becoming a bottleneck)
+    IGL_INLINE bool mosek_linprog(
+        const Eigen::VectorXd & c,
+        const Eigen::SparseMatrix<double> & A,
+        const Eigen::VectorXd & lc,
+        const Eigen::VectorXd & uc,
+        const Eigen::VectorXd & lx,
+        const Eigen::VectorXd & ux,
+        const MSKenv_t & env,
+        Eigen::VectorXd & x);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 3 - 3
include/igl/mosek/mosek_quadprog.cpp

@@ -17,7 +17,7 @@
 #include "../EPS.h"
 
 
-igl::MosekData::MosekData()
+igl::mosek::MosekData::MosekData()
 {
   // These are the default settings that worked well for BBW. Your miles may
   // very well be kilometers.
@@ -59,7 +59,7 @@ igl::MosekData::MosekData()
 }
 
 template <typename Index, typename Scalar>
-IGL_INLINE bool igl::mosek_quadprog(
+IGL_INLINE bool igl::mosek::mosek_quadprog(
   const Index n,
   std::vector<Index> & Qi,
   std::vector<Index> & Qj,
@@ -267,7 +267,7 @@ IGL_INLINE bool igl::mosek_quadprog(
   return success;
 }
 
-IGL_INLINE bool igl::mosek_quadprog(
+IGL_INLINE bool igl::mosek::mosek_quadprog(
   const Eigen::SparseMatrix<double> & Q,
   const Eigen::VectorXd & c,
   const double cf,

+ 100 - 97
include/igl/mosek/mosek_quadprog.h

@@ -19,105 +19,108 @@
 
 namespace igl
 {
-  struct MosekData
+  namespace mosek
   {
-    // Integer parameters
-    std::map<MSKiparame,int> intparam;
-    // Double parameters
-    std::map<MSKdparame,double> douparam;
-    // Default values
-    MosekData();
-  };
-  // Solve a convex quadratic optimization problem with linear and constant
-  // bounds, that is:
-  //
-  // Minimize: ½ * xT * Q⁰ * x + cT * x + cf
-  //
-  // Subject to: lc ≤ Ax ≤ uc
-  //             lx ≤ x ≤ ux
-  //
-  // where we are trying to find the optimal vector of values x. 
-  //
-  // Note: Q⁰ must be symmetric and the ½ is a convention of MOSEK
-  //
-  // Note: Because of how MOSEK accepts different parts of the system, Q should
-  // be stored in IJV (aka Coordinate) format and should only include entries in
-  // the lower triangle. A should be stored in Column compressed (aka Harwell
-  // Boeing) format. As described:
-  // http://netlib.org/linalg/html_templates/node92.html
-  // or
-  // http://en.wikipedia.org/wiki/Sparse_matrix
-  //   #Compressed_sparse_column_.28CSC_or_CCS.29
-  // 
-  //
-  // Templates:
-  //   Index  type for index variables
-  //   Scalar  type for floating point variables (gets cast to double?)
-  // Input:
-  //   n  number of variables, i.e. size of x
-  //   Qi  vector of qnnz row indices of non-zeros in LOWER TRIANGLE ONLY of Q⁰
-  //   Qj  vector of qnnz column indices of non-zeros in LOWER TRIANGLE ONLY of 
-  //     Q⁰
-  //   Qv  vector of qnnz values of non-zeros in LOWER TRIANGLE ONLY of Q⁰, 
-  //     such that:
-  //     Q⁰(Qi[k],Qj[k]) = Qv[k] for k ∈ [0,Qnnz-1], where Qnnz is the number of
-  //     non-zeros in Q⁰
-  //   c   (optional) vector of n values of c, transpose of coefficient row vector
-  //     of linear terms, EMPTY means c == 0
-  //   cf  (optional) value of constant term in objective, 0 means cf == 0, so
-  //     optional only in the sense that it is mandatory
-  //   m  number of constraints, therefore also number of rows in linear
-  //     constraint coefficient matrix A, and in linear constraint bound vectors 
-  //     lc and uc
-  //   Av  vector of non-zero values of A, in column compressed order
-  //   Ari  vector of row indices corresponding to non-zero values of A,
-  //   Acp  vector of indices into Ari and Av of the first entry for each column
-  //     of A, size(Acp) = (# columns of A) + 1 = n + 1
-  //   lc  vector of m linear constraint lower bounds
-  //   uc  vector of m linear constraint upper bounds
-  //   lx  vector of n constant lower bounds
-  //   ux  vector of n constant upper bounds
-  // Output:
-  //   x  vector of size n to hold output of optimization
-  // Return:
-  //   true only if optimization was successful with no errors
-  // 
-  // Note: All indices are 0-based
-  //
-  template <typename Index, typename Scalar>
-  IGL_INLINE bool mosek_quadprog(
-    const Index n,
-    /* mosek won't allow this to be const*/ std::vector<Index> & Qi,
-    /* mosek won't allow this to be const*/ std::vector<Index> & Qj,
-    /* mosek won't allow this to be const*/ std::vector<Scalar> & Qv,
-    const std::vector<Scalar> & c,
-    const Scalar cf,
-    const Index m,
-    /* mosek won't allow this to be const*/ std::vector<Scalar> & Av,
-    /* mosek won't allow this to be const*/ std::vector<Index> & Ari,
-    const std::vector<Index> & Acp,
-    const std::vector<Scalar> & lc,
-    const std::vector<Scalar> & uc,
-    const std::vector<Scalar> & lx,
-    const std::vector<Scalar> & ux,
-    MosekData & mosek_data,
-    std::vector<Scalar> & x);
+    struct MosekData
+    {
+      // Integer parameters
+      std::map<MSKiparame,int> intparam;
+      // Double parameters
+      std::map<MSKdparame,double> douparam;
+      // Default values
+      MosekData();
+    };
+    // Solve a convex quadratic optimization problem with linear and constant
+    // bounds, that is:
+    //
+    // Minimize: ½ * xT * Q⁰ * x + cT * x + cf
+    //
+    // Subject to: lc ≤ Ax ≤ uc
+    //             lx ≤ x ≤ ux
+    //
+    // where we are trying to find the optimal vector of values x. 
+    //
+    // Note: Q⁰ must be symmetric and the ½ is a convention of MOSEK
+    //
+    // Note: Because of how MOSEK accepts different parts of the system, Q should
+    // be stored in IJV (aka Coordinate) format and should only include entries in
+    // the lower triangle. A should be stored in Column compressed (aka Harwell
+    // Boeing) format. As described:
+    // http://netlib.org/linalg/html_templates/node92.html
+    // or
+    // http://en.wikipedia.org/wiki/Sparse_matrix
+    //   #Compressed_sparse_column_.28CSC_or_CCS.29
+    // 
+    //
+    // Templates:
+    //   Index  type for index variables
+    //   Scalar  type for floating point variables (gets cast to double?)
+    // Input:
+    //   n  number of variables, i.e. size of x
+    //   Qi  vector of qnnz row indices of non-zeros in LOWER TRIANGLE ONLY of Q⁰
+    //   Qj  vector of qnnz column indices of non-zeros in LOWER TRIANGLE ONLY of 
+    //     Q⁰
+    //   Qv  vector of qnnz values of non-zeros in LOWER TRIANGLE ONLY of Q⁰, 
+    //     such that:
+    //     Q⁰(Qi[k],Qj[k]) = Qv[k] for k ∈ [0,Qnnz-1], where Qnnz is the number of
+    //     non-zeros in Q⁰
+    //   c   (optional) vector of n values of c, transpose of coefficient row vector
+    //     of linear terms, EMPTY means c == 0
+    //   cf  (optional) value of constant term in objective, 0 means cf == 0, so
+    //     optional only in the sense that it is mandatory
+    //   m  number of constraints, therefore also number of rows in linear
+    //     constraint coefficient matrix A, and in linear constraint bound vectors 
+    //     lc and uc
+    //   Av  vector of non-zero values of A, in column compressed order
+    //   Ari  vector of row indices corresponding to non-zero values of A,
+    //   Acp  vector of indices into Ari and Av of the first entry for each column
+    //     of A, size(Acp) = (# columns of A) + 1 = n + 1
+    //   lc  vector of m linear constraint lower bounds
+    //   uc  vector of m linear constraint upper bounds
+    //   lx  vector of n constant lower bounds
+    //   ux  vector of n constant upper bounds
+    // Output:
+    //   x  vector of size n to hold output of optimization
+    // Return:
+    //   true only if optimization was successful with no errors
+    // 
+    // Note: All indices are 0-based
+    //
+    template <typename Index, typename Scalar>
+      IGL_INLINE bool mosek_quadprog(
+          const Index n,
+          /* mosek won't allow this to be const*/ std::vector<Index> & Qi,
+          /* mosek won't allow this to be const*/ std::vector<Index> & Qj,
+          /* mosek won't allow this to be const*/ std::vector<Scalar> & Qv,
+          const std::vector<Scalar> & c,
+          const Scalar cf,
+          const Index m,
+          /* mosek won't allow this to be const*/ std::vector<Scalar> & Av,
+          /* mosek won't allow this to be const*/ std::vector<Index> & Ari,
+          const std::vector<Index> & Acp,
+          const std::vector<Scalar> & lc,
+          const std::vector<Scalar> & uc,
+          const std::vector<Scalar> & lx,
+          const std::vector<Scalar> & ux,
+          MosekData & mosek_data,
+          std::vector<Scalar> & x);
 
-  // Wrapper with Eigen elements
-  //// Templates:
-  ////   Scalar  Scalar type for sparse matrix  (e.g. double)
-  ////   Derived  dervied type from matrix/vector (e.g. VectorXd)
-  IGL_INLINE bool mosek_quadprog(
-    const Eigen::SparseMatrix<double> & Q,
-    const Eigen::VectorXd & c,
-    const double cf,
-    const Eigen::SparseMatrix<double> & A,
-    const Eigen::VectorXd & lc,
-    const Eigen::VectorXd & uc,
-    const Eigen::VectorXd & lx,
-    const Eigen::VectorXd & ux,
-    MosekData & mosek_data,
-    Eigen::VectorXd & x);
+    // Wrapper with Eigen elements
+    //// Templates:
+    ////   Scalar  Scalar type for sparse matrix  (e.g. double)
+    ////   Derived  dervied type from matrix/vector (e.g. VectorXd)
+    IGL_INLINE bool mosek_quadprog(
+        const Eigen::SparseMatrix<double> & Q,
+        const Eigen::VectorXd & c,
+        const double cf,
+        const Eigen::SparseMatrix<double> & A,
+        const Eigen::VectorXd & lc,
+        const Eigen::VectorXd & uc,
+        const Eigen::VectorXd & lx,
+        const Eigen::VectorXd & ux,
+        MosekData & mosek_data,
+        Eigen::VectorXd & x);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 2 - 2
include/igl/png/render_to_png.cpp

@@ -19,7 +19,7 @@
 #  include <GL/gl.h>
 #endif
 
-IGL_INLINE bool igl::render_to_png(
+IGL_INLINE bool igl::png::render_to_png(
   const std::string png_file,
   const int width,
   const int height,
@@ -52,5 +52,5 @@ IGL_INLINE bool igl::render_to_png(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-// template bool igl::render_to_png(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int, bool, bool);
+// template bool igl::png::render_to_png(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int, int, bool, bool);
 #endif

+ 20 - 17
include/igl/png/render_to_png.h

@@ -12,23 +12,26 @@
 #include <string>
 namespace igl
 {
-  //
-  // Render current open GL image to .png file
-  // Inputs:
-  //   png_file  path to output .png file
-  //   width  width of scene and resulting image
-  //   height height of scene and resulting image
-  //   alpha  whether to include alpha channel
-  //   fast  sacrifice compression ratio for speed
-  // Returns true only if no errors occured
-  //
-  // See also: igl/render_to_tga which is faster but writes .tga files
-  IGL_INLINE bool render_to_png(
-    const std::string png_file,
-    const int width,
-    const int height,
-    const bool alpha = true,
-    const bool fast = false);
+  namespace png
+  {
+    //
+    // Render current open GL image to .png file
+    // Inputs:
+    //   png_file  path to output .png file
+    //   width  width of scene and resulting image
+    //   height height of scene and resulting image
+    //   alpha  whether to include alpha channel
+    //   fast  sacrifice compression ratio for speed
+    // Returns true only if no errors occured
+    //
+    // See also: igl/render_to_tga which is faster but writes .tga files
+    IGL_INLINE bool render_to_png(
+      const std::string png_file,
+      const int width,
+      const int height,
+      const bool alpha = true,
+      const bool fast = false);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 1 - 1
include/igl/png/render_to_png_async.cpp

@@ -44,7 +44,7 @@ static IGL_INLINE bool render_to_png_async_helper(
   return ret;
 }
 
-IGL_INLINE std::thread igl::render_to_png_async(
+IGL_INLINE std::thread igl::png::render_to_png_async(
   const std::string png_file,
   const int width,
   const int height,

+ 22 - 19
include/igl/png/render_to_png_async.h

@@ -14,25 +14,28 @@
 #include <string>
 namespace igl
 {
-  // History:
-  //  added multithreaded parameter and support, Alec Sept 3, 2012
-  //
-  // Render current open GL image to .png file
-  // Inputs:
-  //   png_file  path to output .png file
-  //   width  width of scene and resulting image
-  //   height height of scene and resulting image
-  //   alpha  whether to include alpha channel
-  //   fast  sacrifice compression ratio for speed
-  // Returns true only if no errors occured
-  //
-  // See also: igl/render_to_tga which is faster but writes .tga files
-  IGL_INLINE std::thread render_to_png_async(
-    const std::string png_file,
-    const int width,
-    const int height,
-    const bool alpha = true,
-    const bool fast = false);
+  namespace png
+  {
+    // History:
+    //  added multithreaded parameter and support, Alec Sept 3, 2012
+    //
+    // Render current open GL image to .png file
+    // Inputs:
+    //   png_file  path to output .png file
+    //   width  width of scene and resulting image
+    //   height height of scene and resulting image
+    //   alpha  whether to include alpha channel
+    //   fast  sacrifice compression ratio for speed
+    // Returns true only if no errors occured
+    //
+    // See also: igl/render_to_tga which is faster but writes .tga files
+    IGL_INLINE std::thread render_to_png_async(
+      const std::string png_file,
+      const int width,
+      const int height,
+      const bool alpha = true,
+      const bool fast = false);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 1 - 1
include/igl/png/texture_from_file.cpp

@@ -18,7 +18,7 @@
 #include <algorithm>
 #include <iostream>
 
-IGL_INLINE bool igl::texture_from_file(const std::string filename, GLuint & id)
+IGL_INLINE bool igl::png::texture_from_file(const std::string filename, GLuint & id)
 {
   using namespace igl;
   using namespace std;

+ 13 - 10
include/igl/png/texture_from_file.h

@@ -16,16 +16,19 @@
 
 namespace igl
 {
-  // Read an image from an image file and use it as a texture. Officially, only
-  // .tga and .png are supported. Any filetype read by ImageMagick's `convert`
-  // will work via an unsafe system call.
-  //
-  // Input:
-  //  filename  path to image file
-  // Output:
-  //  id  of generated openGL texture
-  // Returns true on success, false on failure
-  IGL_INLINE bool texture_from_file(const std::string filename, GLuint & id);
+  namespace png
+  {
+    // Read an image from an image file and use it as a texture. Officially, only
+    // .tga and .png are supported. Any filetype read by ImageMagick's `convert`
+    // will work via an unsafe system call.
+    //
+    // Input:
+    //  filename  path to image file
+    // Output:
+    //  id  of generated openGL texture
+    // Returns true on success, false on failure
+    IGL_INLINE bool texture_from_file(const std::string filename, GLuint & id);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

@@ -12,7 +12,7 @@
 
 #ifndef IGL_NO_OPENGL
 
-IGL_INLINE bool igl::texture_from_png(const std::string png_file, GLuint & id)
+IGL_INLINE bool igl::png::texture_from_png(const std::string png_file, GLuint & id)
 {
   YImage yimg;
   if(!yimg.load(png_file.c_str()))
@@ -36,7 +36,7 @@ IGL_INLINE bool igl::texture_from_png(const std::string png_file, GLuint & id)
 
 #endif
 
-IGL_INLINE bool igl::texture_from_png(
+IGL_INLINE bool igl::png::texture_from_png(
   const std::string png_file,
   Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& R,
   Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& G,

+ 27 - 21
include/igl/png/texture_from_png.h

@@ -16,32 +16,38 @@
 
 namespace igl
 {
-  // Read an image from a .png file and use it as a texture
-  //
-  // Input:
-  //  png_file  path to .png file
-  // Output:
-  //  id  of generated openGL texture
-  // Returns true on success, false on failure
-  IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
+  namespace png
+  {
+    // Read an image from a .png file and use it as a texture
+    //
+    // Input:
+    //  png_file  path to .png file
+    // Output:
+    //  id  of generated openGL texture
+    // Returns true on success, false on failure
+    IGL_INLINE bool texture_from_png(const std::string png_file, GLuint & id);
+  }
 }
 #endif
 
 namespace igl
 {
-  // Read an image from a .png file and use it as a texture
-  //
-  // Input:
-  //  png_file  path to .png file
-  // Output:
-  //  R,G,B,A texture channels
-  // Returns true on success, false on failure
-  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,
-  Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& B,
-  Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& A
-  );
+  namespace png
+  {
+    // Read an image from a .png file and use it as a texture
+    //
+    // Input:
+    //  png_file  path to .png file
+    // Output:
+    //  R,G,B,A texture channels
+    // Returns true on success, false on failure
+    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,
+    Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& B,
+    Eigen::Matrix<char,Eigen::Dynamic,Eigen::Dynamic>& A
+    );
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 2 - 2
include/igl/tetgen/cdt.cpp

@@ -15,10 +15,10 @@ template <
   typename DerivedTV, 
   typename DerivedTT, 
   typename DerivedTF>
-IGL_INLINE bool igl::cdt(
+IGL_INLINE bool igl::tetgen::cdt(
   const Eigen::PlainObjectBase<DerivedV>& V,
   const Eigen::PlainObjectBase<DerivedF>& F,
-  const igl::CDTParam & param,
+  const CDTParam & param,
   Eigen::PlainObjectBase<DerivedTV>& TV,
   Eigen::PlainObjectBase<DerivedTT>& TT,
   Eigen::PlainObjectBase<DerivedTF>& TF)

+ 38 - 35
include/igl/tetgen/cdt.h

@@ -18,42 +18,45 @@
 
 namespace igl
 {
-  struct CDTParam
+  namespace tetgen
   {
-    // Tetgen can compute mesh of convex hull of input (i.e. "c") but often
-    // chokes. One workaround is to force it to mesh the entire bounding box.
-    // {false}
-    bool use_bounding_box = false;
-    // Scale the bounding box a bit so that vertices near it do not give tetgen
-    // problems. {1.01}
-    double bounding_box_scale = 1.01;
-    // Flags to tetgen. Do not include the "c" flag here! {"Y"}
-    std::string flags = "Y";
-  };
-  // Create a constrained delaunay tesselation containing convex hull of the
-  // given **non-selfintersecting** mesh.
-  //
-  // Inputs:
-  //    V  #V by 3 list of input mesh vertices
-  //    F  #F by 3 list of input mesh facets
-  //    param  see above
-  //    TV  #TV by 3 list of output mesh vertices (V come first)
-  //    TT  #TT by 3 list of tetrahedra indices into TV.
-  //    TF  #TF by 3 list of facets from F potentially subdivided.
-  // 
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedTV, 
-    typename DerivedTT, 
-    typename DerivedTF>
-  IGL_INLINE bool cdt(
-    const Eigen::PlainObjectBase<DerivedV>& V,
-    const Eigen::PlainObjectBase<DerivedF>& F,
-    const igl::CDTParam & param,
-    Eigen::PlainObjectBase<DerivedTV>& TV,
-    Eigen::PlainObjectBase<DerivedTT>& TT,
-    Eigen::PlainObjectBase<DerivedTF>& TF);
+    struct CDTParam
+    {
+      // Tetgen can compute mesh of convex hull of input (i.e. "c") but often
+      // chokes. One workaround is to force it to mesh the entire bounding box.
+      // {false}
+      bool use_bounding_box = false;
+      // Scale the bounding box a bit so that vertices near it do not give tetgen
+      // problems. {1.01}
+      double bounding_box_scale = 1.01;
+      // Flags to tetgen. Do not include the "c" flag here! {"Y"}
+      std::string flags = "Y";
+    };
+    // Create a constrained delaunay tesselation containing convex hull of the
+    // given **non-selfintersecting** mesh.
+    //
+    // Inputs:
+    //    V  #V by 3 list of input mesh vertices
+    //    F  #F by 3 list of input mesh facets
+    //    param  see above
+    //    TV  #TV by 3 list of output mesh vertices (V come first)
+    //    TT  #TT by 3 list of tetrahedra indices into TV.
+    //    TF  #TF by 3 list of facets from F potentially subdivided.
+    // 
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedTV, 
+      typename DerivedTT, 
+      typename DerivedTF>
+    IGL_INLINE bool cdt(
+      const Eigen::PlainObjectBase<DerivedV>& V,
+      const Eigen::PlainObjectBase<DerivedF>& F,
+      const CDTParam & param,
+      Eigen::PlainObjectBase<DerivedTV>& TV,
+      Eigen::PlainObjectBase<DerivedTT>& TT,
+      Eigen::PlainObjectBase<DerivedTF>& TF);
+  }
 }
 
 

+ 3 - 3
include/igl/tetgen/mesh_to_tetgenio.cpp

@@ -13,7 +13,7 @@
 // STL includes
 #include <cassert>
 
-IGL_INLINE bool igl::mesh_to_tetgenio(
+IGL_INLINE bool igl::tetgen::mesh_to_tetgenio(
   const std::vector<std::vector<REAL > > & V, 
   const std::vector<std::vector<int> > & F, 
   tetgenio & in)
@@ -59,7 +59,7 @@ IGL_INLINE bool igl::mesh_to_tetgenio(
 }
 
 template <typename DerivedV, typename DerivedF>
-IGL_INLINE bool igl::mesh_to_tetgenio(
+IGL_INLINE bool igl::tetgen::mesh_to_tetgenio(
   const Eigen::PlainObjectBase<DerivedV>& V,
   const Eigen::PlainObjectBase<DerivedF>& F,
   tetgenio & in)
@@ -75,5 +75,5 @@ IGL_INLINE bool igl::mesh_to_tetgenio(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template bool igl::mesh_to_tetgenio<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&, tetgenio&);
+template bool igl::tetgen::mesh_to_tetgenio<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&, tetgenio&);
 #endif

+ 24 - 21
include/igl/tetgen/mesh_to_tetgenio.h

@@ -16,27 +16,30 @@
 
 namespace igl
 {
-  // Load a vertex list and face list into a tetgenio object
-  // Inputs:
-  //   V  #V by 3 vertex position list
-  //   F  #F list of polygon face indices into V (0-indexed)
-  // Outputs:
-  //   in  tetgenio input object
-  // Returns true on success, false on error
-  IGL_INLINE bool mesh_to_tetgenio(
-    const std::vector<std::vector<REAL > > & V, 
-    const std::vector<std::vector<int> > & F, 
-    tetgenio & in);
-  
-  // Wrapper with Eigen types
-  // Templates:
-  //   DerivedV  real-value: i.e. from MatrixXd
-  //   DerivedF  integer-value: i.e. from MatrixXi
-  template <typename DerivedV, typename DerivedF>
-  IGL_INLINE bool mesh_to_tetgenio(
-    const Eigen::PlainObjectBase<DerivedV>& V,
-    const Eigen::PlainObjectBase<DerivedF>& F,
-    tetgenio & in);
+  namespace tetgen
+  {
+    // Load a vertex list and face list into a tetgenio object
+    // Inputs:
+    //   V  #V by 3 vertex position list
+    //   F  #F list of polygon face indices into V (0-indexed)
+    // Outputs:
+    //   in  tetgenio input object
+    // Returns true on success, false on error
+    IGL_INLINE bool mesh_to_tetgenio(
+      const std::vector<std::vector<REAL > > & V, 
+      const std::vector<std::vector<int> > & F, 
+      tetgenio & in);
+    
+    // Wrapper with Eigen types
+    // Templates:
+    //   DerivedV  real-value: i.e. from MatrixXd
+    //   DerivedF  integer-value: i.e. from MatrixXi
+    template <typename DerivedV, typename DerivedF>
+    IGL_INLINE bool mesh_to_tetgenio(
+      const Eigen::PlainObjectBase<DerivedV>& V,
+      const Eigen::PlainObjectBase<DerivedF>& F,
+      tetgenio & in);
+  }
 }
 
 

+ 3 - 3
include/igl/tetgen/mesh_with_skeleton.cpp

@@ -18,7 +18,7 @@
 // to produce a graded tet mesh
 const static std::string DEFAULT_TETGEN_FLAGS = "pq2Y";
 
-IGL_INLINE bool igl::mesh_with_skeleton(
+IGL_INLINE bool igl::tetgen::mesh_with_skeleton(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & C,
@@ -85,7 +85,7 @@ IGL_INLINE bool igl::mesh_with_skeleton(
   return true;
 }
 
-IGL_INLINE bool igl::mesh_with_skeleton(
+IGL_INLINE bool igl::tetgen::mesh_with_skeleton(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXd & C,
@@ -97,7 +97,7 @@ IGL_INLINE bool igl::mesh_with_skeleton(
   Eigen::MatrixXi & TT,
   Eigen::MatrixXi & FF)
 {
-  return igl::mesh_with_skeleton(
+  return mesh_with_skeleton(
     V,F,C,P,BE,CE,samples_per_bone,DEFAULT_TETGEN_FLAGS,VV,TT,FF);
 }
 

+ 46 - 43
include/igl/tetgen/mesh_with_skeleton.h

@@ -13,49 +13,52 @@
 
 namespace igl
 {
-  // Mesh the interior of a given surface with tetrahedra which are graded (tend
-  // to be small near the surface and large inside) and conform to the given
-  // handles and samplings thereof.
-  //
-  // Inputs:
-  //  V  #V by 3 list of mesh vertex positions
-  //  F  #F by 3 list of triangle indices
-  //  C  #C by 3 list of vertex positions
-  //  P  #P list of point handle indices
-  //  BE #BE by 2 list of bone-edge indices
-  //  CE #CE by 2 list of cage-edge indices
-  //  samples_per_bone  #samples to add per bone
-  //  tetgen_flags  flags to pass to tetgen {""-->"pq2Y"} otherwise you're on
-  //    your own and it's your funeral if you pass nonsense flags
-  // Outputs:
-  //  VV  #VV by 3 list of tet-mesh vertex positions
-  //  TT  #TT by 4 list of tetrahedra indices
-  //  FF  #FF by 3 list of surface triangle indices
-  // Returns true only on success
-  IGL_INLINE bool mesh_with_skeleton(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & C,
-    const Eigen::VectorXi & /*P*/,
-    const Eigen::MatrixXi & BE,
-    const Eigen::MatrixXi & CE,
-    const int samples_per_bone,
-    const std::string & tetgen_flags,
-    Eigen::MatrixXd & VV,
-    Eigen::MatrixXi & TT,
-    Eigen::MatrixXi & FF);
-  // Wrapper using default tetgen_flags
-  IGL_INLINE bool mesh_with_skeleton(
-    const Eigen::MatrixXd & V,
-    const Eigen::MatrixXi & F,
-    const Eigen::MatrixXd & C,
-    const Eigen::VectorXi & /*P*/,
-    const Eigen::MatrixXi & BE,
-    const Eigen::MatrixXi & CE,
-    const int samples_per_bone,
-    Eigen::MatrixXd & VV,
-    Eigen::MatrixXi & TT,
-    Eigen::MatrixXi & FF);
+  namespace tetgen
+  {
+    // Mesh the interior of a given surface with tetrahedra which are graded
+    // (tend to be small near the surface and large inside) and conform to the
+    // given handles and samplings thereof.
+    //
+    // Inputs:
+    //  V  #V by 3 list of mesh vertex positions
+    //  F  #F by 3 list of triangle indices
+    //  C  #C by 3 list of vertex positions
+    //  P  #P list of point handle indices
+    //  BE #BE by 2 list of bone-edge indices
+    //  CE #CE by 2 list of cage-edge indices
+    //  samples_per_bone  #samples to add per bone
+    //  tetgen_flags  flags to pass to tetgen {""-->"pq2Y"} otherwise you're on
+    //    your own and it's your funeral if you pass nonsense flags
+    // Outputs:
+    //  VV  #VV by 3 list of tet-mesh vertex positions
+    //  TT  #TT by 4 list of tetrahedra indices
+    //  FF  #FF by 3 list of surface triangle indices
+    // Returns true only on success
+    IGL_INLINE bool mesh_with_skeleton(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      const Eigen::MatrixXd & C,
+      const Eigen::VectorXi & /*P*/,
+      const Eigen::MatrixXi & BE,
+      const Eigen::MatrixXi & CE,
+      const int samples_per_bone,
+      const std::string & tetgen_flags,
+      Eigen::MatrixXd & VV,
+      Eigen::MatrixXi & TT,
+      Eigen::MatrixXi & FF);
+    // Wrapper using default tetgen_flags
+    IGL_INLINE bool mesh_with_skeleton(
+      const Eigen::MatrixXd & V,
+      const Eigen::MatrixXi & F,
+      const Eigen::MatrixXd & C,
+      const Eigen::VectorXi & /*P*/,
+      const Eigen::MatrixXi & BE,
+      const Eigen::MatrixXi & CE,
+      const int samples_per_bone,
+      Eigen::MatrixXd & VV,
+      Eigen::MatrixXi & TT,
+      Eigen::MatrixXi & FF);
+  }
 }
 
 

+ 1 - 1
include/igl/tetgen/read_into_tetgenio.cpp

@@ -25,7 +25,7 @@
 #include <iostream>
 #include <vector>
 
-IGL_INLINE bool igl::read_into_tetgenio(
+IGL_INLINE bool igl::tetgen::read_into_tetgenio(
   const std::string & path,
   tetgenio & in)
 {

+ 30 - 27
include/igl/tetgen/read_into_tetgenio.h

@@ -15,33 +15,36 @@
 
 namespace igl
 {
-  // Read a mesh or point set into tetgenio (input object for calling tetgen).
-  // Many file formats are already supported by tetgen:
-  //   .off
-  //   .ply
-  //   .node
-  //   .ply
-  //   .medit
-  //   .vtk
-  //   etc.
-  // Noteably it does not support .obj which is loaded by hand here (also
-  // demonstrating how to load points/faces programatically)
-  //
-  // If the file extension is not recognized the filename is assumed to be the
-  // basename of a collection describe a tetmesh, (of which at least the .node
-  // file must exist):
-  //   [filename].node
-  //   [filename].ele
-  //   [filename].face
-  //   [filename].edge
-  //   [filename].vol
-  //
-  // Inputs:
-  //   path  path to file or basename to files
-  // Outputs:
-  //   in  tetgenio input object
-  // Returns true on success, false on error
-  IGL_INLINE bool read_into_tetgenio(const std::string & path, tetgenio & in);
+  namespace tetgen
+  {
+    // Read a mesh or point set into tetgenio (input object for calling tetgen).
+    // Many file formats are already supported by tetgen:
+    //   .off
+    //   .ply
+    //   .node
+    //   .ply
+    //   .medit
+    //   .vtk
+    //   etc.
+    // Noteably it does not support .obj which is loaded by hand here (also
+    // demonstrating how to load points/faces programatically)
+    //
+    // If the file extension is not recognized the filename is assumed to be the
+    // basename of a collection describe a tetmesh, (of which at least the .node
+    // file must exist):
+    //   [filename].node
+    //   [filename].ele
+    //   [filename].face
+    //   [filename].edge
+    //   [filename].vol
+    //
+    // Inputs:
+    //   path  path to file or basename to files
+    // Outputs:
+    //   in  tetgenio input object
+    // Returns true on success, false on error
+    IGL_INLINE bool read_into_tetgenio(const std::string & path, tetgenio & in);
+  }
 }
 
 

+ 6 - 6
include/igl/tetgen/tetgenio_to_tetmesh.cpp

@@ -13,7 +13,7 @@
 // STL includes
 #include <iostream>
 
-IGL_INLINE bool igl::tetgenio_to_tetmesh(
+IGL_INLINE bool igl::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   std::vector<std::vector<REAL > > & V, 
   std::vector<std::vector<int> > & T,
@@ -84,17 +84,17 @@ IGL_INLINE bool igl::tetgenio_to_tetmesh(
   return true;
 }
 
-IGL_INLINE bool igl::tetgenio_to_tetmesh(
+IGL_INLINE bool igl::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   std::vector<std::vector<REAL > > & V, 
   std::vector<std::vector<int> > & T)
 {
   std::vector<std::vector<int> > F;
-  return igl::tetgenio_to_tetmesh(out,V,T,F);
+  return tetgenio_to_tetmesh(out,V,T,F);
 }
 
 template <typename DerivedV, typename DerivedT, typename DerivedF>
-IGL_INLINE bool igl::tetgenio_to_tetmesh(
+IGL_INLINE bool igl::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   Eigen::PlainObjectBase<DerivedV>& V,
   Eigen::PlainObjectBase<DerivedT>& T,
@@ -125,7 +125,7 @@ IGL_INLINE bool igl::tetgenio_to_tetmesh(
 }
 
 template <typename DerivedV, typename DerivedT>
-IGL_INLINE bool igl::tetgenio_to_tetmesh(
+IGL_INLINE bool igl::tetgen::tetgenio_to_tetmesh(
   const tetgenio & out,
   Eigen::PlainObjectBase<DerivedV>& V,
   Eigen::PlainObjectBase<DerivedT>& T)
@@ -136,5 +136,5 @@ IGL_INLINE bool igl::tetgenio_to_tetmesh(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template bool igl::tetgenio_to_tetmesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(tetgenio const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::tetgen::tetgenio_to_tetmesh<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(tetgenio const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 36 - 33
include/igl/tetgen/tetgenio_to_tetmesh.h

@@ -15,39 +15,42 @@
 #include <Eigen/Core>
 namespace igl
 {
-  // Extract a tetrahedral mesh from a tetgenio object
-  // Inputs:
-  //   out tetgenio output object
-  // Outputs:
-  //   V  #V by 3 vertex position list
-  //   T  #T by 4 list of tetrahedra indices into V
-  //   F  #F by 3 list of marked facets
-  // Returns true on success, false on error
-  IGL_INLINE bool tetgenio_to_tetmesh(
-    const tetgenio & out,
-    std::vector<std::vector<REAL > > & V, 
-    std::vector<std::vector<int> > & T,
-    std::vector<std::vector<int> > & F);
-  IGL_INLINE bool tetgenio_to_tetmesh(
-    const tetgenio & out,
-    std::vector<std::vector<REAL > > & V, 
-    std::vector<std::vector<int> > & T);
-  
-  // Wrapper with Eigen types
-  // Templates:
-  //   DerivedV  real-value: i.e. from MatrixXd
-  //   DerivedT  integer-value: i.e. from MatrixXi
-  template <typename DerivedV, typename DerivedT, typename DerivedF>
-  IGL_INLINE bool tetgenio_to_tetmesh(
-    const tetgenio & out,
-    Eigen::PlainObjectBase<DerivedV>& V,
-    Eigen::PlainObjectBase<DerivedT>& T,
-    Eigen::PlainObjectBase<DerivedF>& F);
-  template <typename DerivedV, typename DerivedT>
-  IGL_INLINE bool tetgenio_to_tetmesh(
-    const tetgenio & out,
-    Eigen::PlainObjectBase<DerivedV>& V,
-    Eigen::PlainObjectBase<DerivedT>& T);
+  namespace tetgen
+  {
+    // Extract a tetrahedral mesh from a tetgenio object
+    // Inputs:
+    //   out tetgenio output object
+    // Outputs:
+    //   V  #V by 3 vertex position list
+    //   T  #T by 4 list of tetrahedra indices into V
+    //   F  #F by 3 list of marked facets
+    // Returns true on success, false on error
+    IGL_INLINE bool tetgenio_to_tetmesh(
+      const tetgenio & out,
+      std::vector<std::vector<REAL > > & V, 
+      std::vector<std::vector<int> > & T,
+      std::vector<std::vector<int> > & F);
+    IGL_INLINE bool tetgenio_to_tetmesh(
+      const tetgenio & out,
+      std::vector<std::vector<REAL > > & V, 
+      std::vector<std::vector<int> > & T);
+    
+    // Wrapper with Eigen types
+    // Templates:
+    //   DerivedV  real-value: i.e. from MatrixXd
+    //   DerivedT  integer-value: i.e. from MatrixXi
+    template <typename DerivedV, typename DerivedT, typename DerivedF>
+    IGL_INLINE bool tetgenio_to_tetmesh(
+      const tetgenio & out,
+      Eigen::PlainObjectBase<DerivedV>& V,
+      Eigen::PlainObjectBase<DerivedT>& T,
+      Eigen::PlainObjectBase<DerivedF>& F);
+    template <typename DerivedV, typename DerivedT>
+    IGL_INLINE bool tetgenio_to_tetmesh(
+      const tetgenio & out,
+      Eigen::PlainObjectBase<DerivedV>& V,
+      Eigen::PlainObjectBase<DerivedT>& T);
+  }
 }
 
 

+ 3 - 3
include/igl/tetgen/tetrahedralize.cpp

@@ -18,7 +18,7 @@
 #include <cassert>
 #include <iostream>
 
-IGL_INLINE int igl::tetrahedralize(
+IGL_INLINE int igl::tetgen::tetrahedralize(
   const std::vector<std::vector<REAL > > & V, 
   const std::vector<std::vector<int> > & F, 
   const std::string switches,
@@ -65,7 +65,7 @@ template <
   typename DerivedTV, 
   typename DerivedTT, 
   typename DerivedTF>
-IGL_INLINE int igl::tetrahedralize(
+IGL_INLINE int igl::tetgen::tetrahedralize(
   const Eigen::PlainObjectBase<DerivedV>& V,
   const Eigen::PlainObjectBase<DerivedF>& F,
   const std::string switches,
@@ -103,5 +103,5 @@ IGL_INLINE int igl::tetrahedralize(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template int igl::tetrahedralize<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::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&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template int igl::tetgen::tetrahedralize<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::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&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 47 - 44
include/igl/tetgen/tetrahedralize.h

@@ -19,50 +19,53 @@
 
 namespace igl
 {
-  // Mesh the interior of a surface mesh (V,F) using tetgen
-  //
-  // Inputs:
-  //   V  #V by 3 vertex position list
-  //   F  #F list of polygon face indices into V (0-indexed)
-  //   switches  string of tetgen options (See tetgen documentation) e.g.
-  //     "pq1.414a0.01" tries to mesh the interior of a given surface with
-  //       quality and area constraints
-  //     "" will mesh the convex hull constrained to pass through V (ignores F)
-  // Outputs:
-  //   TV  #V by 3 vertex position list
-  //   TT  #T by 4 list of tet face indices
-  //   TF  #F by 3 list of trianlge face indices
-  // Returns status:
-  //   0 success
-  //   1 tetgen threw exception
-  //   2 tetgen did not crash but could not create any tets (probably there are
-  //     holes, duplicate faces etc.)
-  //   -1 other error
-  IGL_INLINE int tetrahedralize(
-    const std::vector<std::vector<REAL > > & V, 
-    const std::vector<std::vector<int> > & F, 
-    const std::string switches,
-    std::vector<std::vector<REAL > > & TV, 
-    std::vector<std::vector<int > > & TT, 
-    std::vector<std::vector<int> > & TF);
-  
-  // Wrapper with Eigen types
-  // Templates:
-  //   DerivedV  real-value: i.e. from MatrixXd
-  //   DerivedF  integer-value: i.e. from MatrixXi
-  template <
-    typename DerivedV, 
-    typename DerivedF, 
-    typename DerivedTV, 
-    typename DerivedTT, 
-    typename DerivedTF>
-  IGL_INLINE int tetrahedralize(
-    const Eigen::PlainObjectBase<DerivedV>& V,
-    const Eigen::PlainObjectBase<DerivedF>& F,
-    const std::string switches,
-    Eigen::PlainObjectBase<DerivedTV>& TV,
-    Eigen::PlainObjectBase<DerivedTT>& TT,
-    Eigen::PlainObjectBase<DerivedTF>& TF);
+  namespace tetgen
+  {
+    // Mesh the interior of a surface mesh (V,F) using tetgen
+    //
+    // Inputs:
+    //   V  #V by 3 vertex position list
+    //   F  #F list of polygon face indices into V (0-indexed)
+    //   switches  string of tetgen options (See tetgen documentation) e.g.
+    //     "pq1.414a0.01" tries to mesh the interior of a given surface with
+    //       quality and area constraints
+    //     "" will mesh the convex hull constrained to pass through V (ignores F)
+    // Outputs:
+    //   TV  #V by 3 vertex position list
+    //   TT  #T by 4 list of tet face indices
+    //   TF  #F by 3 list of trianlge face indices
+    // Returns status:
+    //   0 success
+    //   1 tetgen threw exception
+    //   2 tetgen did not crash but could not create any tets (probably there are
+    //     holes, duplicate faces etc.)
+    //   -1 other error
+    IGL_INLINE int tetrahedralize(
+      const std::vector<std::vector<REAL > > & V, 
+      const std::vector<std::vector<int> > & F, 
+      const std::string switches,
+      std::vector<std::vector<REAL > > & TV, 
+      std::vector<std::vector<int > > & TT, 
+      std::vector<std::vector<int> > & TF);
+    
+    // Wrapper with Eigen types
+    // Templates:
+    //   DerivedV  real-value: i.e. from MatrixXd
+    //   DerivedF  integer-value: i.e. from MatrixXi
+    template <
+      typename DerivedV, 
+      typename DerivedF, 
+      typename DerivedTV, 
+      typename DerivedTT, 
+      typename DerivedTF>
+    IGL_INLINE int tetrahedralize(
+      const Eigen::PlainObjectBase<DerivedV>& V,
+      const Eigen::PlainObjectBase<DerivedF>& F,
+      const std::string switches,
+      Eigen::PlainObjectBase<DerivedTV>& TV,
+      Eigen::PlainObjectBase<DerivedTT>& TT,
+      Eigen::PlainObjectBase<DerivedTF>& TF);
+  }
 }
 
 

+ 1 - 1
include/igl/triangle/triangulate.cpp

@@ -42,7 +42,7 @@ extern "C"
 #  undef VOID
 #endif
 
-IGL_INLINE void igl::triangulate(
+IGL_INLINE void igl::triangle::triangulate(
   const Eigen::MatrixXd& V,
   const Eigen::MatrixXi& E,
   const Eigen::MatrixXd& H,

+ 23 - 21
include/igl/triangle/triangulate.h

@@ -13,27 +13,29 @@
 
 namespace igl
 {
-  // Triangulate the interior of a polygon using the triangle library.
-  //
-  // Inputs:
-  //   V #V by 2 list of 2D vertex positions
-  //   E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
-  //   H #H by 2 coordinates of points contained inside holes of the polygon
-  //   flags  string of options pass to triangle (see triangle documentation)
-  // Outputs:
-  //   V2  #V2 by 2  coordinates of the vertives of the generated triangulation
-  //   F2  #F2 by 3  list of indices forming the faces of the generated triangulation
-  //
-  // TODO: expose the option to prevent Steiner points on the boundary
-  //
-  IGL_INLINE void triangulate(
-    const Eigen::MatrixXd& V,
-    const Eigen::MatrixXi& E,
-    const Eigen::MatrixXd& H,
-    const std::string flags,
-    Eigen::MatrixXd& V2,
-    Eigen::MatrixXi& F2);
-
+  namespace triangle
+  {
+    // Triangulate the interior of a polygon using the triangle library.
+    //
+    // Inputs:
+    //   V #V by 2 list of 2D vertex positions
+    //   E #E by 2 list of vertex ids forming unoriented edges of the boundary of the polygon
+    //   H #H by 2 coordinates of points contained inside holes of the polygon
+    //   flags  string of options pass to triangle (see triangle documentation)
+    // Outputs:
+    //   V2  #V2 by 2  coordinates of the vertives of the generated triangulation
+    //   F2  #F2 by 3  list of indices forming the faces of the generated triangulation
+    //
+    // TODO: expose the option to prevent Steiner points on the boundary
+    //
+    IGL_INLINE void triangulate(
+      const Eigen::MatrixXd& V,
+      const Eigen::MatrixXi& E,
+      const Eigen::MatrixXd& H,
+      const std::string flags,
+      Eigen::MatrixXd& V2,
+      Eigen::MatrixXi& F2);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 8 - 8
include/igl/viewer/OpenGL_shader.cpp

@@ -26,7 +26,7 @@
 #include <iostream>
 #include <fstream>
 
-IGL_INLINE bool igl::OpenGL_shader::init_from_files(
+IGL_INLINE bool igl::viewer::OpenGL_shader::init_from_files(
   const std::string &vertex_shader_filename,
   const std::string &fragment_shader_filename,
   const std::string &fragment_data_name,
@@ -49,7 +49,7 @@ IGL_INLINE bool igl::OpenGL_shader::init_from_files(
  );
 }
 
-IGL_INLINE bool igl::OpenGL_shader::init(
+IGL_INLINE bool igl::viewer::OpenGL_shader::init(
   const std::string &vertex_shader_string,
   const std::string &fragment_shader_string,
   const std::string &fragment_data_name,
@@ -97,22 +97,22 @@ IGL_INLINE bool igl::OpenGL_shader::init(
   return true;
 }
 
-IGL_INLINE void igl::OpenGL_shader::bind()
+IGL_INLINE void igl::viewer::OpenGL_shader::bind()
 {
   glUseProgram(program_shader);
 }
 
-IGL_INLINE GLint igl::OpenGL_shader::attrib(const std::string &name) const
+IGL_INLINE GLint igl::viewer::OpenGL_shader::attrib(const std::string &name) const
 {
   return glGetAttribLocation(program_shader, name.c_str());
 }
 
-IGL_INLINE GLint igl::OpenGL_shader::uniform(const std::string &name) const
+IGL_INLINE GLint igl::viewer::OpenGL_shader::uniform(const std::string &name) const
 {
   return glGetUniformLocation(program_shader, name.c_str());
 }
 
-IGL_INLINE GLint igl::OpenGL_shader::bindVertexAttribArray(
+IGL_INLINE GLint igl::viewer::OpenGL_shader::bindVertexAttribArray(
   const std::string &name, GLuint bufferID, const Eigen::MatrixXf &M, bool refresh) const
 {
   GLint id = attrib(name);
@@ -131,7 +131,7 @@ IGL_INLINE GLint igl::OpenGL_shader::bindVertexAttribArray(
   return id;
 }
 
-IGL_INLINE void igl::OpenGL_shader::free()
+IGL_INLINE void igl::viewer::OpenGL_shader::free()
 {
   if (program_shader)
   {
@@ -155,7 +155,7 @@ IGL_INLINE void igl::OpenGL_shader::free()
   }
 }
 
-IGL_INLINE GLuint igl::OpenGL_shader::create_shader_helper(GLint type, const std::string &shader_string)
+IGL_INLINE GLuint igl::viewer::OpenGL_shader::create_shader_helper(GLint type, const std::string &shader_string)
 {
   using namespace std;
   if (shader_string.empty())

+ 3 - 0
include/igl/viewer/OpenGL_shader.h

@@ -36,6 +36,8 @@
 
 namespace igl
 {
+namespace viewer
+{
 
 // This class wraps an OpenGL program composed of three shaders
 // TODO: write documentation
@@ -88,6 +90,7 @@ public:
 
 };
 
+}
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 11 - 11
include/igl/viewer/OpenGL_state.cpp

@@ -9,7 +9,7 @@
 #include "OpenGL_state.h"
 #include "ViewerData.h"
 
-IGL_INLINE void igl::OpenGL_state::init_buffers()
+IGL_INLINE void igl::viewer::OpenGL_state::init_buffers()
 {
   // Mesh: Vertex Array Object & Buffer objects
   glGenVertexArrays(1, &vao_mesh);
@@ -40,7 +40,7 @@ IGL_INLINE void igl::OpenGL_state::init_buffers()
   dirty = ViewerData::DIRTY_ALL;
 }
 
-IGL_INLINE void igl::OpenGL_state::free_buffers()
+IGL_INLINE void igl::viewer::OpenGL_state::free_buffers()
 {
   glDeleteVertexArrays(1, &vao_mesh);
   glDeleteVertexArrays(1, &vao_overlay_lines);
@@ -63,7 +63,7 @@ IGL_INLINE void igl::OpenGL_state::free_buffers()
   glDeleteTextures(1, &vbo_tex);
 }
 
-IGL_INLINE void igl::OpenGL_state::set_data(const igl::ViewerData &data, bool invert_normals)
+IGL_INLINE void igl::viewer::OpenGL_state::set_data(const igl::viewer::ViewerData &data, bool invert_normals)
 {
   bool per_corner_uv = (data.F_uv.rows() == data.F.rows());
   bool per_corner_normals = (data.F_normals.rows() == 3 * data.F.rows());
@@ -271,7 +271,7 @@ IGL_INLINE void igl::OpenGL_state::set_data(const igl::ViewerData &data, bool in
   }
 }
 
-IGL_INLINE void igl::OpenGL_state::bind_mesh()
+IGL_INLINE void igl::viewer::OpenGL_state::bind_mesh()
 {
   glBindVertexArray(vao_mesh);
   shader_mesh.bind();
@@ -301,7 +301,7 @@ IGL_INLINE void igl::OpenGL_state::bind_mesh()
   dirty &= ~ViewerData::DIRTY_MESH;
 }
 
-IGL_INLINE void igl::OpenGL_state::bind_overlay_lines()
+IGL_INLINE void igl::viewer::OpenGL_state::bind_overlay_lines()
 {
   bool is_dirty = dirty & ViewerData::DIRTY_OVERLAY_LINES;
 
@@ -317,7 +317,7 @@ IGL_INLINE void igl::OpenGL_state::bind_overlay_lines()
   dirty &= ~ViewerData::DIRTY_OVERLAY_LINES;
 }
 
-IGL_INLINE void igl::OpenGL_state::bind_overlay_points()
+IGL_INLINE void igl::viewer::OpenGL_state::bind_overlay_points()
 {
   bool is_dirty = dirty & ViewerData::DIRTY_OVERLAY_POINTS;
 
@@ -333,7 +333,7 @@ IGL_INLINE void igl::OpenGL_state::bind_overlay_points()
   dirty &= ~ViewerData::DIRTY_OVERLAY_POINTS;
 }
 
-IGL_INLINE void igl::OpenGL_state::draw_mesh(bool solid)
+IGL_INLINE void igl::viewer::OpenGL_state::draw_mesh(bool solid)
 {
   glPolygonMode(GL_FRONT_AND_BACK, solid ? GL_FILL : GL_LINE);
 
@@ -349,17 +349,17 @@ IGL_INLINE void igl::OpenGL_state::draw_mesh(bool solid)
   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
 }
 
-IGL_INLINE void igl::OpenGL_state::draw_overlay_lines()
+IGL_INLINE void igl::viewer::OpenGL_state::draw_overlay_lines()
 {
   glDrawElements(GL_LINES, lines_F_vbo.cols(), GL_UNSIGNED_INT, 0);
 }
 
-IGL_INLINE void igl::OpenGL_state::draw_overlay_points()
+IGL_INLINE void igl::viewer::OpenGL_state::draw_overlay_points()
 {
   glDrawElements(GL_POINTS, points_F_vbo.cols(), GL_UNSIGNED_INT, 0);
 }
 
-IGL_INLINE void igl::OpenGL_state::init()
+IGL_INLINE void igl::viewer::OpenGL_state::init()
 {
   std::string mesh_vertex_shader_string =
   "#version 150\n"
@@ -478,7 +478,7 @@ IGL_INLINE void igl::OpenGL_state::init()
       overlay_point_fragment_shader_string, "outColor");
 }
 
-IGL_INLINE void igl::OpenGL_state::free()
+IGL_INLINE void igl::viewer::OpenGL_state::free()
 {
   shader_mesh.free();
   shader_overlay_lines.free();

+ 5 - 2
include/igl/viewer/OpenGL_state.h

@@ -9,7 +9,7 @@
 #ifndef IGL_OPENGL_STATE_H
 #define IGL_OPENGL_STATE_H
 
-// Coverts mesh data inside a igl::ViewerData class in an OpenGL compatible format
+// Coverts mesh data inside a igl::viewer::ViewerData class in an OpenGL compatible format
 // The class includes a shader and the opengl calls to plot the data
 
 #include <igl/igl_inline.h>
@@ -18,6 +18,8 @@
 
 namespace igl
 {
+namespace viewer
+{
 
 class OpenGL_state
 {
@@ -81,7 +83,7 @@ public:
   IGL_INLINE void init_buffers();
 
   // Update contents from a 'Data' instance
-  IGL_INLINE void set_data(const igl::ViewerData &data, bool invert_normals);
+  IGL_INLINE void set_data(const igl::viewer::ViewerData &data, bool invert_normals);
 
   // Bind the underlying OpenGL buffer objects for subsequent mesh draw calls
   IGL_INLINE void bind_mesh();
@@ -106,6 +108,7 @@ public:
 
 };
 
+}
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 6 - 6
include/igl/viewer/TextRenderer.cpp

@@ -8,9 +8,9 @@
 #include "TextRenderer.h"
 #include <igl/project.h>
 
-  IGL_INLINE igl::TextRenderer::TextRenderer() : m_shaderHandleBackup(0) { }
+  IGL_INLINE igl::viewer::TextRenderer::TextRenderer() : m_shaderHandleBackup(0) { }
 
-  IGL_INLINE int igl::TextRenderer::Init()
+  IGL_INLINE int igl::viewer::TextRenderer::Init()
   {
     int retval = CTwGraphOpenGLCore::Init();
     if (retval == 1)
@@ -61,7 +61,7 @@
     return retval;
   }
 
-  IGL_INLINE int igl::TextRenderer::Shut()
+  IGL_INLINE int igl::viewer::TextRenderer::Shut()
   {
     for (auto kv : m_textObjects)
       DeleteTextObj(kv.second);
@@ -70,7 +70,7 @@
     return CTwGraphOpenGLCore::Shut();
   }
 
-  IGL_INLINE void igl::TextRenderer::BeginDraw(const Eigen::Matrix4f &view, const Eigen::Matrix4f &proj,
+  IGL_INLINE void igl::viewer::TextRenderer::BeginDraw(const Eigen::Matrix4f &view, const Eigen::Matrix4f &proj,
     const Eigen::Vector4f &_viewport, float _object_scale)
   {
     viewport = _viewport;
@@ -82,7 +82,7 @@
     object_scale = _object_scale;
   }
 
-  IGL_INLINE void igl::TextRenderer::EndDraw()
+  IGL_INLINE void igl::viewer::TextRenderer::EndDraw()
   {
     /* Limit the number of cached text objects */
     for (auto it = m_textObjects.cbegin(); it != m_textObjects.cend(); )
@@ -97,7 +97,7 @@
     CTwGraphOpenGLCore::EndDraw();
   }
 
-  IGL_INLINE void igl::TextRenderer::DrawText(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text)
+  IGL_INLINE void igl::viewer::TextRenderer::DrawText(Eigen::Vector3d pos, Eigen::Vector3d normal, const std::string &text)
   {
     pos += normal * 0.005f * object_scale;
     Eigen::Vector3f coord = igl::project(Eigen::Vector3f(pos(0), pos(1), pos(2)),

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