浏览代码

merge

Former-commit-id: 75b3bcd35ad82a57aa345e426e7079d4eaf72a90
Alec Jacobson 10 年之前
父节点
当前提交
84ecfdf30e
共有 100 个文件被更改,包括 2875 次插入1905 次删除
  1. 6 0
      .gitmodules
  2. 18 6
      README.md
  3. 69 22
      RELEASE_HISTORY.md
  4. 2 4
      examples/Makefile.conf
  5. 1 1
      examples/MatlabWorkspace/example.cpp
  6. 3 4
      examples/ReAntTweakBar/example.cpp
  7. 4 4
      examples/ambient-occlusion/example.cpp
  8. 29 28
      examples/arap/example.cpp
  9. 7 7
      examples/bbw/example.cpp
  10. 6 4
      examples/camera/example.cpp
  11. 3 3
      examples/colored-mesh/example.cpp
  12. 19 19
      examples/components/example.cpp
  13. 11 11
      examples/embree/example.cpp
  14. 0 30
      examples/example_fun/Makefile
  15. 0 10
      examples/example_fun/README
  16. 0 16
      examples/example_fun/example.cpp
  17. 24 24
      examples/flare-eyes/example.cpp
  18. 3 4
      examples/get_seconds/example.cpp
  19. 1 1
      examples/intersections/Makefile
  20. 24 22
      examples/intersections/example.cpp
  21. 1 1
      examples/mode/example.cpp
  22. 12 12
      examples/multi-viewport/example.cpp
  23. 32 32
      examples/patches/example.cpp
  24. 21 21
      examples/randomly-sample-mesh/example.cpp
  25. 2 2
      examples/render_to_png/example.cpp
  26. 20 20
      examples/rotate-widget/example.cpp
  27. 21 21
      examples/scene-rotation/example.cpp
  28. 22 25
      examples/shadow-mapping/example.cpp
  29. 41 41
      examples/skeleton-builder/example.cpp
  30. 18 18
      examples/skeleton-poser/example.cpp
  31. 29 29
      examples/skeleton/example.cpp
  32. 0 23
      examples/svd/Makefile
  33. 0 97
      examples/svd/example.cpp
  34. 23 23
      examples/textured-mesh/example.cpp
  35. 12 13
      examples/transparency/example.cpp
  36. 2 2
      google-soc/index.html
  37. 4 7
      include/igl/AABB.h
  38. 372 0
      include/igl/ConjugateFFSolverData.h
  39. 0 285
      include/igl/ReAntTweakBar.h
  40. 128 0
      include/igl/Singular_Value_Decomposition_Givens_QR_Factorization_Kernel.hpp
  41. 118 0
      include/igl/Singular_Value_Decomposition_Jacobi_Conjugation_Kernel.hpp
  42. 137 0
      include/igl/Singular_Value_Decomposition_Kernel_Declarations.hpp
  43. 1 0
      include/igl/Singular_Value_Decomposition_Main_Kernel_Body.hpp.REMOVED.git-id
  44. 67 0
      include/igl/Singular_Value_Decomposition_Preamble.hpp
  45. 7 0
      include/igl/WindingNumberMethod.h
  46. 0 51
      include/igl/angles.cpp
  47. 0 47
      include/igl/angles.h
  48. 36 26
      include/igl/anttweakbar/ReAntTweakBar.cpp
  49. 286 0
      include/igl/anttweakbar/ReAntTweakBar.h
  50. 1 3
      include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp
  51. 31 0
      include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h
  52. 12 12
      include/igl/arap.cpp
  53. 3 3
      include/igl/arap.h
  54. 23 23
      include/igl/arap_dof.cpp
  55. 2 2
      include/igl/arap_dof.h
  56. 5 5
      include/igl/bbw/bbw.cpp
  57. 70 67
      include/igl/bbw/bbw.h
  58. 0 0
      include/igl/bfs_orient.cpp
  59. 0 0
      include/igl/bfs_orient.h
  60. 117 0
      include/igl/biharmonic_coordinates.cpp
  61. 77 0
      include/igl/biharmonic_coordinates.h
  62. 7 0
      include/igl/bone_parents.cpp
  63. 20 11
      include/igl/boolean/MeshBooleanType.h
  64. 10 3
      include/igl/boolean/from_cork_mesh.cpp
  65. 26 16
      include/igl/boolean/from_cork_mesh.h
  66. 24 5
      include/igl/boolean/mesh_boolean.cpp
  67. 92 77
      include/igl/boolean/mesh_boolean.h
  68. 10 3
      include/igl/boolean/mesh_boolean_cork.cpp
  69. 38 28
      include/igl/boolean/mesh_boolean_cork.h
  70. 10 3
      include/igl/boolean/to_cork_mesh.cpp
  71. 26 16
      include/igl/boolean/to_cork_mesh.h
  72. 0 56
      include/igl/boost/components.cpp
  73. 12 9
      include/igl/cgal/RemeshSelfIntersectionsParam.h
  74. 213 210
      include/igl/cgal/SelfIntersectMesh.h
  75. 2 2
      include/igl/cgal/complex_to_mesh.cpp
  76. 22 19
      include/igl/cgal/complex_to_mesh.h
  77. 1 1
      include/igl/cgal/intersect_other.cpp
  78. 28 25
      include/igl/cgal/intersect_other.h
  79. 5 5
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp
  80. 23 20
      include/igl/cgal/mesh_to_cgal_triangle_list.h
  81. 2 2
      include/igl/cgal/mesh_to_polyhedron.cpp
  82. 21 18
      include/igl/cgal/mesh_to_polyhedron.h
  83. 9 2
      include/igl/cgal/order_facets_around_edges.cpp
  84. 14 4
      include/igl/cgal/order_facets_around_edges.h
  85. 12 5
      include/igl/cgal/outer_hull.cpp
  86. 56 46
      include/igl/cgal/outer_hull.h
  87. 11 4
      include/igl/cgal/peel_outer_hull_layers.cpp
  88. 48 38
      include/igl/cgal/peel_outer_hull_layers.h
  89. 2 2
      include/igl/cgal/polyhedron_to_mesh.cpp
  90. 19 16
      include/igl/cgal/polyhedron_to_mesh.h
  91. 6 4
      include/igl/cgal/remesh_self_intersections.cpp
  92. 57 54
      include/igl/cgal/remesh_self_intersections.h
  93. 2 2
      include/igl/cgal/signed_distance_isosurface.cpp
  94. 31 28
      include/igl/cgal/signed_distance_isosurface.h
  95. 0 30
      include/igl/cocoa_key_to_anttweakbar_key.h
  96. 7 0
      include/igl/collapse_small_triangles.cpp
  97. 4 2
      include/igl/colon.cpp
  98. 5 0
      include/igl/comb_frame_field.cpp
  99. 12 6
      include/igl/comiso/frame_field.cpp
  100. 5 2
      include/igl/comiso/frame_field.h

+ 6 - 0
.gitmodules

@@ -0,0 +1,6 @@
+[submodule "external/nanogui"]
+	path = external/nanogui
+	url = https://github.com/schuellc/nanogui.git
+        fetchRecursiveSubmodules = true
+        ignore = dirty
+

+ 18 - 6
README.md

@@ -19,7 +19,7 @@ header file contains a single function (e.g. `igl/cotmatrix.h` contains
 stored in an n-by-3 matrix of vertex positions V and an m-by-3 matrix of
 stored in an n-by-3 matrix of vertex positions V and an m-by-3 matrix of
 triangle indices F. 
 triangle indices F. 
 
 
-_Optionally_ the library may also be [pre-compiled](build/) into a statically
+_Optionally_ the library may also be [pre-compiled](optional/) into a statically
 linked library, for faster compile times with your projects. This only effects
 linked library, for faster compile times with your projects. This only effects
 compile time (run-time performance and behavior is identical). If in doubt, use
 compile time (run-time performance and behavior is identical). If in doubt, use
 the header-only default mode: (i.e. just include the headers you want to use).
 the header-only default mode: (i.e. just include the headers you want to use).
@@ -65,7 +65,7 @@ If you save this in `hello.cpp`, then you could compile this with (assuming
 Eigen is installed in `/usr/local/include/eigen3`):
 Eigen is installed in `/usr/local/include/eigen3`):
 
 
 ```bash
 ```bash
-gcc -I/usr/local/include/eigen3 -I./libigl/include/ hello.cpp -o hello
+g++ -std=c++11 -I/usr/local/include/eigen3 -I./libigl/include/ hello.cpp -o hello
 ```
 ```
 
 
 Running `./hello` would then produce
 Running `./hello` would then produce
