Переглянути джерело

mv cgal and boolean to copyleft

Former-commit-id: e69b4bb07f6d8a4efe73a7780c8048061b01b991
Alec Jacobson 9 роки тому
батько
коміт
731792aeda
92 змінених файлів з 2727 додано та 2618 видалено
  1. 0 182
      include/igl/boolean/CSGTree.h
  2. 0 26
      include/igl/boolean/MeshBooleanType.h
  3. 0 38
      include/igl/boolean/from_cork_mesh.h
  4. 0 54
      include/igl/boolean/mesh_boolean_cork.h
  5. 0 41
      include/igl/boolean/string_to_mesh_boolean_type.h
  6. 0 38
      include/igl/boolean/to_cork_mesh.h
  7. 0 28
      include/igl/cgal/RemeshSelfIntersectionsParam.h
  8. 0 34
      include/igl/cgal/assign_scalar.h
  9. 0 63
      include/igl/cgal/closest_facet.h
  10. 0 44
      include/igl/cgal/complex_to_mesh.h
  11. 0 270
      include/igl/cgal/intersect_other.cpp
  12. 0 106
      include/igl/cgal/intersect_other.h
  13. 0 65
      include/igl/cgal/mesh_to_cgal_triangle_list.cpp
  14. 0 41
      include/igl/cgal/mesh_to_cgal_triangle_list.h
  15. 0 39
      include/igl/cgal/mesh_to_polyhedron.h
  16. 0 104
      include/igl/cgal/order_facets_around_edges.h
  17. 0 112
      include/igl/cgal/outer_element.h
  18. 0 51
      include/igl/cgal/outer_hull.h
  19. 0 44
      include/igl/cgal/peel_outer_hull_layers.h
  20. 0 85
      include/igl/cgal/point_mesh_squared_distance.h
  21. 0 37
      include/igl/cgal/polyhedron_to_mesh.h
  22. 0 43
      include/igl/cgal/projected_delaunay.h
  23. 0 343
      include/igl/cgal/remesh_intersections.cpp
  24. 0 70
      include/igl/cgal/remesh_intersections.h
  25. 0 95
      include/igl/cgal/remesh_self_intersections.cpp
  26. 0 85
      include/igl/cgal/remesh_self_intersections.h
  27. 0 51
      include/igl/cgal/signed_distance_isosurface.h
  28. 12 9
      include/igl/copyleft/boolean/BinaryWindingNumberOperations.h
  29. 185 0
      include/igl/copyleft/boolean/CSGTree.h
  30. 29 0
      include/igl/copyleft/boolean/MeshBooleanType.h
  31. 3 3
      include/igl/copyleft/boolean/from_cork_mesh.cpp
  32. 41 0
      include/igl/copyleft/boolean/from_cork_mesh.h
  33. 35 33
      include/igl/copyleft/boolean/mesh_boolean.cpp
  34. 7 5
      include/igl/copyleft/boolean/mesh_boolean.h
  35. 3 3
      include/igl/copyleft/boolean/mesh_boolean_cork.cpp
  36. 57 0
      include/igl/copyleft/boolean/mesh_boolean_cork.h
  37. 2 2
      include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp
  38. 44 0
      include/igl/copyleft/boolean/string_to_mesh_boolean_type.h
  39. 3 3
      include/igl/copyleft/boolean/to_cork_mesh.cpp
  40. 41 0
      include/igl/copyleft/boolean/to_cork_mesh.h
  41. 0 0
      include/igl/copyleft/cgal/CGAL_includes.hpp
  42. 31 0
      include/igl/copyleft/cgal/RemeshSelfIntersectionsParam.h
  43. 207 204
      include/igl/copyleft/cgal/SelfIntersectMesh.h
  44. 3 3
      include/igl/copyleft/cgal/assign_scalar.cpp
  45. 37 0
      include/igl/copyleft/cgal/assign_scalar.h
  46. 5 5
      include/igl/copyleft/cgal/closest_facet.cpp
  47. 67 0
      include/igl/copyleft/cgal/closest_facet.h
  48. 4 4
      include/igl/copyleft/cgal/complex_to_mesh.cpp
  49. 47 0
      include/igl/copyleft/cgal/complex_to_mesh.h
  50. 6 6
      include/igl/copyleft/cgal/component_inside_component.cpp
  51. 6 3
      include/igl/copyleft/cgal/component_inside_component.h
  52. 13 13
      include/igl/copyleft/cgal/extract_cells.cpp
  53. 6 3
      include/igl/copyleft/cgal/extract_cells.h
  54. 273 0
      include/igl/copyleft/cgal/intersect_other.cpp
  55. 109 0
      include/igl/copyleft/cgal/intersect_other.h
  56. 65 0
      include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.cpp
  57. 44 0
      include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.h
  58. 2 2
      include/igl/copyleft/cgal/mesh_to_polyhedron.cpp
  59. 42 0
      include/igl/copyleft/cgal/mesh_to_polyhedron.h
  60. 13 11
      include/igl/copyleft/cgal/order_facets_around_edge.cpp
  61. 6 3
      include/igl/copyleft/cgal/order_facets_around_edge.h
  62. 7 7
      include/igl/copyleft/cgal/order_facets_around_edges.cpp
  63. 107 0
      include/igl/copyleft/cgal/order_facets_around_edges.h
  64. 9 9
      include/igl/copyleft/cgal/outer_element.cpp
  65. 115 0
      include/igl/copyleft/cgal/outer_element.h
  66. 6 6
      include/igl/copyleft/cgal/outer_facet.cpp
  67. 6 3
      include/igl/copyleft/cgal/outer_facet.h
  68. 15 15
      include/igl/copyleft/cgal/outer_hull.cpp
  69. 54 0
      include/igl/copyleft/cgal/outer_hull.h
  70. 5 5
      include/igl/copyleft/cgal/peel_outer_hull_layers.cpp
  71. 47 0
      include/igl/copyleft/cgal/peel_outer_hull_layers.h
  72. 2 2
      include/igl/copyleft/cgal/peel_winding_number_layers.cpp
  73. 5 3
      include/igl/copyleft/cgal/peel_winding_number_layers.h
  74. 7 7
      include/igl/copyleft/cgal/point_mesh_squared_distance.cpp
  75. 88 0
      include/igl/copyleft/cgal/point_mesh_squared_distance.h
  76. 15 12
      include/igl/copyleft/cgal/points_inside_component.cpp
  77. 6 3
      include/igl/copyleft/cgal/points_inside_component.h
  78. 2 2
      include/igl/copyleft/cgal/polyhedron_to_mesh.cpp
  79. 40 0
      include/igl/copyleft/cgal/polyhedron_to_mesh.h
  80. 4 4
      include/igl/copyleft/cgal/projected_delaunay.cpp
  81. 46 0
      include/igl/copyleft/cgal/projected_delaunay.h
  82. 10 10
      include/igl/copyleft/cgal/propagate_winding_numbers.cpp
  83. 6 3
      include/igl/copyleft/cgal/propagate_winding_numbers.h
  84. 343 0
      include/igl/copyleft/cgal/remesh_intersections.cpp
  85. 73 0
      include/igl/copyleft/cgal/remesh_intersections.h
  86. 95 0
      include/igl/copyleft/cgal/remesh_self_intersections.cpp
  87. 88 0
      include/igl/copyleft/cgal/remesh_self_intersections.h
  88. 9 9
      include/igl/copyleft/cgal/signed_distance_isosurface.cpp
  89. 54 0
      include/igl/copyleft/cgal/signed_distance_isosurface.h
  90. 3 2
      optional/CMakeLists.txt
  91. 10 10
      tutorial/609_Boolean/main.cpp
  92. 2 2
      tutorial/610_CSGTree/main.cpp

+ 0 - 182
include/igl/boolean/CSGTree.h

@@ -1,182 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_BOOLEAN_CSG_TREE_H
-#define IGL_BOOLEAN_CSG_TREE_H
-
-#include <igl/boolean/string_to_mesh_boolean_type.h>
-#include <igl/boolean/MeshBooleanType.h>
-#include <igl/boolean/mesh_boolean.h>
-#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
-#include <CGAL/number_utils.h>
-
-namespace igl
-{
-  namespace boolean
-  {
-    // Class for defining and computing a constructive solid geometry result
-    // out of a tree of boolean operations on "solid" triangle meshes.
-    //
-    //template <typename DerivedF>
-    class CSGTree
-    {
-      private:
-        typedef CGAL::Epeck::FT ExactScalar;
-        typedef Eigen::Matrix<ExactScalar,Eigen::Dynamic,3> MatrixX3E;
-        //typedef Eigen::PlainObjectBase<DerivedF> POBF;
-        typedef Eigen::MatrixXi POBF;
-        typedef POBF::Index FIndex;
-        typedef Eigen::Matrix<FIndex,Eigen::Dynamic,1> VectorJ;
-        // Resulting mesh
-        MatrixX3E m_V;
-        POBF m_F;
-        VectorJ m_J;
-        // Number of birth faces in A + those in B. I.e. sum of original "leaf"
-        // faces involved in result.
-        size_t m_number_of_birth_faces;
-      public:
-        CSGTree()
-        {
-        }
-        //typedef Eigen::MatrixXd MatrixX3E;
-        //typedef Eigen::MatrixXi POBF;
-        // http://stackoverflow.com/a/3279550/148668
-        CSGTree(const CSGTree & other)
-          :
-          // copy things
-          m_V(other.m_V),
-          // This is an issue if m_F is templated
-          // https://forum.kde.org/viewtopic.php?f=74&t=128414
-          m_F(other.m_F),
-          m_J(other.m_J),
-          m_number_of_birth_faces(other.m_number_of_birth_faces)
-        {
-        }
-        // copy-swap idiom
-        friend void swap(CSGTree& first, CSGTree& second)
-        {
-          using std::swap;
-          // swap things
-          swap(first.m_V,second.m_V);
-          // This is an issue if m_F is templated, similar to
-          // https://forum.kde.org/viewtopic.php?f=74&t=128414
-          swap(first.m_F,second.m_F);
-          swap(first.m_J,second.m_J);
-          swap(first.m_number_of_birth_faces,second.m_number_of_birth_faces);
-        }
-        // Pass-by-value (aka copy)
-        CSGTree& operator=(CSGTree other)
-        {
-          swap(*this,other);
-          return *this;
-        }
-        CSGTree(CSGTree&& other):
-          // initialize via default constructor
-          CSGTree() 
-        {
-          swap(*this,other);
-        }
-        // Construct and compute a boolean operation on existing CSGTree nodes.
-        //
-        // Inputs:
-        //   A  Solid result of previous CSG operation (or identity, see below)
-        //   B  Solid result of previous CSG operation (or identity, see below)
-        //   type  type of mesh boolean to compute 
-        CSGTree(
-          const CSGTree & A,
-          const CSGTree & B,
-          const MeshBooleanType & type)
-        {
-          // conduct boolean operation
-          mesh_boolean(A.V(),A.F(),B.V(),B.F(),type,m_V,m_F,m_J);
-          // reindex m_J
-          std::for_each(m_J.data(),m_J.data()+m_J.size(),
-            [&](typename VectorJ::Scalar & j)
-            {
-              if(j < A.F().rows())
-              {
-                j = A.J()(j);
-              }else
-              {
-                assert(j<(A.F().rows()+B.F().rows()));
-                j = A.number_of_birth_faces()+(B.J()(j-A.F().rows()));
-              }
-            });
-          m_number_of_birth_faces = 
-            A.number_of_birth_faces() + B.number_of_birth_faces();
-        }
-        // Overload using string for type
-        CSGTree(
-          const CSGTree & A,
-          const CSGTree & B,
-          const std::string & s):
-          CSGTree(A,B,string_to_mesh_boolean_type(s))
-        {
-          // do nothing (all done in constructor).
-        }
-        // "Leaf" node with identity operation on assumed "solid" mesh (V,F)
-        //
-        // Inputs:
-        //   V  #V by 3 list of mesh vertices (in any precision, will be
-        //     converted to exact)
-        //   F  #F by 3 list of mesh face indices into V
-        template <typename DerivedV>
-        CSGTree(const Eigen::PlainObjectBase<DerivedV> & V, const POBF & F)//:
-        // Possible Eigen bug:
-        // https://forum.kde.org/viewtopic.php?f=74&t=128414
-          //m_V(V.template cast<ExactScalar>()),m_F(F)
-        {
-          m_V = V.template cast<ExactScalar>();
-          m_F = F;
-          // number of faces
-          m_number_of_birth_faces = m_F.rows();
-          // identity birth index
-          m_J = VectorJ::LinSpaced(
-            m_number_of_birth_faces,0,m_number_of_birth_faces-1);
-        }
-        // Returns reference to resulting mesh vertices m_V in exact scalar
-        // representation
-        const MatrixX3E & V() const
-        {
-          return m_V;
-        }
-        // Returns mesh vertices in the desired output type, casting when
-        // appropriate to floating precision.
-        template <typename DerivedV>
-        Eigen::PlainObjectBase<DerivedV> cast_V() const
-        {
-          Eigen::PlainObjectBase<DerivedV> dV;
-          dV.resize(m_V.rows(),m_V.cols());
-          for(int i = 0;i<m_V.size();i++)
-          {
-            *(dV.data()+i) = CGAL::to_double((*(m_V.data()+i)));
-          }
-          return dV;
-        }
-        // Returns reference to resulting mesh faces m_F
-        const POBF & F() const
-        {
-          return m_F;
-        }
-        // Returns reference to "birth parents" indices into [F1;F2;...;Fn]
-        // where F1, ... , Fn are the face lists of the leaf ("original") input
-        // meshes.
-        const VectorJ & J() const
-        {
-          return m_J;
-        }
-        // The number of leaf faces = #F1 + #F2 + ... + #Fn
-        const size_t & number_of_birth_faces() const
-        {
-          return m_number_of_birth_faces;
-        }
-    };
-  }
-}
-
-
-#endif

+ 0 - 26
include/igl/boolean/MeshBooleanType.h

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

+ 0 - 38
include/igl/boolean/from_cork_mesh.h

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

+ 0 - 54
include/igl/boolean/mesh_boolean_cork.h

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

+ 0 - 41
include/igl/boolean/string_to_mesh_boolean_type.h

