Преглед на файлове

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

Conflicts:
	include/igl/embree/ambient_occlusion.cpp
	include/igl/embree/line_mesh_intersection.cpp
	include/igl/png/render_to_png.cpp
	include/igl/polar_svd.cpp
	include/igl/unproject.cpp
	include/igl/viewer/ViewerCore.cpp
	include/igl/xml/serialize_xml.cpp
	tutorial/cmake/FindSVD3X3.cmake
	tutorial/cmake/FindYIMG.cmake

Former-commit-id: 93b83791416e0e5fc30c6706f92e71a6d6a2e8f7
Olga Diamanti преди 10 години
родител
ревизия
609a219371
променени са 100 файла, в които са добавени 2722 реда и са изтрити 2073 реда
  1. 4 0
      .gitmodules
  2. 12 1
      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. 24 22
      examples/intersections/example.cpp
  20. 1 1
      examples/mode/example.cpp
  21. 12 12
      examples/multi-viewport/example.cpp
  22. 32 32
      examples/patches/example.cpp
  23. 21 21
      examples/randomly-sample-mesh/example.cpp
  24. 2 2
      examples/render_to_png/example.cpp
  25. 20 20
      examples/rotate-widget/example.cpp
  26. 21 21
      examples/scene-rotation/example.cpp
  27. 22 25
      examples/shadow-mapping/example.cpp
  28. 41 41
      examples/skeleton-builder/example.cpp
  29. 18 18
      examples/skeleton-poser/example.cpp
  30. 29 29
      examples/skeleton/example.cpp
  31. 0 23
      examples/svd/Makefile
  32. 0 97
      examples/svd/example.cpp
  33. 23 23
      examples/textured-mesh/example.cpp
  34. 12 13
      examples/transparency/example.cpp
  35. 4 7
      include/igl/AABB.h
  36. 372 0
      include/igl/ConjugateFFSolverData.h
  37. 0 285
      include/igl/ReAntTweakBar.h
  38. 128 0
      include/igl/Singular_Value_Decomposition_Givens_QR_Factorization_Kernel.hpp
  39. 118 0
      include/igl/Singular_Value_Decomposition_Jacobi_Conjugation_Kernel.hpp
  40. 137 0
      include/igl/Singular_Value_Decomposition_Kernel_Declarations.hpp
  41. 1 0
      include/igl/Singular_Value_Decomposition_Main_Kernel_Body.hpp.REMOVED.git-id
  42. 67 0
      include/igl/Singular_Value_Decomposition_Preamble.hpp
  43. 0 51
      include/igl/angles.cpp
  44. 0 47
      include/igl/angles.h
  45. 36 26
      include/igl/anttweakbar/ReAntTweakBar.cpp
  46. 286 0
      include/igl/anttweakbar/ReAntTweakBar.h
  47. 1 3
      include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.cpp
  48. 31 0
      include/igl/anttweakbar/cocoa_key_to_anttweakbar_key.h
  49. 12 12
      include/igl/arap.cpp
  50. 3 3
      include/igl/arap.h
  51. 23 23
      include/igl/arap_dof.cpp
  52. 2 2
      include/igl/arap_dof.h
  53. 5 5
      include/igl/bbw/bbw.cpp
  54. 70 67
      include/igl/bbw/bbw.h
  55. 0 0
      include/igl/bfs_orient.cpp
  56. 0 0
      include/igl/bfs_orient.h
  57. 13 11
      include/igl/boolean/MeshBooleanType.h
  58. 3 3
      include/igl/boolean/from_cork_mesh.cpp
  59. 19 16
      include/igl/boolean/from_cork_mesh.h
  60. 8 7
      include/igl/boolean/mesh_boolean.cpp
  61. 85 77
      include/igl/boolean/mesh_boolean.h
  62. 3 3
      include/igl/boolean/mesh_boolean_cork.cpp
  63. 31 28
      include/igl/boolean/mesh_boolean_cork.h
  64. 3 3
      include/igl/boolean/to_cork_mesh.cpp
  65. 19 16
      include/igl/boolean/to_cork_mesh.h
  66. 0 56
      include/igl/boost/components.cpp
  67. 12 9
      include/igl/cgal/RemeshSelfIntersectionsParam.h
  68. 213 210
      include/igl/cgal/SelfIntersectMesh.h
  69. 2 2
      include/igl/cgal/complex_to_mesh.cpp
  70. 22 19
      include/igl/cgal/complex_to_mesh.h
  71. 1 1
      include/igl/cgal/intersect_other.cpp
  72. 28 25
      include/igl/cgal/intersect_other.h
  73. 5 5
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp
  74. 23 20
      include/igl/cgal/mesh_to_cgal_triangle_list.h
  75. 2 2
      include/igl/cgal/mesh_to_polyhedron.cpp
  76. 21 18
      include/igl/cgal/mesh_to_polyhedron.h
  77. 2 2
      include/igl/cgal/order_facets_around_edges.cpp
  78. 7 4
      include/igl/cgal/order_facets_around_edges.h
  79. 5 5
      include/igl/cgal/outer_hull.cpp
  80. 49 46
      include/igl/cgal/outer_hull.h
  81. 4 4
      include/igl/cgal/peel_outer_hull_layers.cpp
  82. 41 38
      include/igl/cgal/peel_outer_hull_layers.h
  83. 2 2
      include/igl/cgal/polyhedron_to_mesh.cpp
  84. 19 16
      include/igl/cgal/polyhedron_to_mesh.h
  85. 6 4
      include/igl/cgal/remesh_self_intersections.cpp
  86. 57 54
      include/igl/cgal/remesh_self_intersections.h
  87. 2 2
      include/igl/cgal/signed_distance_isosurface.cpp
  88. 31 28
      include/igl/cgal/signed_distance_isosurface.h
  89. 0 30
      include/igl/cocoa_key_to_anttweakbar_key.h
  90. 4 2
      include/igl/colon.cpp
  91. 5 0
      include/igl/comb_frame_field.cpp
  92. 10 11
      include/igl/comiso/frame_field.cpp
  93. 5 2
      include/igl/comiso/frame_field.h
  94. 1 1
      include/igl/comiso/miq.cpp.REMOVED.git-id
  95. 80 76
      include/igl/comiso/miq.h
  96. 39 36
      include/igl/comiso/nrosy.cpp
  97. 45 44
      include/igl/comiso/nrosy.h
  98. 8 4
      include/igl/compile_and_link_program.cpp
  99. 8 4
      include/igl/compile_and_link_program.h
  100. 8 4
      include/igl/compile_shader.cpp