@@ -84,6 +84,14 @@ libigl depends only on the [Eigen](http://eigen.tuxfamily.org) library.
 
 
 For more information see our [tutorial](tutorial/tutorial.html).
 For more information see our [tutorial](tutorial/tutorial.html).
 
 
+### Optional dependencies ###
+
+Libigl compartmentalizes its **optional** dependences via its directory
+organization in the `include/` folder. All header files located _directly_ in
+the `include/igl/` folder have only stl and Eigen as dependencies. For example,
+all of the headers that depend on CGAL are located in `include/igl/cgal`. For a
+full list of _optional_ dependencies check `optional/CMakeLists.txt`.
+
 ### GCC and the optional CGAL dependency
 ### GCC and the optional CGAL dependency
 The `include/igl/cgal/*.h` headers depend on CGAL. It has come to our attention
 The `include/igl/cgal/*.h` headers depend on CGAL. It has come to our attention
 that CGAL does not work properly with GCC 4.8. To the best of our knowledge,
 that CGAL does not work properly with GCC 4.8. To the best of our knowledge,
@@ -100,7 +108,7 @@ You can keep up to date by cloning a read-only copy of our GitHub
 [repository](https://github.com/libigl).
 [repository](https://github.com/libigl).
 
 
 ## Known Issues
 ## Known Issues
-We really heavily on Eigen. Nearly all inputs and outputs are Eigen matrices of
+We rely heavily on Eigen. Nearly all inputs and outputs are Eigen matrices of
 some kind. However, we currently _only_ officially support Eigen's default
 some kind. However, we currently _only_ officially support Eigen's default
 column-major ordering. That means, we **do not** expect our code to work for
 column-major ordering. That means, we **do not** expect our code to work for
 matrices using the `Eigen::RowMajor` flag. If you can, change definitions like:
 matrices using the `Eigen::RowMajor` flag. If you can, change definitions like:
@@ -148,6 +156,9 @@ BibTeX entry:
 ```
 ```
 
 
 ## Projects/Universities using libigl
 ## Projects/Universities using libigl
+Libigl is used by many research groups around the world. In 2015, it won the
+Eurographics/ACM Symposium on Geometry Processing software award. Here are a
+few labs/companies/institutions using libigl:
 
 
  - [Spine by Esoteric Software](http://esotericsoftware.com/) is an animation tool dedicated to 2D characters.
  - [Spine by Esoteric Software](http://esotericsoftware.com/) is an animation tool dedicated to 2D characters.
  - Columbia University, [Columbia Computer Graphics Group](http://www.cs.columbia.edu/cg/), USA
  - Columbia University, [Columbia Computer Graphics Group](http://www.cs.columbia.edu/cg/), USA
@@ -185,7 +196,8 @@ If you find bugs or have problems please use our [github issue tracking
 page](https://github.com/libigl/libigl/issues).
 page](https://github.com/libigl/libigl/issues).
 
 
 ## Copyright
 ## Copyright
-2015 Alec Jacobson, Daniele Panozzo, Olga Diamanti, Christian Schüller, Kenshi
-Takayama, Leo Sacht, Wenzel Jacob, Nico Pietroni, Amir Vaxman
+2015 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan
+Zhou, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De
+Giorgis, Luigi Rocca, Leonardo Sacht, Olga Sorkine-Hornung, and others.
 
 
-![](tutorial/images/libigl-logo.jpg)
+Please see individual files for appropriate copyright notices.

+ 69 - 22
RELEASE_HISTORY.txt → RELEASE_HISTORY.md

@@ -1,7 +1,17 @@
-# Version tracking
+title: libigl Tutorial
+author: Alec Jacobson
+date: 17 June 2015
+css: tutorial/style.css
+html header:   <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+<link rel="stylesheet" href="http://yandex.st/highlightjs/7.3/styles/default.min.css">
+<script src="http://yandex.st/highlightjs/7.3/highlight.min.js"></script>
+<script>hljs.initHighlightingOnLoad();</script>
+
+# Libigl version tracking
 
 
 Version | Short description
 Version | Short description
 --------|----------------------------------------------------------------------
 --------|----------------------------------------------------------------------
+1.2.0   | Reorganization of "extras", rm deprecated funcs, absorb boost & svd3x3
 1.1.7   | Switch build for static library to cmake.
 1.1.7   | Switch build for static library to cmake.
 1.1.6   | Major boolean robustness fix, drop CGAL dependency for AABB/distances
 1.1.6   | Major boolean robustness fix, drop CGAL dependency for AABB/distances
 1.1.5   | Bug fix in booleans
 1.1.5   | Bug fix in booleans
@@ -13,6 +23,63 @@ Version | Short description
 1.0.2   | Bug fix in winding number code
 1.0.2   | Bug fix in winding number code
 1.0.1   | Bug fixes and more CGAL support
 1.0.1   | Bug fixes and more CGAL support
 1.0.0   | Major beta release: many renames, tutorial, triangle, org. build
 1.0.0   | Major beta release: many renames, tutorial, triangle, org. build
+0.4.6   | Generalized Winding Numbers
+0.4.5   | CGAL extra: mesh selfintersection
+0.4.4   | STL file format support
+0.4.3   | ARAP implementation
+0.4.1   | Migrated much of the FAST code including extra for Sifakis' 3x3 svd
+0.4.0   | Release under MPL2 license
+0.3.7   | Embree2.0 support
+0.3.6   | boost extra, patches, mosek 7 support, libiglbbw (mosek optional)
+0.3.5   | More examples, naive primitive sorting
+0.3.3   | Many more examples, ambient occlusion with Embree.
+0.3.1   | Linearly dependent constraints in min_quad_with_fixed, SparseQR buggy
+0.3.0   | Better active set method support
+0.2.3   | More explicits, active set method, opengl/anttweakbar guards
+0.2.2   | More explicit instanciations, faster sorts and uniques
+0.2.1   | Bug fixes in barycenter and doublearea found by Martin Bisson
+0.2.0   | XML serializer more stable and fixed bug in remove_duplicate_vertices
+0.1.8   | Embree and xml (windows only) extras
+0.1.5   | Compilation on windows, bug fix for compilation with cygwin
+0.1.1   | Alpha release with core functions, extras, examples
+
+## Version 1.2 Changes ##
+This change introduces better organization of dependencies and removes some
+deprecated/repeated functions. The 3x3 svd code and dependent functions
+(including ARAP) were absorbed into the main library. Similarly, the boost
+dependency extra was absorbed.
+
+
+### External libraries as git subrepos ###
+The core functionality of libigl (still) just depends on stl, c++11 and Eigen.
+There are additional _optional_ dependencies (e.g. CGAL, embree, glfw, tetgen,
+triangle). Libigl functions using these are located (still) in sub-folders of
+the include directory (e.g.  `include/igl/cgal/`, `include/igl/embree/`). Prior
+to version 1.2 we included copies of the code for some of these dependencies in the
+`external/` directory. As of
+version 1.2, these have been replaced with git sub-repos. If you have cloned
+libigl _before version 1.2_ then you should issue 
+
+    git submodule update --init --recursive
+
+### Deprecated/repeated functions ###
+
+Old                                     | New
+--------------------------------------- | -----------------------------------
+`igl::angles`                           | `igl::internal_angles`
+`igl::get_modifiers`                    | [deleted]
+`igl::nchoosek(offset,K,N,std::vector)` | `igl::nchoosek(Eigen,K,Eigen)`
+`#include <igl/boost/components.h>`     | `#include <igl/components.h>`
+`#include <igl/boost/bfs_orient.h>`     | `#include <igl/bfs_orient.h>`
+`#include <igl/boost/orientable_patches.h>` | `#include <igl/orientable_patches.h>`
+`#include <igl/svd3x3/arap.h>`          | `#include <igl/arap.h>`
+`#include <igl/svd3x3/arap_dof.h>`      | `#include <igl/arap_dof.h>`
+`#include <igl/svd3x3/fit_rotations.h>` | `#include <igl/fit_rotations.h>`
+`#include <igl/svd3x3/polar_svd3x3.h>`  | `#include <igl/polar_svd3x3.h>`
+`#include <igl/svd3x3/svd3x3.h>`        | `#include <igl/svd3x3.h>`
+`#include <igl/svd3x3/svd3x3_avx.h>`    | `#include <igl/svd3x3_avx.h>`
+`#include <igl/svd3x3/svd3x3_sse.h>`    | `#include <igl/svd3x3_sse.h>`
+
 
 
 ## Version 1.0 Changes ##
 ## Version 1.0 Changes ##
 Our beta release marks our confidence that this library can be used outside of
 Our beta release marks our confidence that this library can be used outside of
@@ -71,7 +138,7 @@ Old                              | New
  - `igl::polar_svd` now always returns a rotation in `R`, never a reflection.
  - `igl::polar_svd` now always returns a rotation in `R`, never a reflection.
    This mirrors the behavior of `igl::polar_svd3x3`.  Consequently the `T`
    This mirrors the behavior of `igl::polar_svd3x3`.  Consequently the `T`
    part may have negative skews.
    part may have negative skews.
- - We have organized the static
+ - We have organized the static library build
  - The previous `igl::grad` function, which computed the per-triangle gradient
  - The previous `igl::grad` function, which computed the per-triangle gradient
    of a per-vertex scalar function has been replaced. Now `igl::grad` computes
    of a per-vertex scalar function has been replaced. Now `igl::grad` computes
    the linear operator (previous computed using `igl::gradMat`). The gradient
    the linear operator (previous computed using `igl::gradMat`). The gradient
@@ -81,23 +148,3 @@ Old                              | New
  - The function `igl::project_normals`, which cast a line for each vertex of
  - The function `igl::project_normals`, which cast a line for each vertex of
    mesh _A_ in the normal direction and found the closest intersection along
    mesh _A_ in the normal direction and found the closest intersection along
    these lines with mesh _B_, has been removed.
    these lines with mesh _B_, has been removed.
-
-0.4.6  Generalized Winding Numbers
-0.4.5  CGAL extra: mesh selfintersection
-0.4.4  STL file format support
-0.4.3  ARAP implementation
-0.4.1  Migrated much of the FAST code including extra for Sifakis' 3x3 svd
-0.4.0  Release under MPL2 license
-0.3.7  Embree2.0 support
-0.3.6  boost extra, patches, mosek 7 support, libiglbbw (mosek optional)
-0.3.5  More examples, naive primitive sorting
-0.3.3  Many more examples, ambient occlusion with Embree.
-0.3.1  Linearly dependent constraints in min_quad_with_fixed, SparseQR buggy
-0.3.0  Better active set method support
-0.2.3  More explicits, active set method, opengl/anttweakbar guards
-0.2.2  More explicit instanciations, faster sorts and uniques
-0.2.1  Bug fixes in barycenter and doublearea found by Martin Bisson
-0.2.0  XML serializer more stable and fixed bug in remove_duplicate_vertices
-0.1.8  Embree and xml (windows only) extras
-0.1.5  Compilation on windows, bug fix for compilation with cygwin
-0.1.1  Alpha release with core functions, extras, examples

+ 2 - 4
examples/Makefile.conf

@@ -210,9 +210,7 @@ ifndef EIGEN3_INC
 	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
 	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
 endif
 endif
 
 
-ifndef LIBIGL
-	LIBIGL=$(THIS_DIR)/../
-endif
+LIBIGL=$(THIS_DIR)/../
 LIBIGL_INC=-I$(LIBIGL)/include
 LIBIGL_INC=-I$(LIBIGL)/include
 
 
 ifndef ANTTWEAKBAR_INC
 ifndef ANTTWEAKBAR_INC
@@ -220,7 +218,7 @@ ifndef ANTTWEAKBAR_INC
 endif
 endif
 ifndef ANTTWEAKBAR_LIB
 ifndef ANTTWEAKBAR_LIB
 	# AntTweakBar needs AppKit on mac os x
 	# AntTweakBar needs AppKit on mac os x
-	ANTTWEAKBAR_LIB=-L$(LIBIGL)/external/AntTweakBar/lib -lAntTweakBar -framework AppKit
+	ANTTWEAKBAR_LIB=-L$(LIBIGL)/external/AntTweakBar/lib -lAntTweakBar -framework AppKit -liglanttweakbar
 endif
 endif
 
 
 ifndef SINGULAR_VALUE_DECOMPOSITION_INC
 ifndef SINGULAR_VALUE_DECOMPOSITION_INC

+ 1 - 1
examples/MatlabWorkspace/example.cpp

@@ -24,7 +24,7 @@ int main(int argc, char * argv[])
   }
   }
   MatrixXd M;
   MatrixXd M;
   readDMAT(argv[1],M);
   readDMAT(argv[1],M);
-  MatlabWorkspace mat;
+  igl::matlab::MatlabWorkspace mat;
   mat.save(M,"M");
   mat.save(M,"M");
   mat.write(argv[2]);
   mat.write(argv[2]);
 
 

+ 3 - 4
examples/ReAntTweakBar/example.cpp

@@ -31,8 +31,7 @@
 //  ---------------------------------------------------------------------------
 //  ---------------------------------------------------------------------------
 
 
 
 
-#include <igl/ReAntTweakBar.h>
-using namespace igl;
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <stdlib.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdio.h>
@@ -75,7 +74,7 @@ float g_MatDiffuse[] = { 1.0f, 1.0f, 0.0f, 1.0f };
 double g_LightMultiplier = 1.0f;
 double g_LightMultiplier = 1.0f;
 float g_LightDirection[] = { -0.57735f, -0.57735f, -0.57735f };
 float g_LightDirection[] = { -0.57735f, -0.57735f, -0.57735f };
 
 
-ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 
 
 // Routine to set a quaternion from a rotation axis and angle
 // Routine to set a quaternion from a rotation axis and angle
 // ( input axis = float[3] angle = float  output: quat = float[4] )
 // ( input axis = float[3] angle = float  output: quat = float[4] )
@@ -347,7 +346,7 @@ int main(int argc, char *argv[])
     // ShapeEV associates Shape enum values with labels that will be displayed instead of enum values
     // ShapeEV associates Shape enum values with labels that will be displayed instead of enum values
     TwEnumVal shapeEV[NUM_SHAPES] = { {SHAPE_TEAPOT, "Teapot"}, {SHAPE_TORUS, "Torus"}, {SHAPE_CONE, "Cone"} , {SHAPE_SPHERE, "Sphere"}};
     TwEnumVal shapeEV[NUM_SHAPES] = { {SHAPE_TEAPOT, "Teapot"}, {SHAPE_TORUS, "Torus"}, {SHAPE_CONE, "Cone"} , {SHAPE_SPHERE, "Sphere"}};
     // Create a type for the enum shapeEV
     // Create a type for the enum shapeEV
-    TwType shapeType = ReTwDefineEnum("ShapeType", shapeEV, NUM_SHAPES);
+    TwType shapeType = igl::anttweakbar::ReTwDefineEnum("ShapeType", shapeEV, NUM_SHAPES);
     // add 'g_CurrentShape' to 'bar': this is a variable of type ShapeType. Its key shortcuts are [<] and [>].
     // add 'g_CurrentShape' to 'bar': this is a variable of type ShapeType. Its key shortcuts are [<] and [>].
     rebar.TwAddVarRW("Shape", shapeType, &g_CurrentShape, " keyIncr='<' keyDecr='>' help='Change object shape.' ");
     rebar.TwAddVarRW("Shape", shapeType, &g_CurrentShape, " keyIncr='<' keyDecr='>' help='Change object shape.' ");
   }
   }

+ 4 - 4
examples/ambient-occlusion/example.cpp

@@ -17,7 +17,7 @@
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
 #include <igl/barycenter.h>
 #include <igl/barycenter.h>
 #include <igl/matlab_format.h>
 #include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/pathinfo.h>
 #include <igl/pathinfo.h>
 #include <igl/embree/EmbreeIntersector.h>
 #include <igl/embree/EmbreeIntersector.h>
 #include <igl/embree/ambient_occlusion.h>
 #include <igl/embree/ambient_occlusion.h>
@@ -50,12 +50,12 @@ Eigen::MatrixXd V,N,C,mid;
 Eigen::MatrixXi F;
 Eigen::MatrixXi F;
 // Bounding box diagonal length
 // Bounding box diagonal length
 double bbd;
 double bbd;
-igl::EmbreeIntersector ei;
+igl::embree::EmbreeIntersector ei;
 // Running ambient occlusion
 // Running ambient occlusion
 Eigen::VectorXd S;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 bool lights_on = true;
 bool lights_on = true;
 Eigen::Vector4f color(0.4,0.8,0.3,1.0);
 Eigen::Vector4f color(0.4,0.8,0.3,1.0);
 double ao_factor = 1.0;
 double ao_factor = 1.0;
@@ -156,7 +156,7 @@ void display()
     }
     }
     VectorXd Si;
     VectorXd Si;
     const int num_samples = 20;
     const int num_samples = 20;
-    ambient_occlusion(ei,V,N,num_samples,Si);
+    igl::embree::ambient_occlusion(ei,V,N,num_samples,Si);
     S *= (double)tot_num_samples;
     S *= (double)tot_num_samples;
     S += Si*(double)num_samples;
     S += Si*(double)num_samples;
     tot_num_samples += num_samples;
     tot_num_samples += num_samples;

+ 29 - 28
examples/arap/example.cpp

@@ -1,39 +1,39 @@
-#include <igl/svd3x3/arap.h>
-#include <igl/writeDMAT.h>
-#include <igl/partition.h>
-#include <igl/harmonic.h>
+#include <igl/Camera.h>
+#include <igl/OpenGL_convenience.h>
+#include <igl/PI.h>
+#include <igl/STR.h>
+#include <igl/arap.h>
+#include <igl/barycenter.h>
 #include <igl/cotmatrix.h>
 #include <igl/cotmatrix.h>
-#include <igl/massmatrix.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
+#include <igl/harmonic.h>
 #include <igl/invert_diag.h>
 #include <igl/invert_diag.h>
-#include <igl/OpenGL_convenience.h>
+#include <igl/jet.h>
+#include <igl/list_to_matrix.h>
+#include <igl/massmatrix.h>
+#include <igl/material_colors.h>
+#include <igl/matlab_format.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/partition.h>
+#include <igl/pathinfo.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_vertex_normals.h>
 #include <igl/per_vertex_normals.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
-#include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
 #include <igl/readWRL.h>
 #include <igl/readWRL.h>
-#include <igl/trackball.h>
-#include <igl/list_to_matrix.h>
+#include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/material_colors.h>
-#include <igl/barycenter.h>
-#include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/pathinfo.h>
-#include <igl/Camera.h>
-#include <igl/get_seconds.h>
-#include <igl/PI.h>
-#include <igl/STR.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeDMAT.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 #  include <GLUT/glut.h>
 #  include <GLUT/glut.h>
@@ -141,7 +141,7 @@ int selected_col = 0;
 double bbd;
 double bbd;
 int tot_num_samples = 0;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 
 
 int num_in_selection(const Eigen::VectorXi & S)
 int num_in_selection(const Eigen::VectorXi & S)
 {
 {
@@ -708,7 +708,8 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   s.camera.push_away(3);
   s.camera.dolly_zoom(25-s.camera.m_angle);
   s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
+     "RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 7 - 7
examples/bbw/main.cpp → examples/bbw/example.cpp

@@ -3,15 +3,15 @@
 #include <igl/readOBJ.h>
 #include <igl/readOBJ.h>
 #include <igl/readOFF.h>
 #include <igl/readOFF.h>
 #include <igl/readMESH.h>
 #include <igl/readMESH.h>
-#include <igl/tetgen/mesh_with_skeleton.h>
 #include <igl/faces_first.h>
 #include <igl/faces_first.h>
 #include <igl/readTGF.h>
 #include <igl/readTGF.h>
 #include <igl/launch_medit.h>
 #include <igl/launch_medit.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_conditions.h>
-#include <igl/bbw/bbw.h>
 #include <igl/writeDMAT.h>
 #include <igl/writeDMAT.h>
 #include <igl/writeMESH.h>
 #include <igl/writeMESH.h>
 #include <igl/normalize_row_sums.h>
 #include <igl/normalize_row_sums.h>
+#include <igl/bbw/bbw.h>
+#include <igl/tetgen/mesh_with_skeleton.h>
 
 
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 
 
@@ -231,7 +231,7 @@ int main(int argc, char * argv[])
   MatrixXi TT;
   MatrixXi TT;
   // New surface faces FF
   // New surface faces FF
   MatrixXi FF;
   MatrixXi FF;
-  if(!mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
+  if(!igl::tetgen::mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
   {
   {
     return 1;
     return 1;
   }
   }
@@ -255,12 +255,12 @@ int main(int argc, char * argv[])
 
 
   // compute BBW 
   // compute BBW 
   // Default bbw data and flags
   // Default bbw data and flags
-  BBWData bbw_data;
-  bbw_data.qp_solver = QP_SOLVER_IGL_ACTIVE_SET;
-  //bbw_data.qp_solver = QP_SOLVER_MOSEK;
+  igl::bbw::BBWData bbw_data;
+  bbw_data.qp_solver = igl::bbw::QP_SOLVER_IGL_ACTIVE_SET;
+  //bbw_data.qp_solver = igl::bbw::QP_SOLVER_MOSEK;
   // Weights matrix
   // Weights matrix
   MatrixXd W;
   MatrixXd W;
-  if(!bbw(VV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(VV,TT,b,bc,bbw_data,W))
   {
   {
     return 1;
     return 1;
   }
   }

+ 6 - 4
examples/camera/example.cpp

@@ -3,7 +3,7 @@
 #include <igl/Camera.h>
 #include <igl/Camera.h>
 #include <igl/matlab_format.h>
 #include <igl/matlab_format.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/trackball.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/PI.h>
 #include <igl/PI.h>
@@ -64,7 +64,7 @@ enum CenterType
 
 
 int width,height;
 int width,height;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 struct State
 struct State
 {
 {
   std::vector<igl::Camera> cameras;
   std::vector<igl::Camera> cameras;
@@ -666,10 +666,12 @@ int main(int argc, char * argv[])
   // Create a tweak bar
   // Create a tweak bar
   rebar.TwNewBar("bar");
   rebar.TwNewBar("bar");
   TwDefine("bar label='camera' size='200 550' text=light alpha='200' color='68 68 68'");
   TwDefine("bar label='camera' size='200 550' text=light alpha='200' color='68 68 68'");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType","igl_trackball,two_axis_fixed_up");
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
+      "RotationType","igl_trackball,two_axis_fixed_up");
   rebar.TwAddVarRW("rotation_type", RotationTypeTW,&rotation_type,
   rebar.TwAddVarRW("rotation_type", RotationTypeTW,&rotation_type,
     "keyIncr=] keyDecr=[");
     "keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = ReTwDefineEnumFromString("CenterType","orbit,fps");
+  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
+      "CenterType","orbit,fps");
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
     "keyIncr={ keyDecr=}");
     "keyIncr={ keyDecr=}");
   rebar.TwAddVarRW("rotation", TW_TYPE_QUAT4D,s.cameras[0].m_rotation_conj.coeffs().data(),"");
   rebar.TwAddVarRW("rotation", TW_TYPE_QUAT4D,s.cameras[0].m_rotation_conj.coeffs().data(),"");

+ 3 - 3
examples/colored-mesh/example.cpp

@@ -21,7 +21,7 @@
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
 #include <igl/barycenter.h>
 #include <igl/barycenter.h>
 #include <igl/matlab_format.h>
 #include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/pathinfo.h>
 #include <igl/pathinfo.h>
 #include <igl/Camera.h>
 #include <igl/Camera.h>
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
@@ -129,7 +129,7 @@ double bbd;
 Eigen::VectorXd S;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 
 
 void reshape(int width,int height)
 void reshape(int width,int height)
 {
 {
@@ -567,7 +567,7 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   s.camera.push_away(3);
   s.camera.dolly_zoom(25-s.camera.m_angle);
   s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 19 - 19
examples/components/example.cpp

@@ -1,24 +1,24 @@
-#include <igl/read_triangle_mesh.h>
-#include <igl/init_render_to_texture.h>
-#include <igl/draw_floor.h>
-#include <igl/report_gl_error.h>
-#include <igl/per_face_normals.h>
-#include <igl/trackball.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/REDRUM.h>
+#include <igl/C_STR.h>
 #include <igl/Camera.h>
 #include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/REDRUM.h>
+#include <igl/components.h>
+#include <igl/create_shader_program.h>
+#include <igl/draw_floor.h>
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
-#include <igl/jet.h>
-#include <igl/rgb_to_hsv.h>
 #include <igl/hsv_to_rgb.h>
 #include <igl/hsv_to_rgb.h>
+#include <igl/init_render_to_texture.h>
+#include <igl/jet.h>
+#include <igl/per_face_normals.h>
 #include <igl/randperm.h>
 #include <igl/randperm.h>
-#include <igl/boost/components.h>
-#include <igl/C_STR.h>
-#include <igl/write_triangle_mesh.h>
-#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/read_triangle_mesh.h>
+#include <igl/report_gl_error.h>
+#include <igl/rgb_to_hsv.h>
+#include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/create_shader_program.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/write_triangle_mesh.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -108,7 +108,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 // Forward
 // Forward
 void init_components();
 void init_components();
@@ -1050,11 +1050,11 @@ int main(int argc, char * argv[])
   TwDefine("bar label='Components' size='200 550' text=light alpha='200' color='68 68 68'");
   TwDefine("bar label='Components' size='200 550' text=light alpha='200' color='68 68 68'");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-axis-valuator-fixed-up");
     "igl_trackball,two-axis-valuator-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = ReTwDefineEnumFromString("CenterType","orbit,fps");
+  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
     "keyIncr={ keyDecr=}");
     "keyIncr={ keyDecr=}");
 
 

+ 11 - 11
examples/embree/example.cpp

@@ -1,14 +1,14 @@
-#include <igl/embree/EmbreeIntersector.h>
 #include <igl/OpenGL_convenience.h>
 #include <igl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
-#include <igl/unproject.h>
+#include <igl/draw_mesh.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/per_face_normals.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/trackball.h>
+#include <igl/read_triangle_mesh.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
+#include <igl/trackball.h>
+#include <igl/unproject.h>
+#include <igl/embree/EmbreeIntersector.h>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 #  include <GLUT/glut.h>
 #  include <GLUT/glut.h>
@@ -37,9 +37,9 @@ double bbd;
 // Faces
 // Faces
 Eigen::MatrixXi F;
 Eigen::MatrixXi F;
 // Embree intersection structure
 // Embree intersection structure
-igl::EmbreeIntersector ei;
+igl::embree::EmbreeIntersector ei;
 // Hits collected
 // Hits collected
-std::vector<igl::Hit > hits;
+std::vector<igl::embree::Hit > hits;
 // Ray information, "projection screen" corners
 // Ray information, "projection screen" corners
 Eigen::Vector3f win_s,s,d,dir,NW,NE,SE,SW;
 Eigen::Vector3f win_s,s,d,dir,NW,NE,SE,SW;
 // Textures and framebuffers for "projection screen"
 // Textures and framebuffers for "projection screen"
@@ -213,7 +213,7 @@ void display()
   // Draw all hits
   // Draw all hits
   glBegin(GL_POINTS);
   glBegin(GL_POINTS);
   glColor3f(0,0.2,0.2);
   glColor3f(0,0.2,0.2);
-  for(vector<igl::Hit>::iterator hit = hits.begin();
+  for(vector<igl::embree::Hit>::iterator hit = hits.begin();
       hit != hits.end();
       hit != hits.end();
       hit++)
       hit++)
   {
   {
@@ -327,7 +327,7 @@ void mouse_move(int mouse_x, int mouse_y)
   dir = d-s;
   dir = d-s;
   int num_rays_shot;
   int num_rays_shot;
   ei.intersectRay(s,dir,hits,num_rays_shot);
   ei.intersectRay(s,dir,hits,num_rays_shot);
-  for(vector<igl::Hit>::iterator hit = hits.begin();
+  for(vector<igl::embree::Hit>::iterator hit = hits.begin();
       hit != hits.end();
       hit != hits.end();
       hit++)
       hit++)
   {
   {

+ 0 - 30
examples/example_fun/Makefile

@@ -1,30 +0,0 @@
-.PHONY: all
-
-all: example_static example_header_only
-
-# Shared flags etc.
-include ../Makefile.conf
-
-CFLAGS+=-g
-INC=$(LIBIGL_INC)
-
-STATIC_LIB=-ligl -L../../lib -DIGL_STATIC_LIBRARY
-
-example_static: example_static.o
-	#g++ $(CFLAGS) -o example_static example_static.o $(lib) $(STATIC_LIB) ../../obj/example_fun.o
-	g++ $(CFLAGS) -o example_static example_static.o ../../obj/example_fun.o
-
-example_static.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example_static.o $(INC)
-
-example_header_only: example_header_only.o
-	g++ $(CFLAGS) -o example_header_only example_header_only.o $(lib)
-
-example_header_only.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example_header_only.o $(INC)
-
-clean:
-	rm -f example_static.o
-	rm -f example_static
-	rm -f example_header_only.o
-	rm -f example_header_only

+ 0 - 10
examples/example_fun/README

@@ -1,10 +0,0 @@
-This is a simple example program that shows how to link against the igl static
-library or use the igl library as a headers only library.
-
-
-To Build:
-  make
-
-To Run:
-  ./example_static
-  ./example_header_only

+ 0 - 16
examples/example_fun/example.cpp

@@ -1,16 +0,0 @@
-#include <igl/example_fun.h>
-using namespace igl;
-using namespace std;
-
-int main(int argc, char * argv[])
-{
-  double d = 4.4;
-  example_fun(d);
-  int i = 4;
-  example_fun(i);
-#ifndef IGL_STATIC_LIBRARY
-  const char * s = "string";
-  example_fun(s);
-#endif
-  return 0;
-}

+ 24 - 24
examples/flare-eyes/example.cpp

@@ -1,30 +1,30 @@
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
+#include <igl/Camera.h>
+#include <igl/PI.h>
+#include <igl/REDRUM.h>
+#include <igl/STR.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
+#include <igl/lens_flare.h>
 #include <igl/list_to_matrix.h>
 #include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
-#include <igl/trackball.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/PI.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/readMESH.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/readWRL.h>
 #include <igl/render_to_tga.h>
 #include <igl/render_to_tga.h>
-#include <igl/STR.h>
-#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/report_gl_error.h>
+#include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/lens_flare.h>
-#include <igl/get_seconds.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -96,7 +96,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 bool is_animating = false;
 bool is_animating = false;
 double animation_start_time = 0;
 double animation_start_time = 0;
@@ -695,7 +695,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(),"open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(),"open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-axis-valuator-fixed-up");
     "igl_trackball,two-axis-valuator-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 3 - 4
examples/get_seconds/example.cpp

@@ -1,12 +1,11 @@
-#include <cstdio>
-
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
-using namespace igl;
+#include <cstdio>
 #include <cmath>
 #include <cmath>
-using namespace std;
 
 
 int main(int argc, char * argv[])
 int main(int argc, char * argv[])
 {
 {
+  using namespace igl;
+  using namespace std;
   double start = get_seconds();
   double start = get_seconds();
   printf("start: %lgs\n",start);
   printf("start: %lgs\n",start);
   double lap = start;
   double lap = start;

+ 1 - 1
examples/intersections/Makefile

@@ -2,7 +2,7 @@
 
 
 # Shared flags etc.
 # Shared flags etc.
 include ../Makefile.conf
 include ../Makefile.conf
-LIBIGL_LIB=+liglcgal
+LIBIGL_LIB+=-liglcgal
 
 
 all: example
 all: example
 
 

+ 24 - 22
examples/intersections/example.cpp

@@ -1,31 +1,31 @@
+#include <igl/Camera.h>
 #include <igl/OpenGL_convenience.h>
 #include <igl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
+#include <igl/barycenter.h>
+#include <igl/cat.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
+#include <igl/jet.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
+#include <igl/matlab_format.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
 #include <igl/readDMAT.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
 #include <igl/readWRL.h>
 #include <igl/readWRL.h>
-#include <igl/trackball.h>
-#include <igl/list_to_matrix.h>
+#include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/material_colors.h>
-#include <igl/barycenter.h>
-#include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/pathinfo.h>
-#include <igl/Camera.h>
-#include <igl/cat.h>
-#include <igl/get_seconds.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/cgal/remesh_self_intersections.h>
 #include <igl/cgal/remesh_self_intersections.h>
 #include <igl/cgal/intersect_other.h>
 #include <igl/cgal/intersect_other.h>
 
 
@@ -138,7 +138,7 @@ double bbd;
 Eigen::VectorXd S;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 
 
 void reshape(int width,int height)
 void reshape(int width,int height)
 {
 {
@@ -477,6 +477,7 @@ void color_selfintersections(
   Eigen::MatrixXd & C)
   Eigen::MatrixXd & C)
 {
 {
   using namespace igl;
   using namespace igl;
+  using namespace igl::cgal;
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
   MatrixXd SV;
   MatrixXd SV;
@@ -506,6 +507,7 @@ void color_intersections(
   Eigen::MatrixXd & D)
   Eigen::MatrixXd & D)
 {
 {
   using namespace igl;
   using namespace igl;
+  using namespace igl::cgal;
   using namespace Eigen;
   using namespace Eigen;
   MatrixXi IF;
   MatrixXi IF;
   const bool first_only = false;
   const bool first_only = false;
@@ -663,7 +665,7 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   s.camera.push_away(3);
   s.camera.dolly_zoom(25-s.camera.m_angle);
   s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 1 - 1
examples/mode/example.cpp

@@ -1,7 +1,7 @@
 // g++ -o main main.cpp -I. -I/usr/local/include/eigen3
 // g++ -o main main.cpp -I. -I/usr/local/include/eigen3
+#include <igl/mode.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <iostream>
 #include <iostream>
-#include <igl/mode.h>
 
 
 using namespace std;
 using namespace std;
 using namespace igl;
 using namespace igl;

+ 12 - 12
examples/multi-viewport/example.cpp

@@ -1,21 +1,21 @@
+#include <igl/Camera.h>
+#include <igl/EPS.h>
 #include <igl/OpenGL_convenience.h>
 #include <igl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/normalize_row_lengths.h>
+#include <igl/STR.h>
+#include <igl/Viewport.h>
+#include <igl/canonical_quaternions.h>
+#include <igl/draw_beach_ball.h>
 #include <igl/draw_mesh.h>
 #include <igl/draw_mesh.h>
-#include <igl/unproject.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/per_face_normals.h>
+#include <igl/project.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/trackball.h>
+#include <igl/read_triangle_mesh.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/canonical_quaternions.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
+#include <igl/trackball.h>
+#include <igl/unproject.h>
 #include <igl/unproject_to_zero_plane.h>
 #include <igl/unproject_to_zero_plane.h>
-#include <igl/Camera.h>
-#include <igl/STR.h>
-#include <igl/draw_beach_ball.h>
-#include <igl/Viewport.h>
-#include <igl/project.h>
-#include <igl/EPS.h>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 #  include <OpenGL/gl.h>
 #  include <OpenGL/gl.h>

+ 32 - 32
examples/patches/example.cpp

@@ -1,37 +1,37 @@
-#include <igl/readOBJ.h>
-#include <igl/readPLY.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
-#include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
-#include <igl/material_colors.h>
-#include <igl/trackball.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/REDRUM.h>
+#include <igl/C_STR.h>
 #include <igl/Camera.h>
 #include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/REDRUM.h>
+#include <igl/bfs_orient.h>
+#include <igl/components.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/jet.h>
-#include <igl/randperm.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
 #include <igl/normalize_row_lengths.h>
 #include <igl/normalize_row_lengths.h>
-#include <igl/boost/components.h>
-#include <igl/boost/bfs_orient.h>
 #include <igl/orient_outward.h>
 #include <igl/orient_outward.h>
-#include <igl/embree/reorient_facets_raycast.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/randperm.h>
+#include <igl/readMESH.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/readPLY.h>
+#include <igl/readWRL.h>
+#include <igl/report_gl_error.h>
+#include <igl/snap_to_canonical_view_quat.h>
+#include <igl/snap_to_fixed_up.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/unique_simplices.h>
 #include <igl/unique_simplices.h>
-#include <igl/C_STR.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
 #include <igl/write_triangle_mesh.h>
 #include <igl/write_triangle_mesh.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/snap_to_fixed_up.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
+#include <igl/embree/reorient_facets_raycast.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -121,7 +121,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 // Forward
 // Forward
 void init_patches();
 void init_patches();
@@ -578,7 +578,7 @@ void init_patches()
     case ORIENT_METHOD_AO:
     case ORIENT_METHOD_AO:
     {
     {
       cout<<"orient_outward_ao()"<<endl;
       cout<<"orient_outward_ao()"<<endl;
-      reorient_facets_raycast(V,F,F,I);
+      igl::embree::reorient_facets_raycast(V,F,F,I);
       break;
       break;
     }
     }
     case ORIENT_METHOD_OUTWARD:
     case ORIENT_METHOD_OUTWARD:
@@ -807,14 +807,14 @@ int main(int argc, char * argv[])
   TwDefine("bar label='Patches' size='200 550' text=light alpha='200' color='68 68 68'");
   TwDefine("bar label='Patches' size='200 550' text=light alpha='200' color='68 68 68'");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-axis-valuator-fixed-up");
     "igl_trackball,two-axis-valuator-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = ReTwDefineEnumFromString("CenterType","orbit,fps");
+  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
     "keyIncr={ keyDecr=}");
     "keyIncr={ keyDecr=}");
-  TwType OrientMethodTW = ReTwDefineEnumFromString("OrientMethod",
+  TwType OrientMethodTW = igl::anttweakbar::ReTwDefineEnumFromString("OrientMethod",
     "outward,ambient-occlusion");
     "outward,ambient-occlusion");
   rebar.TwAddVarCB( "orient_method", OrientMethodTW,
   rebar.TwAddVarCB( "orient_method", OrientMethodTW,
     set_orient_method,get_orient_method,NULL,"keyIncr=< keyDecr=>");
     set_orient_method,get_orient_method,NULL,"keyIncr=< keyDecr=>");

+ 21 - 21
examples/randomly-sample-mesh/example.cpp

@@ -1,27 +1,27 @@
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
+#include <igl/Camera.h>
+#include <igl/REDRUM.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
 #include <igl/list_to_matrix.h>
 #include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
-#include <igl/trackball.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/random_points_on_mesh.h>
+#include <igl/readMESH.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/readWRL.h>
+#include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/get_seconds.h>
-#include <igl/random_points_on_mesh.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -88,7 +88,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -589,7 +589,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 2 - 2
examples/render_to_png/example.cpp

@@ -1,6 +1,6 @@
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
-#include <igl/png/render_to_png.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
+#include <igl/png/render_to_png.h>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 #   include <GLUT/glut.h>
 #   include <GLUT/glut.h>
@@ -94,7 +94,7 @@ void Display(void)
   {
   {
     stringstream padnum; 
     stringstream padnum; 
     padnum << "render_to_png-example-" << setw(4) << setfill('0') << capture_count++ << ".png";
     padnum << "render_to_png-example-" << setw(4) << setfill('0') << capture_count++ << ".png";
-    render_to_png(padnum.str(),width,height);
+    igl::png::render_to_png(padnum.str(),width,height);
     capture_on_next = false;
     capture_on_next = false;
   }
   }
   
   

+ 20 - 20
examples/rotate-widget/example.cpp

@@ -1,28 +1,28 @@
+#include <igl/Camera.h>
+#include <igl/REDRUM.h>
 #include <igl/RotateWidget.h>
 #include <igl/RotateWidget.h>
-#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/readMESH.h>
 #include <igl/readOBJ.h>
 #include <igl/readOBJ.h>
+#include <igl/readOFF.h>
 #include <igl/readTGF.h>
 #include <igl/readTGF.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
 #include <igl/readWRL.h>
 #include <igl/readWRL.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
-#include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
-#include <igl/material_colors.h>
-#include <igl/trackball.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/get_seconds.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -94,7 +94,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -616,7 +616,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

+ 21 - 21
examples/scene-rotation/example.cpp

@@ -3,29 +3,29 @@
 
 
 #include "trackball.h"
 #include "trackball.h"
 
 
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
+#include <igl/Camera.h>
+#include <igl/REDRUM.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
 #include <igl/list_to_matrix.h>
 #include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
-#include <igl/trackball.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/readMESH.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/readWRL.h>
+#include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/get_seconds.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -101,7 +101,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -662,11 +662,11 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,bell_trackball,two-axis-valuator,two-a...-fixed-up");
     "igl_trackball,bell_trackball,two-axis-valuator,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = ReTwDefineEnumFromString("CenterType","orbit,fps");
+  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("CenterType","orbit,fps");
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
     "keyIncr={ keyDecr=}");
     "keyIncr={ keyDecr=}");
   rebar.load(REBAR_NAME);
   rebar.load(REBAR_NAME);

+ 22 - 25
examples/shadow-mapping/example.cpp

@@ -1,36 +1,33 @@
 // Small GLUT application to test shadow mapping for closed shapes
 // Small GLUT application to test shadow mapping for closed shapes
 //
 //
 
 
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/readWRL.h>
-#include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
-#include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
-#include <igl/material_colors.h>
-#include <igl/trackball.h>
-#include <igl/snap_to_canonical_view_quat.h>
+#include <igl/C_STR.h>
 #include <igl/REDRUM.h>
 #include <igl/REDRUM.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
 #include <igl/jet.h>
 #include <igl/jet.h>
-#include <igl/randperm.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
 #include <igl/normalize_row_lengths.h>
 #include <igl/normalize_row_lengths.h>
-#include <igl/boost/components.h>
-#include <igl/boost/bfs_orient.h>
 #include <igl/orient_outward.h>
 #include <igl/orient_outward.h>
-//#include <igl/embree/orient_outward_ao.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/randperm.h>
+#include <igl/readMESH.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
+#include <igl/readWRL.h>
+#include <igl/report_gl_error.h>
+#include <igl/snap_to_canonical_view_quat.h>
+#include <igl/trackball.h>
 #include <igl/unique_simplices.h>
 #include <igl/unique_simplices.h>
-#include <igl/C_STR.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
 #include <igl/write_triangle_mesh.h>
 #include <igl/write_triangle_mesh.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -203,7 +200,7 @@ bool is_view_from_light = false;
 Eigen::Vector4f light_pos(9,9,1,1);
 Eigen::Vector4f light_pos(9,9,1,1);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 // Forward
 // Forward
 void init_mesh();
 void init_mesh();
@@ -840,7 +837,7 @@ int main(int argc, char * argv[])
   TwDefine("bar label='Shadow Mapping' size='200 550' text=light alpha='200' color='68 68 68'");
   TwDefine("bar label='Shadow Mapping' size='200 550' text=light alpha='200' color='68 68 68'");
   rebar.TwAddVarRW("camera_zoom", TW_TYPE_DOUBLE,&s.camera.zoom,"");
   rebar.TwAddVarRW("camera_zoom", TW_TYPE_DOUBLE,&s.camera.zoom,"");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,s.camera.rotation.coeffs().data(),"");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,s.camera.rotation.coeffs().data(),"");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType","igl_trackball,two_axis_fixed_up");
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType","igl_trackball,two_axis_fixed_up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW( "is_view_from_light",TW_TYPE_BOOLCPP,&is_view_from_light,
   rebar.TwAddVarRW( "is_view_from_light",TW_TYPE_BOOLCPP,&is_view_from_light,

+ 41 - 41
examples/skeleton-builder/example.cpp

@@ -1,46 +1,46 @@
-#include <igl/draw_skeleton_vector_graphics.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/readTGF.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
-#include <igl/report_gl_error.h>
-#include <igl/draw_mesh.h>
+#include <igl/Camera.h>
+#include <igl/REDRUM.h>
+#include <igl/REDRUM.h>
+#include <igl/adjacency_list.h>
+#include <igl/adjacency_matrix.h>
+#include <igl/boundary_conditions.h>
+#include <igl/centroid.h>
+#include <igl/colon.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/draw_skeleton_3d.h>
+#include <igl/draw_skeleton_vector_graphics.h>
+#include <igl/file_exists.h>
+#include <igl/forward_kinematics.h>
+#include <igl/get_seconds.h>
+#include <igl/lbs_matrix.h>
 #include <igl/list_to_matrix.h>
 #include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
-#include <igl/trackball.h>
-#include <igl/snap_to_canonical_view_quat.h>
-#include <igl/snap_to_fixed_up.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/get_seconds.h>
-#include <igl/forward_kinematics.h>
-#include <igl/boundary_conditions.h>
+#include <igl/matlab_format.h>
 #include <igl/normalize_row_sums.h>
 #include <igl/normalize_row_sums.h>
-#include <igl/lbs_matrix.h>
-#include <igl/sort_triangles.h>
-#include <igl/slice.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
 #include <igl/project.h>
 #include <igl/project.h>
-#include <igl/unproject.h>
-#include <igl/embree/EmbreeIntersector.h>
-#include <igl/embree/unproject_in_mesh.h>
-#include <igl/matlab_format.h>
+#include <igl/quat_to_mat.h>
+#include <igl/readTGF.h>
+#include <igl/read_triangle_mesh.h>
 #include <igl/remove_unreferenced.h>
 #include <igl/remove_unreferenced.h>
-#include <igl/adjacency_list.h>
-#include <igl/adjacency_matrix.h>
+#include <igl/report_gl_error.h>
 #include <igl/right_axis.h>
 #include <igl/right_axis.h>
-#include <igl/colon.h>
+#include <igl/slice.h>
+#include <igl/snap_to_canonical_view_quat.h>
+#include <igl/snap_to_fixed_up.h>
+#include <igl/sort_triangles.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/unique.h>
 #include <igl/unique.h>
-#include <igl/REDRUM.h>
+#include <igl/unproject.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
 #include <igl/writeTGF.h>
 #include <igl/writeTGF.h>
-#include <igl/file_exists.h>
-#include <igl/centroid.h>
-#include <igl/draw_skeleton_3d.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
+#include <igl/embree/EmbreeIntersector.h>
+#include <igl/embree/unproject_in_mesh.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -127,8 +127,8 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
-igl::EmbreeIntersector ei;
+igl::anttweakbar::ReTwBar rebar;
+igl::embree::EmbreeIntersector ei;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -668,7 +668,7 @@ void mouse_drag(int mouse_x, int mouse_y)
       s.C.conservativeResize(s.C.rows()+2,3);
       s.C.conservativeResize(s.C.rows()+2,3);
       const int nc = s.C.rows();
       const int nc = s.C.rows();
       Vector3d obj;
       Vector3d obj;
-      int nhits = unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
+      int nhits = igl::embree::unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
       if(nhits == 0)
       if(nhits == 0)
       {
       {
         Vector3d pV_mid = project(Vcen);
         Vector3d pV_mid = project(Vcen);
@@ -688,7 +688,7 @@ void mouse_drag(int mouse_x, int mouse_y)
     }
     }
     double z = 0;
     double z = 0;
     Vector3d obj,win;
     Vector3d obj,win;
-    int nhits = unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
+    int nhits = igl::embree::unproject_in_mesh(mouse_x,height-mouse_y,ei,obj);
     project(obj,win);
     project(obj,win);
     z = win(2);
     z = win(2);
 
 
@@ -1016,7 +1016,7 @@ void key(unsigned char key, int mouse_x, int mouse_y)
       {
       {
         Vector3d P = project((Vector3d)s.C.row(c));
         Vector3d P = project((Vector3d)s.C.row(c));
         Vector3d obj;
         Vector3d obj;
-        int nhits = unproject_in_mesh(P(0),P(1),ei,obj);
+        int nhits = igl::embree::unproject_in_mesh(P(0),P(1),ei,obj);
         if(nhits > 0)
         if(nhits > 0)
         {
         {
           s.C.row(c) = obj;
           s.C.row(c) = obj;
@@ -1148,13 +1148,13 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   rebar.TwAddVarRW("alpha",TW_TYPE_DOUBLE,&alpha,
   rebar.TwAddVarRW("alpha",TW_TYPE_DOUBLE,&alpha,

+ 18 - 18
examples/skeleton-poser/example.cpp

@@ -1,15 +1,12 @@
 #include <igl/Camera.h>
 #include <igl/Camera.h>
 #include <igl/MouseController.h>
 #include <igl/MouseController.h>
 #include <igl/REDRUM.h>
 #include <igl/REDRUM.h>
-#include <igl/ReAntTweakBar.h>
 #include <igl/STR.h>
 #include <igl/STR.h>
 #include <igl/barycenter.h>
 #include <igl/barycenter.h>
-#include <igl/bbw/bbw.h>
 #include <igl/bone_parents.h>
 #include <igl/bone_parents.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_facets.h>
 #include <igl/boundary_facets.h>
 #include <igl/centroid.h>
 #include <igl/centroid.h>
-#include <igl/cgal/remesh_self_intersections.h>
 #include <igl/colon.h>
 #include <igl/colon.h>
 #include <igl/draw_beach_ball.h>
 #include <igl/draw_beach_ball.h>
 #include <igl/draw_floor.h>
 #include <igl/draw_floor.h>
@@ -20,6 +17,7 @@
 #include <igl/get_seconds.h>
 #include <igl/get_seconds.h>
 #include <igl/lbs_matrix.h>
 #include <igl/lbs_matrix.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
+#include <igl/next_filename.h>
 #include <igl/normalize_row_sums.h>
 #include <igl/normalize_row_sums.h>
 #include <igl/pathinfo.h>
 #include <igl/pathinfo.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_face_normals.h>
@@ -31,18 +29,20 @@
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/tetgen/mesh_with_skeleton.h>
-#include <igl/tetgen/tetrahedralize.h>
 #include <igl/trackball.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/volume.h>
 #include <igl/winding_number.h>
 #include <igl/winding_number.h>
 #include <igl/writeDMAT.h>
 #include <igl/writeDMAT.h>
-#include <igl/writeOBJ.h>
 #include <igl/writeMESH.h>
 #include <igl/writeMESH.h>
+#include <igl/writeOBJ.h>
 #include <igl/writeOFF.h>
 #include <igl/writeOFF.h>
 #include <igl/writeTGF.h>
 #include <igl/writeTGF.h>
-#include <igl/next_filename.h>
-#include <igl/volume.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
+#include <igl/bbw/bbw.h>
+#include <igl/cgal/remesh_self_intersections.h>
+#include <igl/tetgen/mesh_with_skeleton.h>
+#include <igl/tetgen/tetrahedralize.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -144,7 +144,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -770,7 +770,7 @@ bool clean(
 #ifdef VERBOSE
 #ifdef VERBOSE
     cout<<"remesh_self_intersections"<<endl;
     cout<<"remesh_self_intersections"<<endl;
 #endif
 #endif
-    remesh_self_intersections(V,F,{},CV,CF,_1,_2,IM);
+    igl::cgal::remesh_self_intersections(V,F,{},CV,CF,_1,_2,IM);
     for_each(CF.data(),CF.data()+CF.size(),[&IM](int & a){a=IM(a);});
     for_each(CF.data(),CF.data()+CF.size(),[&IM](int & a){a=IM(a);});
     MatrixXd oldCV = CV;
     MatrixXd oldCV = CV;
     MatrixXi oldCF = CF;
     MatrixXi oldCF = CF;
@@ -786,7 +786,7 @@ bool clean(
 #ifdef VERBOSE
 #ifdef VERBOSE
     cout<<"tetrahedralize"<<endl;
     cout<<"tetrahedralize"<<endl;
 #endif
 #endif
-    if(tetrahedralize(CV,CF,"cYpC",TV,TT,_1) != 0)
+    if(igl::tetgen::tetrahedralize(CV,CF,"cYpC",TV,TT,_1) != 0)
     {
     {
       cout<<REDRUM("CDT failed.")<<endl;
       cout<<REDRUM("CDT failed.")<<endl;
       return false;
       return false;
@@ -843,7 +843,7 @@ bool robust_weights(
 #ifdef VERBOSE
 #ifdef VERBOSE
     cout<<"mesh_with_skeleton"<<endl;
     cout<<"mesh_with_skeleton"<<endl;
 #endif
 #endif
-    if(!mesh_with_skeleton(CV,CF,C,{},BE,{},10,"pq1.5Y",TV,TT,_1))
+    if(!igl::tetgen::mesh_with_skeleton(CV,CF,C,{},BE,{},10,"pq1.5Y",TV,TT,_1))
     {
     {
       cout<<REDRUM("tetgen failed.")<<endl;
       cout<<REDRUM("tetgen failed.")<<endl;
       return false;
       return false;
@@ -879,17 +879,17 @@ bool robust_weights(
   }
   }
   // compute BBW
   // compute BBW
   // Default bbw data and flags
   // Default bbw data and flags
-  BBWData bbw_data;
+  igl::bbw::BBWData bbw_data;
   bbw_data.verbosity = 1;
   bbw_data.verbosity = 1;
 #ifdef IGL_NO_MOSEK
 #ifdef IGL_NO_MOSEK
-  bbw_data.qp_solver = QP_SOLVER_IGL_ACTIVE_SET;
+  bbw_data.qp_solver = igl::bbw::QP_SOLVER_IGL_ACTIVE_SET;
   bbw_data.active_set_params.max_iter = 4;
   bbw_data.active_set_params.max_iter = 4;
 #else
 #else
   bbw_data.mosek_data.douparam[MSK_DPAR_INTPNT_TOL_REL_GAP]=1e-14;
   bbw_data.mosek_data.douparam[MSK_DPAR_INTPNT_TOL_REL_GAP]=1e-14;
-  bbw_data.qp_solver = QP_SOLVER_MOSEK;
+  bbw_data.qp_solver = igl::bbw::QP_SOLVER_MOSEK;
 #endif
 #endif
   // Weights matrix
   // Weights matrix
-  if(!bbw(TV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(TV,TT,b,bc,bbw_data,W))
   {
   {
     return false;
     return false;
   }
   }
@@ -996,14 +996,14 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
   rebar.TwAddVarRW("centroid_is_visible", TW_TYPE_BOOLCPP,&centroid_is_visible,
   rebar.TwAddVarRW("centroid_is_visible", TW_TYPE_BOOLCPP,&centroid_is_visible,
     "keyIncr=C keyDecr=c label='centroid visible?'");
     "keyIncr=C keyDecr=c label='centroid visible?'");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   rebar.load(REBAR_NAME);
   rebar.load(REBAR_NAME);

+ 29 - 29
examples/skeleton/example.cpp

@@ -1,35 +1,35 @@
+#include <igl/Camera.h>
+#include <igl/REDRUM.h>
+#include <igl/boundary_conditions.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
 #include <igl/draw_skeleton_3d.h>
 #include <igl/draw_skeleton_3d.h>
 #include <igl/draw_skeleton_vector_graphics.h>
 #include <igl/draw_skeleton_vector_graphics.h>
-#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/forward_kinematics.h>
+#include <igl/get_seconds.h>
+#include <igl/lbs_matrix.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
+#include <igl/normalize_row_sums.h>
+#include <igl/pathinfo.h>
+#include <igl/per_face_normals.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
+#include <igl/quat_to_mat.h>
+#include <igl/readMESH.h>
 #include <igl/readOBJ.h>
 #include <igl/readOBJ.h>
+#include <igl/readOFF.h>
 #include <igl/readTGF.h>
 #include <igl/readTGF.h>
-#include <igl/writeOBJ.h>
-#include <igl/writeOFF.h>
 #include <igl/readWRL.h>
 #include <igl/readWRL.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/readOFF.h>
-#include <igl/readMESH.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
-#include <igl/pathinfo.h>
-#include <igl/list_to_matrix.h>
-#include <igl/quat_to_mat.h>
-#include <igl/per_face_normals.h>
-#include <igl/material_colors.h>
-#include <igl/trackball.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/REDRUM.h>
-#include <igl/Camera.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/get_seconds.h>
-#include <igl/forward_kinematics.h>
-#include <igl/tetgen/mesh_with_skeleton.h>
-#include <igl/boundary_conditions.h>
-#include <igl/normalize_row_sums.h>
-#include <igl/lbs_matrix.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/bbw/bbw.h>
 #include <igl/bbw/bbw.h>
+#include <igl/tetgen/mesh_with_skeleton.h>
 
 
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Geometry>
 #include <Eigen/Geometry>
@@ -106,7 +106,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 
 void push_undo()
 void push_undo()
 {
 {
@@ -556,7 +556,7 @@ bool init_weights(
   MatrixXd VV;
   MatrixXd VV;
   MatrixXi TT,FF,CE;
   MatrixXi TT,FF,CE;
   VectorXi P;
   VectorXi P;
-  if(!mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
+  if(!igl::tetgen::mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
   {
   {
     return false;
     return false;
   }
   }
@@ -571,10 +571,10 @@ bool init_weights(
 
 
   // compute BBW
   // compute BBW
   // Default bbw data and flags
   // Default bbw data and flags
-  BBWData bbw_data;
+  igl::bbw::BBWData bbw_data;
   bbw_data.active_set_params.max_iter = 4;
   bbw_data.active_set_params.max_iter = 4;
   // Weights matrix
   // Weights matrix
-  if(!bbw(VV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(VV,TT,b,bc,bbw_data,W))
   {
   {
     return false;
     return false;
   }
   }
@@ -691,13 +691,13 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"key=s");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"key=s");
   rebar.load(REBAR_NAME);
   rebar.load(REBAR_NAME);

+ 0 - 23
examples/svd/Makefile

@@ -1,23 +0,0 @@
-.PHONY: all
-
-# Shared flags etc.
-include ../Makefile.conf
-
-all: example
-
-.PHONY: example
-
-igl_lib=../../
-
-CFLAGS+=-g
-inc=$(LIBIGL_INC) 
-lib=$(LIBIGL_LIB) -framework Accelerate
-
-example: example.o
-	g++ $(CFLAGS) -o example example.o $(lib)
-
-example.o: example.cpp
-	g++ $(CFLAGS) -c example.cpp -o example.o $(inc)
-clean:
-	rm -f example.o
-	rm -f example

+ 0 - 97
examples/svd/example.cpp

@@ -1,97 +0,0 @@
-int main(){}
-//#include <igl/svd.h>
-//#include <cstdlib>
-//#include <Accelerate/Accelerate.h>
-//#include <cstdio>
-//
-///* Auxiliary routines prototypes */
-//extern void print_matrix( char* desc, int m, int n, double* a, int lda );
-//
-///* Parameters */
-//
-//void print3x3(const char * s, double * a)
-//{
-//  printf("%s =\n",s);
-//  for(int i = 0;i<3;i++)
-//  {
-//    for(int j = 0;j<3;j++)
-//    {
-//      printf("%g ",a[j*3+i]);
-//    }
-//    printf("\n");
-//  }
-//  printf("\n");
-//}
-//
-//int main(int argc, char * argv[])
-//{
-//  //// List of rest positions
-//  ////        (0,1)
-//  ////         / \
-//  ////        /   \
-//  ////       /     \
-//  ////      /       \
-//  ////  (-1,0)-----(1,0)
-//  ////
-//  //double rest[3][3] = {
-//  //  {-1,0,0},
-//  //  {1,0,0},
-//  //  {0,1,0}};
-//  //// List of pose positions
-//  //// 
-//  //// (0,1)
-//  ////  |   \
-//  ////  |    \
-//  ////  |     (1,0)
-//  ////  |    /
-//  ////  |   /
-//  //// (0,-1)
-//  //double pose[3][3] = {
-//  //  {0,1,0},
-//  //  {0,-1,0},
-//  //  {1,0,0}};
-//  //// Compute covariance matrix C
-//  //double C[3*3];
-//  //// Initialize to zero
-//  //for(int i = 0;i<3*3;i++)
-//  //{
-//  //  C[i] = 0;
-//  //}
-//
-//  //// Loop over vertices
-//  //for(int i = 0;i<3;i++)
-//  //{
-//  //  // Compute outer product rest[i] * pose[i]
-//  //  // Loop over coordinates
-//  //  for(int j = 0;j<3;j++)
-//  //  {
-//  //    // Loop over coordinates
-//  //    for(int k = 0;k<3;k++)
-//  //    {
-//  //      C[k*3+j] = rest[i][j] * pose[i][k];
-//  //    }
-//  //  }
-//  //}
-//  //print3x3("C",C);
-//
-//
-//  //
-//  //double C[3*3] = {8,3,4,1,5,9,6,7,2};
-//  double C[3*3] = {5242.55,3364,-0,-8170.15,-5242.56,0,-0,-0,0};
-//  double u[3*3],s[3],vt[3*3];
-//  print3x3("C",C);
-//  // Compute SVD of C
-//  igl::svd3x3(C,u,s,vt);
-//  print3x3("u",u);
-//  print3x3("vt",vt);
-//
-//  // Compute R = u*vt
-//  double R[3*3];
-//  const double _3 = 3;
-//  const double _1 = 1;
-//  cblas_dgemm(CblasColMajor, CblasNoTrans,CblasNoTrans,3,3,3,1,u,3,vt,3,1,R,3);
-//  print3x3("RT (transposed to be row-major)",R);
-//
-//
-//  return 0;
-//}

+ 23 - 23
examples/textured-mesh/example.cpp

@@ -1,34 +1,34 @@
+#include <igl/Camera.h>
 #include <igl/OpenGL_convenience.h>
 #include <igl/OpenGL_convenience.h>
+#include <igl/STR.h>
+#include <igl/barycenter.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.h>
+#include <igl/jet.h>
+#include <igl/list_to_matrix.h>
+#include <igl/material_colors.h>
+#include <igl/matlab_format.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/pathinfo.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_face_normals.h>
 #include <igl/per_vertex_normals.h>
 #include <igl/per_vertex_normals.h>
-#include <igl/two_axis_valuator_fixed_up.h>
-#include <igl/normalize_row_lengths.h>
-#include <igl/draw_mesh.h>
-#include <igl/draw_floor.h>
+#include <igl/polygon_mesh_to_triangle_mesh.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/report_gl_error.h>
-#include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.h>
 #include <igl/readWRL.h>
 #include <igl/readWRL.h>
-#include <igl/trackball.h>
-#include <igl/list_to_matrix.h>
+#include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_canonical_view_quat.h>
 #include <igl/snap_to_fixed_up.h>
 #include <igl/snap_to_fixed_up.h>
-#include <igl/polygon_mesh_to_triangle_mesh.h>
-#include <igl/material_colors.h>
-#include <igl/barycenter.h>
-#include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/pathinfo.h>
-#include <igl/Camera.h>
-#include <igl/get_seconds.h>
 #include <igl/texture_from_tga.h>
 #include <igl/texture_from_tga.h>
+#include <igl/trackball.h>
+#include <igl/two_axis_valuator_fixed_up.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/png/texture_from_file.h>
 #include <igl/png/texture_from_file.h>
-#include <igl/png/texture_from_png.h>
-#include <igl/STR.h>
+
 #include <YImage.hpp>
 #include <YImage.hpp>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
@@ -135,7 +135,7 @@ double bbd;
 Eigen::VectorXd S;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 int tot_num_samples = 0;
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 bool flip_y = false;
 bool flip_y = false;
 bool rotate_xy = false;
 bool rotate_xy = false;
 
 
@@ -581,7 +581,7 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   s.camera.push_away(3);
   s.camera.dolly_zoom(25-s.camera.m_angle);
   s.camera.dolly_zoom(25-s.camera.m_angle);
-  TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
+  TwType RotationTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("RotationType",
     "igl_trackball,two-a...-fixed-up");
     "igl_trackball,two-a...-fixed-up");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
@@ -615,7 +615,7 @@ int main(int argc, char * argv[])
 
 
 
 
   // Must be called after opengl context is initialized
   // Must be called after opengl context is initialized
-  if(!texture_from_file(tfilename,tex_id))
+  if(!igl::png::texture_from_file(tfilename,tex_id))
   {
   {
     return 1;
     return 1;
   }
   }

+ 12 - 13
examples/transparency/example.cpp

@@ -1,23 +1,22 @@
+#include <igl/EPS.h>
 #include <igl/OpenGL_convenience.h>
 #include <igl/OpenGL_convenience.h>
-#include <igl/per_face_normals.h>
-#include <igl/read_triangle_mesh.h>
-#include <igl/normalize_row_lengths.h>
+#include <igl/colon.h>
+#include <igl/draw_floor.h>
 #include <igl/draw_mesh.h>
 #include <igl/draw_mesh.h>
 #include <igl/jet.h>
 #include <igl/jet.h>
 #include <igl/material_colors.h>
 #include <igl/material_colors.h>
-#include <igl/draw_floor.h>
-#include <igl/unproject.h>
+#include <igl/matlab_format.h>
+#include <igl/normalize_row_lengths.h>
+#include <igl/per_face_normals.h>
 #include <igl/quat_to_mat.h>
 #include <igl/quat_to_mat.h>
-#include <igl/trackball.h>
+#include <igl/read_triangle_mesh.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/matlab_format.h>
-#include <igl/colon.h>
-#include <igl/slice.h>
 #include <igl/report_gl_error.h>
 #include <igl/report_gl_error.h>
-#include <igl/ReAntTweakBar.h>
-#include <igl/EPS.h>
-#define IGL_HEADER_ONLY
+#include <igl/slice.h>
 #include <igl/sort_triangles.h>
 #include <igl/sort_triangles.h>
+#include <igl/trackball.h>
+#include <igl/unproject.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 
 #ifdef __APPLE__
 #ifdef __APPLE__
 #  include <GLUT/glut.h>
 #  include <GLUT/glut.h>
@@ -50,7 +49,7 @@ Eigen::MatrixXi F,sorted_F;
 double alpha = 0.2;
 double alpha = 0.2;
 
 
 #define REBAR_NAME "temp.rbr"
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar; // Pointer to the tweak bar
+igl::anttweakbar::ReTwBar rebar; // Pointer to the tweak bar
 
 
 void reshape(int width,int height)
 void reshape(int width,int height)
 {
 {

+ 2 - 2
google-soc/index.html

@@ -18,7 +18,7 @@
 
 
 <figure>
 <figure>
 <img src="./libigl-logo-python-matlab.jpg" alt="" />
 <img src="./libigl-logo-python-matlab.jpg" alt="" />
-<figcaption></figcaption></figure>
+</figure>
 
 
 <p>Libigl is a C++ library, but its functional interface make it very friendly to
 <p>Libigl is a C++ library, but its functional interface make it very friendly to
 wrapping individual functions for popular scripting languages like Python or
 wrapping individual functions for popular scripting languages like Python or
@@ -39,7 +39,7 @@ variety of functions in the library.</p>
 
 
 <figure>
 <figure>
 <img src="./collapse-split-flip.jpg" alt="" />
 <img src="./collapse-split-flip.jpg" alt="" />
-<figcaption></figcaption></figure>
+</figure>
 
 
 <p>Libigl avoids complicated mesh data-structures to ensure that its interface is
 <p>Libigl avoids complicated mesh data-structures to ensure that its interface is
 clean and easy to port into users&#8217; existing projects. Our mesh format is a
 clean and easy to port into users&#8217; existing projects. Our mesh format is a

+ 4 - 7
include/igl/AABB.h

@@ -259,14 +259,13 @@ private:
         int & i,
         int & i,
         RowVectorDIMS & c) const;
         RowVectorDIMS & c) const;
 public:
 public:
-      template <int SS>
       static
       static
       inline void barycentric_coordinates(
       inline void barycentric_coordinates(
         const RowVectorDIMS & p, 
         const RowVectorDIMS & p, 
         const RowVectorDIMS & a, 
         const RowVectorDIMS & a, 
         const RowVectorDIMS & b, 
         const RowVectorDIMS & b, 
         const RowVectorDIMS & c,
         const RowVectorDIMS & c,
-        Eigen::Matrix<Scalar,1,SS> & bary);
+        Eigen::Matrix<Scalar,1,3> & bary);
 public:
 public:
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
       EIGEN_MAKE_ALIGNED_OPERATOR_NEW
     };
     };
@@ -858,7 +857,7 @@ inline typename igl::AABB<DerivedV,DIM>::Scalar igl::AABB<DerivedV,DIM>::squared
   //other->m_max_sqr_d = std::max(other->m_left->m_max_sqr_d,other->m_right->m_max_sqr_d);
   //other->m_max_sqr_d = std::max(other->m_left->m_max_sqr_d,other->m_right->m_max_sqr_d);
 
 
   return 0;
   return 0;
-#if false
+#if 0 // False
 
 
   // _Very_ conservative approximation of maximum squared distance between
   // _Very_ conservative approximation of maximum squared distance between
   // primitives inside this and other's bounding boxes
   // primitives inside this and other's bounding boxes
@@ -1114,16 +1113,14 @@ inline void igl::AABB<DerivedV,DIM>::set_min(
 
 
 
 
 template <typename DerivedV, int DIM>
 template <typename DerivedV, int DIM>
-template <int SS>
 inline void
 inline void
 igl::AABB<DerivedV,DIM>::barycentric_coordinates(
 igl::AABB<DerivedV,DIM>::barycentric_coordinates(
   const RowVectorDIMS & p, 
   const RowVectorDIMS & p, 
   const RowVectorDIMS & a, 
   const RowVectorDIMS & a, 
   const RowVectorDIMS & b, 
   const RowVectorDIMS & b, 
   const RowVectorDIMS & c,
   const RowVectorDIMS & c,
-  Eigen::Matrix<Scalar,1,SS> & bary)
+  Eigen::Matrix<Scalar,1,3> & bary)
 {
 {
-  assert(SS==3);
   // http://gamedev.stackexchange.com/a/23745
   // http://gamedev.stackexchange.com/a/23745
   const RowVectorDIMS v0 = b - a;
   const RowVectorDIMS v0 = b - a;
   const RowVectorDIMS v1 = c - a;
   const RowVectorDIMS v1 = c - a;
@@ -1137,6 +1134,6 @@ igl::AABB<DerivedV,DIM>::barycentric_coordinates(
   bary(1) = (d11 * d20 - d01 * d21) / denom;
   bary(1) = (d11 * d20 - d01 * d21) / denom;
   bary(2) = (d00 * d21 - d01 * d20) / denom;
   bary(2) = (d00 * d21 - d01 * d20) / denom;
   bary(0) = 1.0f - bary(1) - bary(2);
   bary(0) = 1.0f - bary(1) - bary(2);
-};
+}
 
 
 #endif
 #endif

+ 372 - 0
include/igl/ConjugateFFSolverData.h

@@ -0,0 +1,372 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2013 Olga Diamanti, 2015 Alec Jacobson
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_CONJUGATE_FF_SOLVER_DATA_H
+#define IGL_CONJUGATE_FF_SOLVER_DATA_H
+#include "igl_inline.h"
+#include <Eigen/Core>
+#include <Eigen/Sparse>
+
+namespace igl {
+  template <typename DerivedV, typename DerivedF>
+  class ConjugateFFSolverData
+  {
+    public:
+      const Eigen::PlainObjectBase<DerivedV> &V; int numV;
+      const Eigen::PlainObjectBase<DerivedF> &F; int numF;
+
+      Eigen::MatrixXi EV; int numE;
+      Eigen::MatrixXi F2E;
+      Eigen::MatrixXi E2F;
+      Eigen::VectorXd K;
+
+      Eigen::VectorXi isBorderEdge;
+      int numInteriorEdges;
+      Eigen::Matrix<int,Eigen::Dynamic,2> E2F_int;
+      Eigen::VectorXi indInteriorToFull;
+      Eigen::VectorXi indFullToInterior;
+
+      Eigen::PlainObjectBase<DerivedV> B1, B2, FN;
+
+
+      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,1> kmin, kmax;
+      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,2> dmin, dmax;
+      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,3> dmin3, dmax3;
+
+      Eigen::VectorXd nonPlanarityMeasure;
+      Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > planarityWeight;
+
+      //conjugacy matrix
+      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,4> > H;
+
+      //conjugacy matrix eigenvectors and (scaled) eigenvalues
+      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,4> > UH;
+      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,1> > s;
+
+      //laplacians
+      Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar>> DDA, DDB;
+
+  private:
+    IGL_INLINE void computeCurvatureAndPrincipals();
+    IGL_INLINE void precomputeConjugacyStuff();
+    IGL_INLINE void computeLaplacians();
+    IGL_INLINE void computek();
+    IGL_INLINE void computeCoefficientLaplacian(int n, Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &D);
+
+    IGL_INLINE void precomputeInteriorEdges();
+
+public:
+    IGL_INLINE ConjugateFFSolverData(const Eigen::PlainObjectBase<DerivedV> &_V,
+                                   const Eigen::PlainObjectBase<DerivedF> &_F);
+    IGL_INLINE void evaluateConjugacy(const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvU,
+                                      const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvV,
+                                      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> &conjValues) const ;
+  };
+}
+
+#include <igl/colon.h>
+#include <igl/edge_topology.h>
+#include <igl/false_barycentric_subdivision.h>
+#include <igl/local_basis.h>
+#include <igl/principal_curvature.h>
+#include <igl/sparse.h>
+
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE igl::ConjugateFFSolverData<DerivedV, DerivedF>::
+ConjugateFFSolverData(const Eigen::PlainObjectBase<DerivedV> &_V,
+                  const Eigen::PlainObjectBase<DerivedF> &_F):
+V(_V),
+numV(_V.rows()),
+F(_F),
+numF(_F.rows())
+{
+  igl::edge_topology(V,F,EV,F2E,E2F);
+  numE = EV.rows();
+
+  precomputeInteriorEdges();
+
+  igl::local_basis(V,F,B1,B2,FN);
+
+  computek();
+
+  computeLaplacians();
+
+  computeCurvatureAndPrincipals();
+  precomputeConjugacyStuff();
+
+};
+
+
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::computeCurvatureAndPrincipals()
+{
+  Eigen::MatrixXd VCBary;
+  Eigen::MatrixXi FCBary;
+
+  VCBary.setZero(numV+numF,3);
+  FCBary.setZero(3*numF,3);
+  igl::false_barycentric_subdivision(V, F, VCBary, FCBary);
+
+  Eigen::MatrixXd dmax3_,dmin3_;
+  igl::principal_curvature(VCBary, FCBary, dmax3_, dmin3_, kmax, kmin, 5,true);
+
+  dmax3 = dmax3_.bottomRows(numF);
+  dmin3 = dmin3_.bottomRows(numF);
+
+  kmax = kmax.bottomRows(numF);
+  kmin = kmin.bottomRows(numF);
+
+  //  kmax = dmax3.rowwise().norm();
+  //  kmin = dmin3.rowwise().norm();
+
+  dmin3.rowwise().normalize();
+  dmax3.rowwise().normalize();
+  dmax.setZero(numF,2);
+  dmin.setZero(numF,2);
+  for (int i= 0; i <numF; ++i)
+  {
+    if(kmin[i] != kmin[i] || kmax[i] != kmax[i] || (dmin3.row(i).array() != dmin3.row(i).array()).any() || (dmax3.row(i).array() != dmax3.row(i).array()).any())
+    {
+      kmin[i] = 0;
+      kmax[i] = 0;
+      dmin3.row(i) = B1.row(i);
+      dmax3.row(i) = B2.row(i);
+    }
+    else
+    {
+      dmax3.row(i) = (dmax3.row(i) - (dmax3.row(i).dot(FN.row(i)))*FN.row(i)).normalized();
+      dmin3.row(i) = dmin3.row(i) - (dmin3.row(i).dot(FN.row(i)))*FN.row(i);
+      dmin3.row(i) = (dmin3.row(i) - (dmin3.row(i).dot(dmax3.row(i)))*dmax3.row(i)).normalized();
+      if ((dmin3.row(i).cross(dmax3.row(i))).dot(FN.row(i))<0)
+        dmin3.row(i) = -dmin3.row(i);
+    }
+    dmax.row(i) << dmax3.row(i).dot(B1.row(i)), dmax3.row(i).dot(B2.row(i));
+    dmax.row(i).normalize();
+    dmin.row(i) << dmin3.row(i).dot(B1.row(i)), dmin3.row(i).dot(B2.row(i));
+    dmin.row(i).normalize();
+
+  }
+
+  nonPlanarityMeasure = kmax.cwiseAbs().array()*kmin.cwiseAbs().array();
+  typename DerivedV::Scalar minP = nonPlanarityMeasure.minCoeff();
+  typename DerivedV::Scalar maxP = nonPlanarityMeasure.maxCoeff();
+  nonPlanarityMeasure = (nonPlanarityMeasure.array()-minP)/(maxP-minP);
+  Eigen::VectorXi I = igl::colon<typename DerivedF::Scalar>(0, numF-1);
+  igl::sparse(I, I, nonPlanarityMeasure, numF, numF, planarityWeight);
+
+}
+
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::precomputeConjugacyStuff()
+{
+  H.resize(numF);
+  UH.resize(numF);
+  s.resize(numF);
+
+  for (int i = 0; i<numF; ++i)
+  {
+    //compute conjugacy matrix
+    typename DerivedV::Scalar e1x = dmin(i,0), e1y = dmin(i,1), e2x = dmax(i,0), e2y = dmax(i,1), k1 = kmin[i], k2 = kmax[i];
+
+    H[i]<<
+    0,          0, k1*e1x*e1x, k1*e1x*e1y,
+    0,          0, k1*e1x*e1y, k1*e1y*e1y,
+    k2*e2x*e2x, k2*e2x*e2y,          0,          0,
+    k2*e2x*e2y, k2*e2y*e2y,          0,          0;
+    Eigen::Matrix<typename DerivedV::Scalar, 4, 4> Ht = H[i].transpose();
+    H[i] = .5*(H[i]+Ht);
+
+    Eigen::EigenSolver<Eigen::Matrix<typename DerivedV::Scalar, 4, 4> > es(H[i]);
+    s[i] = es.eigenvalues().real();//ok to do this because H symmetric
+    //scale
+    s[i] = s[i]/(s[i].cwiseAbs().minCoeff());
+    UH[i] = es.eigenvectors().real();
+
+
+  }
+}
+
+
+template <typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::computeLaplacians()
+{
+  computeCoefficientLaplacian(2, DDA);
+
+  computeCoefficientLaplacian(4, DDB);
+}
+
+template<typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
+precomputeInteriorEdges()
+{
+  // Flag border edges
+  numInteriorEdges = 0;
+  isBorderEdge.setZero(numE,1);
+  indFullToInterior = -1*Eigen::VectorXi::Ones(numE,1);
+
+  for(unsigned i=0; i<numE; ++i)
+  {
+    if ((E2F(i,0) == -1) || ((E2F(i,1) == -1)))
+      isBorderEdge[i] = 1;
+    else
+    {
+      indFullToInterior[i] = numInteriorEdges;
+      numInteriorEdges++;
+    }
+  }
+
+  E2F_int.resize(numInteriorEdges, 2);
+  indInteriorToFull.setZero(numInteriorEdges,1);
+  int ii = 0;
+  for (int k=0; k<numE; ++k)
+  {
+    if (isBorderEdge[k])
+      continue;
+    E2F_int.row(ii) = E2F.row(k);
+    indInteriorToFull[ii] = k;
+    ii++;
+  }
+
+}
+
+
+
+template<typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
+computeCoefficientLaplacian(int n, Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &D)
+{
+  std::vector<Eigen::Triplet<std::complex<typename DerivedV::Scalar> >> tripletList;
+
+  // For every non-border edge
+  for (unsigned eid=0; eid<numE; ++eid)
+  {
+    if (!isBorderEdge[eid])
+    {
+      int fid0 = E2F(eid,0);
+      int fid1 = E2F(eid,1);
+
+      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid0,
+                                                                                     fid0,
+                                                                                     std::complex<typename DerivedV::Scalar>(1.)));
+      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid1,
+                                                                                     fid1,
+                                                                                     std::complex<typename DerivedV::Scalar>(1.)));
+      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid0,
+                                                                                     fid1,
+                                                                                     -1.*std::polar(1.,-1.*n*K[eid])));
+      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid1,
+                                                                                     fid0,
+                                                                                     -1.*std::polar(1.,1.*n*K[eid])));
+
+    }
+  }
+  D.resize(numF,numF);
+  D.setFromTriplets(tripletList.begin(), tripletList.end());
+
+
+}
+
+template<typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
+computek()
+{
+  K.setZero(numE);
+  // For every non-border edge
+  for (unsigned eid=0; eid<numE; ++eid)
+  {
+    if (!isBorderEdge[eid])
+    {
+      int fid0 = E2F(eid,0);
+      int fid1 = E2F(eid,1);
+
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> N0 = FN.row(fid0);
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> N1 = FN.row(fid1);
+
+      // find common edge on triangle 0 and 1
+      int fid0_vc = -1;
+      int fid1_vc = -1;
+      for (unsigned i=0;i<3;++i)
+      {
+        if (F2E(fid0,i) == eid)
+          fid0_vc = i;
+        if (F2E(fid1,i) == eid)
+          fid1_vc = i;
+      }
+      assert(fid0_vc != -1);
+      assert(fid1_vc != -1);
+
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> common_edge = V.row(F(fid0,(fid0_vc+1)%3)) - V.row(F(fid0,fid0_vc));
+      common_edge.normalize();
+
+      // Map the two triangles in a new space where the common edge is the x axis and the N0 the z axis
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> P;
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> o = V.row(F(fid0,fid0_vc));
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> tmp = -N0.cross(common_edge);
+      P << common_edge, tmp, N0;
+      //      P.transposeInPlace();
+
+
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> V0;
+      V0.row(0) = V.row(F(fid0,0)) -o;
+      V0.row(1) = V.row(F(fid0,1)) -o;
+      V0.row(2) = V.row(F(fid0,2)) -o;
+
+      V0 = (P*V0.transpose()).transpose();
+
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> V1;
+      V1.row(0) = V.row(F(fid1,0)) -o;
+      V1.row(1) = V.row(F(fid1,1)) -o;
+      V1.row(2) = V.row(F(fid1,2)) -o;
+      V1 = (P*V1.transpose()).transpose();
+
+      // compute rotation R such that R * N1 = N0
+      // i.e. map both triangles to the same plane
+      double alpha = -atan2(V1((fid1_vc+2)%3,2),V1((fid1_vc+2)%3,1));
+
+      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> R;
+      R << 1,          0,            0,
+      0, cos(alpha), -sin(alpha) ,
+      0, sin(alpha),  cos(alpha);
+      V1 = (R*V1.transpose()).transpose();
+
+      // measure the angle between the reference frames
+      // k_ij is the angle between the triangle on the left and the one on the right
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> ref0 = V0.row(1) - V0.row(0);
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> ref1 = V1.row(1) - V1.row(0);
+
+      ref0.normalize();
+      ref1.normalize();
+
+      double ktemp = atan2(ref1(1),ref1(0)) - atan2(ref0(1),ref0(0));
+
+      // just to be sure, rotate ref0 using angle ktemp...
+      Eigen::Matrix<typename DerivedV::Scalar, 2, 2> R2;
+      R2 << cos(ktemp), -sin(ktemp), sin(ktemp), cos(ktemp);
+
+      Eigen::Matrix<typename DerivedV::Scalar, 1, 2> tmp1 = R2*(ref0.head(2)).transpose();
+
+      K[eid] = ktemp;
+    }
+  }
+
+}
+
+template<typename DerivedV, typename DerivedF>
+IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
+evaluateConjugacy(const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvU,
+                   const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvV,
+                  Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> &conjValues) const 
+{
+  conjValues.resize(numF,1);
+  for (int j =0; j<numF; ++j)
+  {
+    Eigen::Matrix<typename DerivedV::Scalar, 4, 1> x; x<<pvU.row(j).transpose(), pvV.row(j).transpose();
+    conjValues[j] = x.transpose()*H[j]*x;
+  }
+}
+
+#endif

+ 0 - 285
include/igl/ReAntTweakBar.h

@@ -1,285 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_REANTTWEAKBAR_H
-#define IGL_REANTTWEAKBAR_H
-#ifndef IGL_NO_ANTTWEAKBAR
-#include "igl_inline.h"
-// ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
-// "bars" to be saved and load from disk. Changing your existing app that uses
-// AntTweakBar to use ReAntTweakBar is trivial.
-// 
-// Many (but not all) variable types are supported. I'll try to keep track them
-// here:
-//   TW_TYPE_BOOLCPP
-//   TW_TYPE_QUAT4F
-//   TW_TYPE_QUAT4D
-//   TW_TYPE_COLOR4F
-//   TW_TYPE_COLOR4D
-//   TW_TYPE_COLOR3F
-//   TW_TYPE_DIR3F
-//   TW_TYPE_DIR3D
-//   TW_TYPE_BOOL32
-//   TW_TYPE_INT32
-//   TW_TYPE_UINT32
-//   TW_TYPE_FLOAT
-//   TW_TYPE_DOUBLE
-//   TW_TYPE_UINT8
-//   and
-//   custom TwTypes made with TwDefineEnum
-// 
-// I'm working on adding the rest on an as-needed basis. Adding a new type only
-// requires changes in a few places...
-// 
-//
-//
-
-// This allows the user to have a non-global, static installation of
-// AntTweakBar
-#include <AntTweakBar.h>
-// Instead of including AntTweakBar.h, just define the necessary types
-// Types used:
-//   - TwType
-//   - TwEnumVal
-//   - TwSetVarCallback
-//   - TwGetVarCallback
-//   - TwBar
-//   - TwButtonCallback
-
-
-#include <vector>
-#include <string>
-
-#define REANTTWEAKBAR_MAX_CB_VAR_SIZE 1000
-// Max line size for reading files
-#define REANTTWEAKBAR_MAX_LINE 1000
-#define REANTTWEAKBAR_MAX_WORD 100
-
-namespace igl
-{
-  TwType ReTwDefineEnum(
-    const char *name, 
-    const TwEnumVal *enumValues, 
-    unsigned int nbValues);
-  TwType ReTwDefineEnumFromString(const char * name,const char * enumString);
-  
-  struct ReTwRWItem
-  {
-    //const char * name;
-    std::string name;
-    TwType type;
-    void * var;
-    // Default constructor
-    IGL_INLINE ReTwRWItem(
-      const std::string _name,
-      TwType _type, 
-      void *_var):
-      name(_name),
-      type(_type),
-      var(_var)
-    {
-    }
-    // Shallow copy constructor
-    // I solemnly swear it's OK to copy var this way
-    // Q: Is it really?
-    IGL_INLINE ReTwRWItem(const ReTwRWItem & that):
-      name(that.name),
-      type(that.type),
-      var(that.var)
-    {
-    }
-    // Shallow assignment 
-    // I solemnly swear it's OK to copy var this way
-    IGL_INLINE ReTwRWItem & operator=(const ReTwRWItem & that)
-    {
-      if(this != &that)
-      {
-        this->name = that.name;
-        this->type = that.type;
-        this->var = that.var;
-      }
-      return *this;
-    }
-  };
-  
-  struct ReTwCBItem
-  {
-    //const char * name;
-    std::string name;
-    TwType type;
-    TwSetVarCallback setCallback;
-    TwGetVarCallback getCallback;
-    void * clientData;
-    // Default constructor
-    IGL_INLINE ReTwCBItem(
-      const std::string _name,
-      TwType _type, 
-      TwSetVarCallback _setCallback,
-      TwGetVarCallback _getCallback,
-      void * _clientData):
-      name(_name),
-      type(_type),
-      setCallback(_setCallback),
-      getCallback(_getCallback),
-      clientData(_clientData)
-    {
-    }
-    // Shallow copy
-    // I solemnly swear it's OK to copy clientData this way
-    IGL_INLINE ReTwCBItem(const ReTwCBItem & that):
-      name(that.name),
-      type(that.type),
-      setCallback(that.setCallback),
-      getCallback(that.getCallback),
-      clientData(that.clientData)
-    {
-    }
-    // Shallow assignment
-    // I solemnly swear it's OK to copy clientData this way
-    IGL_INLINE ReTwCBItem & operator=(const ReTwCBItem & that)
-    {
-      if(this != &that)
-      {
-        name = that.name;
-        type = that.type;
-        setCallback = that.setCallback;
-        getCallback = that.getCallback;
-        clientData = that.clientData;
-      }
-      return *this;
-    }
-
-  };
-  
-  class ReTwBar
-  {
-    // VARIABLES
-    // Should be private, but seeing as I'm not going to implement all of the
-    // AntTweakBar public functions right away, I'll expose this so that at
-    // anytime AntTweakBar functions can be called directly on the bar
-    public:
-      TwBar * bar;
-      std::string name;
-    protected:
-      std::vector<ReTwRWItem> rw_items;
-      std::vector<ReTwCBItem> cb_items;
-    public:
-      // Default constructor with explicit initialization
-      IGL_INLINE ReTwBar();
-    private:
-      // Copy constructor does shallow copy
-      IGL_INLINE ReTwBar(const ReTwBar & that);
-      // Assignment operator does shallow assignment
-      IGL_INLINE ReTwBar &operator=(const ReTwBar & that);
-  
-    // WRAPPERS FOR ANTTWEAKBAR FUNCTIONS 
-    public:
-      IGL_INLINE void TwNewBar(const char *_name);
-      IGL_INLINE int TwAddVarRW(
-        const char *name, 
-        TwType type, 
-        void *var, 
-        const char *def,
-        const bool record=true);
-      IGL_INLINE int TwAddVarCB(
-        const char *name, 
-        TwType type, 
-        TwSetVarCallback setCallback, 
-        TwGetVarCallback getCallback, 
-        void *clientData, 
-        const char *def,
-        const bool record=true);
-      // Wrappers for convenience (not recorded, just passed on)
-      IGL_INLINE int TwAddVarRO(const char *name, TwType type, void *var, const char *def);
-      IGL_INLINE int TwAddButton(
-        const char *name, 
-        TwButtonCallback buttonCallback, 
-        void *clientData, 
-        const char *def);
-      IGL_INLINE int TwSetParam(
-        const char *varName, 
-        const char *paramName, 
-        TwParamValueType paramValueType, 
-        unsigned int inValueCount, 
-        const void *inValues);
-      IGL_INLINE int TwGetParam(
-        const char *varName, 
-        const char *paramName, 
-        TwParamValueType paramValueType, 
-        unsigned int outValueMaxCount, 
-        void *outValues);
-      IGL_INLINE int TwRefreshBar();
-      IGL_INLINE int TwTerminate();
-  
-  
-    // IO FUNCTIONS
-    public:
-      // Save current items to file
-      // Input:
-      //   file_name  name of file to save data to, can be null which means print
-      //   to stdout
-      // Return:
-      //   true only if there were no (fatal) errors
-      IGL_INLINE bool save(const char *file_name);
-      std::string get_value_as_string(
-        void * var, 
-        TwType type);
-      // Load into current items from file
-      // Input:
-      //   file_name  name of input file to load
-      // Return:
-      //   true only if there were no (fatal) errors
-      IGL_INLINE bool load(const char *file_name);
-      // Get TwType from string
-      // Input
-      //   type_str  string of type 
-      // Output
-      //   type  TwType converted from string
-      // Returns
-      //   true only if string matched a valid type
-      IGL_INLINE bool type_from_string(const char *type_str, TwType & type);
-      // I realize that I mix std::string and const char * all over the place.
-      // What can you do...
-      IGL_INLINE bool set_value_from_string(
-        const char * name, 
-        TwType type, 
-        const char * value_str);
-      IGL_INLINE const std::vector<ReTwRWItem> & get_rw_items();
-      IGL_INLINE const std::vector<ReTwCBItem> & get_cb_items();
-  };
-}
-
-// List of TwBar functions
-//TW_API TwBar *      TW_CALL TwNewBar(const char *barName);
-//TW_API int          TW_CALL TwDeleteBar(TwBar *bar);
-//TW_API int          TW_CALL TwDeleteAllBars();
-//TW_API int          TW_CALL TwSetTopBar(const TwBar *bar);
-//TW_API TwBar *      TW_CALL TwGetTopBar();
-//TW_API int          TW_CALL TwSetBottomBar(const TwBar *bar);
-//TW_API TwBar *      TW_CALL TwGetBottomBar();
-//TW_API const char * TW_CALL TwGetBarName(TwBar *bar);
-//TW_API int          TW_CALL TwGetBarCount();
-//TW_API TwBar *      TW_CALL TwGetBarByIndex(int barIndex);
-//TW_API TwBar *      TW_CALL TwGetBarByName(const char *barName);
-//TW_API int          TW_CALL TwRefreshBar(TwBar *bar);
-//TW_API int          TW_CALL TwTerminate();
-//
-//TW_API int      TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def);
-//TW_API int      TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def);
-//TW_API int      TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def);
-//TW_API int      TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def);
-//TW_API int      TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def);
-//TW_API int      TW_CALL TwRemoveVar(TwBar *bar, const char *name);
-//TW_API int      TW_CALL TwRemoveAllVars(TwBar *bar);
-
-// Until AntTweakBar dependency folder exists, this is header-only
-//#ifndef IGL_STATIC_LIBRARY
-#  include "ReAntTweakBar.cpp"
-//#endif
-
-#endif
-#endif

+ 128 - 0
include/igl/Singular_Value_Decomposition_Givens_QR_Factorization_Kernel.hpp

@@ -0,0 +1,128 @@
+//#####################################################################
+// Copyright (c) 2010-2011, Eftychios Sifakis.
+//
+// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+//   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
+//     other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//#####################################################################
+
+//###########################################################
+// Compute the Givens half-angle, construct the Givens quaternion and the rotation sine/cosine (for the full angle)
+//###########################################################
+
+#ifdef _WIN32
+  #undef max
+  #undef min
+#endif
+
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=SANPIVOT.f*SANPIVOT.f;)                                ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(VANPIVOT,VANPIVOT);)                             ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(VANPIVOT,VANPIVOT);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=(Ssh.f>=Ssmall_number.f)?0xffffffff:0;)               ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_cmpge_ps(Vsh,Vsmall_number);)                           ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_cmp_ps(Vsh,Vsmall_number, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_cmpge_ps(Vsh,Vsmall_number);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui&SANPIVOT.ui;)                                  ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vsh,VANPIVOT);)                                  ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_and_ps(Vsh,VANPIVOT);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=0.;)                                                 ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_xor_ps(Vtmp5,Vtmp5);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_xor_ps(Vtmp5,Vtmp5);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Stmp5.f-SAPIVOT.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vch=_mm_sub_ps(Vtmp5,VAPIVOT);)                                 ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_sub_ps(Vtmp5,VAPIVOT);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=std::max(Sch.f,SAPIVOT.f);)                            ENABLE_SSE_IMPLEMENTATION(Vch=_mm_max_ps(Vch,VAPIVOT);)                                   ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_max_ps(Vch,VAPIVOT);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=std::max(Sch.f,Ssmall_number.f);)                      ENABLE_SSE_IMPLEMENTATION(Vch=_mm_max_ps(Vch,Vsmall_number);)                             ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_max_ps(Vch,Vsmall_number);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp5.ui=(SAPIVOT.f>=Stmp5.f)?0xffffffff:0;)                 ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_cmpge_ps(VAPIVOT,Vtmp5);)                             ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_cmp_ps(VAPIVOT,Vtmp5, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_cmpge_ps(VAPIVOT,Vtmp5);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sch.f*Sch.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vch,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vch,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp1.f+Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(Vtmp1,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(Vtmp1,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=rsqrt(Stmp2.f);)                                     ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_rsqrt_ps(Vtmp2);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_rsqrt_ps(Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp1.f*Sone_half.f;)                                ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vtmp1,Vone_half);)                             ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vtmp1,Vone_half);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp2.f*Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp2,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp2,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f+Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_add_ps(Vtmp1,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_add_ps(Vtmp1,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f-Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_sub_ps(Vtmp1,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_sub_ps(Vtmp1,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f*Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vtmp1,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vtmp1,Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Sch.f+Stmp1.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vch=_mm_add_ps(Vch,Vtmp1);)                                     ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_add_ps(Vch,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=~Stmp5.ui&Ssh.ui;)                                  ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_andnot_ps(Vtmp5,Vsh);)                                ENABLE_AVX_IMPLEMENTATION(Vtmp1=Vch;)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=~Stmp5.ui&Sch.ui;)                                  ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_andnot_ps(Vtmp5,Vch);)                                ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vsh,Vch,Vtmp5);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Stmp5.ui&Sch.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vch=_mm_and_ps(Vtmp5,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_blendv_ps(Vtmp1,Vsh,Vtmp5);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Stmp5.ui&Ssh.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vtmp5,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp1.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui|Stmp2.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_or_ps(Vsh,Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sch.f*Sch.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vch,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vch,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp1.f+Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(Vtmp1,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(Vtmp1,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=rsqrt(Stmp2.f);)                                     ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_rsqrt_ps(Vtmp2);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_rsqrt_ps(Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp1.f*Sone_half.f;)                                ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vtmp1,Vone_half);)                             ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vtmp1,Vone_half);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp2.f*Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp2,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp2,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f+Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_add_ps(Vtmp1,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_add_ps(Vtmp1,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f-Stmp3.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_sub_ps(Vtmp1,Vtmp3);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_sub_ps(Vtmp1,Vtmp3);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Sch.f*Stmp1.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vch=_mm_mul_ps(Vch,Vtmp1);)                                     ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_mul_ps(Vch,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Ssh.f*Stmp1.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vsh,Vtmp1);)                                     ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vsh,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Sch.f*Sch.f;)                                           ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vch,Vch);)                                        ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vch,Vch);)ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ssh.f*Ssh.f;)                                           ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vsh,Vsh);)                                        ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Sc.f-Ss.f;)                                             ENABLE_SSE_IMPLEMENTATION(Vc=_mm_sub_ps(Vc,Vs);)                                          ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_sub_ps(Vc,Vs);)
+ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ssh.f*Sch.f;)                                           ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vsh,Vch);)                                        ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vsh,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ss.f+Ss.f;)                                             ENABLE_SSE_IMPLEMENTATION(Vs=_mm_add_ps(Vs,Vs);)                                          ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_add_ps(Vs,Vs);)
+
+//###########################################################
+// Rotate matrix A
+//###########################################################
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA11.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA11);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA11);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA21.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA21);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA21);)
+ENABLE_SCALAR_IMPLEMENTATION(SA11.f=Sc.f*SA11.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA11=_mm_mul_ps(Vc,VA11);)                                      ENABLE_AVX_IMPLEMENTATION(VA11=_mm256_mul_ps(Vc,VA11);)
+ENABLE_SCALAR_IMPLEMENTATION(SA21.f=Sc.f*SA21.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA21=_mm_mul_ps(Vc,VA21);)                                      ENABLE_AVX_IMPLEMENTATION(VA21=_mm256_mul_ps(Vc,VA21);)
+ENABLE_SCALAR_IMPLEMENTATION(SA11.f=SA11.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA11=_mm_add_ps(VA11,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VA11=_mm256_add_ps(VA11,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SA21.f=SA21.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA21=_mm_sub_ps(VA21,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VA21=_mm256_sub_ps(VA21,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA12.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA12);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA12);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA22.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA22);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA22);)
+ENABLE_SCALAR_IMPLEMENTATION(SA12.f=Sc.f*SA12.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA12=_mm_mul_ps(Vc,VA12);)                                      ENABLE_AVX_IMPLEMENTATION(VA12=_mm256_mul_ps(Vc,VA12);)
+ENABLE_SCALAR_IMPLEMENTATION(SA22.f=Sc.f*SA22.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA22=_mm_mul_ps(Vc,VA22);)                                      ENABLE_AVX_IMPLEMENTATION(VA22=_mm256_mul_ps(Vc,VA22);)
+ENABLE_SCALAR_IMPLEMENTATION(SA12.f=SA12.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA12=_mm_add_ps(VA12,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VA12=_mm256_add_ps(VA12,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SA22.f=SA22.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA22=_mm_sub_ps(VA22,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VA22=_mm256_sub_ps(VA22,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA13.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA13);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA13);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA23.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA23);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA23);)
+ENABLE_SCALAR_IMPLEMENTATION(SA13.f=Sc.f*SA13.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA13=_mm_mul_ps(Vc,VA13);)                                      ENABLE_AVX_IMPLEMENTATION(VA13=_mm256_mul_ps(Vc,VA13);)
+ENABLE_SCALAR_IMPLEMENTATION(SA23.f=Sc.f*SA23.f;)                                         ENABLE_SSE_IMPLEMENTATION(VA23=_mm_mul_ps(Vc,VA23);)                                      ENABLE_AVX_IMPLEMENTATION(VA23=_mm256_mul_ps(Vc,VA23);)
+ENABLE_SCALAR_IMPLEMENTATION(SA13.f=SA13.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA13=_mm_add_ps(VA13,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VA13=_mm256_add_ps(VA13,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SA23.f=SA23.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VA23=_mm_sub_ps(VA23,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VA23=_mm256_sub_ps(VA23,Vtmp1);)
+
+//###########################################################
+// Update matrix U
+//###########################################################
+
+#ifdef COMPUTE_U_AS_MATRIX
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU11.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU11);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU11);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU12.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU12);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU12);)
+ENABLE_SCALAR_IMPLEMENTATION(SU11.f=Sc.f*SU11.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU11=_mm_mul_ps(Vc,VU11);)                                      ENABLE_AVX_IMPLEMENTATION(VU11=_mm256_mul_ps(Vc,VU11);)
+ENABLE_SCALAR_IMPLEMENTATION(SU12.f=Sc.f*SU12.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU12=_mm_mul_ps(Vc,VU12);)                                      ENABLE_AVX_IMPLEMENTATION(VU12=_mm256_mul_ps(Vc,VU12);)
+ENABLE_SCALAR_IMPLEMENTATION(SU11.f=SU11.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU11=_mm_add_ps(VU11,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VU11=_mm256_add_ps(VU11,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SU12.f=SU12.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU12=_mm_sub_ps(VU12,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VU12=_mm256_sub_ps(VU12,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU21.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU21);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU21);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU22.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU22);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU22);)
+ENABLE_SCALAR_IMPLEMENTATION(SU21.f=Sc.f*SU21.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU21=_mm_mul_ps(Vc,VU21);)                                      ENABLE_AVX_IMPLEMENTATION(VU21=_mm256_mul_ps(Vc,VU21);)
+ENABLE_SCALAR_IMPLEMENTATION(SU22.f=Sc.f*SU22.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU22=_mm_mul_ps(Vc,VU22);)                                      ENABLE_AVX_IMPLEMENTATION(VU22=_mm256_mul_ps(Vc,VU22);)
+ENABLE_SCALAR_IMPLEMENTATION(SU21.f=SU21.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU21=_mm_add_ps(VU21,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VU21=_mm256_add_ps(VU21,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SU22.f=SU22.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU22=_mm_sub_ps(VU22,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VU22=_mm256_sub_ps(VU22,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU31.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU31);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU31);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU32.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU32);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU32);)
+ENABLE_SCALAR_IMPLEMENTATION(SU31.f=Sc.f*SU31.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU31=_mm_mul_ps(Vc,VU31);)                                      ENABLE_AVX_IMPLEMENTATION(VU31=_mm256_mul_ps(Vc,VU31);)
+ENABLE_SCALAR_IMPLEMENTATION(SU32.f=Sc.f*SU32.f;)                                         ENABLE_SSE_IMPLEMENTATION(VU32=_mm_mul_ps(Vc,VU32);)                                      ENABLE_AVX_IMPLEMENTATION(VU32=_mm256_mul_ps(Vc,VU32);)
+ENABLE_SCALAR_IMPLEMENTATION(SU31.f=SU31.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU31=_mm_add_ps(VU31,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VU31=_mm256_add_ps(VU31,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SU32.f=SU32.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VU32=_mm_sub_ps(VU32,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VU32=_mm256_sub_ps(VU32,Vtmp1);)
+#endif

+ 118 - 0
include/igl/Singular_Value_Decomposition_Jacobi_Conjugation_Kernel.hpp

@@ -0,0 +1,118 @@
+//#####################################################################
+// Copyright (c) 2010-2011, Eftychios Sifakis.
+//
+// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+//   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
+//     other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//#####################################################################
+
+//###########################################################
+// Compute the Givens angle (and half-angle) 
+//###########################################################
+
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=SS21.f*Sone_half.f;)                                   ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(VS21,Vone_half);)                                ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(VS21,Vone_half);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=SS11.f-SS22.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_sub_ps(VS11,VS22);)                                   ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_sub_ps(VS11,VS22);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=(Stmp2.f>=Stiny_number.f)?0xffffffff:0;)            ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_cmpge_ps(Vtmp2,Vtiny_number);)                        ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmp_ps(Vtmp2,Vtiny_number, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmpge_ps(Vtmp2,Vtiny_number);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Stmp1.ui&Ssh.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vtmp1,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_and_ps(Vtmp1,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Stmp1.ui&Stmp5.ui;)                                   ENABLE_SSE_IMPLEMENTATION(Vch=_mm_and_ps(Vtmp1,Vtmp5);)                                   ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vone,Vtmp5,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=~Stmp1.ui&Sone.ui;)                                 ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_andnot_ps(Vtmp1,Vone);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp2.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Sch.f*Sch.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vch,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vch,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f+Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_add_ps(Vtmp1,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_add_ps(Vtmp1,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=rsqrt(Stmp3.f);)                                     ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_rsqrt_ps(Vtmp3);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_rsqrt_ps(Vtmp3);)
+
+#ifdef USE_ACCURATE_RSQRT_IN_JACOBI_CONJUGATION
+ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Stmp4.f*Sone_half.f;)                                   ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vtmp4,Vone_half);)                                ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vtmp4,Vone_half);)
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp4.f*Ss.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp4,Vs);)                                       ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp4,Vs);)
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp4.f*Sc.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp4,Vc);)                                       ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp4,Vc);)
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp3.f*Sc.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp3,Vc);)                                       ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp3,Vc);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f+Ss.f;)                                       ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_add_ps(Vtmp4,Vs);)                                    ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_add_ps(Vtmp4,Vs);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f-Sc.f;)                                       ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_sub_ps(Vtmp4,Vc);)                                    ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_sub_ps(Vtmp4,Vc);)
+#endif
+
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Stmp4.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vtmp4,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vtmp4,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Stmp4.f*Sch.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vch=_mm_mul_ps(Vtmp4,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_mul_ps(Vtmp4,Vch);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sfour_gamma_squared.f*Stmp1.f;)                      ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vfour_gamma_squared,Vtmp1);)                   ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vfour_gamma_squared,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=(Stmp2.f<=Stmp1.f)?0xffffffff:0;)                   ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_cmple_ps(Vtmp2,Vtmp1);)                               ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmp_ps(Vtmp2,Vtmp1, _CMP_LE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmple_ps(Vtmp2,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=Ssine_pi_over_eight.ui&Stmp1.ui;)                   ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_and_ps(Vsine_pi_over_eight,Vtmp1);)                   ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_blendv_ps(Vsh,Vsine_pi_over_eight,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=~Stmp1.ui&Ssh.ui;)                                    ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_andnot_ps(Vtmp1,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui|Stmp2.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_or_ps(Vsh,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=Scosine_pi_over_eight.ui&Stmp1.ui;)                 ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_and_ps(Vcosine_pi_over_eight,Vtmp1);)                 ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vch,Vcosine_pi_over_eight,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=~Stmp1.ui&Sch.ui;)                                    ENABLE_SSE_IMPLEMENTATION(Vch=_mm_andnot_ps(Vtmp1,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp2.ui;)                                     ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp2);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Ssh.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vsh);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Sch.f*Sch.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vch,Vch);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vch,Vch);)
+ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp2.f-Stmp1.f;)                                       ENABLE_SSE_IMPLEMENTATION(Vc=_mm_sub_ps(Vtmp2,Vtmp1);)                                    ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_sub_ps(Vtmp2,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Sch.f*Ssh.f;)                                           ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vch,Vsh);)                                        ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vch,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ss.f+Ss.f;)                                             ENABLE_SSE_IMPLEMENTATION(Vs=_mm_add_ps(Vs,Vs);)                                          ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_add_ps(Vs,Vs);)
+
+//###########################################################
+// Perform the actual Givens conjugation
+//###########################################################
+
+#ifndef USE_ACCURATE_RSQRT_IN_JACOBI_CONJUGATION
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f+Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_add_ps(Vtmp1,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_add_ps(Vtmp1,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SS33.f=SS33.f*Stmp3.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS33=_mm_mul_ps(VS33,Vtmp3);)                                   ENABLE_AVX_IMPLEMENTATION(VS33=_mm256_mul_ps(VS33,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(SS31.f=SS31.f*Stmp3.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS31=_mm_mul_ps(VS31,Vtmp3);)                                   ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_mul_ps(VS31,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(SS32.f=SS32.f*Stmp3.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS32=_mm_mul_ps(VS32,Vtmp3);)                                   ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_mul_ps(VS32,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(SS33.f=SS33.f*Stmp3.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS33=_mm_mul_ps(VS33,Vtmp3);)                                   ENABLE_AVX_IMPLEMENTATION(VS33=_mm256_mul_ps(VS33,Vtmp3);)
+#endif
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SS31.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VS31);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VS31);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SS32.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VS32);)                                     ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VS32);)
+ENABLE_SCALAR_IMPLEMENTATION(SS31.f=Sc.f*SS31.f;)                                         ENABLE_SSE_IMPLEMENTATION(VS31=_mm_mul_ps(Vc,VS31);)                                      ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_mul_ps(Vc,VS31);)
+ENABLE_SCALAR_IMPLEMENTATION(SS32.f=Sc.f*SS32.f;)                                         ENABLE_SSE_IMPLEMENTATION(VS32=_mm_mul_ps(Vc,VS32);)                                      ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_mul_ps(Vc,VS32);)
+ENABLE_SCALAR_IMPLEMENTATION(SS31.f=Stmp2.f+SS31.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS31=_mm_add_ps(Vtmp2,VS31);)                                   ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_add_ps(Vtmp2,VS31);)
+ENABLE_SCALAR_IMPLEMENTATION(SS32.f=SS32.f-Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS32=_mm_sub_ps(VS32,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_sub_ps(VS32,Vtmp1);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*Ss.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,Vs);)                                       ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,Vs);)         
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=SS22.f*Stmp2.f;)                                     ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(VS22,Vtmp2);)                                  ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(VS22,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=SS11.f*Stmp2.f;)                                     ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(VS11,Vtmp2);)                                  ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(VS11,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Sc.f*Sc.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vc,Vc);)                                       ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vc,Vc);)
+ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f*Stmp4.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS11=_mm_mul_ps(VS11,Vtmp4);)                                   ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_mul_ps(VS11,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f*Stmp4.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS22=_mm_mul_ps(VS22,Vtmp4);)                                   ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_mul_ps(VS22,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f+Stmp1.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS11=_mm_add_ps(VS11,Vtmp1);)                                   ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_add_ps(VS11,Vtmp1);)
+ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f+Stmp3.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS22=_mm_add_ps(VS22,Vtmp3);)                                   ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_add_ps(VS22,Vtmp3);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f-Stmp2.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_sub_ps(Vtmp4,Vtmp2);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_sub_ps(Vtmp4,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=SS21.f+SS21.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(VS21,VS21);)                                   ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(VS21,VS21);)
+ENABLE_SCALAR_IMPLEMENTATION(SS21.f=SS21.f*Stmp4.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS21=_mm_mul_ps(VS21,Vtmp4);)                                   ENABLE_AVX_IMPLEMENTATION(VS21=_mm256_mul_ps(VS21,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Sc.f*Ss.f;)                                          ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vc,Vs);)                                       ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vc,Vs);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp2.f*Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vtmp2,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vtmp2,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=Stmp5.f*Stmp4.f;)                                    ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_mul_ps(Vtmp5,Vtmp4);)                                 ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_mul_ps(Vtmp5,Vtmp4);)
+ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f+Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS11=_mm_add_ps(VS11,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_add_ps(VS11,Vtmp2);)
+ENABLE_SCALAR_IMPLEMENTATION(SS21.f=SS21.f-Stmp5.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS21=_mm_sub_ps(VS21,Vtmp5);)                                   ENABLE_AVX_IMPLEMENTATION(VS21=_mm256_sub_ps(VS21,Vtmp5);)
+ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f-Stmp2.f;)                                      ENABLE_SSE_IMPLEMENTATION(VS22=_mm_sub_ps(VS22,Vtmp2);)                                   ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_sub_ps(VS22,Vtmp2);)
+
+//###########################################################
+// Compute the cumulative rotation, in quaternion form
+//###########################################################
+
+ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Sqvvx.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vqvvx);)                                   ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vqvvx);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Sqvvy.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vqvvy);)                                   ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vqvvy);)
+ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Ssh.f*Sqvvz.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vsh,Vqvvz);)                                   ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vsh,Vqvvz);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Ssh.f*Sqvs.f;)                                         ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vsh,Vqvs);)                                      ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vsh,Vqvs);)
+
+ENABLE_SCALAR_IMPLEMENTATION(Sqvs.f=Sch.f*Sqvs.f;)                                        ENABLE_SSE_IMPLEMENTATION(Vqvs=_mm_mul_ps(Vch,Vqvs);)                                     ENABLE_AVX_IMPLEMENTATION(Vqvs=_mm256_mul_ps(Vch,Vqvs);)
+ENABLE_SCALAR_IMPLEMENTATION(Sqvvx.f=Sch.f*Sqvvx.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vqvvx=_mm_mul_ps(Vch,Vqvvx);)                                   ENABLE_AVX_IMPLEMENTATION(Vqvvx=_mm256_mul_ps(Vch,Vqvvx);)
+ENABLE_SCALAR_IMPLEMENTATION(Sqvvy.f=Sch.f*Sqvvy.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vqvvy=_mm_mul_ps(Vch,Vqvvy);)                                   ENABLE_AVX_IMPLEMENTATION(Vqvvy=_mm256_mul_ps(Vch,Vqvvy);)
+ENABLE_SCALAR_IMPLEMENTATION(Sqvvz.f=Sch.f*Sqvvz.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vqvvz=_mm_mul_ps(Vch,Vqvvz);)                                   ENABLE_AVX_IMPLEMENTATION(Vqvvz=_mm256_mul_ps(Vch,Vqvvz);)
+
+ENABLE_SCALAR_IMPLEMENTATION(SQVVZ.f=SQVVZ.f+Ssh.f;)                                      ENABLE_SSE_IMPLEMENTATION(VQVVZ=_mm_add_ps(VQVVZ,Vsh);)                                   ENABLE_AVX_IMPLEMENTATION(VQVVZ=_mm256_add_ps(VQVVZ,Vsh);)
+ENABLE_SCALAR_IMPLEMENTATION(Sqvs.f=Sqvs.f-STMP3.f;)                                      ENABLE_SSE_IMPLEMENTATION(Vqvs=_mm_sub_ps(Vqvs,VTMP3);)                                   ENABLE_AVX_IMPLEMENTATION(Vqvs=_mm256_sub_ps(Vqvs,VTMP3);)
+ENABLE_SCALAR_IMPLEMENTATION(SQVVX.f=SQVVX.f+STMP2.f;)                                    ENABLE_SSE_IMPLEMENTATION(VQVVX=_mm_add_ps(VQVVX,VTMP2);)                                 ENABLE_AVX_IMPLEMENTATION(VQVVX=_mm256_add_ps(VQVVX,VTMP2);)
+ENABLE_SCALAR_IMPLEMENTATION(SQVVY.f=SQVVY.f-STMP1.f;)                                    ENABLE_SSE_IMPLEMENTATION(VQVVY=_mm_sub_ps(VQVVY,VTMP1);)                                 ENABLE_AVX_IMPLEMENTATION(VQVVY=_mm256_sub_ps(VQVVY,VTMP1);)

