Browse Source

separate boolean code to cgal and cork, fix cmake for lib and tutorial

Former-commit-id: b44cb68b3dd7ec2ab8d6b756d73b9f004a8dbc48
Alec Jacobson 9 years ago
parent
commit
dab8fad5dd

+ 3 - 0
.gitmodules

@@ -24,3 +24,6 @@ url=https://github.com/libigl/nanogui.git
 [submodule "external/CoMISo"]
 	path = external/CoMISo
 	url = https://github.com/libigl/CoMISo.git
+[submodule "external/cork"]
+	path = external/cork
+	url = https://github.com/libigl/cork.git

+ 23 - 0
include/igl/MeshBooleanType.h

@@ -0,0 +1,23 @@
+// 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_MESH_BOOLEAN_TYPE_H
+#define IGL_MESH_BOOLEAN_TYPE_H
+namespace igl
+{
+  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 - 29
include/igl/copyleft/boolean/MeshBooleanType.h

@@ -1,29 +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_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

+ 6 - 6
include/igl/copyleft/boolean/BinaryWindingNumberOperations.h → include/igl/copyleft/cgal/BinaryWindingNumberOperations.h

@@ -6,21 +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_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H
-#define IGL_COPYLEFT_BOOLEAN_BINARY_WINDING_NUMBER_OPERATIONS_H
+#ifndef IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H
+#define IGL_COPYLEFT_CGAL_BINARY_WINDING_NUMBER_OPERATIONS_H
 
 #include <stdexcept>
 #include "../../igl_inline.h"
-#include "MeshBooleanType.h"
+#include "../../MeshBooleanType.h"
 #include <Eigen/Core>
 
 namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cgal
     {
-      template <igl::copyleft::boolean::MeshBooleanType Op>
+      template <igl::MeshBooleanType Op>
       class BinaryWindingNumberOperations {
         public:
           template<typename DerivedW>
@@ -72,7 +72,7 @@ namespace igl
       };
 
       template <>
-      class BinaryWindingNumberOperations<igl::copyleft::boolean::MESH_BOOLEAN_TYPE_RESOLVE> {
+      class BinaryWindingNumberOperations<MESH_BOOLEAN_TYPE_RESOLVE> {
         public:
           template<typename DerivedW>
             typename DerivedW::Scalar operator()(

+ 4 - 4
include/igl/copyleft/boolean/CSGTree.h → include/igl/copyleft/cgal/CSGTree.h

@@ -5,11 +5,11 @@
 // 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
+#ifndef IGL_COPYLEFT_CGAL_CSG_TREE_H
+#define IGL_COPYLEFT_CGAL_CSG_TREE_H
 
+#include "../../MeshBooleanType.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>
@@ -18,7 +18,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cgal
     {
       // Class for defining and computing a constructive solid geometry result
       // out of a tree of boolean operations on "solid" triangle meshes.

+ 28 - 28
include/igl/copyleft/boolean/mesh_boolean.cpp → include/igl/copyleft/cgal/mesh_boolean.cpp

@@ -9,11 +9,11 @@
 //
 #include "mesh_boolean.h"
 #include "BinaryWindingNumberOperations.h"
-#include "../cgal/assign_scalar.h"
-#include "../cgal/propagate_winding_numbers.h"
-#include "../cgal/remesh_self_intersections.h"
-#include "../cgal/relabel_small_immersed_cells.h"
-#include "../cgal/extract_cells.h"
+#include "assign_scalar.h"
+#include "propagate_winding_numbers.h"
+#include "remesh_self_intersections.h"
+#include "relabel_small_immersed_cells.h"
+#include "extract_cells.h"
 #include "../../extract_manifold_patches.h"
 #include "../../remove_unreferenced.h"
 #include "../../unique_simplices.h"
@@ -40,7 +40,7 @@ template <
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedJ>
-IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
+IGL_INLINE bool igl::copyleft::cgal::mesh_boolean(
     const Eigen::PlainObjectBase<DerivedVA> & VA,
     const Eigen::PlainObjectBase<DerivedFA> & FA,
     const Eigen::PlainObjectBase<DerivedVB> & VB,
@@ -265,7 +265,7 @@ template <
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedJ>
-IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
+IGL_INLINE bool igl::copyleft::cgal::mesh_boolean(
     const Eigen::PlainObjectBase<DerivedVA > & VA,
     const Eigen::PlainObjectBase<DerivedFA > & FA,
     const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -279,26 +279,26 @@ IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
   switch (type) 
   {
     case MESH_BOOLEAN_TYPE_UNION:
-      return igl::copyleft::boolean::mesh_boolean(
-          VA, FA, VB, FB, igl::copyleft::boolean::BinaryUnion(),
-          igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
+      return igl::copyleft::cgal::mesh_boolean(
+          VA, FA, VB, FB, igl::copyleft::cgal::BinaryUnion(),
+          igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J);
     case MESH_BOOLEAN_TYPE_INTERSECT:
-      return igl::copyleft::boolean::mesh_boolean(
-          VA, FA, VB, FB, igl::copyleft::boolean::BinaryIntersect(),
-          igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
+      return igl::copyleft::cgal::mesh_boolean(
+          VA, FA, VB, FB, igl::copyleft::cgal::BinaryIntersect(),
+          igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J);
     case MESH_BOOLEAN_TYPE_MINUS:
-      return igl::copyleft::boolean::mesh_boolean(
-          VA, FA, VB, FB, igl::copyleft::boolean::BinaryMinus(),
-          igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
+      return igl::copyleft::cgal::mesh_boolean(
+          VA, FA, VB, FB, igl::copyleft::cgal::BinaryMinus(),
+          igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J);
     case MESH_BOOLEAN_TYPE_XOR:
-      return igl::copyleft::boolean::mesh_boolean(
-          VA, FA, VB, FB, igl::copyleft::boolean::BinaryXor(),
-          igl::copyleft::boolean::KeepInside(), resolve_func, VC, FC, J);
+      return igl::copyleft::cgal::mesh_boolean(
+          VA, FA, VB, FB, igl::copyleft::cgal::BinaryXor(),
+          igl::copyleft::cgal::KeepInside(), resolve_func, VC, FC, J);
     case MESH_BOOLEAN_TYPE_RESOLVE:
       //op = binary_resolve();
-      return igl::copyleft::boolean::mesh_boolean(
-          VA, FA, VB, FB, igl::copyleft::boolean::BinaryResolve(),
-          igl::copyleft::boolean::KeepAll(), resolve_func, VC, FC, J);
+      return igl::copyleft::cgal::mesh_boolean(
+          VA, FA, VB, FB, igl::copyleft::cgal::BinaryResolve(),
+          igl::copyleft::cgal::KeepAll(), resolve_func, VC, FC, J);
     default:
       assert(false && "Unsupported boolean type.");
       return false;
@@ -313,7 +313,7 @@ template <
   typename DerivedVC,
   typename DerivedFC,
   typename DerivedJ>
-IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
+IGL_INLINE bool igl::copyleft::cgal::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -371,7 +371,7 @@ template <
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedFC>
-IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
+IGL_INLINE bool igl::copyleft::cgal::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -381,14 +381,14 @@ IGL_INLINE bool igl::copyleft::boolean::mesh_boolean(
   Eigen::PlainObjectBase<DerivedFC > & FC) 
 {
   Eigen::Matrix<typename DerivedFC::Index, Eigen::Dynamic,1> J;
-  return igl::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J);
+  return igl::copyleft::cgal::mesh_boolean(VA,FA,VB,FB,type,VC,FC,J);
 }
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-template bool 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 bool 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 bool 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> >&);
+template bool igl::copyleft::cgal::mesh_boolean<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
+template bool igl::copyleft::cgal::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::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 bool igl::copyleft::cgal::mesh_boolean<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #undef IGL_STATIC_LIBRARY
 #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> >&);

+ 4 - 4
include/igl/copyleft/boolean/mesh_boolean.h → include/igl/copyleft/cgal/mesh_boolean.h

@@ -7,11 +7,11 @@
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
 //
-#ifndef IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
-#define IGL_COPYLEFT_BOOLEAN_MESH_BOOLEAN_H
+#ifndef IGL_COPYLEFT_CGAL_MESH_BOOLEAN_H
+#define IGL_COPYLEFT_CGAL_MESH_BOOLEAN_H
 
 #include "../../igl_inline.h"
-#include "MeshBooleanType.h"
+#include "../../MeshBooleanType.h"
 #include <Eigen/Core>
 #include <functional>
 
@@ -19,7 +19,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cgal
     {
       //  MESH_BOOLEAN Compute boolean csg operations on "solid", consistently
       //  oriented meshes.

+ 4 - 4
include/igl/copyleft/boolean/minkowski_sum.cpp → include/igl/copyleft/cgal/minkowski_sum.cpp

@@ -12,7 +12,7 @@
 #include "../../unique.h"
 #include "../../get_seconds.h"
 #include "../../edges.h"
-#include "../cgal/assign_scalar.h"
+#include "assign_scalar.h"
 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
 #include <cassert>
 #include <vector>
@@ -24,7 +24,7 @@ template <
   typename DerivedW,
   typename DerivedG,
   typename DerivedJ>
-IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
+IGL_INLINE void igl::copyleft::cgal::minkowski_sum(
   const Eigen::PlainObjectBase<DerivedVA> & VA,
   const Eigen::PlainObjectBase<DerivedFA> & FA,
   const Eigen::PlainObjectBase<DerivedVB> & VB,
@@ -149,7 +149,7 @@ template <
   typename DerivedW,
   typename DerivedG,
   typename DerivedJ>
-IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
+IGL_INLINE void igl::copyleft::cgal::minkowski_sum(
   const Eigen::PlainObjectBase<DerivedVA> & VA,
   const Eigen::PlainObjectBase<DerivedFA> & FA,
   const Eigen::Matrix<sType,1,sCols,sOptions> & s,
@@ -354,7 +354,7 @@ template <
   typename DerivedW,
   typename DerivedG,
   typename DerivedJ>
-IGL_INLINE void igl::copyleft::boolean::minkowski_sum(
+IGL_INLINE void igl::copyleft::cgal::minkowski_sum(
   const Eigen::PlainObjectBase<DerivedVA> & VA,
   const Eigen::PlainObjectBase<DerivedFA> & FA,
   const Eigen::Matrix<sType,1,sCols,sOptions> & s,

+ 1 - 1
include/igl/copyleft/boolean/minkowski_sum.h → include/igl/copyleft/cgal/minkowski_sum.h

@@ -15,7 +15,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cgal
     {
       // Compute the Minkowski sum of a closed triangle mesh (V,F) and a
       // set of simplices in 3D.

+ 2 - 1
include/igl/copyleft/cgal/points_inside_component.h

@@ -12,7 +12,8 @@
 #include <Eigen/Core>
 #include <vector>
 
-namespace igl {
+namespace igl 
+{
   namespace copyleft
   {
     namespace cgal {

+ 5 - 3
include/igl/copyleft/boolean/string_to_mesh_boolean_type.cpp → include/igl/copyleft/cgal/string_to_mesh_boolean_type.cpp

@@ -3,7 +3,7 @@
 #include <cassert>
 #include <vector>
 
-IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type( 
+IGL_INLINE bool igl::copyleft::cgal::string_to_mesh_boolean_type( 
   const std::string & s,
   MeshBooleanType & type)
 {
@@ -22,7 +22,8 @@ IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type(
   {
     type = MESH_BOOLEAN_TYPE_INTERSECT;
   }else if(
-    find_any({"minus","subtract","difference","relative complement","m","\\"},eff_s))
+    find_any(
+      {"minus","subtract","difference","relative complement","m","\\"},eff_s))
   {
     type = MESH_BOOLEAN_TYPE_MINUS;
   }else if(find_any({"xor","symmetric difference","x","∆"},eff_s))
@@ -38,7 +39,8 @@ IGL_INLINE bool igl::copyleft::boolean::string_to_mesh_boolean_type(
   return true;
 }
 
-IGL_INLINE igl::copyleft::boolean::MeshBooleanType igl::copyleft::boolean::string_to_mesh_boolean_type( 
+IGL_INLINE igl::MeshBooleanType 
+igl::copyleft::cgal::string_to_mesh_boolean_type( 
   const std::string & s)
 {
   MeshBooleanType type;

+ 4 - 4
include/igl/copyleft/boolean/string_to_mesh_boolean_type.h → include/igl/copyleft/cgal/string_to_mesh_boolean_type.h

@@ -5,18 +5,18 @@
 // 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
+#ifndef IGL_COPYLEFT_CGAL_STRING_TO_MESH_BOOLEAN_H
+#define IGL_COPYLEFT_CGAL_STRING_TO_MESH_BOOLEAN_H
 
 #include "../../igl_inline.h"
-#include "MeshBooleanType.h"
+#include "../../MeshBooleanType.h"
 #include <string>
 
 namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cgal
     {
       // Convert string to boolean type
       //

+ 3 - 6
include/igl/copyleft/boolean/from_cork_mesh.cpp → include/igl/copyleft/cork/from_cork_mesh.cpp

@@ -5,13 +5,12 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_NO_CORK
 #include "from_cork_mesh.h"
 
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::copyleft::boolean::from_cork_mesh(
+IGL_INLINE void igl::copyleft::cork::from_cork_mesh(
   const CorkTriMesh & mesh,
   Eigen::PlainObjectBase<DerivedV > & V,
   Eigen::PlainObjectBase<DerivedF > & F)
@@ -37,8 +36,6 @@ IGL_INLINE void igl::copyleft::boolean::from_cork_mesh(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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
-
+template void igl::copyleft::cork::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::cork::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

+ 3 - 5
include/igl/copyleft/boolean/from_cork_mesh.h → include/igl/copyleft/cork/from_cork_mesh.h

@@ -5,9 +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_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H
-#define IGL_COPYLEFT_BOOLEAN_FROM_CORK_MESH_H
-#ifndef IGL_NO_CORK
+#ifndef IGL_COPYLEFT_CORK_FROM_CORK_MESH_H
+#define IGL_COPYLEFT_CORK_FROM_CORK_MESH_H
 #include "../../igl_inline.h"
 #include <cork.h>
 #include <Eigen/Core>
@@ -15,7 +14,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cork
     {
       // Convert cork's triangle mesh representation to a (V,F) mesh.
       //
@@ -38,4 +37,3 @@ namespace igl
 #  include "from_cork_mesh.cpp"
 #endif
 #endif
-#endif

+ 4 - 6
include/igl/copyleft/boolean/mesh_boolean_cork.cpp → include/igl/copyleft/cork/mesh_boolean.cpp

@@ -5,8 +5,7 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_NO_CORK
-#include "mesh_boolean_cork.h"
+#include "mesh_boolean.h"
 #include "to_cork_mesh.h"
 #include "from_cork_mesh.h"
 
@@ -17,7 +16,7 @@ template <
   typename DerivedFB,
   typename DerivedVC,
   typename DerivedFC>
-IGL_INLINE void igl::copyleft::boolean::mesh_boolean_cork(
+IGL_INLINE void igl::copyleft::cork::mesh_boolean(
   const Eigen::PlainObjectBase<DerivedVA > & VA,
   const Eigen::PlainObjectBase<DerivedFA > & FA,
   const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -94,8 +93,7 @@ IGL_INLINE void igl::copyleft::boolean::mesh_boolean_cork(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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> >&);
+template void igl::copyleft::cork::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&, 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::cork::mesh_boolean<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::MeshBooleanType const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
 #endif
 
-#endif

+ 6 - 8
include/igl/copyleft/boolean/mesh_boolean_cork.h → include/igl/copyleft/cork/mesh_boolean.h

@@ -5,10 +5,9 @@
 // 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"
+#ifndef IGL_COPYLEFT_CORK_MESH_BOOLEAN_H
+#define IGL_COPYLEFT_CORK_MESH_BOOLEAN_H
+#include "../../MeshBooleanType.h"
 #include "../../igl_inline.h"
 #include <Eigen/Core>
 #include <cork.h> // for consistent uint
@@ -17,7 +16,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cork
     {
       // Compute a boolean operation on two input meshes using the cork library.
       //
@@ -37,7 +36,7 @@ namespace igl
         typename DerivedFB,
         typename DerivedVC,
         typename DerivedFC>
-      IGL_INLINE void mesh_boolean_cork(
+      IGL_INLINE void mesh_boolean(
         const Eigen::PlainObjectBase<DerivedVA > & VA,
         const Eigen::PlainObjectBase<DerivedFA > & FA,
         const Eigen::PlainObjectBase<DerivedVB > & VB,
@@ -50,8 +49,7 @@ namespace igl
 }
 
 #ifndef IGL_STATIC_LIBRARY
-#  include "mesh_boolean_cork.cpp"
-#endif
+#  include "mesh_boolean.cpp"
 #endif
 
 #endif

+ 4 - 6
include/igl/copyleft/boolean/to_cork_mesh.cpp → include/igl/copyleft/cork/to_cork_mesh.cpp

@@ -5,12 +5,11 @@
 // This Source Code Form is subject to the terms of the Mozilla Public License 
 // v. 2.0. If a copy of the MPL was not distributed with this file, You can 
 // obtain one at http://mozilla.org/MPL/2.0/.
-#ifndef IGL_NO_CORK
 #include "to_cork_mesh.h"
 template <
   typename DerivedV,
   typename DerivedF>
-IGL_INLINE void igl::copyleft::boolean::to_cork_mesh(
+IGL_INLINE void igl::copyleft::cork::to_cork_mesh(
   const Eigen::PlainObjectBase<DerivedV > & V,
   const Eigen::PlainObjectBase<DerivedF > & F,
   CorkTriMesh & mesh)
@@ -20,7 +19,7 @@ IGL_INLINE void igl::copyleft::boolean::to_cork_mesh(
   assert((V.cols() == 0 || V.cols() == 3) && "Vertices should be in 3D.");
   mesh.n_triangles = F.rows();
   mesh.n_vertices = V.rows();
-  mesh.vertices = new double[mesh.n_vertices*3];
+  mesh.vertices = new float[mesh.n_vertices*3];
   mesh.triangles = new uint[mesh.n_triangles*3];
   for(size_t v = 0;v<mesh.n_vertices;v++)
   {
@@ -39,7 +38,6 @@ IGL_INLINE void igl::copyleft::boolean::to_cork_mesh(
 }
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
-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
+template void igl::copyleft::cork::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::cork::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

+ 3 - 5
include/igl/copyleft/boolean/to_cork_mesh.h → include/igl/copyleft/cork/to_cork_mesh.h

@@ -5,9 +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_COPYLEFT_BOOLEAN_TO_CORK_MESH_H
-#define IGL_COPYLEFT_BOOLEAN_TO_CORK_MESH_H
-#ifndef IGL_NO_CORK
+#ifndef IGL_COPYLEFT_CORK_TO_CORK_MESH_H
+#define IGL_COPYLEFT_CORK_TO_CORK_MESH_H
 #include "../../igl_inline.h"
 #include <cork.h>
 #include <Eigen/Core>
@@ -15,7 +14,7 @@ namespace igl
 {
   namespace copyleft
   {
-    namespace boolean
+    namespace cork
     {
       // Convert a (V,F) mesh to a cork's triangle mesh representation.
       //
@@ -38,4 +37,3 @@ namespace igl
 #  include "to_cork_mesh.cpp"
 #endif
 #endif
-#endif

+ 10 - 6
optional/CMakeLists.txt

@@ -17,17 +17,21 @@ endif()
 option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
 
 
-option(LIBIGL_WITH_ANTTWEAKBAR      "Use AntTweakBar"    OFF)
+option(LIBIGL_WITH_ANTTWEAKBAR      "Use AntTweakBar"    ON)
 option(LIBIGL_WITH_BBW              "Use BBW"            ON)
-option(LIBIGL_WITH_BOOLEAN          "Use Cork boolean"   OFF)
-option(LIBIGL_WITH_CGAL             "Use CGAL"           OFF)
+find_package(CGAL QUIET)
+option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")
 option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
+option(LIBIGL_WITH_CORK             "Use Cork"           ON)
 option(LIBIGL_WITH_EMBREE           "Use Embree"         ON)
 option(LIBIGL_WITH_LIM              "Use LIM"            ON)
-option(LIBIGL_WITH_MATLAB           "Use Matlab"         OFF)
-option(LIBIGL_WITH_MOSEK            "Use MOSEK"          OFF)
+find_package(MATLAB QUIET)
+option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")
+find_package(MOSEK  QUIET)
+option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")
 option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
-option(LIBIGL_WITH_OPENGL_AND_PNG   "Use OpenGL"         ON)
+option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)
+option(LIBIGL_WITH_PNG              "Use PNG"            ON)
 option(LIBIGL_WITH_TETGEN           "Use Tetgen"         ON)
 option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       ON)
 option(LIBIGL_WITH_VIEWER           "Use OpenGL viewer"  ON)

+ 58 - 65
shared/cmake/CMakeLists.txt

@@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 2.8.12)
 project(libigl)
 
 ### Available options ###
-option(LIBIGL_USE_STATIC_LIBRARY    "Use libIGL as static library" OFF)
+option(LIBIGL_USE_STATIC_LIBRARY    "Use libigl as static library" OFF)
 option(LIBIGL_WITH_ANTTWEAKBAR      "Use AntTweakBar"    OFF)
 option(LIBIGL_WITH_BBW              "Use BBW"            OFF)
-option(LIBIGL_WITH_BOOLEAN          "Use Cork boolean"   OFF)
+option(LIBIGL_WITH_CORK             "Use Cork"           OFF)
 option(LIBIGL_WITH_CGAL             "Use CGAL"           OFF)
 option(LIBIGL_WITH_COMISO           "Use CoMiso"         OFF)
 option(LIBIGL_WITH_EMBREE           "Use Embree"         OFF)
@@ -13,7 +13,8 @@ option(LIBIGL_WITH_LIM              "Use LIM"            OFF)
 option(LIBIGL_WITH_MATLAB           "Use Matlab"         OFF)
 option(LIBIGL_WITH_MOSEK            "Use MOSEK"          OFF)
 option(LIBIGL_WITH_NANOGUI          "Use Nanogui menu"   OFF)
-option(LIBIGL_WITH_OPENGL_AND_PNG   "Use OpenGL"         OFF)
+option(LIBIGL_WITH_OPENGL           "Use OpenGL"         OFF)
+option(LIBIGL_WITH_PNG              "Use PNG"            OFF)
 option(LIBIGL_WITH_TETGEN           "Use Tetgen"         OFF)
 option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       OFF)
 option(LIBIGL_WITH_VIEWER           "Use OpenGL viewer"  OFF)
@@ -116,6 +117,42 @@ if(LIBIGL_WITH_BBW)
   endif()
 endif()
 
+### Compile the cgal parts ###
+if(LIBIGL_WITH_CGAL) # to be cleaned
+  find_package(CGAL REQUIRED)
+  # set(Boost_USE_MULTITHREADED      ON)
+  # set(Boost_USE_STATIC_LIBS      ON)
+  #
+  # find_package(BOOST REQUIRED)
+  include(${CGAL_USE_FILE})
+  list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_3RD_PARTY_INCLUDE_DIRS})
+  list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS})
+  list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_3RD_PARTY_LIBRARIES})
+  list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_LIBRARIES})
+  if(LIBIGL_USE_STATIC_LIBRARY)
+    CompileIGL_Module_Copyleft("cgal")
+    target_include_directories(iglcgal PRIVATE
+      ${CGAL_3RD_PARTY_INCLUDE_DIRS}
+      ${CGAL_INCLUDE_DIRS})
+  endif()
+endif()
+
+### Compile the cork parts ###
+if(LIBIGL_WITH_CORK)
+  set(CORK_DIR "${LIBIGL_EXTERNAL}/cork")
+  set(CORK_INCLUDE_DIR "${CORK_DIR}/src")
+  # call this "lib-cork" instead of "cork", otherwise cmake gets confused about
+  # "cork" executable
+  add_subdirectory("${CORK_DIR}" "lib-cork")
+  list(APPEND LIBIGL_INCLUDE_DIRS "${CORK_INCLUDE_DIR}")
+  list(APPEND LIBIGL_EXTRA_LIBRARIES "cork")
+  if(LIBIGL_USE_STATIC_LIBRARY)
+    CompileIGL_Module_Copyleft("cork")
+    target_include_directories(iglcork PRIVATE
+      ${CORK_INCLUDE_DIR})
+  endif()
+endif()
+
 ### Compile the embree part ###
 if(LIBIGL_WITH_EMBREE)
   set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
@@ -255,21 +292,28 @@ if(LIBIGL_WITH_VIEWER)
   endif()
 endif()
 
-### Compile the opengl and png parts ###
-if(LIBIGL_WITH_OPENGL_AND_PNG)
+### Compile the opengl parts ###
+if(LIBIGL_WITH_OPENGL)
+  if(LIBIGL_USE_STATIC_LIBRARY)
+    CompileIGL_Module("opengl")
+    CompileIGL_Module("opengl2")
+    if(NOT APPLE)
+      target_include_directories(iglopengl PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include")
+      target_include_directories(iglopengl2 PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include")
+    endif()
+  endif()
+endif()
+
+### Compile the png parts ###
+if(LIBIGL_WITH_PNG)
   set(STB_IMAGE_DIR "${LIBIGL_EXTERNAL}/stb_image")
   add_subdirectory("${STB_IMAGE_DIR}" "stb_image")
   list(APPEND LIBIGL_INCLUDE_DIRS ${STB_IMAGE_DIR})
   list(APPEND LIBIGL_EXTRA_LIBRARIES "stb_image")
-
   if(LIBIGL_USE_STATIC_LIBRARY)
-    CompileIGL_Module("opengl")
-    CompileIGL_Module("opengl2")
     CompileIGL_Module("png")
     target_include_directories(iglpng PRIVATE ${STB_IMAGE_DIR})
     if(NOT APPLE)
-      target_include_directories(iglopengl PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include")
-      target_include_directories(iglopengl2 PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include")
       target_include_directories(iglpng PRIVATE "${LIBIGL_EXTERNAL}/nanogui/ext/glew/include")
     endif()
   endif()
@@ -333,7 +377,6 @@ endif()
 ### Compile the xml part ###
 if(LIBIGL_WITH_XML)
   set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2")
-
   add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h)
   set_target_properties(tinyxml2 PROPERTIES
           COMPILE_DEFINITIONS "TINYXML2_EXPORT"
@@ -341,62 +384,12 @@ if(LIBIGL_WITH_XML)
           SOVERSION "3")
   list(APPEND LIBIGL_INCLUDE_DIRS ${TINYXML2_DIR})
   list(APPEND LIBIGL_EXTRA_LIBRARIES "tinyxml2")
-
   if(LIBIGL_USE_STATIC_LIBRARY)
     CompileIGL_Module("xml")
     target_include_directories(iglxml PRIVATE ${TINYXML2_DIR})
   endif()
 endif()
 
-### Compile the boolean and cgal parts ###
-if(LIBIGL_WITH_CGAL) # to be cleaned
-  find_package(CGAL REQUIRED)
-  # set(Boost_USE_MULTITHREADED      ON)
-  # set(Boost_USE_STATIC_LIBS      ON)
-  #
-  # find_package(BOOST REQUIRED)
-
-  include(${CGAL_USE_FILE})
-
-  list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_3RD_PARTY_INCLUDE_DIRS})
-  list(APPEND LIBIGL_INCLUDE_DIRS ${CGAL_INCLUDE_DIRS})
-  list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_3RD_PARTY_LIBRARIES})
-  list(APPEND LIBIGL_EXTRA_LIBRARIES ${CGAL_LIBRARIES})
-
-  if(LIBIGL_USE_STATIC_LIBRARY)
-    CompileIGL_Module_Copyleft("cgal")
-    target_include_directories(iglcgal PRIVATE
-      ${CGAL_3RD_PARTY_INCLUDE_DIRS}
-      ${CGAL_INCLUDE_DIRS})
-  endif()
-
-  if(LIBIGL_WITH_BOOLEAN)
-    find_package(CORK QUIET)
-    if(CORK_FOUND)
-      list(APPEND LIBIGL_INCLUDE_DIRS ${CORK_INCLUDE_DIR})
-      list(APPEND LIBIGL_EXTRA_LIBRARIES ${CORK_LIBRARIES})
-
-      if(LIBIGL_USE_STATIC_LIBRARY)
-        CompileIGL_Module_Copyleft("boolean")
-        target_include_directories(iglboolean PRIVATE
-          ${CGAL_3RD_PARTY_INCLUDE_DIRS}
-          ${CGAL_INCLUDE_DIRS}
-          ${CORK_INCLUDE_DIR})
-      endif()
-    else()
-      list(APPEND LIBIGL_DEFINITIONS "-DIGL_NO_CORK")
-
-      if(LIBIGL_USE_STATIC_LIBRARY)
-        CompileIGL_Module_Copyleft("boolean")
-        target_include_directories(iglboolean PRIVATE
-          ${CGAL_3RD_PARTY_INCLUDE_DIRS}
-          ${CGAL_INCLUDE_DIRS})
-        target_compile_definitions(iglboolean PRIVATE -DIGL_NO_CORK)
-      endif()
-    endif()
-  endif()
-endif()
-
 # Function to print list nicely
 function(print_list title list)
   message("-- ${title}:")
@@ -415,8 +408,8 @@ if(NOT ${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
   set(LIBIGL_DEFINITIONS ${LIBIGL_DEFINITIONS} PARENT_SCOPE)
 
   ### ligIGL information ###
-  print_list("libIGL includes" "${LIBIGL_INCLUDE_DIRS}")
-  print_list("libIGL libraries" "${LIBIGL_LIBRARIES}")
-  print_list("libIGL extra libraries" "${LIBIGL_EXTRA_LIBRARIES}")
-  print_list("libIGL definitions" "${LIBIGL_DEFINITIONS}")
+  print_list("libigl includes" "${LIBIGL_INCLUDE_DIRS}")
+  print_list("libigl libraries" "${LIBIGL_LIBRARIES}")
+  print_list("libigl extra libraries" "${LIBIGL_EXTRA_LIBRARIES}")
+  print_list("libigl definitions" "${LIBIGL_DEFINITIONS}")
 endif()

+ 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/copyleft/boolean/mesh_boolean.h>
+#include <igl/copyleft/cgal/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::copyleft::boolean::MeshBooleanType boolean_type(
-  igl::copyleft::boolean::MESH_BOOLEAN_TYPE_UNION);
+igl::MeshBooleanType boolean_type(
+  igl::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::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC,J);
+  igl::copyleft::cgal::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::copyleft::boolean::MeshBooleanType>(
-          (boolean_type+1)% igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES);
+        static_cast<igl::MeshBooleanType>(
+          (boolean_type+1)% igl::NUM_MESH_BOOLEAN_TYPES);
       break;
     case ',':
       boolean_type =
-        static_cast<igl::copyleft::boolean::MeshBooleanType>(
-          (boolean_type+igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES-1)%
-          igl::copyleft::boolean::NUM_MESH_BOOLEAN_TYPES);
+        static_cast<igl::MeshBooleanType>(
+          (boolean_type+igl::NUM_MESH_BOOLEAN_TYPES-1)%
+          igl::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::copyleft::boolean::mesh_boolean(VA,FA,VB,FB,boolean_type,VC,FC);
+  igl::copyleft::cgal::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/copyleft/boolean/CSGTree.h>
+#include <igl/copyleft/cgal/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::copyleft::boolean;
+  using namespace igl::copyleft::cgal;
   using namespace std;
   using namespace igl;
   cout<<R"(

+ 7 - 5
tutorial/CMakeLists.txt

@@ -7,16 +7,18 @@ option(LIBIGL_WITH_VIEWER      "Use OpenGL viewer"  ON)
 option(LIBIGL_WITH_NANOGUI     "Use Nanogui menu"   OFF)
 
 ### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer) ###
+option(LIBIGL_WITH_BBW              "Use BBW"            ON)
 find_package(CGAL QUIET)
 option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")
-option(LIBIGL_WITH_BOOLEAN          "Use Cork boolean"   OFF) # This option is not supported yet
 option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
+option(LIBIGL_WITH_CORK             "Use CORK"           ON)
 option(LIBIGL_WITH_EMBREE           "Use Embree"         ON)
 option(LIBIGL_WITH_LIM              "Use LIM"            ON)
-option(LIBIGL_WITH_MATLAB           "Use Matlab"         OFF) # This option is not supported yet
-option(LIBIGL_WITH_MOSEK            "Use MOSEK"          OFF) # This option is not supported yet
-option(LIBIGL_WITH_BBW              "Use BBW"            ON)
-option(LIBIGL_WITH_OPENGL_AND_PNG   "Use OpenGL"         ON)
+find_package(MATLAB QUIET)
+option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")
+option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")
+option(LIBIGL_WITH_OPENGL           "Use OpenGL"         ON)
+option(LIBIGL_WITH_PNG              "Use PNG"            ON)
 option(LIBIGL_WITH_TETGEN           "Use Tetgen"         ON)
 option(LIBIGL_WITH_TRIANGLE         "Use Triangle"       ON)
 option(LIBIGL_WITH_XML              "Use XML"            ON)