+ 4 - 0
.gitmodules

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

+ 12 - 1
README.md

@@ -84,6 +84,14 @@ libigl depends only on the [Eigen](http://eigen.tuxfamily.org) library.
 
 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
 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,
@@ -100,7 +108,7 @@ You can keep up to date by cloning a read-only copy of our GitHub
 [repository](https://github.com/libigl).
 
 ## 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
 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:
@@ -148,6 +156,9 @@ BibTeX entry:
 ```
 
 ## 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.
  - Columbia University, [Columbia Computer Graphics Group](http://www.cs.columbia.edu/cg/), USA

+ 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
 --------|----------------------------------------------------------------------
+1.2.0   | Reorganization of "extras", rm deprecated funcs, absorb boost & svd3x3
 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.5   | Bug fix in booleans
@@ -13,6 +23,63 @@ Version | Short description
 1.0.2   | Bug fix in winding number code
 1.0.1   | Bug fixes and more CGAL support
 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 ##
 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.
    This mirrors the behavior of `igl::polar_svd3x3`.  Consequently the `T`
    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
    of a per-vertex scalar function has been replaced. Now `igl::grad` computes
    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
    mesh _A_ in the normal direction and found the closest intersection along
    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

@@ -212,9 +212,7 @@ ifndef EIGEN3_INC
 	EIGEN3_INC=-I$(DEFAULT_PREFIX)/include/eigen3 -I$(DEFAULT_PREFIX)/include/eigen3/unsupported
 endif
 
-ifndef LIBIGL
-	LIBIGL=$(THIS_DIR)/../
-endif
+LIBIGL=$(THIS_DIR)/../
 LIBIGL_INC=-I$(LIBIGL)/include
 
 ifndef ANTTWEAKBAR_INC
@@ -222,7 +220,7 @@ ifndef ANTTWEAKBAR_INC
 endif
 ifndef ANTTWEAKBAR_LIB
 	# 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
 
 ifndef SINGULAR_VALUE_DECOMPOSITION_INC

+ 1 - 1
examples/MatlabWorkspace/example.cpp

@@ -24,7 +24,7 @@ int main(int argc, char * argv[])
   }
   MatrixXd M;
   readDMAT(argv[1],M);
-  MatlabWorkspace mat;
+  igl::matlab::MatlabWorkspace mat;
   mat.save(M,"M");
   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 <stdio.h>
@@ -75,7 +74,7 @@ float g_MatDiffuse[] = { 1.0f, 1.0f, 0.0f, 1.0f };
 double g_LightMultiplier = 1.0f;
 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
 // ( 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
     TwEnumVal shapeEV[NUM_SHAPES] = { {SHAPE_TEAPOT, "Teapot"}, {SHAPE_TORUS, "Torus"}, {SHAPE_CONE, "Cone"} , {SHAPE_SPHERE, "Sphere"}};
     // 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 [>].
     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/barycenter.h>
 #include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/pathinfo.h>
 #include <igl/embree/EmbreeIntersector.h>
 #include <igl/embree/ambient_occlusion.h>
@@ -50,12 +50,12 @@ Eigen::MatrixXd V,N,C,mid;
 Eigen::MatrixXi F;
 // Bounding box diagonal length
 double bbd;
-igl::EmbreeIntersector ei;
+igl::embree::EmbreeIntersector ei;
 // Running ambient occlusion
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 #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;
 Eigen::Vector4f color(0.4,0.8,0.3,1.0);
 double ao_factor = 1.0;
@@ -156,7 +156,7 @@ void display()
     }
     VectorXd Si;
     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 += Si*(double)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/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/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_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/report_gl_error.h>
-#include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.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_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__
 #  include <GLUT/glut.h>
@@ -141,7 +141,7 @@ int selected_col = 0;
 double bbd;
 int tot_num_samples = 0;
 #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)
 {
@@ -708,7 +708,8 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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/readOFF.h>
 #include <igl/readMESH.h>
-#include <igl/tetgen/mesh_with_skeleton.h>
 #include <igl/faces_first.h>
 #include <igl/readTGF.h>
 #include <igl/launch_medit.h>
 #include <igl/boundary_conditions.h>
-#include <igl/bbw/bbw.h>
 #include <igl/writeDMAT.h>
 #include <igl/writeMESH.h>
 #include <igl/normalize_row_sums.h>
+#include <igl/bbw/bbw.h>
+#include <igl/tetgen/mesh_with_skeleton.h>
 
 #include <Eigen/Dense>
 
@@ -231,7 +231,7 @@ int main(int argc, char * argv[])
   MatrixXi TT;
   // New surface faces 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;
   }
@@ -255,12 +255,12 @@ int main(int argc, char * argv[])
 
   // compute BBW 
   // 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
   MatrixXd W;
-  if(!bbw(VV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(VV,TT,b,bc,bbw_data,W))
   {
     return 1;
   }

+ 6 - 4
examples/camera/example.cpp

@@ -3,7 +3,7 @@
 #include <igl/Camera.h>
 #include <igl/matlab_format.h>
 #include <igl/report_gl_error.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/trackball.h>
 #include <igl/two_axis_valuator_fixed_up.h>
 #include <igl/PI.h>
@@ -64,7 +64,7 @@ enum CenterType
 
 int width,height;
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 struct State
 {
   std::vector<igl::Camera> cameras;
@@ -666,10 +666,12 @@ int main(int argc, char * argv[])
   // Create a tweak bar
   rebar.TwNewBar("bar");
   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,
     "keyIncr=] keyDecr=[");
-  TwType CenterTypeTW = ReTwDefineEnumFromString("CenterType","orbit,fps");
+  TwType CenterTypeTW = igl::anttweakbar::ReTwDefineEnumFromString(
+      "CenterType","orbit,fps");
   rebar.TwAddVarRW("center_type", CenterTypeTW,&center_type,
     "keyIncr={ keyDecr=}");
   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/barycenter.h>
 #include <igl/matlab_format.h>
-#include <igl/ReAntTweakBar.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 #include <igl/pathinfo.h>
 #include <igl/Camera.h>
 #include <igl/get_seconds.h>
@@ -129,7 +129,7 @@ double bbd;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 #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)
 {
@@ -567,7 +567,7 @@ int main(int argc, char * argv[])
     s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
   s.camera.push_away(3);
   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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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/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/jet.h>
-#include <igl/rgb_to_hsv.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/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/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/Geometry>
@@ -108,7 +108,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 // Forward
 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'");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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,
     "keyIncr={ keyDecr=}");
 

+ 11 - 11
examples/embree/example.cpp

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

+ 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/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/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/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/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/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/Geometry>
@@ -96,7 +96,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 bool is_animating = false;
 double animation_start_time = 0;
@@ -695,7 +695,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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>
-using namespace igl;
+#include <cstdio>
 #include <cmath>
-using namespace std;
 
 int main(int argc, char * argv[])
 {
+  using namespace igl;
+  using namespace std;
   double start = get_seconds();
   printf("start: %lgs\n",start);
   double lap = start;

+ 24 - 22
examples/intersections/example.cpp

@@ -1,31 +1,31 @@
+#include <igl/Camera.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_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/report_gl_error.h>
-#include <igl/readOBJ.h>
-#include <igl/writeOBJ.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.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_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/intersect_other.h>
 
@@ -138,7 +138,7 @@ double bbd;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 #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)
 {
@@ -477,6 +477,7 @@ void color_selfintersections(
   Eigen::MatrixXd & C)
 {
   using namespace igl;
+  using namespace igl::cgal;
   using namespace Eigen;
   using namespace std;
   MatrixXd SV;
@@ -506,6 +507,7 @@ void color_intersections(
   Eigen::MatrixXd & D)
 {
   using namespace igl;
+  using namespace igl::cgal;
   using namespace Eigen;
   MatrixXi IF;
   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.push_away(3);
   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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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
+#include <igl/mode.h>
 #include <Eigen/Core>
 #include <iostream>
-#include <igl/mode.h>
 
 using namespace std;
 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/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/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/trackball.h>
+#include <igl/read_triangle_mesh.h>
 #include <igl/report_gl_error.h>
-#include <igl/canonical_quaternions.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/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__
 #  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/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/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/boost/components.h>
-#include <igl/boost/bfs_orient.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/C_STR.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.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/Geometry>
@@ -121,7 +121,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 // Forward
 void init_patches();
@@ -578,7 +578,7 @@ void init_patches()
     case ORIENT_METHOD_AO:
     {
       cout<<"orient_outward_ao()"<<endl;
-      reorient_facets_raycast(V,F,F,I);
+      igl::embree::reorient_facets_raycast(V,F,F,I);
       break;
     }
     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'");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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,
     "keyIncr={ keyDecr=}");
-  TwType OrientMethodTW = ReTwDefineEnumFromString("OrientMethod",
+  TwType OrientMethodTW = igl::anttweakbar::ReTwDefineEnumFromString("OrientMethod",
     "outward,ambient-occlusion");
   rebar.TwAddVarCB( "orient_method", OrientMethodTW,
     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/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.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/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_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/Geometry>
@@ -88,7 +88,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 void push_undo()
 {
@@ -589,7 +589,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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/png/render_to_png.h>
 #include <igl/material_colors.h>
+#include <igl/png/render_to_png.h>
 
 #ifdef __APPLE__
 #   include <GLUT/glut.h>
@@ -94,7 +94,7 @@ void Display(void)
   {
     stringstream padnum; 
     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;
   }
   

+ 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/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/readOFF.h>
 #include <igl/readTGF.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/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/Geometry>
@@ -94,7 +94,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 void push_undo()
 {
@@ -616,7 +616,7 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");

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

@@ -3,29 +3,29 @@
 
 #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/pathinfo.h>
+#include <igl/draw_mesh.h>
+#include <igl/get_seconds.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/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_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/Geometry>
@@ -101,7 +101,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 void push_undo()
 {
@@ -662,11 +662,11 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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,
     "keyIncr={ keyDecr=}");
   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
 //
 
-#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/ReAntTweakBar.h>
+#include <igl/draw_floor.h>
+#include <igl/draw_mesh.h>
 #include <igl/get_seconds.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/boost/components.h>
-#include <igl/boost/bfs_orient.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/C_STR.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.h>
 #include <igl/write_triangle_mesh.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 #include <Eigen/Core>
 #include <Eigen/Geometry>
@@ -203,7 +200,7 @@ bool is_view_from_light = false;
 Eigen::Vector4f light_pos(9,9,1,1);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 // Forward
 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'");
   rebar.TwAddVarRW("camera_zoom", TW_TYPE_DOUBLE,&s.camera.zoom,"");
   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,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   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/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/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_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/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/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/adjacency_list.h>
-#include <igl/adjacency_matrix.h>
+#include <igl/report_gl_error.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/REDRUM.h>
+#include <igl/unproject.h>
+#include <igl/writeOBJ.h>
+#include <igl/writeOFF.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/Geometry>
@@ -127,8 +127,8 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
-igl::EmbreeIntersector ei;
+igl::anttweakbar::ReTwBar rebar;
+igl::embree::EmbreeIntersector ei;
 
 void push_undo()
 {
@@ -668,7 +668,7 @@ void mouse_drag(int mouse_x, int mouse_y)
       s.C.conservativeResize(s.C.rows()+2,3);
       const int nc = s.C.rows();
       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)
       {
         Vector3d pV_mid = project(Vcen);
@@ -688,7 +688,7 @@ void mouse_drag(int mouse_x, int mouse_y)
     }
     double z = 0;
     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);
     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 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)
         {
           s.C.row(c) = obj;
@@ -1148,13 +1148,13 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   rebar.TwAddVarRW("alpha",TW_TYPE_DOUBLE,&alpha,

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

@@ -1,15 +1,12 @@
 #include <igl/Camera.h>
 #include <igl/MouseController.h>
 #include <igl/REDRUM.h>
-#include <igl/ReAntTweakBar.h>
 #include <igl/STR.h>
 #include <igl/barycenter.h>
-#include <igl/bbw/bbw.h>
 #include <igl/bone_parents.h>
 #include <igl/boundary_conditions.h>
 #include <igl/boundary_facets.h>
 #include <igl/centroid.h>
-#include <igl/cgal/remesh_self_intersections.h>
 #include <igl/colon.h>
 #include <igl/draw_beach_ball.h>
 #include <igl/draw_floor.h>
@@ -20,6 +17,7 @@
 #include <igl/get_seconds.h>
 #include <igl/lbs_matrix.h>
 #include <igl/material_colors.h>
+#include <igl/next_filename.h>
 #include <igl/normalize_row_sums.h>
 #include <igl/pathinfo.h>
 #include <igl/per_face_normals.h>
@@ -31,18 +29,20 @@
 #include <igl/report_gl_error.h>
 #include <igl/snap_to_canonical_view_quat.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/two_axis_valuator_fixed_up.h>
+#include <igl/volume.h>
 #include <igl/winding_number.h>
 #include <igl/writeDMAT.h>
-#include <igl/writeOBJ.h>
 #include <igl/writeMESH.h>
+#include <igl/writeOBJ.h>
 #include <igl/writeOFF.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/Geometry>
@@ -144,7 +144,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 void push_undo()
 {
@@ -770,7 +770,7 @@ bool clean(
 #ifdef VERBOSE
     cout<<"remesh_self_intersections"<<endl;
 #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);});
     MatrixXd oldCV = CV;
     MatrixXi oldCF = CF;
@@ -786,7 +786,7 @@ bool clean(
 #ifdef VERBOSE
     cout<<"tetrahedralize"<<endl;
 #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;
       return false;
@@ -843,7 +843,7 @@ bool robust_weights(
 #ifdef VERBOSE
     cout<<"mesh_with_skeleton"<<endl;
 #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;
       return false;
@@ -879,17 +879,17 @@ bool robust_weights(
   }
   // compute BBW
   // Default bbw data and flags
-  BBWData bbw_data;
+  igl::bbw::BBWData bbw_data;
   bbw_data.verbosity = 1;
 #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;
 #else
   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
   // Weights matrix
-  if(!bbw(TV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(TV,TT,b,bc,bbw_data,W))
   {
     return false;
   }
@@ -996,14 +996,14 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
   rebar.TwAddVarRW("centroid_is_visible", TW_TYPE_BOOLCPP,&centroid_is_visible,
     "keyIncr=C keyDecr=c label='centroid visible?'");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"");
   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_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/readOFF.h>
 #include <igl/readTGF.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/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/tetgen/mesh_with_skeleton.h>
 
 #include <Eigen/Core>
 #include <Eigen/Geometry>
@@ -106,7 +106,7 @@ int width,height;
 Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
 
 #define REBAR_NAME "temp.rbr"
-igl::ReTwBar rebar;
+igl::anttweakbar::ReTwBar rebar;
 
 void push_undo()
 {
@@ -556,7 +556,7 @@ bool init_weights(
   MatrixXd VV;
   MatrixXi TT,FF,CE;
   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;
   }
@@ -571,10 +571,10 @@ bool init_weights(
 
   // compute BBW
   // Default bbw data and flags
-  BBWData bbw_data;
+  igl::bbw::BBWData bbw_data;
   bbw_data.active_set_params.max_iter = 4;
   // Weights matrix
-  if(!bbw(VV,TT,b,bc,bbw_data,W))
+  if(!igl::bbw::bbw(VV,TT,b,bc,bbw_data,W))
   {
     return false;
   }
@@ -691,13 +691,13 @@ int main(int argc, char * argv[])
   rebar.TwNewBar("TweakBar");
   rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
     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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
   rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
   rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
-  TwType SkelStyleTypeTW = ReTwDefineEnumFromString("SkelStyleType",
+  TwType SkelStyleTypeTW = igl::anttweakbar::ReTwDefineEnumFromString("SkelStyleType",
     "3d,vector-graphics");
   rebar.TwAddVarRW("style",SkelStyleTypeTW,&skel_style,"key=s");
   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/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_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/report_gl_error.h>
-#include <igl/readOBJ.h>
 #include <igl/readDMAT.h>
-#include <igl/readOFF.h>
 #include <igl/readMESH.h>
-#include <igl/jet.h>
+#include <igl/readOBJ.h>
+#include <igl/readOFF.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_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/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_png.h>
-#include <igl/STR.h>
+
 #include <YImage.hpp>
 
 #ifdef __APPLE__
@@ -135,7 +135,7 @@ double bbd;
 Eigen::VectorXd S;
 int tot_num_samples = 0;
 #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 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.push_away(3);
   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");
   rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
     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
-  if(!texture_from_file(tfilename,tex_id))
+  if(!igl::png::texture_from_file(tfilename,tex_id))
   {
     return 1;
   }

+ 12 - 13
examples/transparency/example.cpp

@@ -1,23 +1,22 @@
+#include <igl/EPS.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/jet.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/trackball.h>
+#include <igl/read_triangle_mesh.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/ReAntTweakBar.h>
-#include <igl/EPS.h>
-#define IGL_HEADER_ONLY
+#include <igl/slice.h>
 #include <igl/sort_triangles.h>
+#include <igl/trackball.h>
+#include <igl/unproject.h>
+#include <igl/anttweakbar/ReAntTweakBar.h>
 
 #ifdef __APPLE__
 #  include <GLUT/glut.h>
@@ -50,7 +49,7 @@ Eigen::MatrixXi F,sorted_F;
 double alpha = 0.2;
 
 #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)
 {

+ 4 - 7
include/igl/AABB.h

@@ -259,14 +259,13 @@ private:
         int & i,
         RowVectorDIMS & c) const;
 public:
-      template <int SS>
       static
       inline void barycentric_coordinates(
         const RowVectorDIMS & p, 
         const RowVectorDIMS & a, 
         const RowVectorDIMS & b, 
         const RowVectorDIMS & c,
-        Eigen::Matrix<Scalar,1,SS> & bary);
+        Eigen::Matrix<Scalar,1,3> & bary);
 public:
       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);
 
   return 0;
-#if false
+#if 0 // False
 
   // _Very_ conservative approximation of maximum squared distance between
   // 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 <int SS>
 inline void
 igl::AABB<DerivedV,DIM>::barycentric_coordinates(
   const RowVectorDIMS & p, 
   const RowVectorDIMS & a, 
   const RowVectorDIMS & b, 
   const RowVectorDIMS & c,
-  Eigen::Matrix<Scalar,1,SS> & bary)
+  Eigen::Matrix<Scalar,1,3> & bary)
 {
-  assert(SS==3);
   // http://gamedev.stackexchange.com/a/23745
   const RowVectorDIMS v0 = b - a;
   const RowVectorDIMS v1 = c - a;
@@ -1137,6 +1134,6 @@ igl::AABB<DerivedV,DIM>::barycentric_coordinates(
   bary(1) = (d11 * d20 - d01 * d21) / denom;
   bary(2) = (d00 * d21 - d01 * d20) / denom;
   bary(0) = 1.0f - bary(1) - bary(2);
-};
+}
 
 #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
+
+

+ 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 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "ReAntTweakBar.h"
-#ifndef IGL_NO_ANTTWEAKBAR
 
 #include <cstdio>
 #include <cstring>
@@ -18,10 +17,12 @@
 // GLOBAL WRAPPERS
 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 TwEnumVal *enumValues, 
   unsigned int nbValues)
@@ -42,7 +43,7 @@ IGL_INLINE TwType igl::ReTwDefineEnum(
   return type;
 }
 
-IGL_INLINE TwType igl::ReTwDefineEnumFromString(
+IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnumFromString(
   const char * _Name,
   const char * _EnumString)
 {
@@ -82,7 +83,10 @@ IGL_INLINE TwType igl::ReTwDefineEnumFromString(
         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;
   }
 }
@@ -124,14 +128,15 @@ namespace
   };
 }
 
-IGL_INLINE igl::ReTwBar::ReTwBar():
+IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar():
  bar(NULL),
   name(),
   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),
   name(that.name),
   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
   if(this != &that)
@@ -153,7 +159,7 @@ IGL_INLINE igl::ReTwBar & igl::ReTwBar::operator=(const igl::ReTwBar & that)
 
 
 // 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);
   // 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";
 }
 
-IGL_INLINE int igl::ReTwBar::TwAddVarRW(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRW(
   const char *name, 
   TwType type, 
   void *var, 
@@ -178,7 +184,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarRW(
   return ret;
 }
 
-IGL_INLINE int igl::ReTwBar::TwAddVarCB(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarCB(
   const char *name, 
   TwType type, 
   TwSetVarCallback setCallback, 
@@ -196,7 +202,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarCB(
   return ret;
 }
 
-IGL_INLINE int igl::ReTwBar::TwAddVarRO(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRO(
   const char *name, 
   TwType type, 
   void *var, 
@@ -211,7 +217,7 @@ IGL_INLINE int igl::ReTwBar::TwAddVarRO(
   return ret;
 }
 
-IGL_INLINE int igl::ReTwBar::TwAddButton(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddButton(
   const char *name, 
   TwButtonCallback buttonCallback, 
   void *clientData, 
@@ -227,7 +233,7 @@ IGL_INLINE int igl::ReTwBar::TwAddButton(
   return ret;
 }
 
-IGL_INLINE int igl::ReTwBar::TwSetParam(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwSetParam(
   const char *varName, 
   const char *paramName, 
   TwParamValueType paramValueType, 
@@ -245,7 +251,7 @@ IGL_INLINE int igl::ReTwBar::TwSetParam(
       inValues);
 }
 
-IGL_INLINE int igl::ReTwBar::TwGetParam(
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwGetParam(
   const char *varName, 
   const char *paramName, 
   TwParamValueType paramValueType, 
@@ -262,12 +268,12 @@ IGL_INLINE int igl::ReTwBar::TwGetParam(
       outValues);
 }
 
-IGL_INLINE int igl::ReTwBar::TwRefreshBar()
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwRefreshBar()
 {
   return ::TwRefreshBar(this->bar);
 }
 
-IGL_INLINE int igl::ReTwBar::TwTerminate()
+IGL_INLINE int igl::anttweakbar::ReTwBar::TwTerminate()
 {
   //std::cout<<"TwTerminate"<<std::endl;
   int r = ::TwTerminate();
@@ -275,7 +281,7 @@ IGL_INLINE int igl::ReTwBar::TwTerminate()
   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;
   if(file_name == NULL)
@@ -338,7 +344,7 @@ IGL_INLINE bool igl::ReTwBar::save(const char *file_name)
   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, 
   TwType type)
 {
@@ -476,7 +482,7 @@ IGL_INLINE std::string igl::ReTwBar::get_value_as_string(
   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;
   fp = fopen(file_name,"r");
@@ -537,7 +543,8 @@ IGL_INLINE bool igl::ReTwBar::load(const char *file_name)
   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
   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
-  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();
   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;
 }
 
-bool igl::ReTwBar::set_value_from_string(
+bool igl::anttweakbar::ReTwBar::set_value_from_string(
   const char * name, 
   TwType type, 
   const char * value_str)
@@ -912,13 +921,14 @@ bool igl::ReTwBar::set_value_from_string(
   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;
 }
 
-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;
 }
-#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 
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "cocoa_key_to_anttweakbar_key.h"
-#ifndef IGL_NO_ANTTWEAKBAR
 
 #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
   // 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;
 }
-#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
 // obtain one at http://mozilla.org/MPL/2.0/.
 #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 <cassert>
 #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/.
 #ifndef 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/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/.
 #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 <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
 #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/.
 #ifndef 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/Sparse>
-#include <igl/ARAPEnergyType.h>
+#include "ARAPEnergyType.h"
 #include <vector>
 
 namespace igl

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

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

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

+ 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


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

@@ -5,20 +5,22 @@
 // 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 MESH_BOOLEAN_TYPE_H
-#define MESH_BOOLEAN_TYPE_H
-
+#ifndef IGL_BOOLEAN_MESH_BOOLEAN_TYPE_H
+#define IGL_BOOLEAN_MESH_BOOLEAN_TYPE_H
 namespace igl
 {
-  enum MeshBooleanType
+  namespace boolean
   {
-    MESH_BOOLEAN_TYPE_UNION = 0,
-    MESH_BOOLEAN_TYPE_INTERSECT = 1,
-    MESH_BOOLEAN_TYPE_MINUS = 2,
-    MESH_BOOLEAN_TYPE_XOR = 3,
-    MESH_BOOLEAN_TYPE_RESOLVE = 4,
-    NUM_MESH_BOOLEAN_TYPES = 5
-  };
+    enum MeshBooleanType
+    {
+      MESH_BOOLEAN_TYPE_UNION = 0,
+      MESH_BOOLEAN_TYPE_INTERSECT = 1,
+      MESH_BOOLEAN_TYPE_MINUS = 2,
+      MESH_BOOLEAN_TYPE_XOR = 3,
+      MESH_BOOLEAN_TYPE_RESOLVE = 4,
+      NUM_MESH_BOOLEAN_TYPES = 5
+    };
+  }
 };
 
 #endif

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

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

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

@@ -5,28 +5,31 @@
 // 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_FROM_CORK_MESH_H
-#define IGL_FROM_CORK_MESH_H
+#ifndef IGL_BOOLEAN_FROM_CORK_MESH_H
+#define IGL_BOOLEAN_FROM_CORK_MESH_H
 #ifndef IGL_NO_CORK
 #include <igl/igl_inline.h>
 #include <cork.h>
 #include <Eigen/Core>
 namespace igl
 {
-  // Convert cork's triangle mesh representation to a (V,F) mesh.
-  //
-  // Inputs:
-  //   mesh  cork representation of mesh
-  // Outputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  template <
-    typename DerivedV,
-    typename DerivedF>
-  IGL_INLINE void from_cork_mesh(
-    const CorkTriMesh & mesh,
-    Eigen::PlainObjectBase<DerivedV > & V,
-    Eigen::PlainObjectBase<DerivedF > & F);
+  namespace boolean
+  {
+    // Convert cork's triangle mesh representation to a (V,F) mesh.
+    //
+    // Inputs:
+    //   mesh  cork representation of mesh
+    // Outputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    template <
+      typename DerivedV,
+      typename DerivedF>
+    IGL_INLINE void from_cork_mesh(
+      const CorkTriMesh & mesh,
+      Eigen::PlainObjectBase<DerivedV > & V,
+      Eigen::PlainObjectBase<DerivedF > & F);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "from_cork_mesh.cpp"

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

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

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

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

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

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

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

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

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

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

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

@@ -5,28 +5,31 @@
 // 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_TO_CORK_MESH_H
-#define IGL_TO_CORK_MESH_H
+#ifndef IGL_BOOLEAN_TO_CORK_MESH_H
+#define IGL_BOOLEAN_TO_CORK_MESH_H
 #ifndef IGL_NO_CORK
 #include <igl/igl_inline.h>
 #include <cork.h>
 #include <Eigen/Core>
 namespace igl
 {
-  // Convert a (V,F) mesh to a cork's triangle mesh representation.
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  // Outputs:
-  //   mesh  cork representation of mesh
-  template <
-    typename DerivedV,
-    typename DerivedF>
-  IGL_INLINE void to_cork_mesh(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    CorkTriMesh & mesh);
+  namespace boolean
+  {
+    // Convert a (V,F) mesh to a cork's triangle mesh representation.
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    // Outputs:
+    //   mesh  cork representation of mesh
+    template <
+      typename DerivedV,
+      typename DerivedF>
+    IGL_INLINE void to_cork_mesh(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      CorkTriMesh & mesh);
+  }
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "to_cork_mesh.cpp"

+ 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 
 // 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_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
 {
-  // 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -5,14 +5,16 @@
 // 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 ORDER_FACETS_AROUND_EDGES
-#define ORDER_FACETS_AROUND_EDGES
-
+#ifndef IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
+#define IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
 #include "../igl_inline.h"
 #include <Eigen/Core>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
-namespace igl {
+namespace igl
+{
+  namespace cgal
+  {
     // For each undirected edge, sort its adjacent faces.
     //
     // Inputs:
@@ -77,6 +79,7 @@ namespace igl {
             const std::vector<std::vector<uE2EType> >& uE2E,
             std::vector<std::vector<uE2oEType> >& uE2oE,
             std::vector<std::vector<uE2CType > >& uE2C );
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

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

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

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

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

@@ -24,7 +24,7 @@ template <
   typename DerivedN,
   typename Derivedodd,
   typename Derivedflip>
-IGL_INLINE size_t igl::peel_outer_hull_layers(
+IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   const Eigen::PlainObjectBase<DerivedN > & N,
@@ -120,7 +120,7 @@ template <
   typename DerivedF,
   typename Derivedodd,
   typename Derivedflip>
-IGL_INLINE size_t igl::peel_outer_hull_layers(
+IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   Eigen::PlainObjectBase<Derivedodd > & odd,
@@ -134,6 +134,6 @@ IGL_INLINE size_t igl::peel_outer_hull_layers(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template size_t igl::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
-template size_t igl::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template size_t igl::cgal::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
+template size_t igl::cgal::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<bool, -1, 1, 0, -1, 1>, Eigen::Matrix<bool, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<bool, -1, 1, 0, -1, 1> >&);
 #endif

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

@@ -5,48 +5,51 @@
 // 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_PEEL_OUTER_HULL_LAYERS_H
-#define IGL_PEEL_OUTER_HULL_LAYERS_H
+#ifndef IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
+#define IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
 #include "../igl_inline.h"
 #include <Eigen/Core>
 namespace igl
 {
-  // Computes necessary generic information for boolean operations by
-  // successively "peeling" off the "outer hull" of a mesh (V,F) resulting from
-  // "resolving" all (self-)intersections.
-  //
-  // Inputs:
-  //   V  #V by 3 list of vertex positions
-  //   F  #F by 3 list of triangle indices into V
-  //   N  #F by 3 list of per-face normals
-  // Outputs:
-  //   odd  #F list of whether facet belongs to an odd iteration peel (otherwise
-  //     an even iteration peel)
-  //   flip  #F list of whether a facet's orientation was flipped when facet
-  //     "peeled" into its associated outer hull layer.
-  // Returns number of peels
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename DerivedN,
-    typename Derivedodd,
-    typename Derivedflip>
-  IGL_INLINE size_t peel_outer_hull_layers(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    const Eigen::PlainObjectBase<DerivedN > & N,
-    Eigen::PlainObjectBase<Derivedodd > & odd,
-    Eigen::PlainObjectBase<Derivedflip > & flip);
-  template <
-    typename DerivedV,
-    typename DerivedF,
-    typename Derivedodd,
-    typename Derivedflip>
-  IGL_INLINE size_t peel_outer_hull_layers(
-    const Eigen::PlainObjectBase<DerivedV > & V,
-    const Eigen::PlainObjectBase<DerivedF > & F,
-    Eigen::PlainObjectBase<Derivedodd > & odd,
-    Eigen::PlainObjectBase<Derivedflip > & flip);
+  namespace cgal
+  {
+    // Computes necessary generic information for boolean operations by
+    // successively "peeling" off the "outer hull" of a mesh (V,F) resulting from
+    // "resolving" all (self-)intersections.
+    //
+    // Inputs:
+    //   V  #V by 3 list of vertex positions
+    //   F  #F by 3 list of triangle indices into V
+    //   N  #F by 3 list of per-face normals
+    // Outputs:
+    //   odd  #F list of whether facet belongs to an odd iteration peel (otherwise
+    //     an even iteration peel)
+    //   flip  #F list of whether a facet's orientation was flipped when facet
+    //     "peeled" into its associated outer hull layer.
+    // Returns number of peels
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename DerivedN,
+      typename Derivedodd,
+      typename Derivedflip>
+    IGL_INLINE size_t peel_outer_hull_layers(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      const Eigen::PlainObjectBase<DerivedN > & N,
+      Eigen::PlainObjectBase<Derivedodd > & odd,
+      Eigen::PlainObjectBase<Derivedflip > & flip);
+    template <
+      typename DerivedV,
+      typename DerivedF,
+      typename Derivedodd,
+      typename Derivedflip>
+    IGL_INLINE size_t peel_outer_hull_layers(
+      const Eigen::PlainObjectBase<DerivedV > & V,
+      const Eigen::PlainObjectBase<DerivedF > & F,
+      Eigen::PlainObjectBase<Derivedodd > & odd,
+      Eigen::PlainObjectBase<Derivedflip > & flip);
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

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

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

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

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

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

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

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

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

+ 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

+ 4 - 2
include/igl/colon.cpp

@@ -42,11 +42,13 @@ IGL_INLINE Eigen::Matrix<T,Eigen::Dynamic,1> igl::colon(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 // 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
-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, 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, 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

+ 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
 // obtain one at http://mozilla.org/MPL/2.0/.
 
+#ifdef WIN32
+  #define _USE_MATH_DEFINES
+#endif
+#include <cmath>
+
 #include "comb_frame_field.h"
 #include "local_basis.h"
 

+ 10 - 11
include/igl/comiso/frame_field.cpp

@@ -1,9 +1,9 @@
 // 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 
+//
+// 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"
 
@@ -15,6 +15,8 @@
 
 namespace igl
 {
+namespace comiso
+{
 
 class FrameInterpolator
 {
@@ -100,9 +102,6 @@ private:
 
 };
 
-
-
-
 FrameInterpolator::FrameInterpolator(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
 {
   using namespace std;
@@ -230,7 +229,7 @@ void FrameInterpolator::interpolateCross()
   b.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
   assert(R.rows() == F.rows());
 
@@ -648,10 +647,10 @@ Eigen::MatrixXd FrameInterpolator::getFieldPerFace()
   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::MatrixXi& F,
                                  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
 // 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_FRAMEFIELD_H
-#define IGL_FRAMEFIELD_H
+#ifndef IGL_COMISO_FRAMEFIELD_H
+#define IGL_COMISO_FRAMEFIELD_H
 
 #include <igl/igl_inline.h>
 #include <Eigen/Dense>
@@ -14,6 +14,8 @@
 
 namespace igl
 {
+namespace comiso
+{
 // Generate a piecewise-constant frame-field field from a sparse set of constraints on faces
 // using the algorithm proposed in:
 // Frame Fields: Anisotropic and Non-Orthogonal Cross Fields
@@ -42,6 +44,7 @@ IGL_INLINE void frame_field(
   Eigen::MatrixXd& FF2
   );
 }
+}
 
 #ifndef IGL_STATIC_LIBRARY
 #  include "frame_field.cpp"

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

@@ -1 +1 @@
-b8c177f12c7c718591018aa69a0fa939242647b1
+6ac6a3c6a26d8ec8e1cc351df0b57a5080fa766d

+ 80 - 76
include/igl/comiso/miq.h

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

+ 39 - 36
include/igl/comiso/nrosy.cpp

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

+ 45 - 44
include/igl/comiso/nrosy.h

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

+ 8 - 4
include/igl/compile_and_link_program.cpp

@@ -1,9 +1,9 @@
 // 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 
+//
+// 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 "compile_and_link_program.h"
 #include "compile_shader.h"
@@ -11,6 +11,8 @@
 #include <iostream>
 #include <cassert>
 
+#ifndef IGL_NO_OPENGL
+
 IGL_INLINE GLuint igl::compile_and_link_program(
   const char * v_str, const char * f_str)
 {
@@ -38,3 +40,5 @@ IGL_INLINE GLuint igl::compile_and_link_program(
   }
   return prog_id;
 }
+
+#endif

+ 8 - 4
include/igl/compile_and_link_program.h

@@ -1,9 +1,9 @@
 // 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 
+//
+// 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_COMPILE_AND_LINK_PROGRAM_H
 #define IGL_COMPILE_AND_LINK_PROGRAM_H
@@ -11,6 +11,8 @@
 #include "OpenGL_convenience.h"
 namespace igl
 {
+  #ifndef IGL_NO_OPENGL
+
   // Compile and link very simple vertex/fragment shaders
   //
   // Inputs:
@@ -22,6 +24,8 @@ namespace igl
   // functionality.
   IGL_INLINE GLuint compile_and_link_program(
     const char * v_str, const char * f_str);
+
+  #endif
 }
 #ifndef IGL_STATIC_LIBRARY
 #  include "compile_and_link_program.cpp"

+ 8 - 4
include/igl/compile_shader.cpp

@@ -1,14 +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 
+//
+// 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 "compile_shader.h"
 #include "report_gl_error.h"
 #include <iostream>
 
+#ifndef IGL_NO_OPENGL
+
 IGL_INLINE GLuint igl::compile_shader(const GLint type, const char * str)
 {
   GLuint id = glCreateShader(type);
@@ -33,3 +35,5 @@ IGL_INLINE GLuint igl::compile_shader(const GLint type, const char * str)
   }
   return id;
 }
+
+#endif

Някои файлове не бяха показани, защото твърде много файлове са промени