+ 137 - 0
include/igl/Singular_Value_Decomposition_Kernel_Declarations.hpp

@@ -0,0 +1,137 @@
+//#####################################################################
+// Copyright (c) 2010-2011, Eftychios Sifakis.
+//
+// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+//   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
+//     other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//#####################################################################
+
+//###########################################################
+// Local variable declarations
+//###########################################################
+
+#ifdef PRINT_DEBUGGING_OUTPUT
+
+#ifdef USE_SSE_IMPLEMENTATION
+    float buf[4];
+    float A11,A21,A31,A12,A22,A32,A13,A23,A33;
+    float S11,S21,S31,S22,S32,S33;
+#ifdef COMPUTE_V_AS_QUATERNION
+    float QVS,QVVX,QVVY,QVVZ;
+#endif
+#ifdef COMPUTE_V_AS_MATRIX
+    float V11,V21,V31,V12,V22,V32,V13,V23,V33;
+#endif
+#ifdef COMPUTE_U_AS_QUATERNION
+    float QUS,QUVX,QUVY,QUVZ;
+#endif
+#ifdef COMPUTE_U_AS_MATRIX
+    float U11,U21,U31,U12,U22,U32,U13,U23,U33;
+#endif
+#endif
+
+#ifdef USE_AVX_IMPLEMENTATION
+    float buf[8];
+    float A11,A21,A31,A12,A22,A32,A13,A23,A33;
+    float S11,S21,S31,S22,S32,S33;
+#ifdef COMPUTE_V_AS_QUATERNION
+    float QVS,QVVX,QVVY,QVVZ;
+#endif
+#ifdef COMPUTE_V_AS_MATRIX
+    float V11,V21,V31,V12,V22,V32,V13,V23,V33;
+#endif
+#ifdef COMPUTE_U_AS_QUATERNION
+    float QUS,QUVX,QUVY,QUVZ;
+#endif
+#ifdef COMPUTE_U_AS_MATRIX
+    float U11,U21,U31,U12,U22,U32,U13,U23,U33;
+#endif
+#endif
+
+#endif
+
+const float Four_Gamma_Squared=sqrt(8.)+3.;
+const float Sine_Pi_Over_Eight=.5*sqrt(2.-sqrt(2.));
+const float Cosine_Pi_Over_Eight=.5*sqrt(2.+sqrt(2.));
+
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sfour_gamma_squared;)       ENABLE_SSE_IMPLEMENTATION(__m128 Vfour_gamma_squared;)                                    ENABLE_AVX_IMPLEMENTATION(__m256 Vfour_gamma_squared;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssine_pi_over_eight;)       ENABLE_SSE_IMPLEMENTATION(__m128 Vsine_pi_over_eight;)                                    ENABLE_AVX_IMPLEMENTATION(__m256 Vsine_pi_over_eight;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Scosine_pi_over_eight;)     ENABLE_SSE_IMPLEMENTATION(__m128 Vcosine_pi_over_eight;)                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vcosine_pi_over_eight;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sone_half;)                 ENABLE_SSE_IMPLEMENTATION(__m128 Vone_half;)                                              ENABLE_AVX_IMPLEMENTATION(__m256 Vone_half;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sone;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vone;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vone;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stiny_number;)              ENABLE_SSE_IMPLEMENTATION(__m128 Vtiny_number;)                                           ENABLE_AVX_IMPLEMENTATION(__m256 Vtiny_number;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssmall_number;)             ENABLE_SSE_IMPLEMENTATION(__m128 Vsmall_number;)                                          ENABLE_AVX_IMPLEMENTATION(__m256 Vsmall_number;)
+
+ENABLE_SCALAR_IMPLEMENTATION(Sfour_gamma_squared.f=Four_Gamma_Squared;)                   ENABLE_SSE_IMPLEMENTATION(Vfour_gamma_squared=_mm_set1_ps(Four_Gamma_Squared);)           ENABLE_AVX_IMPLEMENTATION(Vfour_gamma_squared=_mm256_set1_ps(Four_Gamma_Squared);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssine_pi_over_eight.f=Sine_Pi_Over_Eight;)                   ENABLE_SSE_IMPLEMENTATION(Vsine_pi_over_eight=_mm_set1_ps(Sine_Pi_Over_Eight);)           ENABLE_AVX_IMPLEMENTATION(Vsine_pi_over_eight=_mm256_set1_ps(Sine_Pi_Over_Eight);)
+ENABLE_SCALAR_IMPLEMENTATION(Scosine_pi_over_eight.f=Cosine_Pi_Over_Eight;)               ENABLE_SSE_IMPLEMENTATION(Vcosine_pi_over_eight=_mm_set1_ps(Cosine_Pi_Over_Eight);)       ENABLE_AVX_IMPLEMENTATION(Vcosine_pi_over_eight=_mm256_set1_ps(Cosine_Pi_Over_Eight);)
+ENABLE_SCALAR_IMPLEMENTATION(Sone_half.f=.5;)                                             ENABLE_SSE_IMPLEMENTATION(Vone_half=_mm_set1_ps(.5);)                                     ENABLE_AVX_IMPLEMENTATION(Vone_half=_mm256_set1_ps(.5);)
+ENABLE_SCALAR_IMPLEMENTATION(Sone.f=1.;)                                                  ENABLE_SSE_IMPLEMENTATION(Vone=_mm_set1_ps(1.);)                                          ENABLE_AVX_IMPLEMENTATION(Vone=_mm256_set1_ps(1.);)
+ENABLE_SCALAR_IMPLEMENTATION(Stiny_number.f=1.e-20;)                                      ENABLE_SSE_IMPLEMENTATION(Vtiny_number=_mm_set1_ps(1.e-20);)                              ENABLE_AVX_IMPLEMENTATION(Vtiny_number=_mm256_set1_ps(1.e-20);)
+ENABLE_SCALAR_IMPLEMENTATION(Ssmall_number.f=1.e-12;)                                     ENABLE_SSE_IMPLEMENTATION(Vsmall_number=_mm_set1_ps(1.e-12);)                             ENABLE_AVX_IMPLEMENTATION(Vsmall_number=_mm256_set1_ps(1.e-12);)
+
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa11;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va11;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va11;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa21;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va21;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va21;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa31;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va31;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va31;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa12;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va12;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va12;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa22;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va22;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va22;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa32;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va32;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va32;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa13;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va13;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va13;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa23;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va23;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va23;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa33;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Va33;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Va33;)
+
+#ifdef COMPUTE_V_AS_MATRIX
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv11;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv11;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv11;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv21;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv21;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv21;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv31;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv31;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv31;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv12;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv12;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv12;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv22;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv22;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv22;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv32;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv32;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv32;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv13;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv13;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv13;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv23;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv23;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv23;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv33;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vv33;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vv33;)
+#endif
+
+#ifdef COMPUTE_V_AS_QUATERNION
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvs;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vqvs;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vqvs;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvx;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvx;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvx;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvy;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvy;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvy;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvz;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvz;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvz;)
+#endif
+
+#ifdef COMPUTE_U_AS_MATRIX
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su11;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu11;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu11;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su21;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu21;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu21;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su31;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu31;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu31;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su12;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu12;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu12;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su22;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu22;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu22;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su32;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu32;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu32;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su13;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu13;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu13;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su23;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu23;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu23;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su33;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vu33;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vu33;)
+#endif
+
+#ifdef COMPUTE_U_AS_QUATERNION
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squs;)                      ENABLE_SSE_IMPLEMENTATION(__m128 Vqus;)                                                   ENABLE_AVX_IMPLEMENTATION(__m256 Vqus;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvx;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vquvx;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vquvx;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvy;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vquvy;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vquvy;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvz;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vquvz;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vquvz;)
+#endif
+
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sc;)                        ENABLE_SSE_IMPLEMENTATION(__m128 Vc;)                                                     ENABLE_AVX_IMPLEMENTATION(__m256 Vc;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ss;)                        ENABLE_SSE_IMPLEMENTATION(__m128 Vs;)                                                     ENABLE_AVX_IMPLEMENTATION(__m256 Vs;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sch;)                       ENABLE_SSE_IMPLEMENTATION(__m128 Vch;)                                                    ENABLE_AVX_IMPLEMENTATION(__m256 Vch;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssh;)                       ENABLE_SSE_IMPLEMENTATION(__m128 Vsh;)                                                    ENABLE_AVX_IMPLEMENTATION(__m256 Vsh;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp1;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp1;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp1;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp2;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp2;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp2;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp3;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp3;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp3;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp4;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp4;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp4;)
+ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp5;)                     ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp5;)                                                  ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp5;)