@@ -1,41 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_BOOLEAN_STRING_TO_MESH_BOOLEAN_H
-#define IGL_BOOLEAN_STRING_TO_MESH_BOOLEAN_H
-
-#include <igl/igl_inline.h>
-#include "MeshBooleanType.h"
-#include <string>
-
-namespace igl
-{
-  namespace boolean
-  {
-    // Convert string to boolean type
-    //
-    //  Inputs:
-    //    s  string identifying type, one of the following:
-    //      "union","intersect","minus","xor","resolve"
-    //  Outputs:
-    //    type  type of boolean operation
-    // Returns true only on success
-    //     
-    IGL_INLINE bool string_to_mesh_boolean_type(
-      const std::string & s,
-      MeshBooleanType & type);
-    // Returns type without error handling
-    IGL_INLINE MeshBooleanType string_to_mesh_boolean_type(
-      const std::string & s);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "string_to_mesh_boolean_type.cpp"
-#endif
-
-#endif

+ 0 - 38
include/igl/boolean/to_cork_mesh.h

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

+ 0 - 28
include/igl/cgal/RemeshSelfIntersectionsParam.h

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

+ 0 - 34
include/igl/cgal/assign_scalar.h

@@ -1,34 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_ASSIGN_SCALAR_H
-#define IGL_CGAL_ASSIGN_SCALAR_H
-#include "../igl_inline.h"
-#include "CGAL_includes.hpp"
-namespace igl
-{
-  namespace cgal
-  {
-    // Inputs:
-    //   cgal  cgal scalar
-    // Outputs:
-    //   d  output scalar
-    IGL_INLINE void assign_scalar(
-      const typename CGAL::Epeck::FT & cgal,
-      CGAL::Epeck::FT & d);
-    IGL_INLINE void assign_scalar(
-      const typename CGAL::Epeck::FT & cgal,
-      double & d);
-    IGL_INLINE void assign_scalar(
-      const double & c,
-      double & d);
-  }
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "assign_scalar.cpp"
-#endif
-#endif

+ 0 - 63
include/igl/cgal/closest_facet.h

@@ -1,63 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Qingnan Zhou <qnzhou@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 CLOSEST_FACET_H
-#define CLOSEST_FACET_H
-
-#include "../igl_inline.h"
-#include <Eigen/Core>
-
-namespace igl {
-    namespace cgal {
-
-        // Determine the closest facet for each of the input points.
-        //
-        // Inputs:
-        //   V  #V by 3 array of vertices.
-        //   F  #F by 3 array of faces.
-        //   I  #I list of triangle indices to consider.
-        //   P  #P by 3 array of query points.
-        //
-        // Outputs:
-        //   R  #P list of closest facet indices.
-        //   S  #P list of bools indicating on which side of the closest facet
-        //      each query point lies.
-        template<
-            typename DerivedV,
-            typename DerivedF,
-            typename DerivedI,
-            typename DerivedP,
-            typename DerivedR,
-            typename DerivedS >
-        IGL_INLINE void closest_facet(
-                const Eigen::PlainObjectBase<DerivedV>& V,
-                const Eigen::PlainObjectBase<DerivedF>& F,
-                const Eigen::PlainObjectBase<DerivedI>& I,
-                const Eigen::PlainObjectBase<DerivedP>& P,
-                Eigen::PlainObjectBase<DerivedR>& R,
-                Eigen::PlainObjectBase<DerivedS>& S);
-
-        template<
-            typename DerivedV,
-            typename DerivedF,
-            typename DerivedP,
-            typename DerivedR,
-            typename DerivedS >
-        IGL_INLINE void closest_facet(
-                const Eigen::PlainObjectBase<DerivedV>& V,
-                const Eigen::PlainObjectBase<DerivedF>& F,
-                const Eigen::PlainObjectBase<DerivedP>& P,
-                Eigen::PlainObjectBase<DerivedR>& R,
-                Eigen::PlainObjectBase<DerivedS>& S);
-    }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#include "closest_facet.cpp"
-#endif
-#endif

+ 0 - 44
include/igl/cgal/complex_to_mesh.h

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

+ 0 - 270
include/igl/cgal/intersect_other.cpp

@@ -1,270 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2014 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 "intersect_other.h"
-#include "CGAL_includes.hpp"
-#include "mesh_to_cgal_triangle_list.h"
-#include "remesh_intersections.h"
-
-#ifndef IGL_FIRST_HIT_EXCEPTION
-#define IGL_FIRST_HIT_EXCEPTION 10
-#endif
-
-// Un-exposed helper functions
-namespace igl
-{
-  namespace cgal
-  {
-    template <typename DerivedF>
-    static IGL_INLINE void push_result(
-      const Eigen::PlainObjectBase<DerivedF> & F,
-      const int f,
-      const CGAL::Object & result,
-      std::map<
-        typename DerivedF::Index,
-        std::pair<typename DerivedF::Index,
-          std::vector<CGAL::Object> > > & offending,
-      std::map<
-        std::pair<typename DerivedF::Index,typename DerivedF::Index>,
-        std::vector<typename DerivedF::Index> > & edge2faces)
-    {
-      typedef typename DerivedF::Index Index;
-      typedef std::pair<Index,Index> EMK;
-      if(offending.count(f) == 0)
-      {
-        // first time marking, initialize with new id and empty list
-        Index id = offending.size();
-        offending[f] = {id,{}};
-        for(Index e = 0; e<3;e++)
-        {
-          // append face to edge's list
-          Index i = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+1)%3) : F(f,(e+2)%3);
-          Index j = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+2)%3) : F(f,(e+1)%3);
-          edge2faces[EMK(i,j)].push_back(f);
-        }
-      }
-      offending[f].second.push_back(result);
-    }
-    template <
-      typename Kernel,
-      typename DerivedVA,
-      typename DerivedFA,
-      typename DerivedVB,
-      typename DerivedFB,
-      typename DerivedIF,
-      typename DerivedVVA,
-      typename DerivedFFA,
-      typename DerivedJA,
-      typename DerivedIMA,
-      typename DerivedVVB,
-      typename DerivedFFB,
-      typename DerivedJB,
-      typename DerivedIMB>
-    static IGL_INLINE bool intersect_other_helper(
-      const Eigen::PlainObjectBase<DerivedVA> & VA,
-      const Eigen::PlainObjectBase<DerivedFA> & FA,
-      const Eigen::PlainObjectBase<DerivedVB> & VB,
-      const Eigen::PlainObjectBase<DerivedFB> & FB,
-      const RemeshSelfIntersectionsParam & params,
-      Eigen::PlainObjectBase<DerivedIF> & IF,
-      Eigen::PlainObjectBase<DerivedVVA> & VVA,
-      Eigen::PlainObjectBase<DerivedFFA> & FFA,
-      Eigen::PlainObjectBase<DerivedJA>  & JA,
-      Eigen::PlainObjectBase<DerivedIMA> & IMA,
-      Eigen::PlainObjectBase<DerivedVVB> & VVB,
-      Eigen::PlainObjectBase<DerivedFFB> & FFB,
-      Eigen::PlainObjectBase<DerivedJB>  & JB,
-      Eigen::PlainObjectBase<DerivedIMB> & IMB)
-    {
-
-      using namespace std;
-      using namespace Eigen;
-
-      typedef typename DerivedFA::Index Index;
-      // 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; 
-      // 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> CTAB_2;
-      typedef CGAL::Triangulation_data_structure_2<TVB_2,CTAB_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;
-      typedef 
-        std::map<Index,std::pair<Index,std::vector<CGAL::Object> > > 
-        OffendingMap;
-      typedef std::map<std::pair<Index,Index>,std::vector<Index> >  EdgeMap;
-      typedef std::pair<Index,Index> EMK;
-
-      Triangles TA,TB;
-      // Compute and process self intersections
-      mesh_to_cgal_triangle_list(VA,FA,TA);
-      mesh_to_cgal_triangle_list(VB,FB,TB);
-      // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d/Chapter_main.html#Section_63.5 
-      // Create the corresponding vector of bounding boxes
-      std::vector<Box> A_boxes,B_boxes;
-      const auto box_up = [](Triangles & T, std::vector<Box> & boxes)
-      {
-        boxes.reserve(T.size());
-        for ( 
-          TrianglesIterator tit = T.begin(); 
-          tit != T.end(); 
-          ++tit)
-        {
-          boxes.push_back(Box(tit->bbox(), tit));
-        }
-      };
-      box_up(TA,A_boxes);
-      box_up(TB,B_boxes);
-      OffendingMap offendingA,offendingB;
-      EdgeMap edge2facesA,edge2facesB;
-
-      std::list<int> lIF;
-      const auto cb = [&](const Box &a, const Box &b)
-      {
-        using namespace std;
-        // index in F and T
-        int fa = a.handle()-TA.begin();
-        int fb = b.handle()-TB.begin();
-        const Triangle_3 & A = *a.handle();
-        const Triangle_3 & B = *b.handle();
-        if(CGAL::do_intersect(A,B))
-        {
-          // There was an intersection
-          lIF.push_back(fa);
-          lIF.push_back(fb);
-          if(params.first_only)
-          {
-            throw IGL_FIRST_HIT_EXCEPTION;
-          }
-          if(!params.detect_only)
-          {
-            CGAL::Object result = CGAL::intersection(A,B);
-
-            push_result(FA,fa,result,offendingA,edge2facesA);
-            push_result(FB,fb,result,offendingB,edge2facesB);
-          }
-        }
-      };
-      try{
-        CGAL::box_intersection_d(
-          A_boxes.begin(), A_boxes.end(),
-          B_boxes.begin(), B_boxes.end(),
-          cb);
-      }catch(int e)
-      {
-        // Rethrow if not FIRST_HIT_EXCEPTION
-        if(e != IGL_FIRST_HIT_EXCEPTION)
-        {
-          throw e;
-        }
-        // Otherwise just fall through
-      }
-
-      // Convert lIF to Eigen matrix
-      assert(lIF.size()%2 == 0);
-      IF.resize(lIF.size()/2,2);
-      {
-        int i=0;
-        for(
-          list<int>::const_iterator ifit = lIF.begin();
-          ifit!=lIF.end();
-          )
-        {
-          IF(i,0) = (*ifit);
-          ifit++; 
-          IF(i,1) = (*ifit);
-          ifit++;
-          i++;
-        }
-      }
-      if(!params.detect_only)
-      {
-        remesh_intersections(VA,FA,TA,offendingA,edge2facesA,VVA,FFA,JA,IMA);
-        remesh_intersections(VB,FB,TB,offendingB,edge2facesB,VVB,FFB,JB,IMB);
-      }
-
-      return IF.rows() > 0;
-    }
-  }
-}
-
-template <
-  typename DerivedVA,
-  typename DerivedFA,
-  typename DerivedVB,
-  typename DerivedFB,
-  typename DerivedIF,
-  typename DerivedVVA,
-  typename DerivedFFA,
-  typename DerivedJA,
-  typename DerivedIMA,
-  typename DerivedVVB,
-  typename DerivedFFB,
-  typename DerivedJB,
-  typename DerivedIMB>
-IGL_INLINE bool igl::cgal::intersect_other(
-  const Eigen::PlainObjectBase<DerivedVA> & VA,
-  const Eigen::PlainObjectBase<DerivedFA> & FA,
-  const Eigen::PlainObjectBase<DerivedVB> & VB,
-  const Eigen::PlainObjectBase<DerivedFB> & FB,
-  const RemeshSelfIntersectionsParam & params,
-  Eigen::PlainObjectBase<DerivedIF> & IF,
-  Eigen::PlainObjectBase<DerivedVVA> & VVA,
-  Eigen::PlainObjectBase<DerivedFFA> & FFA,
-  Eigen::PlainObjectBase<DerivedJA>  & JA,
-  Eigen::PlainObjectBase<DerivedIMA> & IMA,
-  Eigen::PlainObjectBase<DerivedVVB> & VVB,
-  Eigen::PlainObjectBase<DerivedFFB> & FFB,
-  Eigen::PlainObjectBase<DerivedJB>  & JB,
-  Eigen::PlainObjectBase<DerivedIMB> & IMB)
-{
-  if(params.detect_only)
-  {
-    return intersect_other_helper<CGAL::Epick>
-      (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
-  }else
-  {
-    return intersect_other_helper<CGAL::Epeck>
-      (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
-  }
-}
-
-IGL_INLINE bool igl::cgal::intersect_other(
-  const Eigen::MatrixXd & VA,
-  const Eigen::MatrixXi & FA,
-  const Eigen::MatrixXd & VB,
-  const Eigen::MatrixXi & FB,
-  const bool first_only,
-  Eigen::MatrixXi & IF)
-{
-  Eigen::MatrixXd VVA,VVB;
-  Eigen::MatrixXi FFA,FFB;
-  Eigen::VectorXi JA,JB,IMA,IMB;
-  return intersect_other(
-    VA,FA,VB,FB,{true,first_only},IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-#endif

+ 0 - 106
include/igl/cgal/intersect_other.h

@@ -1,106 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_INTERSECT_OTHER_H
-#define IGL_CGAL_INTERSECT_OTHER_H
-#include "../igl_inline.h"
-#include "RemeshSelfIntersectionsParam.h"
-
-#include <Eigen/Dense>
-
-#ifdef MEX
-#  include <mex.h>
-#  include <cassert>
-#  undef assert
-#  define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
-#endif
-
-namespace igl
-{
-  namespace cgal
-  {
-    // INTERSECT_OTHER Given a triangle mesh (VA,FA) and another mesh (VB,FB)
-    // find all pairs of intersecting faces. Note that self-intersections are
-    // ignored.
-    // 
-    // Inputs:
-    //   VA  #V by 3 list of vertex positions
-    //   FA  #F by 3 list of triangle indices into VA
-    //   VB  #V by 3 list of vertex positions
-    //   FB  #F by 3 list of triangle indices into VB
-    //   params   whether to detect only and then whether to only find first
-    //     intersection
-    // Outputs:
-    //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
-    //     indexing FA and FB
-    //   VVA  #VVA by 3 list of vertex positions
-    //   FFA  #FFA by 3 list of triangle indices into VVA
-    //   JA  #FFA list of indices into FA denoting birth triangle
-    //   IMA  #VVA list of indices into VVA of unique vertices.
-    //   VVB  #VVB by 3 list of vertex positions
-    //   FFB  #FFB by 3 list of triangle indices into VVB
-    //   JB  #FFB list of indices into FB denoting birth triangle
-    //   IMB  #VVB list of indices into VVB of unique vertices.
-    template <
-      typename DerivedVA,
-      typename DerivedFA,
-      typename DerivedVB,
-      typename DerivedFB,
-      typename DerivedIF,
-      typename DerivedVVA,
-      typename DerivedFFA,
-      typename DerivedJA,
-      typename DerivedIMA,
-      typename DerivedVVB,
-      typename DerivedFFB,
-      typename DerivedJB,
-      typename DerivedIMB>
-    IGL_INLINE bool intersect_other(
-      const Eigen::PlainObjectBase<DerivedVA> & VA,
-      const Eigen::PlainObjectBase<DerivedFA> & FA,
-      const Eigen::PlainObjectBase<DerivedVB> & VB,
-      const Eigen::PlainObjectBase<DerivedFB> & FB,
-      const RemeshSelfIntersectionsParam & params,
-      Eigen::PlainObjectBase<DerivedIF> & IF,
-      Eigen::PlainObjectBase<DerivedVVA> & VVA,
-      Eigen::PlainObjectBase<DerivedFFA> & FFA,
-      Eigen::PlainObjectBase<DerivedJA>  & JA,
-      Eigen::PlainObjectBase<DerivedIMA> & IMA,
-      Eigen::PlainObjectBase<DerivedVVB> & VVB,
-      Eigen::PlainObjectBase<DerivedFFB> & FFB,
-      Eigen::PlainObjectBase<DerivedJB>  & JB,
-      Eigen::PlainObjectBase<DerivedIMB> & IMB);
-    // Legacy wrapper for detect only using common types.
-    //
-    // Inputs:
-    //   VA  #V by 3 list of vertex positions
-    //   FA  #F by 3 list of triangle indices into VA
-    //   VB  #V by 3 list of vertex positions
-    //   FB  #F by 3 list of triangle indices into VB
-    //   first_only  whether to only detect the first intersection.
-    // Outputs:
-    //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
-    //     indexing FA and FB
-    // Returns true if any intersections were found
-    //
-    // See also: remesh_self_intersections
-    IGL_INLINE bool intersect_other(
-      const Eigen::MatrixXd & VA,
-      const Eigen::MatrixXi & FA,
-      const Eigen::MatrixXd & VB,
-      const Eigen::MatrixXi & FB,
-      const bool first_only,
-      Eigen::MatrixXi & IF);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "intersect_other.cpp"
-#endif
-  
-#endif
-

+ 0 - 65
include/igl/cgal/mesh_to_cgal_triangle_list.cpp

@@ -1,65 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#include "mesh_to_cgal_triangle_list.h"
-#include "assign_scalar.h"
-
-#include <cassert>
-
-template <
-  typename DerivedV,
-  typename DerivedF,
-  typename Kernel>
-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)
-{
-  typedef CGAL::Point_3<Kernel>    Point_3;
-  typedef CGAL::Triangle_3<Kernel> Triangle_3; 
-  // Must be 3D
-  assert(V.cols() == 3);
-  // **Copy** to convert to output type (this is especially/only needed if the
-  // input type DerivedV::Scalar is CGAL::Epeck
-  Eigen::Matrix<
-    typename Kernel::FT,
-    DerivedV::RowsAtCompileTime,
-    DerivedV::ColsAtCompileTime> 
-    KV(V.rows(),V.cols());
-  // Just use f'ing for loops. What if V and KV don't use same ordering?
-  for(int i = 0;i<V.rows();i++)
-  {
-    for(int j = 0;j<V.cols();j++)
-    {
-      assign_scalar(V(i,j),KV(i,j));
-    }
-  }
-  // Must be triangles
-  assert(F.cols() == 3);
-  T.reserve(F.rows());
-  // Loop over faces
-  for(int f = 0;f<(int)F.rows();f++)
-  {
-    T.push_back(
-      Triangle_3(
-        Point_3( KV(F(f,0),0), KV(F(f,0),1), KV(F(f,0),2)),
-        Point_3( KV(F(f,1),0), KV(F(f,1),1), KV(F(f,1),2)),
-        Point_3( KV(F(f,2),0), KV(F(f,2),1), KV(F(f,2),2))));
-  }
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-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> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epick>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
-template void igl::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epeck>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
-#endif

+ 0 - 41
include/igl/cgal/mesh_to_cgal_triangle_list.h

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

+ 0 - 39
include/igl/cgal/mesh_to_polyhedron.h

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

+ 0 - 104
include/igl/cgal/order_facets_around_edges.h

@@ -1,104 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
-#define IGL_CGAL_ORDER_FACETS_AROUND_EDGES_H
-#include "../igl_inline.h"
-#include <Eigen/Core>
-#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
-#include <vector>
-
-namespace igl
-{
-  namespace cgal
-  {
-    // For each undirected edge, sort its adjacent faces.  Assuming the
-    // undirected edge is (s, d).  Sort the adjacent faces clockwise around the
-    // axis (d - s), i.e. left-hand rule.  An adjacent face is consistently
-    // oriented if it contains (d, s) as a directed edge.
-    //
-    // For overlapping faces, break the tie using signed face index, smaller
-    // signed index comes before the larger signed index.  Signed index is
-    // computed as (consistent? 1:-1) * index.
-    //
-    // Inputs:
-    //   V    #V by 3 list of vertices.
-    //   F    #F by 3 list of faces
-    //   N    #F by 3 list of face normals.
-    //  uE    #uE by 2 list of vertex_indices, represents undirected edges.
-    //  uE2E  #uE list of lists that maps uE to E. (a one-to-many map)
-    //
-    // Outputs:
-    //   uE2oE #uE list of lists that maps uE to an ordered list of E. (a
-    //         one-to-many map)
-    //   uE2C  #uE list of lists of bools indicates whether each face in
-    //         uE2oE[i] is consistently orientated as the ordering.
-    //
-    template<
-        typename DerivedV,
-        typename DerivedF,
-        typename DerivedN,
-        typename DeriveduE,
-        typename uE2EType,
-        typename uE2oEType,
-        typename uE2CType >
-    IGL_INLINE
-    typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
-    typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
-    order_facets_around_edges(
-            const Eigen::PlainObjectBase<DerivedV>& V,
-            const Eigen::PlainObjectBase<DerivedF>& F,
-            const Eigen::PlainObjectBase<DerivedN>& N,
-            const Eigen::PlainObjectBase<DeriveduE>& uE,
-            const std::vector<std::vector<uE2EType> >& uE2E,
-            std::vector<std::vector<uE2oEType> >& uE2oE,
-            std::vector<std::vector<uE2CType > >& uE2C );
-
-    template<
-        typename DerivedV,
-        typename DerivedF,
-        typename DerivedN,
-        typename DeriveduE,
-        typename uE2EType,
-        typename uE2oEType,
-        typename uE2CType >
-    IGL_INLINE 
-    typename std::enable_if<std::is_same<typename DerivedV::Scalar,
-    typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
-    order_facets_around_edges(
-            const Eigen::PlainObjectBase<DerivedV>& V,
-            const Eigen::PlainObjectBase<DerivedF>& F,
-            const Eigen::PlainObjectBase<DerivedN>& N,
-            const Eigen::PlainObjectBase<DeriveduE>& uE,
-            const std::vector<std::vector<uE2EType> >& uE2E,
-            std::vector<std::vector<uE2oEType> >& uE2oE,
-            std::vector<std::vector<uE2CType > >& uE2C );
-
-    // Order faces around each edge. Only exact predicate is used in the algorithm.
-    // Normal is not needed.
-    template<
-        typename DerivedV,
-        typename DerivedF,
-        typename DeriveduE,
-        typename uE2EType,
-        typename uE2oEType,
-        typename uE2CType >
-    IGL_INLINE void order_facets_around_edges(
-            const Eigen::PlainObjectBase<DerivedV>& V,
-            const Eigen::PlainObjectBase<DerivedF>& F,
-            const Eigen::PlainObjectBase<DeriveduE>& uE,
-            const std::vector<std::vector<uE2EType> >& uE2E,
-            std::vector<std::vector<uE2oEType> >& uE2oE,
-            std::vector<std::vector<uE2CType > >& uE2C );
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#include "order_facets_around_edges.cpp"
-#endif
-
-#endif

+ 0 - 112
include/igl/cgal/outer_element.h

@@ -1,112 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Qingan Zhou <qnzhou@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_OUTER_ELEMENT_H
-#define IGL_CGAL_OUTER_ELEMENT_H
-#include "../igl_inline.h"
-#include <Eigen/Core>
-namespace igl
-{
-  namespace cgal
-  {
-    // Find a vertex that is reachable from infinite without crossing any faces.
-    // Such vertex is called "outer vertex."
-    //
-    // Precondition: The input mesh must have all self-intersection resolved and
-    // no duplicated vertices.  See cgal::remesh_self_intersections.h for how to
-    // obtain such input.
-    //
-    // Inputs:
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of triangle indices into V
-    //   I  #I list of facets to consider
-    // Outputs:
-    //   v_index  index of outer vertex
-    //   A  #A list of facets incident to the outer vertex
-    template <
-        typename DerivedV,
-        typename DerivedF,
-        typename DerivedI,
-        typename IndexType,
-        typename DerivedA
-        >
-    IGL_INLINE void outer_vertex(
-            const Eigen::PlainObjectBase<DerivedV> & V,
-            const Eigen::PlainObjectBase<DerivedF> & F,
-            const Eigen::PlainObjectBase<DerivedI> & I,
-            IndexType & v_index,
-            Eigen::PlainObjectBase<DerivedA> & A);
-    // Find an edge that is reachable from infinity without crossing any faces.
-    // Such edge is called "outer edge."
-    //
-    // Precondition: The input mesh must have all self-intersection resolved
-    // and no duplicated vertices.  The correctness of the output depends on
-    // the fact that there is no edge overlap.  See
-    // cgal::remesh_self_intersections.h for how to obtain such input.
-    //
-    // Inputs:
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of triangle indices into V
-    //   I  #I list of facets to consider
-    // Outputs:
-    //   v1 index of the first end point of outer edge
-    //   v2 index of the second end point of outer edge
-    //   A  #A list of facets incident to the outer edge
-    template<
-        typename DerivedV,
-        typename DerivedF,
-        typename DerivedI,
-        typename IndexType,
-        typename DerivedA
-        >
-    IGL_INLINE void outer_edge(
-            const Eigen::PlainObjectBase<DerivedV> & V,
-            const Eigen::PlainObjectBase<DerivedF> & F,
-            const Eigen::PlainObjectBase<DerivedI> & I,
-            IndexType & v1,
-            IndexType & v2,
-            Eigen::PlainObjectBase<DerivedA> & A);
-
-
-    // Find a facet that is reachable from infinity without crossing any faces.
-    // Such facet is called "outer facet."
-    //
-    // Precondition: The input mesh must have all self-intersection resolved.
-    // I.e there is no duplicated vertices, no overlapping edge and no
-    // intersecting faces (the only exception is there could be topologically
-    // duplicated faces).  See cgal::remesh_self_intersections.h for how to
-    // obtain such input.
-    //
-    // Inputs:
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of triangle indices into V
-    //   N  #N by 3 list of face normals
-    //   I  #I list of facets to consider
-    // Outputs:
-    //   f  Index of the outer facet.
-    //   flipped  true iff the normal of f points inwards.
-    template<
-        typename DerivedV,
-        typename DerivedF,
-        typename DerivedN,
-        typename DerivedI,
-        typename IndexType
-        >
-    IGL_INLINE void outer_facet(
-            const Eigen::PlainObjectBase<DerivedV> & V,
-            const Eigen::PlainObjectBase<DerivedF> & F,
-            const Eigen::PlainObjectBase<DerivedN> & N,
-            const Eigen::PlainObjectBase<DerivedI> & I,
-            IndexType & f,
-            bool & flipped);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "outer_element.cpp"
-#endif
-#endif

+ 0 - 51
include/igl/cgal/outer_hull.h

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

+ 0 - 44
include/igl/cgal/peel_outer_hull_layers.h

@@ -1,44 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
-#define IGL_CGAL_PEEL_OUTER_HULL_LAYERS_H
-#include "../igl_inline.h"
-#include <Eigen/Core>
-namespace igl
-{
-  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
-    // Outputs:
-    //   I  #F list of which peel Iation a facet belongs 
-    //   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 DerivedI,
-      typename Derivedflip>
-    IGL_INLINE size_t peel_outer_hull_layers(
-      const Eigen::PlainObjectBase<DerivedV > & V,
-      const Eigen::PlainObjectBase<DerivedF > & F,
-      Eigen::PlainObjectBase<DerivedI > & I,
-      Eigen::PlainObjectBase<Derivedflip > & flip);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "peel_outer_hull_layers.cpp"
-#endif
-#endif

+ 0 - 85
include/igl/cgal/point_mesh_squared_distance.h

@@ -1,85 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_POINT_MESH_SQUARED_DISTANCE_H
-#define IGL_CGAL_POINT_MESH_SQUARED_DISTANCE_H
-#include <igl/igl_inline.h>
-#include <Eigen/Core>
-#include <vector>
-#include "CGAL_includes.hpp"
-namespace igl
-{
-  namespace cgal
-  {
-    // Compute distances from a set of points P to a triangle mesh (V,F)
-    //
-    // Templates:
-    //   Kernal  CGAL computation and construction kernel (e.g.
-    //     CGAL::Simple_cartesian<double>)
-    // Inputs:
-    //   P  #P by 3 list of query point positions
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of triangle indices
-    // Outputs:
-    //   sqrD  #P list of smallest squared distances
-    //   I  #P list of facet indices corresponding to smallest distances
-    //   C  #P by 3 list of closest points
-    //
-    // Known bugs: This only computes distances to triangles. So unreferenced
-    // vertices and degenerate triangles (segments) are ignored.
-    template <typename Kernel>
-    IGL_INLINE void point_mesh_squared_distance(
-      const Eigen::MatrixXd & P,
-      const Eigen::MatrixXd & V,
-      const Eigen::MatrixXi & F,
-      Eigen::VectorXd & sqrD,
-      Eigen::VectorXi & I,
-      Eigen::MatrixXd & C);
-    // Probably can do this in a way that we don't pass around `tree` and `T`
-    //
-    // Outputs:
-    //   tree  CGAL's AABB tree
-    //   T  list of CGAL triangles in order of F (for determining which was found
-    //     in computation)
-    template <typename Kernel>
-    IGL_INLINE void point_mesh_squared_distance_precompute(
-      const Eigen::MatrixXd & V,
-      const Eigen::MatrixXi & F,
-      CGAL::AABB_tree<
-        CGAL::AABB_traits<Kernel, 
-          CGAL::AABB_triangle_primitive<Kernel, 
-            typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
-          >
-        >
-      > & tree,
-      std::vector<CGAL::Triangle_3<Kernel> > & T);
-    // Inputs:
-    //  see above
-    // Outputs:
-    //  see above
-    template <typename Kernel>
-    IGL_INLINE void point_mesh_squared_distance(
-      const Eigen::MatrixXd & P,
-      const CGAL::AABB_tree<
-        CGAL::AABB_traits<Kernel, 
-          CGAL::AABB_triangle_primitive<Kernel, 
-            typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
-          >
-        >
-      > & tree,
-      const std::vector<CGAL::Triangle_3<Kernel> > & T,
-      Eigen::VectorXd & sqrD,
-      Eigen::VectorXi & I,
-      Eigen::MatrixXd & C);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "point_mesh_squared_distance.cpp"
-#endif
-
-#endif

+ 0 - 37
include/igl/cgal/polyhedron_to_mesh.h

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

+ 0 - 43
include/igl/cgal/projected_delaunay.h

@@ -1,43 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_PROJECTED_DELAUNAY_H
-#define IGL_CGAL_PROJECTED_DELAUNAY_H
-#include "../igl_inline.h"
-#include "CGAL_includes.hpp"
-namespace igl
-{
-  namespace cgal
-  {
-    // 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
-    template <typename Kernel>
-    IGL_INLINE void projected_delaunay(
-      const CGAL::Triangle_3<Kernel> & A,
-      const std::vector<CGAL::Object> & A_objects_3,
-      CGAL::Constrained_triangulation_plus_2<
-        CGAL::Constrained_Delaunay_triangulation_2<
-          Kernel,
-          CGAL::Triangulation_data_structure_2<
-            CGAL::Triangulation_vertex_base_2<Kernel>,
-            CGAL::Constrained_triangulation_face_base_2<Kernel> >,
-          CGAL::Exact_intersections_tag> > & cdt);
-  }
-}
-#ifndef IGL_STATIC_LIBRARY
-#  include "projected_delaunay.cpp"
-#endif
-#endif

Різницю між файлами не показано, бо вона завелика
+ 0 - 343
include/igl/cgal/remesh_intersections.cpp


+ 0 - 70
include/igl/cgal/remesh_intersections.h

@@ -1,70 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2015 Qingnan Zhou <qnzhou@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-//
-#ifndef IGL_CGAL_REMESH_INTERSECTIONS_H
-#define IGL_CGAL_REMESH_INTERSECTIONS_H
-
-#include <igl/igl_inline.h>
-#include <Eigen/Dense>
-#include "CGAL_includes.hpp"
-
-namespace igl
-{
-  namespace cgal
-  {
-    // Remesh faces according to results of intersection detection and
-    // construction (e.g. from `igl::cgal::intersect_other` or
-    // `igl::cgal::SelfIntersectMesh`)
-    //
-    // Inputs:
-    //   V  #V by 3 list of vertex positions
-    //   F  #F by 3 list of triangle indices into V
-    //   T  #F list of cgal triangles
-    //   offending #offending map taking face indices into F to pairs of order
-    //     of first finding and list of intersection objects from all
-    //     intersections
-    //   edge2faces  #edges <= #offending*3 to incident offending faces 
-    // 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.
-    //
-    template <
-      typename DerivedV,
-      typename DerivedF,
-      typename Kernel,
-      typename DerivedVV,
-      typename DerivedFF,
-      typename DerivedJ,
-      typename DerivedIM>
-    IGL_INLINE void remesh_intersections(
-      const Eigen::PlainObjectBase<DerivedV> & V,
-      const Eigen::PlainObjectBase<DerivedF> & F,
-      const std::vector<CGAL::Triangle_3<Kernel> > & T,
-      const std::map<
-        typename DerivedF::Index,
-        std::pair<typename DerivedF::Index,
-          std::vector<CGAL::Object> > > & offending,
-      const std::map<
-        std::pair<typename DerivedF::Index,typename DerivedF::Index>,
-        std::vector<typename DerivedF::Index> > & edge2faces,
-      Eigen::PlainObjectBase<DerivedVV> & VV,
-      Eigen::PlainObjectBase<DerivedFF> & FF,
-      Eigen::PlainObjectBase<DerivedJ> & J,
-      Eigen::PlainObjectBase<DerivedIM> & IM);
-  }
-}
-
-#ifndef IGL_STATIC_LIBRARY
-#  include "remesh_intersections.cpp"
-#endif
-
-#endif

+ 0 - 95
include/igl/cgal/remesh_self_intersections.cpp

@@ -1,95 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2014 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 "remesh_self_intersections.h"
-#include "SelfIntersectMesh.h"
-#include <igl/C_STR.h>
-#include <list>
-#include <iostream>
-
-template <
-  typename DerivedV,
-  typename DerivedF,
-  typename DerivedVV,
-  typename DerivedFF,
-  typename DerivedIF,
-  typename DerivedJ,
-  typename DerivedIM>
-IGL_INLINE void igl::cgal::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)
-{
-  using namespace std;
-  if(params.detect_only)
-  {
-    //// This is probably a terrible idea, but CGAL is throwing floating point
-    //// exceptions.
-
-//#ifdef __APPLE__
-//#define IGL_THROW_FPE 11
-//    const auto & throw_fpe = [](int e)
-//    {
-//      throw "IGL_THROW_FPE";
-//    };
-//    signal(SIGFPE,throw_fpe);
-//#endif
-
-    typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
-    typedef
-      SelfIntersectMesh<
-        Kernel,
-        DerivedV,
-        DerivedF,
-        DerivedVV,
-        DerivedFF,
-        DerivedIF,
-        DerivedJ,
-        DerivedIM>
-      SelfIntersectMeshK;
-    SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM);
-
-//#ifdef __APPLE__
-//    signal(SIGFPE,SIG_DFL);
-//#endif
-
-  }else
-  {
-    typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
-    typedef
-      SelfIntersectMesh<
-        Kernel,
-        DerivedV,
-        DerivedF,
-        DerivedVV,
-        DerivedFF,
-        DerivedIF,
-        DerivedJ,
-        DerivedIM>
-      SelfIntersectMeshK;
-    SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM);
-  }
-}
-
-#ifdef IGL_STATIC_LIBRARY
-// Explicit template specialization
-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> >&);
-template void igl::cgal::remesh_self_intersections<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, 2, 0, -1, 2>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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&, 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<long, -1, 1, 0, -1, 1>, Eigen::Matrix<long, -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<long, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::remesh_self_intersections<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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, -1, 0, -1, -1> > const&, igl::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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> >&);
-#endif

+ 0 - 85
include/igl/cgal/remesh_self_intersections.h

@@ -1,85 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-// 
-// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
-// obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_CGAL_REMESH_SELF_INTERSECTIONS_H
-#define IGL_CGAL_REMESH_SELF_INTERSECTIONS_H
-#include <igl/igl_inline.h>
-#include "RemeshSelfIntersectionsParam.h"
-
-#include <Eigen/Dense>
-
-#ifdef MEX
-#  include <mex.h>
-#  include <cassert>
-#  undef assert
-#  define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
-#endif
-  
-namespace igl
-{
-  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 VV
-    //   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
-#  include "remesh_self_intersections.cpp"
-#endif
-  
-#endif

+ 0 - 51
include/igl/cgal/signed_distance_isosurface.h

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

+ 12 - 9
include/igl/boolean/BinaryWindingNumberOperations.h → include/igl/copyleft/boolean/BinaryWindingNumberOperations.h

@@ -6,19 +6,21 @@
 // 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_BINARY_WINDING_NUMBER_OPERATIONS
-#define IGL_BINARY_WINDING_NUMBER_OPERATIONS
+#ifndef IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H
+#define IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H
 
 #include <stdexcept>
-#include <igl/igl_inline.h>
+#include "../../igl_inline.h"
 #include "MeshBooleanType.h"
 #include <Eigen/Core>
 
 namespace igl
 {
+  namespace copyleft
+  {
     namespace boolean
     {
-        template <igl::boolean::MeshBooleanType Op>
+        template <igl::copyleft::boolean::MeshBooleanType Op>
         class BinaryWindingNumberOperations {
             public:
                 template<typename DerivedW>
@@ -29,7 +31,7 @@ namespace igl
         };
 
         template <>
-        class BinaryWindingNumberOperations<igl::boolean::MESH_BOOLEAN_TYPE_UNION> {
+        class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_UNION> {
             public:
                 template<typename DerivedW>
                     typename DerivedW::Scalar operator()(
@@ -39,7 +41,7 @@ namespace igl
         };
 
         template <>
-        class BinaryWindingNumberOperations<igl::boolean::MESH_BOOLEAN_TYPE_INTERSECT> {
+        class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_INTERSECT> {
             public:
                 template<typename DerivedW>
                     typename DerivedW::Scalar operator()(
@@ -49,7 +51,7 @@ namespace igl
         };
 
         template <>
-        class BinaryWindingNumberOperations<igl::boolean::MESH_BOOLEAN_TYPE_MINUS> {
+        class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_MINUS> {
             public:
                 template<typename DerivedW>
                     typename DerivedW::Scalar operator()(
@@ -59,7 +61,7 @@ namespace igl
         };
 
         template <>
-        class BinaryWindingNumberOperations<igl::boolean::MESH_BOOLEAN_TYPE_XOR> {
+        class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_XOR> {
             public:
                 template<typename DerivedW>
                     typename DerivedW::Scalar operator()(
@@ -70,7 +72,7 @@ namespace igl
         };
 
         template <>
-        class BinaryWindingNumberOperations<igl::boolean::MESH_BOOLEAN_TYPE_RESOLVE> {
+        class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_RESOLVE> {
             public:
                 template<typename DerivedW>
                     typename DerivedW::Scalar operator()(
@@ -123,6 +125,7 @@ namespace igl
         typedef WindingNumberFilter<KEEP_INSIDE> KeepInside;
         typedef WindingNumberFilter<KEEP_ALL> KeepAll;
     }
+  }
 }
 
 #endif

+ 185 - 0
include/igl/copyleft/boolean/CSGTree.h

@@ -0,0 +1,185 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_BOOLEAN_CSG_TREE_H
+#define IGL_COPYLEFT_BOOLEAN_CSG_TREE_H
+
+#include "string_to_mesh_boolean_type.h"
+#include "MeshBooleanType.h"
+#include "mesh_boolean.h"
+#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
+#include <CGAL/number_utils.h>
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace boolean
+    {
+      // Class for defining and computing a constructive solid geometry result
+      // out of a tree of boolean operations on "solid" triangle meshes.
+      //
+      //template <typename DerivedF>
+      class CSGTree
+      {
+        private:
+          typedef CGAL::Epeck::FT ExactScalar;
+          typedef Eigen::Matrix<ExactScalar,Eigen::Dynamic,3> MatrixX3E;
+          //typedef Eigen::PlainObjectBase<DerivedF> POBF;
+          typedef Eigen::MatrixXi POBF;
+          typedef POBF::Index FIndex;
+          typedef Eigen::Matrix<FIndex,Eigen::Dynamic,1> VectorJ;
+          // Resulting mesh
+          MatrixX3E m_V;
+          POBF m_F;
+          VectorJ m_J;
+          // Number of birth faces in A + those in B. I.e. sum of original "leaf"
+          // faces involved in result.
+          size_t m_number_of_birth_faces;
+        public:
+          CSGTree()
+          {
+          }
+          //typedef Eigen::MatrixXd MatrixX3E;
+          //typedef Eigen::MatrixXi POBF;
+          // http://stackoverflow.com/a/3279550/148668
+          CSGTree(const CSGTree & other)
+            :
+            // copy things
+            m_V(other.m_V),
+            // This is an issue if m_F is templated
+            // https://forum.kde.org/viewtopic.php?f=74&t=128414
+            m_F(other.m_F),
+            m_J(other.m_J),
+            m_number_of_birth_faces(other.m_number_of_birth_faces)
+          {
+          }
+          // copy-swap idiom
+          friend void swap(CSGTree& first, CSGTree& second)
+          {
+            using std::swap;
+            // swap things
+            swap(first.m_V,second.m_V);
+            // This is an issue if m_F is templated, similar to
+            // https://forum.kde.org/viewtopic.php?f=74&t=128414
+            swap(first.m_F,second.m_F);
+            swap(first.m_J,second.m_J);
+            swap(first.m_number_of_birth_faces,second.m_number_of_birth_faces);
+          }
+          // Pass-by-value (aka copy)
+          CSGTree& operator=(CSGTree other)
+          {
+            swap(*this,other);
+            return *this;
+          }
+          CSGTree(CSGTree&& other):
+            // initialize via default constructor
+            CSGTree() 
+          {
+            swap(*this,other);
+          }
+          // Construct and compute a boolean operation on existing CSGTree nodes.
+          //
+          // Inputs:
+          //   A  Solid result of previous CSG operation (or identity, see below)
+          //   B  Solid result of previous CSG operation (or identity, see below)
+          //   type  type of mesh boolean to compute 
+          CSGTree(
+            const CSGTree & A,
+            const CSGTree & B,
+            const MeshBooleanType & type)
+          {
+            // conduct boolean operation
+            mesh_boolean(A.V(),A.F(),B.V(),B.F(),type,m_V,m_F,m_J);
+            // reindex m_J
+            std::for_each(m_J.data(),m_J.data()+m_J.size(),
+              [&](typename VectorJ::Scalar & j)
+              {
+                if(j < A.F().rows())
+                {
+                  j = A.J()(j);
+                }else
+                {
+                  assert(j<(A.F().rows()+B.F().rows()));
+                  j = A.number_of_birth_faces()+(B.J()(j-A.F().rows()));
+                }
+              });
+            m_number_of_birth_faces = 
+              A.number_of_birth_faces() + B.number_of_birth_faces();
+          }
+          // Overload using string for type
+          CSGTree(
+            const CSGTree & A,
+            const CSGTree & B,
+            const std::string & s):
+            CSGTree(A,B,string_to_mesh_boolean_type(s))
+          {
+            // do nothing (all done in constructor).
+          }
+          // "Leaf" node with identity operation on assumed "solid" mesh (V,F)
+          //
+          // Inputs:
+          //   V  #V by 3 list of mesh vertices (in any precision, will be
+          //     converted to exact)
+          //   F  #F by 3 list of mesh face indices into V
+          template <typename DerivedV>
+          CSGTree(const Eigen::PlainObjectBase<DerivedV> & V, const POBF & F)//:
+          // Possible Eigen bug:
+          // https://forum.kde.org/viewtopic.php?f=74&t=128414
+            //m_V(V.template cast<ExactScalar>()),m_F(F)
+          {
+            m_V = V.template cast<ExactScalar>();
+            m_F = F;
+            // number of faces
+            m_number_of_birth_faces = m_F.rows();
+            // identity birth index
+            m_J = VectorJ::LinSpaced(
+              m_number_of_birth_faces,0,m_number_of_birth_faces-1);
+          }
+          // Returns reference to resulting mesh vertices m_V in exact scalar
+          // representation
+          const MatrixX3E & V() const
+          {
+            return m_V;
+          }
+          // Returns mesh vertices in the desired output type, casting when
+          // appropriate to floating precision.
+          template <typename DerivedV>
+          Eigen::PlainObjectBase<DerivedV> cast_V() const
+          {
+            Eigen::PlainObjectBase<DerivedV> dV;
+            dV.resize(m_V.rows(),m_V.cols());
+            for(int i = 0;i<m_V.size();i++)
+            {
+              *(dV.data()+i) = CGAL::to_double((*(m_V.data()+i)));
+            }
+            return dV;
+          }
+          // Returns reference to resulting mesh faces m_F
+          const POBF & F() const
+          {
+            return m_F;
+          }
+          // Returns reference to "birth parents" indices into [F1;F2;...;Fn]
+          // where F1, ... , Fn are the face lists of the leaf ("original") input
+          // meshes.
+          const VectorJ & J() const
+          {
+            return m_J;
+          }
+          // The number of leaf faces = #F1 + #F2 + ... + #Fn
+          const size_t & number_of_birth_faces() const
+          {
+            return m_number_of_birth_faces;
+          }
+      };
+    }
+  }
+}
+
+
+#endif

+ 29 - 0
include/igl/copyleft/boolean/MeshBooleanType.h

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

@@ -11,7 +11,7 @@
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::boolean::from_cork_mesh(
+IGL_INLINE void igl::copyleft::boolean::from_cork_mesh(
   const CorkTriMesh & mesh,
   Eigen::PlainObjectBase<DerivedV > & V,
   Eigen::PlainObjectBase<DerivedF > & F)
@@ -37,8 +37,8 @@ IGL_INLINE void igl::boolean::from_cork_mesh(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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> >&);
+template void igl::copyleft::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::copyleft::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

+ 41 - 0
include/igl/copyleft/boolean/from_cork_mesh.h

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

+ 35 - 33
include/igl/boolean/mesh_boolean.cpp → include/igl/copyleft/boolean/mesh_boolean.cpp

@@ -12,15 +12,16 @@
 #include "../cgal/assign_scalar.h"
 #include "../cgal/propagate_winding_numbers.h"
 #include "../cgal/remesh_self_intersections.h"
-#include "../remove_unreferenced.h"
-#include "../unique_simplices.h"
-#include "../slice.h"
+#include "../../remove_unreferenced.h"
+#include "../../unique_simplices.h"
+#include "../../slice.h"
 
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 #include <algorithm>
 
 
 namespace igl {
+  namespace copyleft {
     namespace boolean {
         namespace mesh_boolean_helper {
             typedef CGAL::Epeck Kernel;
@@ -39,12 +40,12 @@ namespace igl {
                     Eigen::PlainObjectBase<DerivedFo>& Fo,
                     Eigen::PlainObjectBase<DerivedJ>& J) {
                 Eigen::VectorXi I;
-                igl::cgal::RemeshSelfIntersectionsParam params;
+                igl::copyleft::cgal::RemeshSelfIntersectionsParam params;
 
                 DerivedVo Vr;
                 DerivedFo Fr;
                 Eigen::MatrixXi IF;
-                igl::cgal::remesh_self_intersections(V, F, params, Vr, Fr, IF, J, I);
+                igl::copyleft::cgal::remesh_self_intersections(V, F, params, Vr, Fr, IF, J, I);
                 assert(I.size() == Vr.rows());
 
                 // Merge coinciding vertices into non-manifold vertices.
@@ -164,6 +165,7 @@ namespace igl {
             }
         }
     }
+  }
 }
 
 template <
@@ -177,7 +179,7 @@ typename ResolveFunc,
 typename DerivedVC,
 typename DerivedFC,
 typename DerivedJ>
-IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation(
+IGL_INLINE void igl::copyleft::boolean::per_face_winding_number_binary_operation(
         const Eigen::PlainObjectBase<DerivedVA> & VA,
         const Eigen::PlainObjectBase<DerivedFA> & FA,
         const Eigen::PlainObjectBase<DerivedVB> & VB,
@@ -188,7 +190,7 @@ IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation(
         Eigen::PlainObjectBase<DerivedVC > & VC,
         Eigen::PlainObjectBase<DerivedFC > & FC,
         Eigen::PlainObjectBase<DerivedJ > & J) {
-    using namespace igl::boolean::mesh_boolean_helper;
+    using namespace igl::copyleft::boolean::mesh_boolean_helper;
 
     typedef typename DerivedVC::Scalar Scalar;
     typedef typename DerivedFC::Scalar Index;
@@ -213,7 +215,7 @@ IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation(
     Eigen::VectorXi labels(num_faces);
     std::transform(CJ.data(), CJ.data()+CJ.size(), labels.data(),
             [&](int i) { return i<FA.rows() ? 0:1; });
-    igl::cgal::propagate_winding_numbers(V, F, labels, W);
+    igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, W);
     assert(W.rows() == num_faces);
     if (W.cols() == 2) {
         assert(FB.rows() == 0);
@@ -275,7 +277,7 @@ IGL_INLINE void igl::boolean::per_face_winding_number_binary_operation(
         MatrixX3S Vs(V.rows(), V.cols());
         for (size_t i=0; i<V.rows(); i++) {
             for (size_t j=0; j<V.cols(); j++) {
-                igl::cgal::assign_scalar(V(i,j), Vs(i,j));
+                igl::copyleft::cgal::assign_scalar(V(i,j), Vs(i,j));
             }
         }
         Eigen::VectorXi newIM;
@@ -291,7 +293,7 @@ typename DerivedFB,
 typename DerivedVC,
 typename DerivedFC,
 typename DerivedJ>
-IGL_INLINE void igl::boolean::mesh_boolean(
+IGL_INLINE void igl::copyleft::boolean::mesh_boolean(
         const Eigen::PlainObjectBase<DerivedVA > & VA,
         const Eigen::PlainObjectBase<DerivedFA > & FA,
         const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -300,7 +302,7 @@ IGL_INLINE void igl::boolean::mesh_boolean(
         Eigen::PlainObjectBase<DerivedVC > & VC,
         Eigen::PlainObjectBase<DerivedFC > & FC,
         Eigen::PlainObjectBase<DerivedJ > & J) {
-    using namespace igl::boolean::mesh_boolean_helper;
+    using namespace igl::copyleft::boolean::mesh_boolean_helper;
     typedef Eigen::Matrix<
         ExactScalar,
         Eigen::Dynamic,
@@ -316,30 +318,30 @@ IGL_INLINE void igl::boolean::mesh_boolean(
 
     switch (type) {
         case MESH_BOOLEAN_TYPE_UNION:
-            igl::boolean::per_face_winding_number_binary_operation(
-                    VA, FA, VB, FB, igl::boolean::BinaryUnion(),
-                    igl::boolean::KeepInside(), resolve_func, VC, FC, J);
+            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+                    VA, FA, VB, FB, igl::copyleft::boolean::BinaryUnion(),
+                    igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_INTERSECT:
-            igl::boolean::per_face_winding_number_binary_operation(
-                    VA, FA, VB, FB, igl::boolean::BinaryIntersect(),
-                    igl::boolean::KeepInside(), resolve_func, VC, FC, J);
+            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+                    VA, FA, VB, FB, igl::copyleft::boolean::BinaryIntersect(),
+                    igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_MINUS:
-            igl::boolean::per_face_winding_number_binary_operation(
-                    VA, FA, VB, FB, igl::boolean::BinaryMinus(),
-                    igl::boolean::KeepInside(), resolve_func, VC, FC, J);
+            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+                    VA, FA, VB, FB, igl::copyleft::boolean::BinaryMinus(),
+                    igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_XOR:
-            igl::boolean::per_face_winding_number_binary_operation(
-                    VA, FA, VB, FB, igl::boolean::BinaryXor(),
-                    igl::boolean::KeepInside(), resolve_func, VC, FC, J);
+            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+                    VA, FA, VB, FB, igl::copyleft::boolean::BinaryXor(),
+                    igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
             break;
         case MESH_BOOLEAN_TYPE_RESOLVE:
             //op = binary_resolve();
-            igl::boolean::per_face_winding_number_binary_operation(
-                    VA, FA, VB, FB, igl::boolean::BinaryResolve(),
-                    igl::boolean::KeepAll(), resolve_func, VC, FC, J);
+            igl::copyleft::boolean::per_face_winding_number_binary_operation(
+                    VA, FA, VB, FB, igl::copyleft::boolean::BinaryResolve(),
+                    igl::copyleft::boolean::KeepAll(), resolve_func, VC, FC, J);
             break;
         default:
             throw std::runtime_error("Unsupported boolean type.");
@@ -353,7 +355,7 @@ typename DerivedVB,
 typename DerivedFB,
 typename DerivedVC,
 typename DerivedFC>
-IGL_INLINE void igl::boolean::mesh_boolean(
+IGL_INLINE void igl::copyleft::boolean::mesh_boolean(
         const Eigen::PlainObjectBase<DerivedVA > & VA,
         const Eigen::PlainObjectBase<DerivedFA > & FA,
         const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -362,17 +364,17 @@ IGL_INLINE void igl::boolean::mesh_boolean(
         Eigen::PlainObjectBase<DerivedVC > & VC,
         Eigen::PlainObjectBase<DerivedFC > & FC) {
     Eigen::Matrix<typename DerivedFC::Index, Eigen::Dynamic,1> J;
-    return igl::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J);
+    return igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J);
 }
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -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, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::boolean::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -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> >&);
+template void igl::copyleft::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::copyleft::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::copyleft::boolean::mesh_boolean<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -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, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::copyleft::boolean::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::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::copyleft::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> >&);
 #undef IGL_STATIC_LIBRARY
-#include "../remove_unreferenced.cpp"
+#include "../../remove_unreferenced.cpp"
 template void igl::remove_unreferenced<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, 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, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-#include "../slice.cpp"
+#include "../../slice.cpp"
 template void igl::slice<Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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> > >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&);
 #endif

+ 7 - 5
include/igl/boolean/mesh_boolean.h → include/igl/copyleft/boolean/mesh_boolean.h

@@ -7,18 +7,20 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
-#ifndef IGL_BOOLEAN_MESH_BOOLEAN_H
-#define IGL_BOOLEAN_MESH_BOOLEAN_H
+#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
+#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
 
-#include <igl/igl_inline.h>
+#include "../../igl_inline.h"
 #include "MeshBooleanType.h"
 #include <Eigen/Core>
 #include <functional>
 
 namespace igl
 {
-  namespace boolean
+  namespace copyleft
   {
+    namespace boolean
+    {
       template <
           typename DerivedVA,
           typename DerivedFA,
@@ -75,7 +77,7 @@ namespace igl
       const MeshBooleanType & type,
       Eigen::PlainObjectBase<DerivedVC > & VC,
       Eigen::PlainObjectBase<DerivedFC > & FC);
-
+    }
   }
 }
 

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

@@ -17,7 +17,7 @@ template <
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedFC>
-IGL_INLINE void igl::boolean::mesh_boolean_cork(
+IGL_INLINE void igl::copyleft::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::boolean::mesh_boolean_cork(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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> >&);
+template void igl::copyleft::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::copyleft::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::copyleft::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

+ 57 - 0
include/igl/copyleft/boolean/mesh_boolean_cork.h

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

+ 2 - 2
include/igl/boolean/string_to_mesh_boolean_type.cpp → include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp

@@ -3,7 +3,7 @@
 #include <cassert>
 #include <vector>
 
-IGL_INLINE bool igl::boolean::string_to_mesh_boolean_type( 
+IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( 
   const std::string & s,
   MeshBooleanType & type)
 {
@@ -38,7 +38,7 @@ IGL_INLINE bool igl::boolean::string_to_mesh_boolean_type(
   return true;
 }
 
-IGL_INLINE igl::boolean::MeshBooleanType igl::boolean::string_to_mesh_boolean_type( 
+IGL_INLINE igl::copyleft::boolean::MeshBooleanType igl::copyleft::boolean::string_to_mesh_boolean_type( 
   const std::string & s)
 {
   MeshBooleanType type;

+ 44 - 0
include/igl/copyleft/boolean/string_to_mesh_boolean_type.h

@@ -0,0 +1,44 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H
+#define IGL_COPYLEFT_BOOLEAN_STRING_TO_MESH_BOOLEAN_H
+
+#include "../../igl_inline.h"
+#include "MeshBooleanType.h"
+#include <string>
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace boolean
+    {
+      // Convert string to boolean type
+      //
+      //  Inputs:
+      //    s  string identifying type, one of the following:
+      //      "union","intersect","minus","xor","resolve"
+      //  Outputs:
+      //    type  type of boolean operation
+      // Returns true only on success
+      //     
+      IGL_INLINE bool string_to_mesh_boolean_type(
+        const std::string & s,
+        MeshBooleanType & type);
+      // Returns type without error handling
+      IGL_INLINE MeshBooleanType string_to_mesh_boolean_type(
+        const std::string & s);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "string_to_mesh_boolean_type.cpp"
+#endif
+
+#endif

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

@@ -10,7 +10,7 @@
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::boolean::to_cork_mesh(
+IGL_INLINE void igl::copyleft::boolean::to_cork_mesh(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   CorkTriMesh & mesh)
@@ -39,7 +39,7 @@ IGL_INLINE void igl::boolean::to_cork_mesh(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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&);
+template void igl::copyleft::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::copyleft::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

+ 41 - 0
include/igl/copyleft/boolean/to_cork_mesh.h

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

+ 0 - 0
include/igl/cgal/CGAL_includes.hpp → include/igl/copyleft/cgal/CGAL_includes.hpp


+ 31 - 0
include/igl/copyleft/cgal/RemeshSelfIntersectionsParam.h

@@ -0,0 +1,31 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H
+#define IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_PARAM_H
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // 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){};
+        RemeshSelfIntersectionsParam(bool _detect_only, bool _first_only):
+          detect_only(_detect_only),first_only(_first_only){};
+      };
+    }
+  }
+}
+
+#endif

+ 207 - 204
include/igl/cgal/SelfIntersectMesh.h → include/igl/copyleft/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_CGAL_SELFINTERSECTMESH_H
-#define IGL_CGAL_SELFINTERSECTMESH_H
+#ifndef IGL_COPYLEFT_CGAL_SELFINTERSECTMESH_H
+#define IGL_COPYLEFT_CGAL_SELFINTERSECTMESH_H
 
 #include "CGAL_includes.hpp"
 #include "RemeshSelfIntersectionsParam.h"
@@ -25,199 +25,202 @@
 
 namespace igl
 {
-  namespace cgal
+  namespace copyleft
   {
-    // 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;
-        // Using a vector here makes this **not** output sensitive
-        Triangles T;
-        typedef std::vector<Index> IndexList;
-        IndexList lIF;
-        // #F-long list of faces with intersections mapping to the order in
-        // which they were first found
-        std::map<Index,std::pair<Index,ObjectList> > 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;
-        // Maps edges of offending faces to all incident offending faces
-        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 key into offending)
-        //   fb  index of A in F (and key into offending)
-        // 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 key into offending)
-        //   fb  index of B in F (and key into offending)
-        //   va  index of shared vertex in A (and key into offending)
-        //   vb  index of shared vertex in B (and key into offending)
-        //// 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,
-            const std::vector<std::pair<Index,Index> > shared);
-  
-      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
-      public:
-        // Getters:
-        //const IndexList& get_lIF() const{ return lIF;}
-        static inline void box_intersect_static(
-          SelfIntersectMesh * SIM, 
-          const Box &a, 
-          const Box &b);
-    };
+          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;
+          // Using a vector here makes this **not** output sensitive
+          Triangles T;
+          typedef std::vector<Index> IndexList;
+          IndexList lIF;
+          // #F-long list of faces with intersections mapping to the order in
+          // which they were first found
+          std::map<Index,std::pair<Index,ObjectList> > 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;
+          // Maps edges of offending faces to all incident offending faces
+          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 key into offending)
+          //   fb  index of A in F (and key into offending)
+          // 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 key into offending)
+          //   fb  index of B in F (and key into offending)
+          //   va  index of shared vertex in A (and key into offending)
+          //   vb  index of shared vertex in B (and key into offending)
+          //// 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,
+              const std::vector<std::pair<Index,Index> > shared);
+    
+        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
+        public:
+          // Getters:
+          //const IndexList& get_lIF() const{ return lIF;}
+          static inline void box_intersect_static(
+            SelfIntersectMesh * SIM, 
+            const Box &a, 
+            const Box &b);
+      };
+    }
   }
 }
 
@@ -227,9 +230,9 @@ namespace igl
 #include "remesh_intersections.h"
 #include "remesh_intersections.h"
 
-#include <igl/REDRUM.h>
-#include <igl/get_seconds.h>
-#include <igl/C_STR.h>
+#include "../../REDRUM.h"
+#include "../../get_seconds.h"
+#include "../../C_STR.h"
 
 
 #include <functional>
@@ -272,7 +275,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::cgal::SelfIntersectMesh<
+inline void igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -297,7 +300,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline igl::cgal::SelfIntersectMesh<
+inline igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -430,7 +433,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::cgal::SelfIntersectMesh<
+inline void igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -466,7 +469,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::cgal::SelfIntersectMesh<
+inline void igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -497,7 +500,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::cgal::SelfIntersectMesh<
+inline bool igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -536,7 +539,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::cgal::SelfIntersectMesh<
+inline bool igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -582,7 +585,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::cgal::SelfIntersectMesh<
+inline bool igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -661,7 +664,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline bool igl::cgal::SelfIntersectMesh<
+inline bool igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,
@@ -803,7 +806,7 @@ template <
   typename DerivedIF,
   typename DerivedJ,
   typename DerivedIM>
-inline void igl::cgal::SelfIntersectMesh<
+inline void igl::copyleft::cgal::SelfIntersectMesh<
   Kernel,
   DerivedV,
   DerivedF,

+ 3 - 3
include/igl/cgal/assign_scalar.cpp → include/igl/copyleft/cgal/assign_scalar.cpp

@@ -7,21 +7,21 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "assign_scalar.h"
 
-IGL_INLINE void igl::cgal::assign_scalar(
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
   const typename CGAL::Epeck::FT & cgal,
   CGAL::Epeck::FT & d)
 {
   d = cgal;
 }
 
-IGL_INLINE void igl::cgal::assign_scalar(
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
   const typename CGAL::Epeck::FT & cgal,
   double & d)
 {
   d = CGAL::to_double(cgal);
 }
 
-IGL_INLINE void igl::cgal::assign_scalar(
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
   const double & c,
   double & d)
 {

+ 37 - 0
include/igl/copyleft/cgal/assign_scalar.h

@@ -0,0 +1,37 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
+#define IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
+#include "../../igl_inline.h"
+#include "CGAL_includes.hpp"
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // Inputs:
+      //   cgal  cgal scalar
+      // Outputs:
+      //   d  output scalar
+      IGL_INLINE void assign_scalar(
+        const typename CGAL::Epeck::FT & cgal,
+        CGAL::Epeck::FT & d);
+      IGL_INLINE void assign_scalar(
+        const typename CGAL::Epeck::FT & cgal,
+        double & d);
+      IGL_INLINE void assign_scalar(
+        const double & c,
+        double & d);
+    }
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "assign_scalar.cpp"
+#endif
+#endif

+ 5 - 5
include/igl/cgal/closest_facet.cpp → include/igl/copyleft/cgal/closest_facet.cpp

@@ -26,7 +26,7 @@ template<
     typename DerivedP,
     typename DerivedR,
     typename DerivedS >
-IGL_INLINE void igl::cgal::closest_facet(
+IGL_INLINE void igl::copyleft::cgal::closest_facet(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedI>& I,
@@ -172,7 +172,7 @@ IGL_INLINE void igl::cgal::closest_facet(
 
         Eigen::VectorXi order;
         DerivedP pivot = P.row(query_idx).eval();
-        igl::cgal::order_facets_around_edge(V, F, s, d,
+        igl::copyleft::cgal::order_facets_around_edge(V, F, s, d,
                 intersected_face_signed_indices,
                 pivot, order);
 
@@ -343,7 +343,7 @@ template<
     typename DerivedP,
     typename DerivedR,
     typename DerivedS >
-IGL_INLINE void igl::cgal::closest_facet(
+IGL_INLINE void igl::copyleft::cgal::closest_facet(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedP>& P,
@@ -352,9 +352,9 @@ IGL_INLINE void igl::cgal::closest_facet(
     const size_t num_faces = F.rows();
     Eigen::VectorXi I(num_faces);
     I.setLinSpaced(num_faces, 0, num_faces-1);
-    igl::cgal::closest_facet(V, F, I, P, R, S);
+    igl::copyleft::cgal::closest_facet(V, F, I, P, R, S);
 }
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::cgal::closest_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::closest_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 67 - 0
include/igl/copyleft/cgal/closest_facet.h

@@ -0,0 +1,67 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Qingnan Zhou <qnzhou@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_COPYLET_CGAL_CLOSEST_FACET_H
+#define IGL_COPYLET_CGAL_CLOSEST_FACET_H
+
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // Determine the closest facet for each of the input points.
+      //
+      // Inputs:
+      //   V  #V by 3 array of vertices.
+      //   F  #F by 3 array of faces.
+      //   I  #I list of triangle indices to consider.
+      //   P  #P by 3 array of query points.
+      //
+      // Outputs:
+      //   R  #P list of closest facet indices.
+      //   S  #P list of bools indicating on which side of the closest facet
+      //      each query point lies.
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedI,
+          typename DerivedP,
+          typename DerivedR,
+          typename DerivedS >
+      IGL_INLINE void closest_facet(
+        const Eigen::PlainObjectBase<DerivedV>& V,
+        const Eigen::PlainObjectBase<DerivedF>& F,
+        const Eigen::PlainObjectBase<DerivedI>& I,
+        const Eigen::PlainObjectBase<DerivedP>& P,
+              Eigen::PlainObjectBase<DerivedR>& R,
+              Eigen::PlainObjectBase<DerivedS>& S);
+
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedP,
+          typename DerivedR,
+          typename DerivedS >
+      IGL_INLINE void closest_facet(
+              const Eigen::PlainObjectBase<DerivedV>& V,
+              const Eigen::PlainObjectBase<DerivedF>& F,
+              const Eigen::PlainObjectBase<DerivedP>& P,
+              Eigen::PlainObjectBase<DerivedR>& R,
+              Eigen::PlainObjectBase<DerivedS>& S);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#include "closest_facet.cpp"
+#endif
+#endif

+ 4 - 4
include/igl/cgal/complex_to_mesh.cpp → include/igl/copyleft/cgal/complex_to_mesh.cpp

@@ -7,8 +7,8 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "complex_to_mesh.h"
 
-#include <igl/centroid.h>
-#include <igl/remove_unreferenced.h>
+#include "../../centroid.h"
+#include "../../remove_unreferenced.h"
 
 #include <CGAL/Surface_mesh_default_triangulation_3.h>
 #include <CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h>
@@ -16,7 +16,7 @@
 #include <stack>
 
 template <typename Tr, typename DerivedV, typename DerivedF>
-IGL_INLINE bool igl::cgal::complex_to_mesh(
+IGL_INLINE bool igl::copyleft::cgal::complex_to_mesh(
   const CGAL::Complex_2_in_triangulation_3<Tr> & c2t3,
   Eigen::PlainObjectBase<DerivedV> & V, 
   Eigen::PlainObjectBase<DerivedF> & F)
@@ -149,5 +149,5 @@ IGL_INLINE bool igl::cgal::complex_to_mesh(
 }
 
 #ifdef IGL_STATIC_LIBRARY
-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> >&);
+template bool igl::copyleft::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

+ 47 - 0
include/igl/copyleft/cgal/complex_to_mesh.h

@@ -0,0 +1,47 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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_COPYLEFT_CGAL_COMPLEX_TO_MESH_H
+#define IGL_COPYLEFT_CGAL_COMPLEX_TO_MESH_H
+#include "../../igl_inline.h"
+
+#include <Eigen/Dense>
+#include <CGAL/Complex_2_in_triangulation_3.h>
+
+namespace igl 
+{
+  namespace copyleft
+  {
+    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
+#  include "complex_to_mesh.cpp"
+#endif
+
+#endif
+

+ 6 - 6
include/igl/cgal/component_inside_component.cpp → include/igl/copyleft/cgal/component_inside_component.cpp

@@ -22,7 +22,7 @@
 #include "points_inside_component.h"
 
 template <typename DerivedV, typename DerivedF, typename DerivedI>
-IGL_INLINE bool igl::cgal::component_inside_component(
+IGL_INLINE bool igl::copyleft::cgal::component_inside_component(
         const Eigen::PlainObjectBase<DerivedV>& V1,
         const Eigen::PlainObjectBase<DerivedF>& F1,
         const Eigen::PlainObjectBase<DerivedI>& I1,
@@ -39,13 +39,13 @@ IGL_INLINE bool igl::cgal::component_inside_component(
             (V1(f[0],1) + V1(f[1],1) + V1(f[2],1))/3.0,
             (V1(f[0],2) + V1(f[1],2) + V1(f[2],2))/3.0);
     Eigen::VectorXi inside;
-    igl::cgal::points_inside_component(V2, F2, I2, query, inside);
+    igl::copyleft::cgal::points_inside_component(V2, F2, I2, query, inside);
     assert(inside.size() == 1);
     return inside[0];
 }
 
 template<typename DerivedV, typename DerivedF>
-IGL_INLINE bool igl::cgal::component_inside_component(
+IGL_INLINE bool igl::copyleft::cgal::component_inside_component(
         const Eigen::PlainObjectBase<DerivedV>& V1,
         const Eigen::PlainObjectBase<DerivedF>& F1,
         const Eigen::PlainObjectBase<DerivedV>& V2,
@@ -56,13 +56,13 @@ IGL_INLINE bool igl::cgal::component_inside_component(
     Eigen::VectorXi I1(F1.rows()), I2(F2.rows());
     I1.setLinSpaced(F1.rows(), 0, F1.rows()-1);
     I2.setLinSpaced(F2.rows(), 0, F2.rows()-1);
-    return igl::cgal::component_inside_component(V1, F1, I1, V2, F2, I2);
+    return igl::copyleft::cgal::component_inside_component(V1, F1, I1, V2, F2, I2);
 }
 
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template bool igl::cgal::component_inside_component<
+template bool igl::copyleft::cgal::component_inside_component<
 Eigen::Matrix<double, -1, -1, 0, -1, -1>,
 Eigen::Matrix<   int, -1, -1, 0, -1, -1>,
 Eigen::Matrix<   int, -1, -1, 0, -1, -1> > (
@@ -73,7 +73,7 @@ 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&);
 
-template bool igl::cgal::component_inside_component<
+template bool igl::copyleft::cgal::component_inside_component<
 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&,

+ 6 - 3
include/igl/cgal/component_inside_component.h → include/igl/copyleft/cgal/component_inside_component.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 COMONENT_INSIDE_COMPONENT
-#define COMONENT_INSIDE_COMPONENT
+#ifndef IGL_COPYLEFT_CGAL_COMONENT_INSIDE_COMPONENT
+#define IGL_COPYLEFT_CGAL_COMONENT_INSIDE_COMPONENT
 
-#include "../igl_inline.h"
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>
 
 namespace igl {
+  namespace copyleft
+  {
     namespace cgal {
 
         // Determine if connected facet component (V1, F1, I1) is inside of
@@ -64,6 +66,7 @@ namespace igl {
                     const Eigen::PlainObjectBase<DerivedV>& V2,
                     const Eigen::PlainObjectBase<DerivedF>& F2);
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 13 - 13
include/igl/cgal/extract_cells.cpp → include/igl/copyleft/cgal/extract_cells.cpp

@@ -7,10 +7,10 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
 #include "extract_cells.h"
-#include "../extract_manifold_patches.h"
-#include "../facet_components.h"
-#include "../triangle_triangle_adjacency.h"
-#include "../unique_edge_map.h"
+#include "../../extract_manifold_patches.h"
+#include "../../facet_components.h"
+#include "../../triangle_triangle_adjacency.h"
+#include "../../unique_edge_map.h"
 #include "closest_facet.h"
 #include "order_facets_around_edge.h"
 #include "outer_facet.h"
@@ -26,7 +26,7 @@ typename DeriveduE,
 typename uE2EType,
 typename DerivedEMAP,
 typename DerivedC >
-IGL_INLINE size_t igl::cgal::extract_cells_single_component(
+IGL_INLINE size_t igl::copyleft::cgal::extract_cells_single_component(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedP>& P,
@@ -69,7 +69,7 @@ IGL_INLINE size_t igl::cgal::extract_cells_single_component(
                 signed_adj_faces.push_back((fid+1)*(cons ? 1:-1));
             }
             auto& order = orders[i];
-            igl::cgal::order_facets_around_edge(
+            igl::copyleft::cgal::order_facets_around_edge(
                     V, F, s, d, signed_adj_faces, order);
             auto& orientation = orientations[i];
             orientation.resize(order.size());
@@ -162,7 +162,7 @@ template<
     typename uE2EType,
     typename DerivedEMAP,
     typename DerivedC >
-IGL_INLINE size_t igl::cgal::extract_cells(
+IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedP>& P,
@@ -177,7 +177,7 @@ IGL_INLINE size_t igl::cgal::extract_cells(
 
     DerivedC raw_cells;
     const size_t num_raw_cells =
-        igl::cgal::extract_cells_single_component(
+        igl::copyleft::cgal::extract_cells_single_component(
                 V, F, P, uE, uE2E, EMAP, raw_cells);
 
     std::vector<std::vector<std::vector<Index > > > TT,_1;
@@ -203,7 +203,7 @@ IGL_INLINE size_t igl::cgal::extract_cells(
     Eigen::VectorXi outer_cells(num_components);
     for (size_t i=0; i<num_components; i++) {
         bool flipped;
-        igl::cgal::outer_facet(V, F, Is[i], outer_facets[i], flipped);
+        igl::copyleft::cgal::outer_facet(V, F, Is[i], outer_facets[i], flipped);
         outer_facet_orientation[i] = flipped?1:0;
         outer_cells[i] = raw_cells(P[outer_facets[i]], outer_facet_orientation[i]);
     }
@@ -226,7 +226,7 @@ IGL_INLINE size_t igl::cgal::extract_cells(
 
             const auto& I = Is[i];
             Eigen::VectorXi closest_facets, closest_facet_orientations;
-            igl::cgal::closest_facet(V, F, I, queries,
+            igl::copyleft::cgal::closest_facet(V, F, I, queries,
                     closest_facets, closest_facet_orientations);
 
             for (size_t j=0; j<num_components; j++) {
@@ -313,7 +313,7 @@ template<
 typename DerivedV,
 typename DerivedF,
 typename DerivedC >
-IGL_INLINE size_t igl::cgal::extract_cells(
+IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         Eigen::PlainObjectBase<DerivedC>& cells) {
@@ -330,7 +330,7 @@ IGL_INLINE size_t igl::cgal::extract_cells(
 
     DerivedC per_patch_cells;
     const size_t num_cells =
-        igl::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells);
+        igl::copyleft::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells);
 
     cells.resize(num_faces, 2);
     for (size_t i=0; i<num_faces; i++) {
@@ -341,5 +341,5 @@ IGL_INLINE size_t igl::cgal::extract_cells(
 
 #ifdef IGL_STATIC_LIBRARY
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
-template unsigned long igl::cgal::extract_cells<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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>, unsigned long, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >, std::__1::allocator<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template unsigned long igl::copyleft::cgal::extract_cells<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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>, unsigned long, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >, std::__1::allocator<std::__1::vector<unsigned long, std::__1::allocator<unsigned long> > > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 6 - 3
include/igl/cgal/extract_cells.h → include/igl/copyleft/cgal/extract_cells.h

@@ -6,14 +6,16 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
-#ifndef IGL_CGAL_EXTRACT_CELLS
-#define IGL_CGAL_EXTRACT_CELLS
+#ifndef IGL_COPYLEFT_CGAL_EXTRACT_CELLS
+#define IGL_COPYLEFT_CGAL_EXTRACT_CELLS
 
-#include "../igl_inline.h"
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>
 
 namespace igl {
+  namespace copyleft
+  {
     namespace cgal {
         // Extract connected 3D space partitioned by mesh (V, F).
         //
@@ -103,6 +105,7 @@ namespace igl {
                 Eigen::PlainObjectBase<DerivedC>& cells);
 
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 273 - 0
include/igl/copyleft/cgal/intersect_other.cpp

@@ -0,0 +1,273 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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 "intersect_other.h"
+#include "CGAL_includes.hpp"
+#include "mesh_to_cgal_triangle_list.h"
+#include "remesh_intersections.h"
+
+#ifndef IGL_FIRST_HIT_EXCEPTION
+#define IGL_FIRST_HIT_EXCEPTION 10
+#endif
+
+// Un-exposed helper functions
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      template <typename DerivedF>
+      static IGL_INLINE void push_result(
+        const Eigen::PlainObjectBase<DerivedF> & F,
+        const int f,
+        const CGAL::Object & result,
+        std::map<
+          typename DerivedF::Index,
+          std::pair<typename DerivedF::Index,
+            std::vector<CGAL::Object> > > & offending,
+        std::map<
+          std::pair<typename DerivedF::Index,typename DerivedF::Index>,
+          std::vector<typename DerivedF::Index> > & edge2faces)
+      {
+        typedef typename DerivedF::Index Index;
+        typedef std::pair<Index,Index> EMK;
+        if(offending.count(f) == 0)
+        {
+          // first time marking, initialize with new id and empty list
+          Index id = offending.size();
+          offending[f] = {id,{}};
+          for(Index e = 0; e<3;e++)
+          {
+            // append face to edge's list
+            Index i = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+1)%3) : F(f,(e+2)%3);
+            Index j = F(f,(e+1)%3) < F(f,(e+2)%3) ? F(f,(e+2)%3) : F(f,(e+1)%3);
+            edge2faces[EMK(i,j)].push_back(f);
+          }
+        }
+        offending[f].second.push_back(result);
+      }
+      template <
+        typename Kernel,
+        typename DerivedVA,
+        typename DerivedFA,
+        typename DerivedVB,
+        typename DerivedFB,
+        typename DerivedIF,
+        typename DerivedVVA,
+        typename DerivedFFA,
+        typename DerivedJA,
+        typename DerivedIMA,
+        typename DerivedVVB,
+        typename DerivedFFB,
+        typename DerivedJB,
+        typename DerivedIMB>
+      static IGL_INLINE bool intersect_other_helper(
+        const Eigen::PlainObjectBase<DerivedVA> & VA,
+        const Eigen::PlainObjectBase<DerivedFA> & FA,
+        const Eigen::PlainObjectBase<DerivedVB> & VB,
+        const Eigen::PlainObjectBase<DerivedFB> & FB,
+        const RemeshSelfIntersectionsParam & params,
+        Eigen::PlainObjectBase<DerivedIF> & IF,
+        Eigen::PlainObjectBase<DerivedVVA> & VVA,
+        Eigen::PlainObjectBase<DerivedFFA> & FFA,
+        Eigen::PlainObjectBase<DerivedJA>  & JA,
+        Eigen::PlainObjectBase<DerivedIMA> & IMA,
+        Eigen::PlainObjectBase<DerivedVVB> & VVB,
+        Eigen::PlainObjectBase<DerivedFFB> & FFB,
+        Eigen::PlainObjectBase<DerivedJB>  & JB,
+        Eigen::PlainObjectBase<DerivedIMB> & IMB)
+      {
+
+        using namespace std;
+        using namespace Eigen;
+
+        typedef typename DerivedFA::Index Index;
+        // 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; 
+        // 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> CTAB_2;
+        typedef CGAL::Triangulation_data_structure_2<TVB_2,CTAB_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;
+        typedef 
+          std::map<Index,std::pair<Index,std::vector<CGAL::Object> > > 
+          OffendingMap;
+        typedef std::map<std::pair<Index,Index>,std::vector<Index> >  EdgeMap;
+        typedef std::pair<Index,Index> EMK;
+
+        Triangles TA,TB;
+        // Compute and process self intersections
+        mesh_to_cgal_triangle_list(VA,FA,TA);
+        mesh_to_cgal_triangle_list(VB,FB,TB);
+        // http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Box_intersection_d/Chapter_main.html#Section_63.5 
+        // Create the corresponding vector of bounding boxes
+        std::vector<Box> A_boxes,B_boxes;
+        const auto box_up = [](Triangles & T, std::vector<Box> & boxes)
+        {
+          boxes.reserve(T.size());
+          for ( 
+            TrianglesIterator tit = T.begin(); 
+            tit != T.end(); 
+            ++tit)
+          {
+            boxes.push_back(Box(tit->bbox(), tit));
+          }
+        };
+        box_up(TA,A_boxes);
+        box_up(TB,B_boxes);
+        OffendingMap offendingA,offendingB;
+        EdgeMap edge2facesA,edge2facesB;
+
+        std::list<int> lIF;
+        const auto cb = [&](const Box &a, const Box &b)
+        {
+          using namespace std;
+          // index in F and T
+          int fa = a.handle()-TA.begin();
+          int fb = b.handle()-TB.begin();
+          const Triangle_3 & A = *a.handle();
+          const Triangle_3 & B = *b.handle();
+          if(CGAL::do_intersect(A,B))
+          {
+            // There was an intersection
+            lIF.push_back(fa);
+            lIF.push_back(fb);
+            if(params.first_only)
+            {
+              throw IGL_FIRST_HIT_EXCEPTION;
+            }
+            if(!params.detect_only)
+            {
+              CGAL::Object result = CGAL::intersection(A,B);
+
+              push_result(FA,fa,result,offendingA,edge2facesA);
+              push_result(FB,fb,result,offendingB,edge2facesB);
+            }
+          }
+        };
+        try{
+          CGAL::box_intersection_d(
+            A_boxes.begin(), A_boxes.end(),
+            B_boxes.begin(), B_boxes.end(),
+            cb);
+        }catch(int e)
+        {
+          // Rethrow if not FIRST_HIT_EXCEPTION
+          if(e != IGL_FIRST_HIT_EXCEPTION)
+          {
+            throw e;
+          }
+          // Otherwise just fall through
+        }
+
+        // Convert lIF to Eigen matrix
+        assert(lIF.size()%2 == 0);
+        IF.resize(lIF.size()/2,2);
+        {
+          int i=0;
+          for(
+            list<int>::const_iterator ifit = lIF.begin();
+            ifit!=lIF.end();
+            )
+          {
+            IF(i,0) = (*ifit);
+            ifit++; 
+            IF(i,1) = (*ifit);
+            ifit++;
+            i++;
+          }
+        }
+        if(!params.detect_only)
+        {
+          remesh_intersections(VA,FA,TA,offendingA,edge2facesA,VVA,FFA,JA,IMA);
+          remesh_intersections(VB,FB,TB,offendingB,edge2facesB,VVB,FFB,JB,IMB);
+        }
+
+        return IF.rows() > 0;
+      }
+    }
+  }
+}
+
+template <
+  typename DerivedVA,
+  typename DerivedFA,
+  typename DerivedVB,
+  typename DerivedFB,
+  typename DerivedIF,
+  typename DerivedVVA,
+  typename DerivedFFA,
+  typename DerivedJA,
+  typename DerivedIMA,
+  typename DerivedVVB,
+  typename DerivedFFB,
+  typename DerivedJB,
+  typename DerivedIMB>
+IGL_INLINE bool igl::copyleft::cgal::intersect_other(
+  const Eigen::PlainObjectBase<DerivedVA> & VA,
+  const Eigen::PlainObjectBase<DerivedFA> & FA,
+  const Eigen::PlainObjectBase<DerivedVB> & VB,
+  const Eigen::PlainObjectBase<DerivedFB> & FB,
+  const RemeshSelfIntersectionsParam & params,
+  Eigen::PlainObjectBase<DerivedIF> & IF,
+  Eigen::PlainObjectBase<DerivedVVA> & VVA,
+  Eigen::PlainObjectBase<DerivedFFA> & FFA,
+  Eigen::PlainObjectBase<DerivedJA>  & JA,
+  Eigen::PlainObjectBase<DerivedIMA> & IMA,
+  Eigen::PlainObjectBase<DerivedVVB> & VVB,
+  Eigen::PlainObjectBase<DerivedFFB> & FFB,
+  Eigen::PlainObjectBase<DerivedJB>  & JB,
+  Eigen::PlainObjectBase<DerivedIMB> & IMB)
+{
+  if(params.detect_only)
+  {
+    return intersect_other_helper<CGAL::Epick>
+      (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
+  }else
+  {
+    return intersect_other_helper<CGAL::Epeck>
+      (VA,FA,VB,FB,params,IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
+  }
+}
+
+IGL_INLINE bool igl::copyleft::cgal::intersect_other(
+  const Eigen::MatrixXd & VA,
+  const Eigen::MatrixXi & FA,
+  const Eigen::MatrixXd & VB,
+  const Eigen::MatrixXi & FB,
+  const bool first_only,
+  Eigen::MatrixXi & IF)
+{
+  Eigen::MatrixXd VVA,VVB;
+  Eigen::MatrixXi FFA,FFB;
+  Eigen::VectorXi JA,JB,IMA,IMB;
+  return intersect_other(
+    VA,FA,VB,FB,{true,first_only},IF,VVA,FFA,JA,IMA,VVB,FFB,JB,IMB);
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
+#endif

+ 109 - 0
include/igl/copyleft/cgal/intersect_other.h

@@ -0,0 +1,109 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H
+#define IGL_COPYLEFT_CGAL_INTERSECT_OTHER_H
+#include "../../igl_inline.h"
+#include "RemeshSelfIntersectionsParam.h"
+
+#include <Eigen/Dense>
+
+#ifdef MEX
+#  include <mex.h>
+#  include <cassert>
+#  undef assert
+#  define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
+#endif
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // INTERSECT_OTHER Given a triangle mesh (VA,FA) and another mesh (VB,FB)
+      // find all pairs of intersecting faces. Note that self-intersections are
+      // ignored.
+      // 
+      // Inputs:
+      //   VA  #V by 3 list of vertex positions
+      //   FA  #F by 3 list of triangle indices into VA
+      //   VB  #V by 3 list of vertex positions
+      //   FB  #F by 3 list of triangle indices into VB
+      //   params   whether to detect only and then whether to only find first
+      //     intersection
+      // Outputs:
+      //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
+      //     indexing FA and FB
+      //   VVA  #VVA by 3 list of vertex positions
+      //   FFA  #FFA by 3 list of triangle indices into VVA
+      //   JA  #FFA list of indices into FA denoting birth triangle
+      //   IMA  #VVA list of indices into VVA of unique vertices.
+      //   VVB  #VVB by 3 list of vertex positions
+      //   FFB  #FFB by 3 list of triangle indices into VVB
+      //   JB  #FFB list of indices into FB denoting birth triangle
+      //   IMB  #VVB list of indices into VVB of unique vertices.
+      template <
+        typename DerivedVA,
+        typename DerivedFA,
+        typename DerivedVB,
+        typename DerivedFB,
+        typename DerivedIF,
+        typename DerivedVVA,
+        typename DerivedFFA,
+        typename DerivedJA,
+        typename DerivedIMA,
+        typename DerivedVVB,
+        typename DerivedFFB,
+        typename DerivedJB,
+        typename DerivedIMB>
+      IGL_INLINE bool intersect_other(
+        const Eigen::PlainObjectBase<DerivedVA> & VA,
+        const Eigen::PlainObjectBase<DerivedFA> & FA,
+        const Eigen::PlainObjectBase<DerivedVB> & VB,
+        const Eigen::PlainObjectBase<DerivedFB> & FB,
+        const RemeshSelfIntersectionsParam & params,
+        Eigen::PlainObjectBase<DerivedIF> & IF,
+        Eigen::PlainObjectBase<DerivedVVA> & VVA,
+        Eigen::PlainObjectBase<DerivedFFA> & FFA,
+        Eigen::PlainObjectBase<DerivedJA>  & JA,
+        Eigen::PlainObjectBase<DerivedIMA> & IMA,
+        Eigen::PlainObjectBase<DerivedVVB> & VVB,
+        Eigen::PlainObjectBase<DerivedFFB> & FFB,
+        Eigen::PlainObjectBase<DerivedJB>  & JB,
+        Eigen::PlainObjectBase<DerivedIMB> & IMB);
+      // Legacy wrapper for detect only using common types.
+      //
+      // Inputs:
+      //   VA  #V by 3 list of vertex positions
+      //   FA  #F by 3 list of triangle indices into VA
+      //   VB  #V by 3 list of vertex positions
+      //   FB  #F by 3 list of triangle indices into VB
+      //   first_only  whether to only detect the first intersection.
+      // Outputs:
+      //   IF  #intersecting face pairs by 2 list of intersecting face pairs,
+      //     indexing FA and FB
+      // Returns true if any intersections were found
+      //
+      // See also: remesh_self_intersections
+      IGL_INLINE bool intersect_other(
+        const Eigen::MatrixXd & VA,
+        const Eigen::MatrixXi & FA,
+        const Eigen::MatrixXd & VB,
+        const Eigen::MatrixXi & FB,
+        const bool first_only,
+        Eigen::MatrixXi & IF);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "intersect_other.cpp"
+#endif
+  
+#endif
+

+ 65 - 0
include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.cpp

@@ -0,0 +1,65 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "mesh_to_cgal_triangle_list.h"
+#include "assign_scalar.h"
+
+#include <cassert>
+
+template <
+  typename DerivedV,
+  typename DerivedF,
+  typename Kernel>
+IGL_INLINE void igl::copyleft::cgal::mesh_to_cgal_triangle_list(
+  const Eigen::PlainObjectBase<DerivedV> & V,
+  const Eigen::PlainObjectBase<DerivedF> & F,
+  std::vector<CGAL::Triangle_3<Kernel> > & T)
+{
+  typedef CGAL::Point_3<Kernel>    Point_3;
+  typedef CGAL::Triangle_3<Kernel> Triangle_3; 
+  // Must be 3D
+  assert(V.cols() == 3);
+  // **Copy** to convert to output type (this is especially/only needed if the
+  // input type DerivedV::Scalar is CGAL::Epeck
+  Eigen::Matrix<
+    typename Kernel::FT,
+    DerivedV::RowsAtCompileTime,
+    DerivedV::ColsAtCompileTime> 
+    KV(V.rows(),V.cols());
+  // Just use f'ing for loops. What if V and KV don't use same ordering?
+  for(int i = 0;i<V.rows();i++)
+  {
+    for(int j = 0;j<V.cols();j++)
+    {
+      assign_scalar(V(i,j),KV(i,j));
+    }
+  }
+  // Must be triangles
+  assert(F.cols() == 3);
+  T.reserve(F.rows());
+  // Loop over faces
+  for(int f = 0;f<(int)F.rows();f++)
+  {
+    T.push_back(
+      Triangle_3(
+        Point_3( KV(F(f,0),0), KV(F(f,0),1), KV(F(f,0),2)),
+        Point_3( KV(F(f,1),0), KV(F(f,1),1), KV(F(f,1),2)),
+        Point_3( KV(F(f,2),0), KV(F(f,2),1), KV(F(f,2),2))));
+  }
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
+template void igl::copyleft::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::copyleft::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::copyleft::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::copyleft::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
+template void igl::copyleft::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
+template void igl::copyleft::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
+template void igl::copyleft::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epick>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epick>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
+template void igl::copyleft::cgal::mesh_to_cgal_triangle_list<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epeck>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::__1::vector<CGAL::Triangle_3<CGAL::Epeck>, std::__1::allocator<CGAL::Triangle_3<CGAL::Epeck> > >&);
+#endif

+ 44 - 0
include/igl/copyleft/cgal/mesh_to_cgal_triangle_list.h

@@ -0,0 +1,44 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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_COPYLEFT_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H
+#define IGL_COPYLEFT_CGAL_MESH_TO_CGAL_TRIANGLE_LIST_H
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+#include "CGAL_includes.hpp"
+namespace igl
+{
+  namespace copyleft
+  {
+    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"
+#endif
+
+#endif

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

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

+ 42 - 0
include/igl/copyleft/cgal/mesh_to_polyhedron.h

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

+ 13 - 11
include/igl/cgal/order_facets_around_edge.cpp → include/igl/copyleft/cgal/order_facets_around_edge.cpp

@@ -5,6 +5,8 @@
 
 namespace igl
 {
+  namespace copyleft
+  {
     namespace cgal
     {
         namespace order_facets_around_edges_helper
@@ -27,6 +29,7 @@ namespace igl
             }
         }
     }
+  }
 }
 
 // adj_faces contains signed index starting from +- 1.
@@ -34,7 +37,7 @@ template<
     typename DerivedV,
     typename DerivedF,
     typename DerivedI >
-void igl::cgal::order_facets_around_edge(
+void igl::copyleft::cgal::order_facets_around_edge(
     const Eigen::PlainObjectBase<DerivedV>& V,
     const Eigen::PlainObjectBase<DerivedF>& F,
     size_t s,
@@ -42,7 +45,7 @@ void igl::cgal::order_facets_around_edge(
     const std::vector<int>& adj_faces,
     Eigen::PlainObjectBase<DerivedI>& order, bool debug)
 {
-    using namespace igl::cgal::order_facets_around_edges_helper;
+    using namespace igl::copyleft::cgal::order_facets_around_edges_helper;
 
     // Although we only need exact predicates in the algorithm,
     // exact constructions are needed to avoid degeneracies due to
@@ -297,7 +300,7 @@ template<
     typename DerivedF,
     typename DerivedI>
 IGL_INLINE
-void igl::cgal::order_facets_around_edge(
+void igl::copyleft::cgal::order_facets_around_edge(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         size_t s,
@@ -390,7 +393,7 @@ void igl::cgal::order_facets_around_edge(
     }
 
     DerivedI order_with_pivot;
-    igl::cgal::order_facets_around_edge(
+    order_facets_around_edge(
             vertices, faces, N+1, N+2,
             adj_faces_with_pivot, order_with_pivot);
 
@@ -416,11 +419,10 @@ void igl::cgal::order_facets_around_edge(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void
-igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, bool);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, bool);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, bool);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, bool);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, unsigned long, unsigned long, std::vector<int, std::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, unsigned long, unsigned long, std::__1::vector<int, std::__1::allocator<int> > const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 6 - 3
include/igl/cgal/order_facets_around_edge.h → include/igl/copyleft/cgal/order_facets_around_edge.h

@@ -6,13 +6,15 @@
 // 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_EDGE_H
-#define ORDER_FACETS_AROUND_EDGE_H
-#include "../igl_inline.h"
+#ifndef IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H
+#define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGE_H
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>
 
 namespace igl {
+  namespace copyleft
+  {
     namespace cgal {
         // Given a directed edge, sort its adjacent faces.  Assuming the
         // directed edge is (s, d).  Sort the adjacent faces clockwise around the
@@ -63,6 +65,7 @@ namespace igl {
                 const Eigen::PlainObjectBase<DerivedV>& pivot_point,
                 Eigen::PlainObjectBase<DerivedI>& order);
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 7 - 7
include/igl/cgal/order_facets_around_edges.cpp → include/igl/copyleft/cgal/order_facets_around_edges.cpp

@@ -7,7 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "order_facets_around_edges.h"
 #include "order_facets_around_edge.h"
-#include "../sort_angles.h"
+#include "../../sort_angles.h"
 #include <type_traits>
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 
@@ -22,7 +22,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::cgal::order_facets_around_edges(
+igl::copyleft::cgal::order_facets_around_edges(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,
@@ -162,7 +162,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::cgal::order_facets_around_edges(
+igl::copyleft::cgal::order_facets_around_edges(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedN>& N,
@@ -253,7 +253,7 @@ template<
     typename uE2EType,
     typename uE2oEType,
     typename uE2CType >
-IGL_INLINE void igl::cgal::order_facets_around_edges(
+IGL_INLINE void igl::copyleft::cgal::order_facets_around_edges(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DeriveduE>& uE,
@@ -320,7 +320,7 @@ IGL_INLINE void igl::cgal::order_facets_around_edges(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
-template void igl::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
+template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
+template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
+template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
 #endif

+ 107 - 0
include/igl/copyleft/cgal/order_facets_around_edges.h

@@ -0,0 +1,107 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H
+#define IGL_COPYLEFT_CGAL_ORDER_FACETS_AROUND_EDGES_H
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
+#include <vector>
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // For each undirected edge, sort its adjacent faces.  Assuming the
+      // undirected edge is (s, d).  Sort the adjacent faces clockwise around the
+      // axis (d - s), i.e. left-hand rule.  An adjacent face is consistently
+      // oriented if it contains (d, s) as a directed edge.
+      //
+      // For overlapping faces, break the tie using signed face index, smaller
+      // signed index comes before the larger signed index.  Signed index is
+      // computed as (consistent? 1:-1) * index.
+      //
+      // Inputs:
+      //   V    #V by 3 list of vertices.
+      //   F    #F by 3 list of faces
+      //   N    #F by 3 list of face normals.
+      //  uE    #uE by 2 list of vertex_indices, represents undirected edges.
+      //  uE2E  #uE list of lists that maps uE to E. (a one-to-many map)
+      //
+      // Outputs:
+      //   uE2oE #uE list of lists that maps uE to an ordered list of E. (a
+      //         one-to-many map)
+      //   uE2C  #uE list of lists of bools indicates whether each face in
+      //         uE2oE[i] is consistently orientated as the ordering.
+      //
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedN,
+          typename DeriveduE,
+          typename uE2EType,
+          typename uE2oEType,
+          typename uE2CType >
+      IGL_INLINE
+      typename std::enable_if<!std::is_same<typename DerivedV::Scalar,
+      typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
+      order_facets_around_edges(
+              const Eigen::PlainObjectBase<DerivedV>& V,
+              const Eigen::PlainObjectBase<DerivedF>& F,
+              const Eigen::PlainObjectBase<DerivedN>& N,
+              const Eigen::PlainObjectBase<DeriveduE>& uE,
+              const std::vector<std::vector<uE2EType> >& uE2E,
+              std::vector<std::vector<uE2oEType> >& uE2oE,
+              std::vector<std::vector<uE2CType > >& uE2C );
+
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedN,
+          typename DeriveduE,
+          typename uE2EType,
+          typename uE2oEType,
+          typename uE2CType >
+      IGL_INLINE 
+      typename std::enable_if<std::is_same<typename DerivedV::Scalar,
+      typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
+      order_facets_around_edges(
+              const Eigen::PlainObjectBase<DerivedV>& V,
+              const Eigen::PlainObjectBase<DerivedF>& F,
+              const Eigen::PlainObjectBase<DerivedN>& N,
+              const Eigen::PlainObjectBase<DeriveduE>& uE,
+              const std::vector<std::vector<uE2EType> >& uE2E,
+              std::vector<std::vector<uE2oEType> >& uE2oE,
+              std::vector<std::vector<uE2CType > >& uE2C );
+
+      // Order faces around each edge. Only exact predicate is used in the algorithm.
+      // Normal is not needed.
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DeriveduE,
+          typename uE2EType,
+          typename uE2oEType,
+          typename uE2CType >
+      IGL_INLINE void order_facets_around_edges(
+              const Eigen::PlainObjectBase<DerivedV>& V,
+              const Eigen::PlainObjectBase<DerivedF>& F,
+              const Eigen::PlainObjectBase<DeriveduE>& uE,
+              const std::vector<std::vector<uE2EType> >& uE2E,
+              std::vector<std::vector<uE2oEType> >& uE2oE,
+              std::vector<std::vector<uE2CType > >& uE2C );
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#include "order_facets_around_edges.cpp"
+#endif
+
+#endif

+ 9 - 9
include/igl/cgal/outer_element.cpp → include/igl/copyleft/cgal/outer_element.cpp

@@ -16,7 +16,7 @@ template <
      typename IndexType,
      typename DerivedA
      >
-IGL_INLINE void igl::cgal::outer_vertex(
+IGL_INLINE void igl::copyleft::cgal::outer_vertex(
         const Eigen::PlainObjectBase<DerivedV> & V,
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<DerivedI> & I,
@@ -85,7 +85,7 @@ template<
     typename IndexType,
     typename DerivedA
     >
-IGL_INLINE void igl::cgal::outer_edge(
+IGL_INLINE void igl::copyleft::cgal::outer_edge(
         const Eigen::PlainObjectBase<DerivedV> & V,
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<DerivedI> & I,
@@ -211,7 +211,7 @@ template<
     typename DerivedI,
     typename IndexType
     >
-IGL_INLINE void igl::cgal::outer_facet(
+IGL_INLINE void igl::copyleft::cgal::outer_facet(
         const Eigen::PlainObjectBase<DerivedV> & V,
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<DerivedN> & N,
@@ -274,10 +274,10 @@ IGL_INLINE void igl::cgal::outer_facet(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
-template void igl::cgal::outer_facet<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<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 1, -1, -1>, unsigned long>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 1, -1, -1> > const&, unsigned long&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int&, bool&);
-template void igl::cgal::outer_facet<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>, int>(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&, int&, bool&);
-template void igl::cgal::outer_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, long, Eigen::Matrix<long, -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<long, -1, 1, 0, -1, 1> > const&, long&, long&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::outer_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, long, Eigen::Matrix<long, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, long&, long&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::outer_facet<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<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 1, -1, -1>, unsigned long>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 1, -1, -1> > const&, unsigned long&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(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, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<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>, int>(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&, int&, bool&);
+template void igl::copyleft::cgal::outer_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, long, Eigen::Matrix<long, -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<long, -1, 1, 0, -1, 1> > const&, long&, long&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::outer_edge<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, long, Eigen::Matrix<long, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, long&, long&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&);
 #endif

+ 115 - 0
include/igl/copyleft/cgal/outer_element.h

@@ -0,0 +1,115 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Qingan Zhou <qnzhou@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_COPYLEFT_CGAL_OUTER_ELEMENT_H
+#define IGL_COPYLEFT_CGAL_OUTER_ELEMENT_H
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // Find a vertex that is reachable from infinite without crossing any faces.
+      // Such vertex is called "outer vertex."
+      //
+      // Precondition: The input mesh must have all self-intersection resolved and
+      // no duplicated vertices.  See cgal::remesh_self_intersections.h for how to
+      // obtain such input.
+      //
+      // Inputs:
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of triangle indices into V
+      //   I  #I list of facets to consider
+      // Outputs:
+      //   v_index  index of outer vertex
+      //   A  #A list of facets incident to the outer vertex
+      template <
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedI,
+          typename IndexType,
+          typename DerivedA
+          >
+      IGL_INLINE void outer_vertex(
+              const Eigen::PlainObjectBase<DerivedV> & V,
+              const Eigen::PlainObjectBase<DerivedF> & F,
+              const Eigen::PlainObjectBase<DerivedI> & I,
+              IndexType & v_index,
+              Eigen::PlainObjectBase<DerivedA> & A);
+      // Find an edge that is reachable from infinity without crossing any faces.
+      // Such edge is called "outer edge."
+      //
+      // Precondition: The input mesh must have all self-intersection resolved
+      // and no duplicated vertices.  The correctness of the output depends on
+      // the fact that there is no edge overlap.  See
+      // cgal::remesh_self_intersections.h for how to obtain such input.
+      //
+      // Inputs:
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of triangle indices into V
+      //   I  #I list of facets to consider
+      // Outputs:
+      //   v1 index of the first end point of outer edge
+      //   v2 index of the second end point of outer edge
+      //   A  #A list of facets incident to the outer edge
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedI,
+          typename IndexType,
+          typename DerivedA
+          >
+      IGL_INLINE void outer_edge(
+              const Eigen::PlainObjectBase<DerivedV> & V,
+              const Eigen::PlainObjectBase<DerivedF> & F,
+              const Eigen::PlainObjectBase<DerivedI> & I,
+              IndexType & v1,
+              IndexType & v2,
+              Eigen::PlainObjectBase<DerivedA> & A);
+
+
+      // Find a facet that is reachable from infinity without crossing any faces.
+      // Such facet is called "outer facet."
+      //
+      // Precondition: The input mesh must have all self-intersection resolved.
+      // I.e there is no duplicated vertices, no overlapping edge and no
+      // intersecting faces (the only exception is there could be topologically
+      // duplicated faces).  See cgal::remesh_self_intersections.h for how to
+      // obtain such input.
+      //
+      // Inputs:
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of triangle indices into V
+      //   N  #N by 3 list of face normals
+      //   I  #I list of facets to consider
+      // Outputs:
+      //   f  Index of the outer facet.
+      //   flipped  true iff the normal of f points inwards.
+      template<
+          typename DerivedV,
+          typename DerivedF,
+          typename DerivedN,
+          typename DerivedI,
+          typename IndexType
+          >
+      IGL_INLINE void outer_facet(
+              const Eigen::PlainObjectBase<DerivedV> & V,
+              const Eigen::PlainObjectBase<DerivedF> & F,
+              const Eigen::PlainObjectBase<DerivedN> & N,
+              const Eigen::PlainObjectBase<DerivedI> & I,
+              IndexType & f,
+              bool & flipped);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "outer_element.cpp"
+#endif
+#endif

+ 6 - 6
include/igl/cgal/outer_facet.cpp → include/igl/copyleft/cgal/outer_facet.cpp

@@ -18,7 +18,7 @@ template<
     typename DerivedI,
     typename IndexType
     >
-IGL_INLINE void igl::cgal::outer_facet(
+IGL_INLINE void igl::copyleft::cgal::outer_facet(
         const Eigen::PlainObjectBase<DerivedV> & V,
         const Eigen::PlainObjectBase<DerivedF> & F,
         const Eigen::PlainObjectBase<DerivedI> & I,
@@ -83,9 +83,9 @@ IGL_INLINE void igl::cgal::outer_facet(
 // Explicit template specialization
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 #include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
-template void igl::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(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&, int&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned long>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, unsigned long&, bool&);
-template void igl::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, int>(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<long, -1, 1, 0, -1, 1> > const&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(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&, int&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned long>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, unsigned long&, bool&);
+template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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&, int&, bool&);
 #endif

+ 6 - 3
include/igl/cgal/outer_facet.h → include/igl/copyleft/cgal/outer_facet.h

@@ -6,13 +6,15 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 
-#ifndef IGL_CGAL_OUTER_FACET_H
-#define IGL_CGAL_OUTER_FACET_H
-#include "../igl_inline.h"
+#ifndef IGL_COPYLEFT_CGAL_OUTER_FACET_H
+#define IGL_COPYLEFT_CGAL_OUTER_FACET_H
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 
 namespace igl
 {
+  namespace copyleft
+  {
     namespace cgal
     {
         // Find a facet that is reachable from infinity without crossing any faces.
@@ -47,6 +49,7 @@ namespace igl
                 bool & flipped);
     }
 
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 15 - 15
include/igl/cgal/outer_hull.cpp → include/igl/copyleft/cgal/outer_hull.cpp

@@ -9,16 +9,16 @@
 #include "outer_hull.h"
 #include "order_facets_around_edges.h"
 #include "outer_facet.h"
-#include "../sortrows.h"
-#include "../facet_components.h"
-#include "../winding_number.h"
-#include "../triangle_triangle_adjacency.h"
-#include "../unique_edge_map.h"
-#include "../barycenter.h"
-#include "../per_face_normals.h"
-#include "../writePLY.h"
-#include "../sort_angles.h"
-#include "../writePLY.h"
+#include "../../sortrows.h"
+#include "../../facet_components.h"
+#include "../../winding_number.h"
+#include "../../triangle_triangle_adjacency.h"
+#include "../../unique_edge_map.h"
+#include "../../barycenter.h"
+#include "../../per_face_normals.h"
+#include "../../writePLY.h"
+#include "../../sort_angles.h"
+#include "../../writePLY.h"
 
 #include <Eigen/Geometry>
 #include <vector>
@@ -35,7 +35,7 @@ template <
   typename DerivedG,
   typename DerivedJ,
   typename Derivedflip>
-IGL_INLINE void igl::cgal::outer_hull(
+IGL_INLINE void igl::copyleft::cgal::outer_hull(
   const Eigen::PlainObjectBase<DerivedV> & V,
   const Eigen::PlainObjectBase<DerivedF> & F,
   Eigen::PlainObjectBase<DerivedG> & G,
@@ -159,7 +159,7 @@ IGL_INLINE void igl::cgal::outer_hull(
 #ifdef IGL_OUTER_HULL_DEBUG
   cout<<"outer facet..."<<endl;
 #endif
-  igl::cgal::outer_facet(V,F,IM,f,f_flip);
+  igl::copyleft::cgal::outer_facet(V,F,IM,f,f_flip);
 #ifdef IGL_OUTER_HULL_DEBUG
   cout<<"outer facet: "<<f<<endl;
   //cout << V.row(F(f, 0)) << std::endl;
@@ -399,7 +399,7 @@ IGL_INLINE void igl::cgal::outer_hull(
         query_points(i,2) = (V(f(0,0), 2) + V(f(0,1), 2) + V(f(0,2), 2))/3.0;
     }
     Eigen::VectorXi inside;
-    igl::cgal::points_inside_component(V, vG[id], query_points, inside);
+    igl::copyleft::cgal::points_inside_component(V, vG[id], query_points, inside);
     assert((size_t)inside.size() == num_unresolved_components);
     for (size_t i=0; i<num_unresolved_components; i++) {
         if (inside(i, 0)) {
@@ -435,6 +435,6 @@ IGL_INLINE void igl::cgal::outer_hull(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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::copyleft::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::copyleft::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> >&);
 #endif

+ 54 - 0
include/igl/copyleft/cgal/outer_hull.h

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

+ 5 - 5
include/igl/cgal/peel_outer_hull_layers.cpp → include/igl/copyleft/cgal/peel_outer_hull_layers.cpp

@@ -11,9 +11,9 @@
 #include <iostream>
 //#define IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
 #ifdef IGL_PEEL_OUTER_HULL_LAYERS_DEBUG
-#include "../writePLY.h"
-#include "../writeDMAT.h"
-#include "../STR.h"
+#include "../../writePLY.h"
+#include "../../writeDMAT.h"
+#include "../../STR.h"
 #endif
 
 template <
@@ -21,7 +21,7 @@ template <
   typename DerivedF,
   typename DerivedI,
   typename Derivedflip>
-IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
+IGL_INLINE size_t igl::copyleft::cgal::peel_outer_hull_layers(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   Eigen::PlainObjectBase<DerivedI> & I,
@@ -115,5 +115,5 @@ IGL_INLINE size_t igl::cgal::peel_outer_hull_layers(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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<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&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template size_t igl::copyleft::cgal::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::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&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif

+ 47 - 0
include/igl/copyleft/cgal/peel_outer_hull_layers.h

@@ -0,0 +1,47 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_PEEL_OUTER_HULL_LAYERS_H
+#define IGL_COPYLEFT_CGAL_PEEL_OUTER_HULL_LAYERS_H
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+namespace igl
+{
+  namespace copyleft
+  {
+    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
+      // Outputs:
+      //   I  #F list of which peel Iation a facet belongs 
+      //   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 DerivedI,
+        typename Derivedflip>
+      IGL_INLINE size_t peel_outer_hull_layers(
+        const Eigen::PlainObjectBase<DerivedV > & V,
+        const Eigen::PlainObjectBase<DerivedF > & F,
+        Eigen::PlainObjectBase<DerivedI > & I,
+        Eigen::PlainObjectBase<Derivedflip > & flip);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "peel_outer_hull_layers.cpp"
+#endif
+#endif

+ 2 - 2
include/igl/cgal/peel_winding_number_layers.cpp → include/igl/copyleft/cgal/peel_winding_number_layers.cpp

@@ -8,7 +8,7 @@ template<
 typename DerivedV,
 typename DerivedF,
 typename DerivedW >
-IGL_INLINE size_t igl::cgal::peel_winding_number_layers(
+IGL_INLINE size_t igl::copyleft::cgal::peel_winding_number_layers(
         const Eigen::PlainObjectBase<DerivedV > & V,
         const Eigen::PlainObjectBase<DerivedF > & F,
         Eigen::PlainObjectBase<DerivedW>& W) {
@@ -17,7 +17,7 @@ IGL_INLINE size_t igl::cgal::peel_winding_number_layers(
     labels.setZero();
 
     Eigen::MatrixXi winding_numbers;
-    igl::cgal::propagate_winding_numbers(V, F, labels, winding_numbers);
+    igl::copyleft::cgal::propagate_winding_numbers(V, F, labels, winding_numbers);
     assert(winding_numbers.rows() == num_faces);
     assert(winding_numbers.cols() == 2);
 

+ 5 - 3
include/igl/cgal/peel_winding_number_layers.h → include/igl/copyleft/cgal/peel_winding_number_layers.h

@@ -1,9 +1,10 @@
-#ifndef IGL_CGAL_PEEL_WINDING_NUMBER_LAYERS_H
-#define IGL_CGAL_PEEL_WINDING_NUMBER_LAYERS_H
-#include "../igl_inline.h"
+#ifndef IGL_COPYLEFT_CGAL_PEEL_WINDING_NUMBER_LAYERS_H
+#define IGL_COPYLEFT_CGAL_PEEL_WINDING_NUMBER_LAYERS_H
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 
 namespace igl {
+  namespace copyleft {
     namespace cgal {
         template<
             typename DerivedV,
@@ -14,6 +15,7 @@ namespace igl {
                 const Eigen::PlainObjectBase<DerivedF > & F,
                 Eigen::PlainObjectBase<DerivedW>& W);
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

+ 7 - 7
include/igl/cgal/point_mesh_squared_distance.cpp → include/igl/copyleft/cgal/point_mesh_squared_distance.cpp

@@ -9,7 +9,7 @@
 #include "mesh_to_cgal_triangle_list.h"
 
 template <typename Kernel>
-IGL_INLINE void igl::cgal::point_mesh_squared_distance(
+IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance(
   const Eigen::MatrixXd & P,
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
@@ -30,7 +30,7 @@ IGL_INLINE void igl::cgal::point_mesh_squared_distance(
 }
 
 template <typename Kernel>
-IGL_INLINE void igl::cgal::point_mesh_squared_distance_precompute(
+IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance_precompute(
   const Eigen::MatrixXd & V,
   const Eigen::MatrixXi & F,
   CGAL::AABB_tree<
@@ -78,7 +78,7 @@ IGL_INLINE void igl::cgal::point_mesh_squared_distance_precompute(
 }
 
 template <typename Kernel>
-IGL_INLINE void igl::cgal::point_mesh_squared_distance(
+IGL_INLINE void igl::copyleft::cgal::point_mesh_squared_distance(
   const Eigen::MatrixXd & P,
   const CGAL::AABB_tree<
     CGAL::AABB_traits<Kernel, 
@@ -120,8 +120,8 @@ IGL_INLINE void igl::cgal::point_mesh_squared_distance(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::point_mesh_squared_distance_precompute<CGAL::Epick>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epick, CGAL::AABB_triangle_primitive<CGAL::Epick, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >::iterator, CGAL::Boolean_tag<false> > > >&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
-template void igl::cgal::point_mesh_squared_distance<CGAL::Epeck>( const Eigen::MatrixXd & P, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, Eigen::VectorXd & sqrD, Eigen::VectorXi & I, Eigen::MatrixXd & C);
-template void igl::cgal::point_mesh_squared_distance<CGAL::Epick>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
-template void igl::cgal::point_mesh_squared_distance<CGAL::Simple_cartesian<double> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
+template void igl::copyleft::cgal::point_mesh_squared_distance_precompute<CGAL::Epick>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Epick, CGAL::AABB_triangle_primitive<CGAL::Epick, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >::iterator, CGAL::Boolean_tag<false> > > >&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > >&);
+template void igl::copyleft::cgal::point_mesh_squared_distance<CGAL::Epeck>( const Eigen::MatrixXd & P, const Eigen::MatrixXd & V, const Eigen::MatrixXi & F, Eigen::VectorXd & sqrD, Eigen::VectorXi & I, Eigen::MatrixXd & C);
+template void igl::copyleft::cgal::point_mesh_squared_distance<CGAL::Epick>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
+template void igl::copyleft::cgal::point_mesh_squared_distance<CGAL::Simple_cartesian<double> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<int, -1, 1, 0, -1, 1>&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
 #endif

+ 88 - 0
include/igl/copyleft/cgal/point_mesh_squared_distance.h

@@ -0,0 +1,88 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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_COPYLEFT_CGAL_POINT_MESH_SQUARED_DISTANCE_H
+#define IGL_COPYLEFT_CGAL_POINT_MESH_SQUARED_DISTANCE_H
+#include "../../igl_inline.h"
+#include <Eigen/Core>
+#include <vector>
+#include "CGAL_includes.hpp"
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // Compute distances from a set of points P to a triangle mesh (V,F)
+      //
+      // Templates:
+      //   Kernal  CGAL computation and construction kernel (e.g.
+      //     CGAL::Simple_cartesian<double>)
+      // Inputs:
+      //   P  #P by 3 list of query point positions
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of triangle indices
+      // Outputs:
+      //   sqrD  #P list of smallest squared distances
+      //   I  #P list of facet indices corresponding to smallest distances
+      //   C  #P by 3 list of closest points
+      //
+      // Known bugs: This only computes distances to triangles. So unreferenced
+      // vertices and degenerate triangles (segments) are ignored.
+      template <typename Kernel>
+      IGL_INLINE void point_mesh_squared_distance(
+        const Eigen::MatrixXd & P,
+        const Eigen::MatrixXd & V,
+        const Eigen::MatrixXi & F,
+        Eigen::VectorXd & sqrD,
+        Eigen::VectorXi & I,
+        Eigen::MatrixXd & C);
+      // Probably can do this in a way that we don't pass around `tree` and `T`
+      //
+      // Outputs:
+      //   tree  CGAL's AABB tree
+      //   T  list of CGAL triangles in order of F (for determining which was found
+      //     in computation)
+      template <typename Kernel>
+      IGL_INLINE void point_mesh_squared_distance_precompute(
+        const Eigen::MatrixXd & V,
+        const Eigen::MatrixXi & F,
+        CGAL::AABB_tree<
+          CGAL::AABB_traits<Kernel, 
+            CGAL::AABB_triangle_primitive<Kernel, 
+              typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
+            >
+          >
+        > & tree,
+        std::vector<CGAL::Triangle_3<Kernel> > & T);
+      // Inputs:
+      //  see above
+      // Outputs:
+      //  see above
+      template <typename Kernel>
+      IGL_INLINE void point_mesh_squared_distance(
+        const Eigen::MatrixXd & P,
+        const CGAL::AABB_tree<
+          CGAL::AABB_traits<Kernel, 
+            CGAL::AABB_triangle_primitive<Kernel, 
+              typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
+            >
+          >
+        > & tree,
+        const std::vector<CGAL::Triangle_3<Kernel> > & T,
+        Eigen::VectorXd & sqrD,
+        Eigen::VectorXi & I,
+        Eigen::MatrixXd & C);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "point_mesh_squared_distance.cpp"
+#endif
+
+#endif

+ 15 - 12
include/igl/cgal/points_inside_component.cpp → include/igl/copyleft/cgal/points_inside_component.cpp

@@ -21,6 +21,8 @@
 #include "assign_scalar.h"
 
 namespace igl {
+  namespace copyleft 
+  {
     namespace cgal {
         namespace points_inside_component_helper {
             typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
@@ -153,9 +155,9 @@ namespace igl {
                 assert(num_adj_faces > 0);
 
                 DerivedV pivot_point(1, 3);
-                igl::cgal::assign_scalar(query.x(), pivot_point(0, 0));
-                igl::cgal::assign_scalar(query.y(), pivot_point(0, 1));
-                igl::cgal::assign_scalar(query.z(), pivot_point(0, 2));
+                igl::copyleft::cgal::assign_scalar(query.x(), pivot_point(0, 0));
+                igl::copyleft::cgal::assign_scalar(query.y(), pivot_point(0, 1));
+                igl::copyleft::cgal::assign_scalar(query.z(), pivot_point(0, 2));
                 Eigen::VectorXi order;
                 order_facets_around_edge(V, F, s, d,
                         adj_faces, pivot_point, order);
@@ -263,17 +265,18 @@ namespace igl {
             }
         }
     }
+  }
 }
 
 template<typename DerivedV, typename DerivedF, typename DerivedI,
     typename DerivedP, typename DerivedB>
-IGL_INLINE void igl::cgal::points_inside_component(
+IGL_INLINE void igl::copyleft::cgal::points_inside_component(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedI>& I,
         const Eigen::PlainObjectBase<DerivedP>& P,
         Eigen::PlainObjectBase<DerivedB>& inside) {
-    using namespace igl::cgal::points_inside_component_helper;
+    using namespace igl::copyleft::cgal::points_inside_component_helper;
     if (F.rows() <= 0 || I.rows() <= 0) {
         throw "Inside check cannot be done on empty facet component.";
     }
@@ -330,21 +333,21 @@ IGL_INLINE void igl::cgal::points_inside_component(
 
 template<typename DerivedV, typename DerivedF, typename DerivedP,
     typename DerivedB>
-IGL_INLINE void igl::cgal::points_inside_component(
+IGL_INLINE void igl::copyleft::cgal::points_inside_component(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedP>& P,
         Eigen::PlainObjectBase<DerivedB>& inside) {
     Eigen::VectorXi I(F.rows());
     I.setLinSpaced(F.rows(), 0, F.rows()-1);
-    igl::cgal::points_inside_component(V, F, I, P, inside);
+    igl::copyleft::cgal::points_inside_component(V, F, I, P, inside);
 }
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::points_inside_component< 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<   int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> >&);
-template void igl::cgal::points_inside_component< Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<   int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<   int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix< int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> >&);
-template void igl::cgal::points_inside_component<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, 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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::points_inside_component<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, 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<int, -1, 1, 0, -1, 1> >&);
-template void igl::cgal::points_inside_component<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::points_inside_component< 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<   int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> >&);
+template void igl::copyleft::cgal::points_inside_component< Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<   int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<   int, -1, -1, 0, -1, -1> > ( Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix< int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<   int, -1, -1, 0, -1, -1> >&);
+template void igl::copyleft::cgal::points_inside_component<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, 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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::points_inside_component<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, 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<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::points_inside_component<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> >&);
 #endif

+ 6 - 3
include/igl/cgal/points_inside_component.h → include/igl/copyleft/cgal/points_inside_component.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 POINTS_INSIDE_COMPONENTS
-#define POINTS_INSIDE_COMPONENTS
+#ifndef IGL_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS
+#define IGL_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS
 
-#include "../igl_inline.h"
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>
 
 namespace igl {
+  namespace copyleft
+  {
     namespace cgal {
 
         // Determine if queries points P are inside of connected facet component
@@ -51,6 +53,7 @@ namespace igl {
                     const Eigen::PlainObjectBase<DerivedP>& P,
                     Eigen::PlainObjectBase<DerivedB>& inside);
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

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

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

+ 40 - 0
include/igl/copyleft/cgal/polyhedron_to_mesh.h

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

+ 4 - 4
include/igl/cgal/projected_delaunay.cpp → include/igl/copyleft/cgal/projected_delaunay.cpp

@@ -6,7 +6,7 @@
 // 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 "projected_delaunay.h"
-#include "../REDRUM.h"
+#include "../../REDRUM.h"
 #include <iostream>
 #include <cassert>
 
@@ -15,7 +15,7 @@
 #endif
 
 template <typename Kernel>
-IGL_INLINE void igl::cgal::projected_delaunay(
+IGL_INLINE void igl::copyleft::cgal::projected_delaunay(
   const CGAL::Triangle_3<Kernel> & A,
   const std::vector<CGAL::Object> & A_objects_3,
   CGAL::Constrained_triangulation_plus_2<
@@ -101,6 +101,6 @@ IGL_INLINE void igl::cgal::projected_delaunay(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template void igl::cgal::projected_delaunay<CGAL::Epeck>(CGAL::Triangle_3<CGAL::Epeck> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epeck, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epeck, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
-template void igl::cgal::projected_delaunay<CGAL::Epick>(CGAL::Triangle_3<CGAL::Epick> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
+template void igl::copyleft::cgal::projected_delaunay<CGAL::Epeck>(CGAL::Triangle_3<CGAL::Epeck> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epeck, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epeck, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_face_base_2<CGAL::Epeck, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
+template void igl::copyleft::cgal::projected_delaunay<CGAL::Epick>(CGAL::Triangle_3<CGAL::Epick> const&, std::vector<CGAL::Object, std::allocator<CGAL::Object> > const&, CGAL::Constrained_triangulation_plus_2<CGAL::Constrained_Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_2<CGAL::Epick, CGAL::Triangulation_ds_vertex_base_2<void> >, CGAL::Constrained_triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_face_base_2<CGAL::Epick, CGAL::Triangulation_ds_face_base_2<void> > > >, CGAL::Exact_intersections_tag> >&);
 #endif

+ 46 - 0
include/igl/copyleft/cgal/projected_delaunay.h

@@ -0,0 +1,46 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
+// 
+// This Source Code Form is subject to the terms of the Mozilla Public License 
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_COPYLEFT_CGAL_PROJECTED_DELAUNAY_H
+#define IGL_COPYLEFT_CGAL_PROJECTED_DELAUNAY_H
+#include "../../igl_inline.h"
+#include "CGAL_includes.hpp"
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // 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
+      template <typename Kernel>
+      IGL_INLINE void projected_delaunay(
+        const CGAL::Triangle_3<Kernel> & A,
+        const std::vector<CGAL::Object> & A_objects_3,
+        CGAL::Constrained_triangulation_plus_2<
+          CGAL::Constrained_Delaunay_triangulation_2<
+            Kernel,
+            CGAL::Triangulation_data_structure_2<
+              CGAL::Triangulation_vertex_base_2<Kernel>,
+              CGAL::Constrained_triangulation_face_base_2<Kernel> >,
+            CGAL::Exact_intersections_tag> > & cdt);
+    }
+  }
+}
+#ifndef IGL_STATIC_LIBRARY
+#  include "projected_delaunay.cpp"
+#endif
+#endif

+ 10 - 10
include/igl/cgal/propagate_winding_numbers.cpp → include/igl/copyleft/cgal/propagate_winding_numbers.cpp

@@ -7,12 +7,12 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
 #include "propagate_winding_numbers.h"
-#include "../extract_manifold_patches.h"
-#include "../extract_non_manifold_edge_curves.h"
-#include "../facet_components.h"
-#include "../unique_edge_map.h"
-#include "../writeOBJ.h"
-#include "../writePLY.h"
+#include "../../extract_manifold_patches.h"
+#include "../../extract_non_manifold_edge_curves.h"
+#include "../../facet_components.h"
+#include "../../unique_edge_map.h"
+#include "../../writeOBJ.h"
+#include "../../writePLY.h"
 #include "order_facets_around_edge.h"
 #include "outer_facet.h"
 #include "closest_facet.h"
@@ -71,7 +71,7 @@ typename DerivedV,
 typename DerivedF,
 typename DerivedL,
 typename DerivedW>
-IGL_INLINE void igl::cgal::propagate_winding_numbers(
+IGL_INLINE void igl::copyleft::cgal::propagate_winding_numbers(
         const Eigen::PlainObjectBase<DerivedV>& V,
         const Eigen::PlainObjectBase<DerivedF>& F,
         const Eigen::PlainObjectBase<DerivedL>& labels,
@@ -90,7 +90,7 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers(
 
     DerivedW per_patch_cells;
     const size_t num_cells =
-        igl::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells);
+        igl::copyleft::cgal::extract_cells(V, F, P, E, uE, uE2E, EMAP, per_patch_cells);
 
     typedef std::tuple<size_t, bool, size_t> CellConnection;
     std::vector<std::set<CellConnection> > cell_adjacency(num_cells);
@@ -183,7 +183,7 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers(
     bool flipped;
     Eigen::VectorXi I;
     I.setLinSpaced(num_faces, 0, num_faces-1);
-    igl::cgal::outer_facet(V, F, I, outer_facet, flipped);
+    igl::copyleft::cgal::outer_facet(V, F, I, outer_facet, flipped);
 
     const size_t outer_patch = P[outer_facet];
     const size_t infinity_cell = per_patch_cells(outer_patch, flipped?1:0);
@@ -257,5 +257,5 @@ IGL_INLINE void igl::cgal::propagate_winding_numbers(
 
 
 #ifdef IGL_STATIC_LIBRARY
-template void igl::cgal::propagate_winding_numbers<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template void igl::copyleft::cgal::propagate_winding_numbers<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 6 - 3
include/igl/cgal/propagate_winding_numbers.h → include/igl/copyleft/cgal/propagate_winding_numbers.h

@@ -6,9 +6,9 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
-#ifndef IGL_CGAL_PROPAGATE_WINDING_NUMBERS_H
-#define IGL_CGAL_PROPAGATE_WINDING_NUMBERS_H
-#include "../igl_inline.h"
+#ifndef IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H
+#define IGL_COPYLEFT_CGAL_PROPAGATE_WINDING_NUMBERS_H
+#include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <vector>
 
@@ -20,6 +20,8 @@
 // facets.
 
 namespace igl {
+  namespace copyleft
+  {
     namespace cgal {
 
         // Compute winding number on each side of the face.  The input mesh
@@ -49,6 +51,7 @@ namespace igl {
                 const Eigen::PlainObjectBase<DerivedL>& labels,
                 Eigen::PlainObjectBase<DerivedW>& W);
     }
+  }
 }
 
 #ifndef IGL_STATIC_LIBRARY

Різницю між файлами не показано, бо вона завелика
+ 343 - 0
include/igl/copyleft/cgal/remesh_intersections.cpp


+ 73 - 0
include/igl/copyleft/cgal/remesh_intersections.h

@@ -0,0 +1,73 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 Qingnan Zhou <qnzhou@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_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H
+#define IGL_COPYLEFT_CGAL_REMESH_INTERSECTIONS_H
+
+#include "../../igl_inline.h"
+#include <Eigen/Dense>
+#include "CGAL_includes.hpp"
+
+namespace igl
+{
+  namespace copyleft
+  {
+    namespace cgal
+    {
+      // Remesh faces according to results of intersection detection and
+      // construction (e.g. from `igl::copyleft::cgal::intersect_other` or
+      // `igl::copyleft::cgal::SelfIntersectMesh`)
+      //
+      // Inputs:
+      //   V  #V by 3 list of vertex positions
+      //   F  #F by 3 list of triangle indices into V
+      //   T  #F list of cgal triangles
+      //   offending #offending map taking face indices into F to pairs of order
+      //     of first finding and list of intersection objects from all
+      //     intersections
+      //   edge2faces  #edges <= #offending*3 to incident offending faces 
+      // 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.
+      //
+      template <
+        typename DerivedV,
+        typename DerivedF,
+        typename Kernel,
+        typename DerivedVV,
+        typename DerivedFF,
+        typename DerivedJ,
+        typename DerivedIM>
+      IGL_INLINE void remesh_intersections(
+        const Eigen::PlainObjectBase<DerivedV> & V,
+        const Eigen::PlainObjectBase<DerivedF> & F,
+        const std::vector<CGAL::Triangle_3<Kernel> > & T,
+        const std::map<
+          typename DerivedF::Index,
+          std::pair<typename DerivedF::Index,
+            std::vector<CGAL::Object> > > & offending,
+        const std::map<
+          std::pair<typename DerivedF::Index,typename DerivedF::Index>,
+          std::vector<typename DerivedF::Index> > & edge2faces,
+        Eigen::PlainObjectBase<DerivedVV> & VV,
+        Eigen::PlainObjectBase<DerivedFF> & FF,
+        Eigen::PlainObjectBase<DerivedJ> & J,
+        Eigen::PlainObjectBase<DerivedIM> & IM);
+    }
+  }
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "remesh_intersections.cpp"
+#endif
+
+#endif

+ 95 - 0
include/igl/copyleft/cgal/remesh_self_intersections.cpp

@@ -0,0 +1,95 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2014 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 "remesh_self_intersections.h"
+#include "SelfIntersectMesh.h"
+#include "../../C_STR.h"
+#include <list>
+#include <iostream>
+
+template <
+  typename DerivedV,
+  typename DerivedF,
+  typename DerivedVV,
+  typename DerivedFF,
+  typename DerivedIF,
+  typename DerivedJ,
+  typename DerivedIM>
+IGL_INLINE void igl::copyleft::cgal::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)
+{
+  using namespace std;
+  if(params.detect_only)
+  {
+    //// This is probably a terrible idea, but CGAL is throwing floating point
+    //// exceptions.
+
+//#ifdef __APPLE__
+//#define IGL_THROW_FPE 11
+//    const auto & throw_fpe = [](int e)
+//    {
+//      throw "IGL_THROW_FPE";
+//    };
+//    signal(SIGFPE,throw_fpe);
+//#endif
+
+    typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
+    typedef
+      SelfIntersectMesh<
+        Kernel,
+        DerivedV,
+        DerivedF,
+        DerivedVV,
+        DerivedFF,
+        DerivedIF,
+        DerivedJ,
+        DerivedIM>
+      SelfIntersectMeshK;
+    SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM);
+
+//#ifdef __APPLE__
+//    signal(SIGFPE,SIG_DFL);
+//#endif
+
+  }else
+  {
+    typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
+    typedef
+      SelfIntersectMesh<
+        Kernel,
+        DerivedV,
+        DerivedF,
+        DerivedVV,
+        DerivedFF,
+        DerivedIF,
+        DerivedJ,
+        DerivedIM>
+      SelfIntersectMeshK;
+    SelfIntersectMeshK SIM = SelfIntersectMeshK(V,F,params,VV,FF,IF,J,IM);
+  }
+}
+
+#ifdef IGL_STATIC_LIBRARY
+// Explicit template specialization
+template void igl::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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::copyleft::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> >&);
+template void igl::copyleft::cgal::remesh_self_intersections<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, 2, 0, -1, 2>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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&, igl::copyleft::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::copyleft::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<long, -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::copyleft::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<long, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, 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, -1, 0, -1, -1> > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -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::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -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> >&);
+#endif

+ 88 - 0
include/igl/copyleft/cgal/remesh_self_intersections.h

@@ -0,0 +1,88 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_H
+#define IGL_COPYLEFT_CGAL_REMESH_SELF_INTERSECTIONS_H
+#include "../../igl_inline.h"
+#include "RemeshSelfIntersectionsParam.h"
+
+#include <Eigen/Dense>
+
+#ifdef MEX
+#  include <mex.h>
+#  include <cassert>
+#  undef assert
+#  define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
+#endif
+  
+namespace igl
+{
+  namespace copyleft
+  {
+    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 VV
+      //   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::copyleft::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::copyleft::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
+#  include "remesh_self_intersections.cpp"
+#endif
+  
+#endif

+ 9 - 9
include/igl/cgal/signed_distance_isosurface.cpp → include/igl/copyleft/cgal/signed_distance_isosurface.cpp

@@ -9,13 +9,13 @@
 #include "point_mesh_squared_distance.h"
 #include "complex_to_mesh.h"
 
-#include "../AABB.h"
-#include "../per_face_normals.h"
-#include "../per_edge_normals.h"
-#include "../per_vertex_normals.h"
-#include "../centroid.h"
-#include "../WindingNumberAABB.h"
-#include "../matlab_format.h"
+#include "../../AABB.h"
+#include "../../per_face_normals.h"
+#include "../../per_edge_normals.h"
+#include "../../per_vertex_normals.h"
+#include "../../centroid.h"
+#include "../../WindingNumberAABB.h"
+#include "../../matlab_format.h"
 
 #include <CGAL/Surface_mesh_default_triangulation_3.h>
 #include <CGAL/Complex_2_in_triangulation_3.h>
@@ -28,7 +28,7 @@
 #include <CGAL/AABB_triangle_primitive.h>
 #include <vector>
 
-IGL_INLINE bool igl::cgal::signed_distance_isosurface(
+IGL_INLINE bool igl::copyleft::cgal::signed_distance_isosurface(
   const Eigen::MatrixXd & IV,
   const Eigen::MatrixXi & IF,
   const double level,
@@ -135,5 +135,5 @@ IGL_INLINE bool igl::cgal::signed_distance_isosurface(
   // meshing surface
   CGAL::make_surface_mesh(c2t3, surface, criteria, CGAL::Manifold_tag());
   // complex to (V,F)
-  return igl::cgal::complex_to_mesh(c2t3,V,F);
+  return igl::copyleft::cgal::complex_to_mesh(c2t3,V,F);
 }

+ 54 - 0
include/igl/copyleft/cgal/signed_distance_isosurface.h

@@ -0,0 +1,54 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2014 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_COPYLEFT_CGAL_SIGNED_DISTANCE_ISOSURFACE_H
+#define IGL_COPYLEFT_CGAL_SIGNED_DISTANCE_ISOSURFACE_H
+#include "../../igl_inline.h"
+#include "../../signed_distance.h"
+#include <Eigen/Core>
+namespace igl
+{
+  namespace copyleft
+  {
+    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
+#  include "signed_distance_isosurface.cpp"
+#endif
+
+#endif
+

+ 3 - 2
optional/CMakeLists.txt

@@ -170,6 +170,7 @@ include_directories( ${PROJECT_SOURCE_DIR}/../include/)
 
 file(GLOB SOURCES
   "${PROJECT_SOURCE_DIR}/../include/igl/*.cpp"
+  "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/*.cpp"
 )
 
 add_library(igl STATIC ${SOURCES})
@@ -198,13 +199,13 @@ if (NOT CORK_FOUND)
   add_definitions(-DIGL_NO_CORK)
 endif(NOT CORK_FOUND)
 file(GLOB SOURCES_BOOLEAN
-  "${PROJECT_SOURCE_DIR}/../include/igl/boolean/*.cpp"
+  "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/boolean/*.cpp"
 )
 add_library(iglboolean STATIC ${SOURCES_BOOLEAN})
 set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES} "iglboolean")
 #### Compile the cgal part
   file(GLOB SOURCES_CGAL
-    "${PROJECT_SOURCE_DIR}/../include/igl/cgal/*.cpp"
+    "${PROJECT_SOURCE_DIR}/../include/igl/copyleft/cgal/*.cpp"
   )
 add_library(iglcgal STATIC ${SOURCES_CGAL})
 set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES} "iglcgal")

+ 10 - 10
tutorial/609_Boolean/main.cpp

@@ -1,7 +1,7 @@
 #include <igl/readOFF.h>
 #define IGL_NO_CORK
 //#undef IGL_STATIC_LIBRARY
-#include <igl/boolean/mesh_boolean.h>
+#include <igl/copyleft/boolean/mesh_boolean.h>
 #include <igl/viewer/Viewer.h>
 
 #include <Eigen/Core>
@@ -12,8 +12,8 @@
 Eigen::MatrixXd VA,VB,VC;
 Eigen::VectorXi J,I;
 Eigen::MatrixXi FA,FB,FC;
-igl::boolean::MeshBooleanType boolean_type(
-  igl::boolean::MESH_BOOLEAN_TYPE_UNION);
+igl::copyleft::boolean::MeshBooleanType boolean_type(
+  igl::copyleft::boolean::MESH_BOOLEAN_TYPE_UNION);
 
 const char * MESH_BOOLEAN_TYPE_NAMES[] =
 {
@@ -26,7 +26,7 @@ const char * MESH_BOOLEAN_TYPE_NAMES[] =
 
 void update(igl::viewer::Viewer &viewer)
 {
-  igl::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J);
+  igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J);
   Eigen::MatrixXd C(FC.rows(),3);
   for(size_t f = 0;f<C.rows();f++)
   {
@@ -51,14 +51,14 @@ bool key_down(igl::viewer::Viewer &viewer, unsigned char key, int mods)
       return false;
     case '.':
       boolean_type =
-        static_cast<igl::boolean::MeshBooleanType>(
-          (boolean_type+1)% igl::boolean::NUM_MESH_BOOLEAN_TYPES);
+        static_cast<igl::copyleft::boolean::MeshBooleanType>(
+          (boolean_type+1)% igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES);
       break;
     case ',':
       boolean_type =
-        static_cast<igl::boolean::MeshBooleanType>(
-          (boolean_type+igl::boolean::NUM_MESH_BOOLEAN_TYPES-1)%
-          igl::boolean::NUM_MESH_BOOLEAN_TYPES);
+        static_cast<igl::copyleft::boolean::MeshBooleanType>(
+          (boolean_type+igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES-1)%
+          igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES);
       break;
     case '[':
       viewer.core.camera_dnear -= 0.1;
@@ -68,7 +68,7 @@ bool key_down(igl::viewer::Viewer &viewer, unsigned char key, int mods)
       return true;
   }
   std::cout<<"A "<<MESH_BOOLEAN_TYPE_NAMES[boolean_type]<<" B."<<std::endl;
-  igl::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC);
+  igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC);
   update(viewer);
   return true;
 }

+ 2 - 2
tutorial/610_CSGTree/main.cpp

@@ -1,5 +1,5 @@
 #include <igl/read_triangle_mesh.h>
-#include <igl/boolean/CSGTree.h>
+#include <igl/copyleft/boolean/CSGTree.h>
 #include <igl/viewer/Viewer.h>
 #include <igl/jet.h>
 #include <Eigen/Core>
@@ -9,7 +9,7 @@
 int main(int argc, char * argv[])
 {
   using namespace Eigen;
-  using namespace igl::boolean;
+  using namespace igl::copyleft::boolean;
   using namespace std;
   using namespace igl;
   MatrixXi FA,FB,FC,FD,FE;

Деякі файли не було показано, через те що забагато файлів було змінено