+ 1 - 0
include/igl/Singular_Value_Decomposition_Main_Kernel_Body.hpp.REMOVED.git-id

@@ -0,0 +1 @@
+e8898a8aa8e920ab7c2cd0bfaac5acc2e4991daf

+ 67 - 0
include/igl/Singular_Value_Decomposition_Preamble.hpp

@@ -0,0 +1,67 @@
+//#####################################################################
+// Copyright (c) 2010-2011, Eftychios Sifakis.
+//
+// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+//   * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
+//     other materials provided with the distribution.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//#####################################################################
+
+#ifdef PRINT_DEBUGGING_OUTPUT
+#include <iomanip>
+#include <iostream>
+#endif
+
+#ifdef USE_SCALAR_IMPLEMENTATION
+#define ENABLE_SCALAR_IMPLEMENTATION(X) X
+#else
+#define ENABLE_SCALAR_IMPLEMENTATION(X)
+#endif
+
+#ifdef USE_SSE_IMPLEMENTATION
+#define ENABLE_SSE_IMPLEMENTATION(X) X
+#else
+#define ENABLE_SSE_IMPLEMENTATION(X)
+#endif
+
+#ifdef USE_AVX_IMPLEMENTATION
+#include <immintrin.h>
+#define ENABLE_AVX_IMPLEMENTATION(X) X
+#else
+// Stefan: removed include. Why does it import MMX instructions, shouldn't this be under the #ifdef USE_SSE_IMPLEMENTATION above?
+//#include <xmmintrin.h>
+#define ENABLE_AVX_IMPLEMENTATION(X)
+#endif
+
+#ifdef USE_SCALAR_IMPLEMENTATION
+// Alec: Why is this using sse intrinsics if it's supposed to be the scalar
+// implementation?
+#ifdef __SSE__
+#include <mmintrin.h>
+// Changed to inline
+inline float rsqrt(const float f)
+{
+    float buf[4];
+    buf[0]=f;
+    __m128 v=_mm_loadu_ps(buf);
+    v=_mm_rsqrt_ss(v);
+    _mm_storeu_ps(buf,v);
+    return buf[0];
+}
+#else
+#include <cmath>
+inline float rsqrt(const float f)
+{
+  return 1./sqrtf(f);
+}
+#endif
+#endif
+
+

+ 7 - 0
include/igl/WindingNumberMethod.h

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_WINDINGNUMBERMETHOD_H
 #ifndef IGL_WINDINGNUMBERMETHOD_H
 #define IGL_WINDINGNUMBERMETHOD_H
 #define IGL_WINDINGNUMBERMETHOD_H
 namespace igl
 namespace igl

+ 0 - 51
include/igl/angles.cpp

@@ -1,51 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "angles.h"
-#include <Eigen/Geometry>
-#include <cassert>
-
-template <
-  typename DerivedV,
-  typename DerivedF,
-  typename Derivedtheta>
-void igl::angles(
-  const Eigen::PlainObjectBase<DerivedV>& V,
-  const Eigen::PlainObjectBase<DerivedF>& F,
-  Eigen::PlainObjectBase<Derivedtheta>& theta)
-{
-  theta.resize(F.rows(),F.cols());
-
-  auto corner = [](const Eigen::PlainObjectBase<DerivedV>& x, const Eigen::PlainObjectBase<DerivedV>& y, const Eigen::PlainObjectBase<DerivedV>& z)
-  {
-    Eigen::RowVector3d v1 = (x-y).normalized();
-    Eigen::RowVector3d v2 = (z-y).normalized();
-
-    // http://stackoverflow.com/questions/10133957/signed-angle-between-two-vectors-without-a-reference-plane
-    double s = v1.cross(v2).norm();
-    double c = v1.dot(v2);
-
-    return atan2(s, c);
-  };
-
-  for(unsigned i=0; i<F.rows(); ++i)
-  {
-    for(unsigned j=0; j<F.cols(); ++j)
-    {
-      theta(i,j) = corner(
-        V.row(F(i,int(j-1+F.cols())%F.cols())),
-        V.row(F(i,j)),
-        V.row(F(i,(j+1+F.cols())%F.cols()))
-        );
-    }
-  }
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-template void igl::angles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
-#endif

+ 0 - 47
include/igl/angles.h

@@ -1,47 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@gmail.com>
-//
-// This Source Code Form is subject to the terms of the Mozilla Public License
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_ANGLES_H
-#define IGL_ANGLES_H
-#ifdef _WIN32
-#  pragma message ( "Deprecated. Use igl/internal_angles.h instead" )
-#else
-#  warning "Deprecated. Use igl/internal_angles.h instead"
-#endif
-
-
-#include "igl_inline.h"
-#include "deprecated.h"
-#include <Eigen/Core>
-namespace igl
-{
-  // ANGLES Compute angles for each corner of each triangle
-  //
-  // Inputs:
-  //   V  #V by dim list of vertex positions
-  //   F  #V by 3[4] list of triangle[quads] indices
-  // Outputs:
-  //   theta  #F by 3[4] list of angles for each corner (in radians)
-  //
-  template <
-  typename DerivedV,
-  typename DerivedF,
-  typename Derivedtheta>
-  IGL_INLINE 
-  IGL_DEPRECATED(
-    void angles(
-    const Eigen::PlainObjectBase<DerivedV>& V,
-    const Eigen::PlainObjectBase<DerivedF>& F,
-    Eigen::PlainObjectBase<Derivedtheta>& theta));
-
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "angles.cpp"
-#endif
-
-#endif

+ 36 - 26
include/igl/ReAntTweakBar.cpp → include/igl/anttweakbar/ReAntTweakBar.cpp

@@ -6,7 +6,6 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "ReAntTweakBar.h"
 #include "ReAntTweakBar.h"
-#ifndef IGL_NO_ANTTWEAKBAR
 
 
 #include <cstdio>
 #include <cstdio>
 #include <cstring>
 #include <cstring>
@@ -18,10 +17,12 @@
 // GLOBAL WRAPPERS
 // GLOBAL WRAPPERS
 namespace 
 namespace 
 {
 {
-  std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > > ReTw_custom_types;
+  std::map<
+    TwType,std::pair<const char *,std::vector<TwEnumVal> > 
+    > ReTw_custom_types;
 }
 }
 
 
-IGL_INLINE TwType igl::ReTwDefineEnum(
+IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnum(
   const char *name, 
   const char *name, 
   const TwEnumVal *enumValues, 
   const TwEnumVal *enumValues, 
   unsigned int nbValues)
   unsigned int nbValues)
@@ -42,7 +43,7 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
   return type;
   return type;
 }
 }
 
 
-IGL_INLINE TwType igl::ReTwDefineEnumFromString(
+IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnumFromString(
   const char * _Name,
   const char * _Name,
   const char * _EnumString)
   const char * _EnumString)
 {
 {
@@ -82,7 +83,10 @@ IGL_INLINE TwType igl::ReTwDefineEnumFromString(
         Vals[i].Label = c_label;
         Vals[i].Label = c_label;
     }
     }
 
 
-    const TwType type = ReTwDefineEnum(_Name, Vals.empty() ? NULL : &(Vals[0]), (unsigned int)Vals.size());
+    const TwType type = 
+      ReTwDefineEnum(_Name, Vals.empty() ? 
+        NULL : 
+        &(Vals[0]), (unsigned int)Vals.size());
     return type;
     return type;
   }
   }
 }
 }
@@ -124,14 +128,15 @@ namespace
   };
   };
 }
 }
 
 
-IGL_INLINE igl::ReTwBar::ReTwBar():
+IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar():
  bar(NULL),
  bar(NULL),
   name(),
   name(),
   rw_items(),cb_items()
   rw_items(),cb_items()
 {
 {
 }
 }
 
 
-IGL_INLINE igl::ReTwBar::ReTwBar(const igl::ReTwBar & that):
+IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar(
+    const igl::anttweakbar::ReTwBar & that):
   bar(that.bar),
   bar(that.bar),
   name(that.name),
   name(that.name),
   rw_items(that.rw_items),
   rw_items(that.rw_items),
@@ -139,7 +144,8 @@ IGL_INLINE igl::ReTwBar::ReTwBar(const igl::ReTwBar & that):
 {
 {
 }
 }
 
 
-IGL_INLINE igl::ReTwBar & igl::ReTwBar::operator=(const igl::ReTwBar & that)
+IGL_INLINE igl::anttweakbar::ReTwBar & 
+igl::anttweakbar::ReTwBar::operator=(const igl::anttweakbar::ReTwBar & that)
 {
 {
   // check for self assignment
   // check for self assignment
   if(this != &that)
   if(this != &that)
@@ -153,7 +159,7 @@ IGL_INLINE igl::ReTwBar & igl::ReTwBar::operator=(const igl::ReTwBar & that)
 
 
 
 
 // BAR WRAPPERS
 // BAR WRAPPERS
-IGL_INLINE void igl::ReTwBar::TwNewBar(const char * _name)
+IGL_INLINE void igl::anttweakbar::ReTwBar::TwNewBar(const char * _name)
 {
 {
   this->bar = ::TwNewBar(_name);
   this->bar = ::TwNewBar(_name);
   // Alec: This causes trouble (not sure why) in multiple applications
   // Alec: This causes trouble (not sure why) in multiple applications
@@ -163,7 +169,7 @@ IGL_INLINE void igl::ReTwBar::TwNewBar(const char * _name)
   //this->name = "foobar";
   //this->name = "foobar";
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwAddVarRW(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRW(
   const char *name, 
   const char *name, 
   TwType type, 
   TwType type, 
   void *var, 
   void *var, 
@@ -178,7 +184,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarRW(
   return ret;
   return ret;
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwAddVarCB(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarCB(
   const char *name, 
   const char *name, 
   TwType type, 
   TwType type, 
   TwSetVarCallback setCallback, 
   TwSetVarCallback setCallback, 
@@ -196,7 +202,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarCB(
   return ret;
   return ret;
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwAddVarRO(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRO(
   const char *name, 
   const char *name, 
   TwType type, 
   TwType type, 
   void *var, 
   void *var, 
@@ -211,7 +217,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarRO(
   return ret;
   return ret;
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwAddButton(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddButton(
   const char *name, 
   const char *name, 
   TwButtonCallback buttonCallback, 
   TwButtonCallback buttonCallback, 
   void *clientData, 
   void *clientData, 
@@ -227,7 +233,7 @@ IGL_INLINE int igl::ReTwBar::TwAddButton(
   return ret;
   return ret;
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwSetParam(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwSetParam(
   const char *varName, 
   const char *varName, 
   const char *paramName, 
   const char *paramName, 
   TwParamValueType paramValueType, 
   TwParamValueType paramValueType, 
@@ -245,7 +251,7 @@ IGL_INLINE int igl::ReTwBar::TwSetParam(
       inValues);
       inValues);
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwGetParam(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwGetParam(
   const char *varName, 
   const char *varName, 
   const char *paramName, 
   const char *paramName, 
   TwParamValueType paramValueType, 
   TwParamValueType paramValueType, 
@@ -262,12 +268,12 @@ IGL_INLINE int igl::ReTwBar::TwGetParam(
       outValues);
       outValues);
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwRefreshBar()
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwRefreshBar()
 {
 {
   return ::TwRefreshBar(this->bar);
   return ::TwRefreshBar(this->bar);
 }
 }
 
 
-IGL_INLINE int igl::ReTwBar::TwTerminate()
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwTerminate()
 {
 {
   //std::cout<<"TwTerminate"<<std::endl;
   //std::cout<<"TwTerminate"<<std::endl;
   int r = ::TwTerminate();
   int r = ::TwTerminate();
@@ -275,7 +281,7 @@ IGL_INLINE int igl::ReTwBar::TwTerminate()
   return r;
   return r;
 }
 }
 
 
-IGL_INLINE bool igl::ReTwBar::save(const char *file_name)
+IGL_INLINE bool igl::anttweakbar::ReTwBar::save(const char *file_name)
 {
 {
   FILE * fp;
   FILE * fp;
   if(file_name == NULL)
   if(file_name == NULL)
@@ -338,7 +344,7 @@ IGL_INLINE bool igl::ReTwBar::save(const char *file_name)
   return true;
   return true;
 }
 }
 
 
-IGL_INLINE std::string igl::ReTwBar::get_value_as_string(
+IGL_INLINE std::string igl::anttweakbar::ReTwBar::get_value_as_string(
   void * var, 
   void * var, 
   TwType type)
   TwType type)
 {
 {
@@ -476,7 +482,7 @@ IGL_INLINE std::string igl::ReTwBar::get_value_as_string(
   return sstr.str();
   return sstr.str();
 }
 }
 
 
-IGL_INLINE bool igl::ReTwBar::load(const char *file_name)
+IGL_INLINE bool igl::anttweakbar::ReTwBar::load(const char *file_name)
 {
 {
   FILE * fp;
   FILE * fp;
   fp = fopen(file_name,"r");
   fp = fopen(file_name,"r");
@@ -537,7 +543,8 @@ IGL_INLINE bool igl::ReTwBar::load(const char *file_name)
   return true;
   return true;
 }
 }
 
 
-IGL_INLINE bool igl::ReTwBar::type_from_string(const char *type_str, TwType & type)
+IGL_INLINE bool igl::anttweakbar::ReTwBar::type_from_string(
+  const char *type_str, TwType & type)
 {
 {
   // first check default types
   // first check default types
   for(int j = 0; j < RETW_NUM_DEFAULT_TYPE_STRINGS; j++)
   for(int j = 0; j < RETW_NUM_DEFAULT_TYPE_STRINGS; j++)
@@ -551,7 +558,9 @@ IGL_INLINE bool igl::ReTwBar::type_from_string(const char *type_str, TwType & ty
   }
   }
 
 
   // then check custom types
   // then check custom types
-  std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter = 
+  std::map<
+    TwType,std::pair<const char *,std::vector<TwEnumVal> > 
+    >::const_iterator iter = 
     ReTw_custom_types.begin();
     ReTw_custom_types.begin();
   for(;iter != ReTw_custom_types.end(); iter++)
   for(;iter != ReTw_custom_types.end(); iter++)
   {
   {
@@ -564,7 +573,7 @@ IGL_INLINE bool igl::ReTwBar::type_from_string(const char *type_str, TwType & ty
   return false;
   return false;
 }
 }
 
 
-bool igl::ReTwBar::set_value_from_string(
+bool igl::anttweakbar::ReTwBar::set_value_from_string(
   const char * name, 
   const char * name, 
   TwType type, 
   TwType type, 
   const char * value_str)
   const char * value_str)
@@ -912,13 +921,14 @@ bool igl::ReTwBar::set_value_from_string(
   return true;
   return true;
 }
 }
 
 
-IGL_INLINE const std::vector<igl::ReTwRWItem> & igl::ReTwBar::get_rw_items()
+IGL_INLINE const std::vector<igl::anttweakbar::ReTwRWItem> & 
+  igl::anttweakbar::ReTwBar::get_rw_items()
 {
 {
   return rw_items;
   return rw_items;
 }
 }
 
 
-IGL_INLINE const std::vector<igl::ReTwCBItem> & igl::ReTwBar::get_cb_items()
+IGL_INLINE const std::vector<igl::anttweakbar::ReTwCBItem> & 
+  igl::anttweakbar::ReTwBar::get_cb_items()
 {
 {
   return cb_items;
   return cb_items;
 }
 }
-#endif

+ 286 - 0
include/igl/anttweakbar/ReAntTweakBar.h

@@ -0,0 +1,286 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_ANTTWEAKBAR_REANTTWEAKBAR_H
+#define IGL_ANTTWEAKBAR_REANTTWEAKBAR_H
+#include "../igl_inline.h"
+// ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
+// "bars" to be saved and load from disk. Changing your existing app that uses
+// AntTweakBar to use ReAntTweakBar is trivial.
+// 
+// Many (but not all) variable types are supported. I'll try to keep track them
+// here:
+//   TW_TYPE_BOOLCPP
+//   TW_TYPE_QUAT4F
+//   TW_TYPE_QUAT4D
+//   TW_TYPE_COLOR4F
+//   TW_TYPE_COLOR4D
+//   TW_TYPE_COLOR3F
+//   TW_TYPE_DIR3F
+//   TW_TYPE_DIR3D
+//   TW_TYPE_BOOL32
+//   TW_TYPE_INT32
+//   TW_TYPE_UINT32
+//   TW_TYPE_FLOAT
+//   TW_TYPE_DOUBLE
+//   TW_TYPE_UINT8
+//   and
+//   custom TwTypes made with TwDefineEnum
+// 
+// I'm working on adding the rest on an as-needed basis. Adding a new type only
+// requires changes in a few places...
+// 
+//
+//
+
+// This allows the user to have a non-global, static installation of
+// AntTweakBar
+#include <AntTweakBar.h>
+// Instead of including AntTweakBar.h, just define the necessary types
+// Types used:
+//   - TwType
+//   - TwEnumVal
+//   - TwSetVarCallback
+//   - TwGetVarCallback
+//   - TwBar
+//   - TwButtonCallback
+
+
+#include <vector>
+#include <string>
+
+#define REANTTWEAKBAR_MAX_CB_VAR_SIZE 1000
+// Max line size for reading files
+#define REANTTWEAKBAR_MAX_LINE 1000
+#define REANTTWEAKBAR_MAX_WORD 100
+
+namespace igl
+{
+  namespace anttweakbar
+  {
+    TwType ReTwDefineEnum(
+      const char *name, 
+      const TwEnumVal *enumValues, 
+      unsigned int nbValues);
+    TwType ReTwDefineEnumFromString(const char * name,const char * enumString);
+    
+    struct ReTwRWItem
+    {
+      //const char * name;
+      std::string name;
+      TwType type;
+      void * var;
+      // Default constructor
+      IGL_INLINE ReTwRWItem(
+        const std::string _name,
+        TwType _type, 
+        void *_var):
+        name(_name),
+        type(_type),
+        var(_var)
+      {
+      }
+      // Shallow copy constructor
+      // I solemnly swear it's OK to copy var this way
+      // Q: Is it really?
+      IGL_INLINE ReTwRWItem(const ReTwRWItem & that):
+        name(that.name),
+        type(that.type),
+        var(that.var)
+      {
+      }
+      // Shallow assignment 
+      // I solemnly swear it's OK to copy var this way
+      IGL_INLINE ReTwRWItem & operator=(const ReTwRWItem & that)
+      {
+        if(this != &that)
+        {
+          this->name = that.name;
+          this->type = that.type;
+          this->var = that.var;
+        }
+        return *this;
+      }
+    };
+    
+    struct ReTwCBItem
+    {
+      //const char * name;
+      std::string name;
+      TwType type;
+      TwSetVarCallback setCallback;
+      TwGetVarCallback getCallback;
+      void * clientData;
+      // Default constructor
+      IGL_INLINE ReTwCBItem(
+        const std::string _name,
+        TwType _type, 
+        TwSetVarCallback _setCallback,
+        TwGetVarCallback _getCallback,
+        void * _clientData):
+        name(_name),
+        type(_type),
+        setCallback(_setCallback),
+        getCallback(_getCallback),
+        clientData(_clientData)
+      {
+      }
+      // Shallow copy
+      // I solemnly swear it's OK to copy clientData this way
+      IGL_INLINE ReTwCBItem(const ReTwCBItem & that):
+        name(that.name),
+        type(that.type),
+        setCallback(that.setCallback),
+        getCallback(that.getCallback),
+        clientData(that.clientData)
+      {
+      }
+      // Shallow assignment
+      // I solemnly swear it's OK to copy clientData this way
+      IGL_INLINE ReTwCBItem & operator=(const ReTwCBItem & that)
+      {
+        if(this != &that)
+        {
+          name = that.name;
+          type = that.type;
+          setCallback = that.setCallback;
+          getCallback = that.getCallback;
+          clientData = that.clientData;
+        }
+        return *this;
+      }
+  
+    };
+    
+    class ReTwBar
+    {
+      // VARIABLES
+      // Should be private, but seeing as I'm not going to implement all of the
+      // AntTweakBar public functions right away, I'll expose this so that at
+      // anytime AntTweakBar functions can be called directly on the bar
+      public:
+        TwBar * bar;
+        std::string name;
+      protected:
+        std::vector<ReTwRWItem> rw_items;
+        std::vector<ReTwCBItem> cb_items;
+      public:
+        // Default constructor with explicit initialization
+        IGL_INLINE ReTwBar();
+      private:
+        // Copy constructor does shallow copy
+        IGL_INLINE ReTwBar(const ReTwBar & that);
+        // Assignment operator does shallow assignment
+        IGL_INLINE ReTwBar &operator=(const ReTwBar & that);
+    
+      // WRAPPERS FOR ANTTWEAKBAR FUNCTIONS 
+      public:
+        IGL_INLINE void TwNewBar(const char *_name);
+        IGL_INLINE int TwAddVarRW(
+          const char *name, 
+          TwType type, 
+          void *var, 
+          const char *def,
+          const bool record=true);
+        IGL_INLINE int TwAddVarCB(
+          const char *name, 
+          TwType type, 
+          TwSetVarCallback setCallback, 
+          TwGetVarCallback getCallback, 
+          void *clientData, 
+          const char *def,
+          const bool record=true);
+        // Wrappers for convenience (not recorded, just passed on)
+        IGL_INLINE int TwAddVarRO(const char *name, TwType type, void *var, const char *def);
+        IGL_INLINE int TwAddButton(
+          const char *name, 
+          TwButtonCallback buttonCallback, 
+          void *clientData, 
+          const char *def);
+        IGL_INLINE int TwSetParam(
+          const char *varName, 
+          const char *paramName, 
+          TwParamValueType paramValueType, 
+          unsigned int inValueCount, 
+          const void *inValues);
+        IGL_INLINE int TwGetParam(
+          const char *varName, 
+          const char *paramName, 
+          TwParamValueType paramValueType, 
+          unsigned int outValueMaxCount, 
+          void *outValues);
+        IGL_INLINE int TwRefreshBar();
+        IGL_INLINE int TwTerminate();
+    
+    
+      // IO FUNCTIONS
+      public:
+        // Save current items to file
+        // Input:
+        //   file_name  name of file to save data to, can be null which means print
+        //   to stdout
+        // Return:
+        //   true only if there were no (fatal) errors
+        IGL_INLINE bool save(const char *file_name);
+        std::string get_value_as_string(
+          void * var, 
+          TwType type);
+        // Load into current items from file
+        // Input:
+        //   file_name  name of input file to load
+        // Return:
+        //   true only if there were no (fatal) errors
+        IGL_INLINE bool load(const char *file_name);
+        // Get TwType from string
+        // Input
+        //   type_str  string of type 
+        // Output
+        //   type  TwType converted from string
+        // Returns
+        //   true only if string matched a valid type
+        IGL_INLINE bool type_from_string(const char *type_str, TwType & type);
+        // I realize that I mix std::string and const char * all over the place.
+        // What can you do...
+        IGL_INLINE bool set_value_from_string(
+          const char * name, 
+          TwType type, 
+          const char * value_str);
+        IGL_INLINE const std::vector<ReTwRWItem> & get_rw_items();
+        IGL_INLINE const std::vector<ReTwCBItem> & get_cb_items();
+    };
+  }
+}
+
+// List of TwBar functions
+//TW_API TwBar *      TW_CALL TwNewBar(const char *barName);
+//TW_API int          TW_CALL TwDeleteBar(TwBar *bar);
+//TW_API int          TW_CALL TwDeleteAllBars();
+//TW_API int          TW_CALL TwSetTopBar(const TwBar *bar);
+//TW_API TwBar *      TW_CALL TwGetTopBar();
+//TW_API int          TW_CALL TwSetBottomBar(const TwBar *bar);
+//TW_API TwBar *      TW_CALL TwGetBottomBar();
+//TW_API const char * TW_CALL TwGetBarName(TwBar *bar);
+//TW_API int          TW_CALL TwGetBarCount();
+//TW_API TwBar *      TW_CALL TwGetBarByIndex(int barIndex);
+//TW_API TwBar *      TW_CALL TwGetBarByName(const char *barName);
+//TW_API int          TW_CALL TwRefreshBar(TwBar *bar);
+//TW_API int          TW_CALL TwTerminate();
+//
+//TW_API int      TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def);
+//TW_API int      TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def);
+//TW_API int      TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def);
+//TW_API int      TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def);
+//TW_API int      TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def);
+//TW_API int      TW_CALL TwRemoveVar(TwBar *bar, const char *name);
+//TW_API int      TW_CALL TwRemoveAllVars(TwBar *bar);
+
+// Until AntTweakBar dependency folder exists, this is header-only
+#ifndef IGL_STATIC_LIBRARY
+#  include "ReAntTweakBar.cpp"
+#endif
+
+#endif

+ 1 - 3
include/igl/cocoa_key_to_anttweakbar_key.cpp → include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp

@@ -6,11 +6,10 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "cocoa_key_to_anttweakbar_key.h"
 #include "cocoa_key_to_anttweakbar_key.h"
-#ifndef IGL_NO_ANTTWEAKBAR
 
 
 #include <AntTweakBar.h>
 #include <AntTweakBar.h>
 
 
-IGL_INLINE int igl::cocoa_key_to_anttweakbar_key(int key)
+IGL_INLINE int igl::anttweakbar::cocoa_key_to_anttweakbar_key(int key)
 {
 {
   // I've left commented the AntTweakBar key codes that correspond to keys I
   // I've left commented the AntTweakBar key codes that correspond to keys I
   // don't have on my keyboard. Please fill this in if you have those keys
   // don't have on my keyboard. Please fill this in if you have those keys
@@ -80,4 +79,3 @@ IGL_INLINE int igl::cocoa_key_to_anttweakbar_key(int key)
   }
   }
   return key;
   return key;
 }
 }
-#endif

+ 31 - 0
include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h

@@ -0,0 +1,31 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
+#define IGL_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
+#include "../igl_inline.h"
+
+
+namespace igl
+{
+  namespace anttweakbar
+  {
+    // Convert an unsigned char (like that from Cocoa apps) to AntTweakBar key
+    // code.
+    // See also: TranslateKey() in TwMgr.cpp in AntTweakBar source
+    // Inputs:
+    //   key  unsigned char key from keyboard
+    // Returns int of new key code 
+    IGL_INLINE int cocoa_key_to_anttweakbar_key(int key);
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "cocoa_key_to_anttweakbar_key.cpp"
+#endif
+
+#endif

+ 12 - 12
include/igl/svd3x3/arap.cpp → include/igl/arap.cpp

@@ -6,18 +6,18 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "arap.h"
 #include "arap.h"
-#include <igl/colon.h>
-#include <igl/cotmatrix.h>
-#include <igl/massmatrix.h>
-#include <igl/group_sum_matrix.h>
-#include <igl/covariance_scatter_matrix.h>
-#include <igl/speye.h>
-#include <igl/mode.h>
-#include <igl/project_isometrically_to_plane.h>
-#include <igl/slice.h>
-#include <igl/arap_rhs.h>
-#include <igl/repdiag.h>
-#include <igl/columnize.h>
+#include "colon.h"
+#include "cotmatrix.h"
+#include "massmatrix.h"
+#include "group_sum_matrix.h"
+#include "covariance_scatter_matrix.h"
+#include "speye.h"
+#include "mode.h"
+#include "project_isometrically_to_plane.h"
+#include "slice.h"
+#include "arap_rhs.h"
+#include "repdiag.h"
+#include "columnize.h"
 #include "fit_rotations.h"
 #include "fit_rotations.h"
 #include <cassert>
 #include <cassert>
 #include <iostream>
 #include <iostream>

+ 3 - 3
include/igl/svd3x3/arap.h → include/igl/arap.h

@@ -7,9 +7,9 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_ARAP_H
 #ifndef IGL_ARAP_H
 #define IGL_ARAP_H
 #define IGL_ARAP_H
-#include <igl/igl_inline.h>
-#include <igl/min_quad_with_fixed.h>
-#include <igl/ARAPEnergyType.h>
+#include "igl_inline.h"
+#include "min_quad_with_fixed.h"
+#include "ARAPEnergyType.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <Eigen/Sparse>
 #include <Eigen/Sparse>
 
 

+ 23 - 23
include/igl/svd3x3/arap_dof.cpp → include/igl/arap_dof.cpp

@@ -7,30 +7,30 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "arap_dof.h"
 #include "arap_dof.h"
 
 
-#include <igl/cotmatrix.h>
-#include <igl/massmatrix.h>
-#include <igl/speye.h>
-#include <igl/repdiag.h>
-#include <igl/repmat.h>
-#include <igl/slice.h>
-#include <igl/colon.h>
-#include <igl/full.h>
-#include <igl/is_sparse.h>
-#include <igl/mode.h>
-#include <igl/is_symmetric.h>
-#include <igl/group_sum_matrix.h>
-#include <igl/arap_rhs.h>
-#include <igl/covariance_scatter_matrix.h>
-#include <igl/svd3x3/fit_rotations.h>
-
-#include <igl/verbose.h>
-#include <igl/print_ijv.h>
-
-#include <igl/get_seconds_hires.h>
+#include "cotmatrix.h"
+#include "massmatrix.h"
+#include "speye.h"
+#include "repdiag.h"
+#include "repmat.h"
+#include "slice.h"
+#include "colon.h"
+#include "full.h"
+#include "is_sparse.h"
+#include "mode.h"
+#include "is_symmetric.h"
+#include "group_sum_matrix.h"
+#include "arap_rhs.h"
+#include "covariance_scatter_matrix.h"
+#include "fit_rotations.h"
+
+#include "verbose.h"
+#include "print_ijv.h"
+
+#include "get_seconds_hires.h"
 //#include "MKLEigenInterface.h"
 //#include "MKLEigenInterface.h"
-#include <igl/min_quad_dense.h>
-#include <igl/get_seconds.h>
-#include <igl/columnize.h>
+#include "min_quad_dense.h"
+#include "get_seconds.h"
+#include "columnize.h"
 
 
 // defined if no early exit is supported, i.e., always take a fixed number of iterations
 // defined if no early exit is supported, i.e., always take a fixed number of iterations
 #define IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
 #define IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT

+ 2 - 2
include/igl/svd3x3/arap_dof.h → include/igl/arap_dof.h

@@ -7,11 +7,11 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_ARAP_ENERGY_TYPE_DOF_H
 #ifndef IGL_ARAP_ENERGY_TYPE_DOF_H
 #define IGL_ARAP_ENERGY_TYPE_DOF_H
 #define IGL_ARAP_ENERGY_TYPE_DOF_H
-#include <igl/igl_inline.h>
+#include "igl_inline.h"
 
 
 #include <Eigen/Dense>
 #include <Eigen/Dense>
 #include <Eigen/Sparse>
 #include <Eigen/Sparse>
-#include <igl/ARAPEnergyType.h>
+#include "ARAPEnergyType.h"
 #include <vector>
 #include <vector>
 
 
 namespace igl
 namespace igl

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

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

+ 70 - 67
include/igl/bbw/bbw.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef BBW_H
-#define BBW_H
+#ifndef IGL_BBW_BBW_H
+#define IGL_BBW_BBW_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 
 
 #include <Eigen/Dense>
 #include <Eigen/Dense>
@@ -17,75 +17,78 @@
 
 
 namespace igl
 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
 #ifndef IGL_NO_MOSEK
-      igl::MosekData mosek_data;
+        igl::mosek::MosekData mosek_data;
 #endif
 #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
 #ifndef IGL_STATIC_LIBRARY

+ 0 - 0
include/igl/boost/bfs_orient.cpp → include/igl/bfs_orient.cpp


+ 0 - 0
include/igl/boost/bfs_orient.h → include/igl/bfs_orient.h


+ 117 - 0
include/igl/biharmonic_coordinates.cpp

@@ -0,0 +1,117 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "biharmonic_coordinates.h"
+#include "cotmatrix.h"
+#include "massmatrix.h"
+#include "min_quad_with_fixed.h"
+#include "normal_derivative.h"
+#include "on_boundary.h"
+#include <Eigen/Sparse>
+
+template <
+  typename DerivedV,
+  typename DerivedT,
+  typename SType,
+  typename DerivedW>
+IGL_INLINE bool igl::biharmonic_coordinates(
+  const Eigen::PlainObjectBase<DerivedV> & V,
+  const Eigen::PlainObjectBase<DerivedT> & T,
+  const std::vector<std::vector<SType> > & S,
+  Eigen::PlainObjectBase<DerivedW> & W)
+{
+  using namespace Eigen;
+  using namespace std;
+  // This is not the most efficient way to build A, but follows "Linear
+  // Subspace Design for Real-Time Shape Deformation" [Wang et al. 2015]. 
+  SparseMatrix<double> A;
+  {
+    SparseMatrix<double> N,Z,L,K,M;
+    normal_derivative(V,T,N);
+    Array<bool,Dynamic,1> I;
+    Array<bool,Dynamic,Dynamic> C;
+    on_boundary(T,I,C);
+    {
+      std::vector<Triplet<double> >ZIJV;
+      for(int t =0;t<T.rows();t++)
+      {
+        for(int f =0;f<T.cols();f++)
+        {
+          if(C(t,f))
+          {
+            const int i = t+f*T.rows();
+            for(int c = 1;c<T.cols();c++)
+            {
+              ZIJV.emplace_back(T(t,(f+c)%T.cols()),i,1);
+            }
+          }
+        }
+      }
+      Z.resize(V.rows(),N.rows());
+      Z.setFromTriplets(ZIJV.begin(),ZIJV.end());
+      N = (Z*N).eval();
+    }
+    cotmatrix(V,T,L);
+    K = N+L;
+    massmatrix(V,T,MASSMATRIX_TYPE_DEFAULT,M);
+    DiagonalMatrix<double,Dynamic> Minv = 
+      ((VectorXd)M.diagonal().array().inverse()).asDiagonal();
+    A = K.transpose() * (Minv * K);
+  }
+  // Vertices in point handles
+  const size_t mp = 
+    count_if(S.begin(),S.end(),[](const vector<int> & h){return h.size()==1;});
+  // number of region handles
+  const size_t r = S.size()-mp;
+  // Vertices in region handles
+  size_t mr = 0;
+  for(const auto & h : S)
+  {
+    if(h.size() > 1)
+    {
+      mr += h.size();
+    }
+  }
+  const size_t dim = T.cols()-1;
+  // Might as well be dense... I think...
+  MatrixXd J = MatrixXd::Zero(mp+mr,mp+r*(dim+1));
+  VectorXi b(mp+mr);
+  MatrixXd H(mp+r*(dim+1),dim);
+  {
+    int v = 0;
+    int c = 0;
+    for(int h = 0;h<S.size();h++)
+    {
+      if(S[h].size()==1)
+      {
+        H.row(c) = V.block(S[h][0],0,1,dim);
+        J(v,c++) = 1;
+        b(v) = S[h][0];
+        v++;
+      }else
+      {
+        assert(S[h].size() >= dim+1);
+        for(int p = 0;p<S[h].size();p++)
+        {
+          for(int d = 0;d<dim;d++)
+          {
+            J(v,c+d) = V(S[h][p],d);
+          }
+          J(v,c+dim) = 1;
+          b(v) = S[h][p];
+          v++;
+        }
+        H.block(c,0,dim+1,dim).setIdentity();
+        c+=dim+1;
+      }
+    }
+  }
+  // minimize    ½ W' A W' 
+  // subject to  W(b,:) = J
+  return min_quad_with_fixed(
+    A,VectorXd::Zero(A.rows()).eval(),b,J,{},VectorXd(),true,W);
+}

+ 77 - 0
include/igl/biharmonic_coordinates.h

@@ -0,0 +1,77 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BIHARMONIC_COORDINATES_H
+#define IGL_BIHARMONIC_COORDINATES_H
+#include "igl_inline.h"
+#include <Eigen/Dense>
+#include <vector>
+namespace igl
+{
+  // Compute "discrete biharmonic generalized barycentric coordinates" as
+  // described in "Linear Subspace Design for Real-Time Shape Deformation"
+  // [Wang et al. 2015]. Not to be confused with "Bounded Biharmonic Weights
+  // for Real-Time Deformation" [Jacobson et al. 2011] or "Biharmonic
+  // Coordinates" (2D complex barycentric coordinates) [Weber et al. 2012].
+  // These weights minimize a discrete version of the squared Laplacian energy
+  // subject to positional interpolation constraints at selected vertices
+  // (point handles) and transformation interpolation constraints at regions
+  // (region handles).
+  //
+  // Templates:
+  //   HType  should be a simple index type e.g. `int`,`size_t`
+  // Inputs:
+  //   V  #V by dim list of mesh vertex positions
+  //   T  #T by dim+1 list of / triangle indices into V      if dim=2
+  //                          \ tetrahedron indices into V   if dim=3
+  //   S  #point-handles+#region-handles list of lists of selected vertices for
+  //     each handle. Point handles should have singleton lists and region
+  //     handles should have lists of size at least dim+1 (and these points
+  //     should be in general position).
+  // Outputs:
+  //   W  #V by #points-handles+(#region-handles * dim+1) matrix of weights so
+  //     that columns correspond to each handles generalized barycentric
+  //     coordinates (for point-handles) or animation space weights (for region
+  //     handles).
+  // returns true only on success
+  //
+  // Example:
+  //
+  //     MatrixXd W;
+  //     igl::biharmonic_coordinates(V,F,S,W);
+  //     const size_t dim = T.cols()-1;
+  //     MatrixXd H(W.cols(),dim);
+  //     {
+  //       int c = 0;
+  //       for(int h = 0;h<S.size();h++)
+  //       {
+  //         if(S[h].size()==1)
+  //         {
+  //           H.row(c++) = V.block(S[h][0],0,1,dim);
+  //         }else
+  //         {
+  //           H.block(c,0,dim+1,dim).setIdentity();
+  //           c+=dim+1;
+  //         }
+  //       }
+  //     }
+  //     assert( (V-(W*H)).array().maxCoeff() < 1e-7 );
+  template <
+    typename DerivedV,
+    typename DerivedT,
+    typename SType,
+    typename DerivedW>
+  IGL_INLINE bool biharmonic_coordinates(
+    const Eigen::PlainObjectBase<DerivedV> & V,
+    const Eigen::PlainObjectBase<DerivedT> & T,
+    const std::vector<std::vector<SType> > & S,
+    Eigen::PlainObjectBase<DerivedW> & W);
+};
+#  ifndef IGL_STATIC_LIBRARY
+#    include "biharmonic_coordinates.cpp"
+#  endif
+#endif

+ 7 - 0
include/igl/bone_parents.cpp

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "bone_parents.h"
 #include "bone_parents.h"
 
 
 template <typename DerivedBE, typename DerivedP>
 template <typename DerivedBE, typename DerivedP>

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

@@ -1,17 +1,26 @@
-#ifndef MESH_BOOLEAN_TYPE_H
-#define MESH_BOOLEAN_TYPE_H
-
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BOOLEAN_MESH_BOOLEAN_TYPE_H
+#define IGL_BOOLEAN_MESH_BOOLEAN_TYPE_H
 namespace igl
 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
 #endif

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

@@ -1,10 +1,17 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include "from_cork_mesh.h"
 #include "from_cork_mesh.h"
 
 
 template <
 template <
   typename DerivedV,
   typename DerivedV,
   typename DerivedF>
   typename DerivedF>
-IGL_INLINE void igl::from_cork_mesh(
+IGL_INLINE void igl::boolean::from_cork_mesh(
   const CorkTriMesh & mesh,
   const CorkTriMesh & mesh,
   Eigen::PlainObjectBase<DerivedV > & V,
   Eigen::PlainObjectBase<DerivedV > & V,
   Eigen::PlainObjectBase<DerivedF > & F)
   Eigen::PlainObjectBase<DerivedF > & F)
@@ -30,8 +37,8 @@ IGL_INLINE void igl::from_cork_mesh(
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // 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
 
 
 #endif
 #endif

+ 26 - 16
include/igl/boolean/from_cork_mesh.h

@@ -1,25 +1,35 @@
-#ifndef IGL_FROM_CORK_MESH_H
-#define IGL_FROM_CORK_MESH_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BOOLEAN_FROM_CORK_MESH_H
+#define IGL_BOOLEAN_FROM_CORK_MESH_H
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <cork.h>
 #include <cork.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY
 #  include "from_cork_mesh.cpp"
 #  include "from_cork_mesh.cpp"

+ 24 - 5
include/igl/boolean/mesh_boolean.cpp

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "mesh_boolean.h"
 #include "mesh_boolean.h"
 #include <igl/per_face_normals.h>
 #include <igl/per_face_normals.h>
 #include <igl/cgal/peel_outer_hull_layers.h>
 #include <igl/cgal/peel_outer_hull_layers.h>
@@ -17,7 +24,7 @@ template <
   typename DerivedVC,
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedFC,
   typename DerivedJ>
   typename DerivedJ>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -44,7 +51,7 @@ template <
   typename DerivedFB,
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedVC,
   typename DerivedFC>
   typename DerivedFC>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -72,7 +79,7 @@ template <
   typename DerivedVC,
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedFC,
   typename DerivedJ>
   typename DerivedJ>
-IGL_INLINE void igl::mesh_boolean(
+IGL_INLINE void igl::boolean::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -92,6 +99,7 @@ IGL_INLINE void igl::mesh_boolean(
   using namespace Eigen;
   using namespace Eigen;
   using namespace std;
   using namespace std;
   using namespace igl;
   using namespace igl;
+  using namespace igl::cgal;
   MeshBooleanType eff_type = type;
   MeshBooleanType eff_type = type;
   // Concatenate A and B into a single mesh
   // Concatenate A and B into a single mesh
   typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
   typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
@@ -303,7 +311,18 @@ IGL_INLINE void igl::mesh_boolean(
 }
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
+// This is a hack to discuss
+#include <igl/remove_unreferenced.cpp>
+
+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::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::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
 // 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
 #endif

+ 92 - 77
include/igl/boolean/mesh_boolean.h

@@ -1,5 +1,12 @@
-#ifndef MESH_BOOLEAN_H
-#define MESH_BOOLEAN_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BOOLEAN_MESH_BOOLEAN_H
+#define IGL_BOOLEAN_MESH_BOOLEAN_H
 
 
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include "MeshBooleanType.h"
 #include "MeshBooleanType.h"
@@ -8,81 +15,89 @@
 
 
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include "mesh_boolean_cork.h"
 #include "mesh_boolean_cork.h"
 #include "to_cork_mesh.h"
 #include "to_cork_mesh.h"
@@ -10,7 +17,7 @@ template <
   typename DerivedFB,
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedVC,
   typename DerivedFC>
   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<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -87,8 +94,8 @@ IGL_INLINE void igl::mesh_boolean_cork(
 }
 }
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // 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
 
 
 #endif
 #endif

+ 38 - 28
include/igl/boolean/mesh_boolean_cork.h

@@ -1,5 +1,12 @@
-#ifndef MESH_BOOLEAN_CORK_H
-#define MESH_BOOLEAN_CORK_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BOOLEAN_MESH_BOOLEAN_CORK_H
+#define IGL_BOOLEAN_MESH_BOOLEAN_CORK_H
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include "MeshBooleanType.h"
 #include "MeshBooleanType.h"
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
@@ -8,32 +15,35 @@
 
 
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

@@ -1,9 +1,16 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include "to_cork_mesh.h"
 #include "to_cork_mesh.h"
 template <
 template <
   typename DerivedV,
   typename DerivedV,
   typename DerivedF>
   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<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedF > & F,
   CorkTriMesh & mesh)
   CorkTriMesh & mesh)
@@ -32,7 +39,7 @@ IGL_INLINE void igl::to_cork_mesh(
 }
 }
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // 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
 #endif
 #endif

+ 26 - 16
include/igl/boolean/to_cork_mesh.h

@@ -1,25 +1,35 @@
-#ifndef IGL_TO_CORK_MESH_H
-#define IGL_TO_CORK_MESH_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_BOOLEAN_TO_CORK_MESH_H
+#define IGL_BOOLEAN_TO_CORK_MESH_H
 #ifndef IGL_NO_CORK
 #ifndef IGL_NO_CORK
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <cork.h>
 #include <cork.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY
 #  include "to_cork_mesh.cpp"
 #  include "to_cork_mesh.cpp"

+ 0 - 56
include/igl/boost/components.cpp

@@ -1,56 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "components.h"
-#include <igl/adjacency_matrix.h>
-
-//#include <boost/graph/adjacency_matrix.hpp>
-#include <boost/graph/adjacency_list.hpp>
-#include <boost/graph/connected_components.hpp>
-#include <iostream>
-#include <vector>
-#include <cassert>
-
-template <typename AScalar, typename DerivedC>
-IGL_INLINE void igl::components(
-  const Eigen::SparseMatrix<AScalar> & A,
-  Eigen::PlainObjectBase<DerivedC> & C)
-{
-  assert(A.rows() == A.cols());
-  using namespace Eigen;
-  // THIS IS DENSE:
-  //boost::adjacency_matrix<boost::undirectedS> bA(A.rows());
-  boost::adjacency_list<boost::vecS,boost::vecS,boost::undirectedS> bA(A.rows());
-  for(int j=0; j<A.outerSize();j++)
-  {
-    // Iterate over inside
-    for(typename SparseMatrix<AScalar>::InnerIterator it (A,j); it; ++it)
-    {
-      if(0 != it.value())
-      {
-        boost::add_edge(it.row(),it.col(),bA);
-      }
-    }
-  }
-  C.resize(A.rows(),1);
-  boost::connected_components(bA,C.data());
-}
-
-template <typename DerivedF, typename DerivedC>
-IGL_INLINE void igl::components(
-  const Eigen::PlainObjectBase<DerivedF> & F,
-  Eigen::PlainObjectBase<DerivedC> & C)
-{
-  Eigen::SparseMatrix<typename DerivedC::Scalar> A;
-  igl::adjacency_matrix(F,A);
-  return components(A,C);
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-template void igl::components<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-#endif

+ 12 - 9
include/igl/cgal/RemeshSelfIntersectionsParam.h

@@ -5,19 +5,22 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_REMESH_SELF_INTERSECTIONS_PARAM_H
-#define IGL_REMESH_SELF_INTERSECTIONS_PARAM_H
+#ifndef IGL_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H
+#define IGL_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H
 
 
 namespace igl
 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
 #endif

+ 213 - 210
include/igl/cgal/SelfIntersectMesh.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_SELFINTERSECTMESH_H
-#define IGL_SELFINTERSECTMESH_H
+#ifndef IGL_CGAL_SELFINTERSECTMESH_H
+#define IGL_CGAL_SELFINTERSECTMESH_H
 
 
 #include "CGAL_includes.hpp"
 #include "CGAL_includes.hpp"
 #include "RemeshSelfIntersectionsParam.h"
 #include "RemeshSelfIntersectionsParam.h"
@@ -25,204 +25,207 @@
 
 
 namespace igl
 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 
       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
 // Implementation
@@ -274,7 +277,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -299,7 +302,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline igl::SelfIntersectMesh<
+inline igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -668,7 +671,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -716,7 +719,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -747,7 +750,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -786,7 +789,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -832,7 +835,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -913,7 +916,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline bool igl::SelfIntersectMesh<
+inline bool igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -993,7 +996,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -1147,7 +1150,7 @@ template <
   typename DerivedIF,
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedJ,
   typename DerivedIM>
   typename DerivedIM>
-inline void igl::SelfIntersectMesh<
+inline void igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -1223,7 +1226,7 @@ template <
   typename DerivedIM>
   typename DerivedIM>
 inline 
 inline 
 void 
 void 
-igl::SelfIntersectMesh<
+igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,
@@ -1249,7 +1252,7 @@ template <
   typename DerivedIM>
   typename DerivedIM>
 inline 
 inline 
 void 
 void 
-igl::SelfIntersectMesh<
+igl::cgal::SelfIntersectMesh<
   Kernel,
   Kernel,
   DerivedV,
   DerivedV,
   DerivedF,
   DerivedF,

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

@@ -16,7 +16,7 @@
 #include <stack>
 #include <stack>
 
 
 template <typename Tr, typename DerivedV, typename DerivedF>
 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,
   const CGAL::Complex_2_in_triangulation_3<Tr> & c2t3,
   Eigen::PlainObjectBase<DerivedV> & V, 
   Eigen::PlainObjectBase<DerivedV> & V, 
   Eigen::PlainObjectBase<DerivedF> & F)
   Eigen::PlainObjectBase<DerivedF> & F)
@@ -147,5 +147,5 @@ IGL_INLINE bool igl::complex_to_mesh(
 }
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 #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
 #endif

+ 22 - 19
include/igl/cgal/complex_to_mesh.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COMPLEX_TO_MESH_H
-#define IGL_COMPLEX_TO_MESH_H
+#ifndef IGL_CGAL_COMPLEX_TO_MESH_H
+#define IGL_CGAL_COMPLEX_TO_MESH_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 
 
 #include <Eigen/Dense>
 #include <Eigen/Dense>
@@ -14,23 +14,26 @@
 
 
 namespace igl 
 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
 #ifndef IGL_STATIC_LIBRARY

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

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

+ 28 - 25
include/igl/cgal/intersect_other.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_INTERSECT_OTHER_H
-#define IGL_INTERSECT_OTHER_H
+#ifndef IGL_CGAL_INTERSECT_OTHER_H
+#define IGL_CGAL_INTERSECT_OTHER_H
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 
 
 #include <Eigen/Dense>
 #include <Eigen/Dense>
@@ -20,29 +20,32 @@
 
 
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

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

+ 23 - 20
include/igl/cgal/mesh_to_cgal_triangle_list.h

@@ -5,31 +5,34 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_MESH_TO_CGAL_TRIANGLE_LIST_H
-#define IGL_MESH_TO_CGAL_TRIANGLE_LIST_H
+#ifndef IGL_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H
+#define IGL_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include "CGAL_includes.hpp"
 #include "CGAL_includes.hpp"
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY
 #  include "mesh_to_cgal_triangle_list.cpp"
 #  include "mesh_to_cgal_triangle_list.cpp"

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

@@ -11,7 +11,7 @@
 
 
 
 
 template <typename Polyhedron>
 template <typename Polyhedron>
-IGL_INLINE bool igl::mesh_to_polyhedron(
+IGL_INLINE bool igl::cgal::mesh_to_polyhedron(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   const Eigen::MatrixXi & F,
   Polyhedron & poly)
   Polyhedron & poly)
@@ -50,5 +50,5 @@ IGL_INLINE bool igl::mesh_to_polyhedron(
 // Explicit template instanciation
 // Explicit template instanciation
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.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
 #endif

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

@@ -5,29 +5,32 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_MESH_TO_POLYHEDRON_H
-#define IGL_MESH_TO_POLYHEDRON_H
+#ifndef IGL_CGAL_MESH_TO_POLYHEDRON_H
+#define IGL_CGAL_MESH_TO_POLYHEDRON_H
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY
 #  include "mesh_to_polyhedron.cpp"
 #  include "mesh_to_polyhedron.cpp"

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

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "order_facets_around_edges.h"
 #include "order_facets_around_edges.h"
 #include "../sort_angles.h"
 #include "../sort_angles.h"
 #include <type_traits>
 #include <type_traits>
@@ -16,7 +23,7 @@ template<
 IGL_INLINE
 IGL_INLINE
 typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
 typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
 typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
 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<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,
         const Eigen::PlainObjectBase<DerivedN>& N,
@@ -160,7 +167,7 @@ template<
 IGL_INLINE 
 IGL_INLINE 
 typename std::enable_if<std::is_same<typename DerivedV::Scalar,
 typename std::enable_if<std::is_same<typename DerivedV::Scalar,
 typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
 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<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,
         const Eigen::PlainObjectBase<DerivedN>& N,

+ 14 - 4
include/igl/cgal/order_facets_around_edges.h

@@ -1,11 +1,20 @@
-#ifndef ORDER_FACETS_AROUND_EDGES
-#define ORDER_FACETS_AROUND_EDGES
-
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
+#define IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
 
-namespace igl {
+namespace igl
+{
+  namespace cgal
+  {
     // For each undirected edge, sort its adjacent faces.
     // For each undirected edge, sort its adjacent faces.
     //
     //
     // Inputs:
     // Inputs:
@@ -70,6 +79,7 @@ namespace igl {
             const std::vector<std::vector<uE2EType> >& uE2E,
             const std::vector<std::vector<uE2EType> >& uE2E,
             std::vector<std::vector<uE2oEType> >& uE2oE,
             std::vector<std::vector<uE2oEType> >& uE2oE,
             std::vector<std::vector<uE2CType > >& uE2C );
             std::vector<std::vector<uE2CType > >& uE2C );
+  }
 }
 }
 
 
 #ifndef IGL_STATIC_LIBRARY
 #ifndef IGL_STATIC_LIBRARY

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

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "outer_hull.h"
 #include "outer_hull.h"
 #include "order_facets_around_edges.h"
 #include "order_facets_around_edges.h"
 #include "../outer_facet.h"
 #include "../outer_facet.h"
@@ -27,7 +34,7 @@ template <
   typename DerivedG,
   typename DerivedG,
   typename DerivedJ,
   typename DerivedJ,
   typename Derivedflip>
   typename Derivedflip>
-IGL_INLINE void igl::outer_hull(
+IGL_INLINE void igl::cgal::outer_hull(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedN> & N,
   const Eigen::PlainObjectBase<DerivedN> & N,
@@ -512,7 +519,7 @@ template <
   typename DerivedG,
   typename DerivedG,
   typename DerivedJ,
   typename DerivedJ,
   typename Derivedflip>
   typename Derivedflip>
-IGL_INLINE void igl::outer_hull(
+IGL_INLINE void igl::cgal::outer_hull(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   const Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedG> & G,
   Eigen::PlainObjectBase<DerivedG> & G,
@@ -532,7 +539,7 @@ IGL_INLINE void igl::outer_hull(
 #include <igl/outer_facet.cpp>
 #include <igl/outer_facet.cpp>
 #include <igl/cgal/order_facets_around_edges.cpp>
 #include <igl/cgal/order_facets_around_edges.cpp>
 #define IGL_STATIC_LIBRARY
 #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
 #endif

+ 56 - 46
include/igl/cgal/outer_hull.h

@@ -1,53 +1,63 @@
-#ifndef IGL_OUTER_HULL_H
-#define IGL_OUTER_HULL_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_CGAL_OUTER_HULL_H
+#define IGL_CGAL_OUTER_HULL_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "peel_outer_hull_layers.h"
 #include "peel_outer_hull_layers.h"
 #include "../per_face_normals.h"
 #include "../per_face_normals.h"
 #include "outer_hull.h"
 #include "outer_hull.h"
@@ -17,7 +24,7 @@ template <
   typename DerivedN,
   typename DerivedN,
   typename Derivedodd,
   typename Derivedodd,
   typename Derivedflip>
   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<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedN > & N,
   const Eigen::PlainObjectBase<DerivedN > & N,
@@ -113,7 +120,7 @@ template <
   typename DerivedF,
   typename DerivedF,
   typename Derivedodd,
   typename Derivedodd,
   typename Derivedflip>
   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<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedF > & F,
   Eigen::PlainObjectBase<Derivedodd > & odd,
   Eigen::PlainObjectBase<Derivedodd > & odd,
@@ -127,6 +134,6 @@ IGL_INLINE size_t igl::peel_outer_hull_layers(
 
 
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // 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
 #endif

+ 48 - 38
include/igl/cgal/peel_outer_hull_layers.h

@@ -1,45 +1,55 @@
-#ifndef IGL_PEEL_OUTER_HULL_LAYERS_H
-#define IGL_PEEL_OUTER_HULL_LAYERS_H
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
+#define IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

@@ -9,7 +9,7 @@
 #include <CGAL/Polyhedron_3.h>
 #include <CGAL/Polyhedron_3.h>
 
 
 template <typename Polyhedron>
 template <typename Polyhedron>
-IGL_INLINE void igl::polyhedron_to_mesh(
+IGL_INLINE void igl::cgal::polyhedron_to_mesh(
   const Polyhedron & poly,
   const Polyhedron & poly,
   Eigen::MatrixXd & V,
   Eigen::MatrixXd & V,
   Eigen::MatrixXi & F)
   Eigen::MatrixXi & F)
@@ -60,5 +60,5 @@ IGL_INLINE void igl::polyhedron_to_mesh(
 // Explicit template instanciation
 // Explicit template instanciation
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Simple_cartesian.h>
 #include <CGAL/Polyhedron_items_with_id_3.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
 #endif

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

@@ -5,27 +5,30 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_POLYHEDRON_TO_MESH_H
-#define IGL_POLYHEDRON_TO_MESH_H
+#ifndef IGL_CGAL_POLYHEDRON_TO_MESH_H
+#define IGL_CGAL_POLYHEDRON_TO_MESH_H
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <Eigen/Core>
 #include <Eigen/Core>
 
 
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY
 #  include "polyhedron_to_mesh.cpp"
 #  include "polyhedron_to_mesh.cpp"

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

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

+ 57 - 54
include/igl/cgal/remesh_self_intersections.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_REMESH_SELF_INTERSECTIONS_H
-#define IGL_REMESH_SELF_INTERSECTIONS_H
+#ifndef IGL_CGAL_REMESH_SELF_INTERSECTIONS_H
+#define IGL_CGAL_REMESH_SELF_INTERSECTIONS_H
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include "RemeshSelfIntersectionsParam.h"
 #include "RemeshSelfIntersectionsParam.h"
 
 
@@ -21,58 +21,61 @@
   
   
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

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

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

+ 31 - 28
include/igl/cgal/signed_distance_isosurface.h

@@ -5,39 +5,42 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_SIGNED_DISTANCE_ISOSURFACE_H
-#define IGL_SIGNED_DISTANCE_ISOSURFACE_H
+#ifndef IGL_CGAL_SIGNED_DISTANCE_ISOSURFACE_H
+#define IGL_CGAL_SIGNED_DISTANCE_ISOSURFACE_H
 #include "../igl_inline.h"
 #include "../igl_inline.h"
 #include "../signed_distance.h"
 #include "../signed_distance.h"
 #include <Eigen/Core>
 #include <Eigen/Core>
 namespace igl
 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
 #ifndef IGL_STATIC_LIBRARY

+ 0 - 30
include/igl/cocoa_key_to_anttweakbar_key.h

@@ -1,30 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
-#define IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
-#ifndef IGL_NO_ANTTWEAKBAR
-#include "igl_inline.h"
-
-
-namespace igl
-{
-  // Convert an unsigned char (like that from Cocoa apps) to AntTweakBar key
-  // code.
-  // See also: TranslateKey() in TwMgr.cpp in AntTweakBar source
-  // Inputs:
-  //   key  unsigned char key from keyboard
-  // Returns int of new key code 
-  IGL_INLINE int cocoa_key_to_anttweakbar_key(int key);
-}
-
-//#ifndef IGL_STATIC_LIBRARY
-#  include "cocoa_key_to_anttweakbar_key.cpp"
-//#endif
-
-#endif
-#endif

+ 7 - 0
include/igl/collapse_small_triangles.cpp

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "collapse_small_triangles.h"
 #include "collapse_small_triangles.h"
 
 
 #include "bounding_box_diagonal.h"
 #include "bounding_box_diagonal.h"

+ 4 - 2
include/igl/colon.cpp

@@ -42,11 +42,13 @@ IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> igl::colon(
 #ifdef IGL_STATIC_LIBRARY
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // Explicit template specialization
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
-template Eigen::Matrix<int, -1, 1, 0, -1, 1> igl::colon<int, int, int>(int, int);
+template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,int>(int, int);
+template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,long>(int,long);
+template Eigen::Matrix<int,-1,1,0,-1,1> igl::colon<int,int,long long int>(int,long long int);
 // generated by autoexplicit.sh
 // generated by autoexplicit.sh
-template Eigen::Matrix<int, -1, 1, 0, -1, 1> igl::colon<int, int, long>(int, long);
 template void igl::colon<int, long, int, int>(int, long, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, long, int, int>(int, long, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, int, long, int>(int, int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, int, long, int>(int, int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, long, int>(int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, long, int>(int, long, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, int, int>(int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
 template void igl::colon<int, int, int>(int, int, Eigen::Matrix<int, -1, 1, 0, -1, 1>&);
+template void igl::colon<int,long long int,int>(int,long long int,Eigen::Matrix<int,-1,1,0,-1,1> &);
 #endif
 #endif

+ 5 - 0
include/igl/comb_frame_field.cpp

@@ -6,6 +6,11 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
 
 
+#ifdef WIN32
+  #define _USE_MATH_DEFINES
+#endif
+#include <cmath>
+
 #include "comb_frame_field.h"
 #include "comb_frame_field.h"
 #include "local_basis.h"
 #include "local_basis.h"
 
 

+ 12 - 6
include/igl/comiso/frame_field.cpp

@@ -1,3 +1,10 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@gmail.com>
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
 #include "frame_field.h"
 #include "frame_field.h"
 
 
 #include <igl/triangle_triangle_adjacency.h>
 #include <igl/triangle_triangle_adjacency.h>
@@ -8,6 +15,8 @@
 
 
 namespace igl
 namespace igl
 {
 {
+namespace comiso
+{
 
 
 class FrameInterpolator
 class FrameInterpolator
 {
 {
@@ -93,9 +102,6 @@ private:
 
 
 };
 };
 
 
-
-
-
 FrameInterpolator::FrameInterpolator(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
 FrameInterpolator::FrameInterpolator(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
 {
 {
   using namespace std;
   using namespace std;
@@ -223,7 +229,7 @@ void FrameInterpolator::interpolateCross()
   b.conservativeResize(num,Eigen::NoChange);
   b.conservativeResize(num,Eigen::NoChange);
   bc.conservativeResize(num,Eigen::NoChange);
   bc.conservativeResize(num,Eigen::NoChange);
 
 
-  igl::nrosy(V, F, b, bc, 4, R, S);
+  igl::comiso::nrosy(V, F, b, bc, 4, R, S);
   //olga:end
   //olga:end
   assert(R.rows() == F.rows());
   assert(R.rows() == F.rows());
 
 
@@ -641,10 +647,10 @@ Eigen::MatrixXd FrameInterpolator::getFieldPerFace()
   P = svd.matrixV() * svd.singularValues().asDiagonal() * svd.matrixV().transpose();
   P = svd.matrixV() * svd.singularValues().asDiagonal() * svd.matrixV().transpose();
 }
 }
 
 
+}
 }
 }
 
 
-
-IGL_INLINE void igl::frame_field(
+IGL_INLINE void igl::comiso::frame_field(
                                  const Eigen::MatrixXd& V,
                                  const Eigen::MatrixXd& V,
                                  const Eigen::MatrixXi& F,
                                  const Eigen::MatrixXi& F,
                                  const Eigen::VectorXi& b,
                                  const Eigen::VectorXi& b,

+ 5 - 2
include/igl/comiso/frame_field.h

@@ -5,8 +5,8 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License
 // This Source Code Form is subject to the terms of the Mozilla Public License
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_FRAMEFIELD_H
-#define IGL_FRAMEFIELD_H
+#ifndef IGL_COMISO_FRAMEFIELD_H
+#define IGL_COMISO_FRAMEFIELD_H
 
 
 #include <igl/igl_inline.h>
 #include <igl/igl_inline.h>
 #include <Eigen/Dense>
 #include <Eigen/Dense>
@@ -14,6 +14,8 @@
 
 
 namespace igl
 namespace igl
 {
 {
+namespace comiso
+{
 // Generate a piecewise-constant frame-field field from a sparse set of constraints on faces
 // Generate a piecewise-constant frame-field field from a sparse set of constraints on faces
 // using the algorithm proposed in:
 // using the algorithm proposed in:
 // Frame Fields: Anisotropic and Non-Orthogonal Cross Fields
 // Frame Fields: Anisotropic and Non-Orthogonal Cross Fields
@@ -42,6 +44,7 @@ IGL_INLINE void frame_field(
   Eigen::MatrixXd& FF2
   Eigen::MatrixXd& FF2
   );
   );
 }
 }
+}
 
 
 #ifndef IGL_STATIC_LIBRARY
 #ifndef IGL_STATIC_LIBRARY
 #  include "frame_field.cpp"
 #  include "frame_field.cpp"

部分文件因为文件数量过多而无法显示