Browse Source

fix cgal cmake settings

Former-commit-id: 2ae404fd282ff1eb971d10631cc0ed60dcf74a4e
Alec Jacobson 8 years ago
parent
commit
3d98ce7f30

+ 33 - 0
include/igl/copyleft/cgal/assign_scalar.cpp

@@ -64,3 +64,36 @@ IGL_INLINE void igl::copyleft::cgal::assign_scalar(
 {
   d = c;
 }
+
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
+  const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+  CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & d)
+{
+  d = cgal;
+}
+
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
+  const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+  double & d)
+{
+  const auto interval = CGAL::to_interval(cgal);
+  d = interval.first;
+  do {
+      const double next = nextafter(d, interval.second);
+      if (CGAL::abs(cgal-d) < CGAL::abs(cgal-next)) break;
+      d = next;
+  } while (d < interval.second);
+}
+
+IGL_INLINE void igl::copyleft::cgal::assign_scalar(
+  const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+  float& d)
+{
+  const auto interval = CGAL::to_interval(cgal);
+  d = interval.first;
+  do {
+      const float next = nextafter(d, float(interval.second));
+      if (CGAL::abs(cgal-d) < CGAL::abs(cgal-next)) break;
+      d = next;
+  } while (d < float(interval.second));
+}

+ 11 - 1
include/igl/copyleft/cgal/assign_scalar.h

@@ -8,7 +8,8 @@
 #ifndef IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
 #define IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
 #include "../../igl_inline.h"
-#include "CGAL_includes.hpp"
+#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
+#include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
 namespace igl
 {
   namespace copyleft
@@ -37,6 +38,15 @@ namespace igl
       IGL_INLINE void assign_scalar(
         const float& c,
         double& d);
+      IGL_INLINE void assign_scalar(
+        const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+        CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & d);
+      IGL_INLINE void assign_scalar(
+        const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+        double & d);
+      IGL_INLINE void assign_scalar(
+        const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
+        float& d);
     }
   }
 }

+ 3 - 1
shared/cmake/CMakeLists.txt

@@ -154,7 +154,9 @@ endif()
 
 ### Compile the cgal parts ###
 if(LIBIGL_WITH_CGAL) # to be cleaned
-  find_package(CGAL REQUIRED)
+  # Core is needed for
+  # `Exact_predicates_exact_constructions_kernel_with_sqrt`
+  find_package(CGAL REQUIRED COMPONENTS Core)
   # set(Boost_USE_MULTITHREADED      ON)
   # set(Boost_USE_STATIC_LIBS      ON)
   #

+ 2 - 2
tutorial/CMakeLists.txt

@@ -9,7 +9,7 @@ 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) ###
-find_package(CGAL QUIET)
+find_package(CGAL QUIET COMPONENTS Core)
 option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")
 option(LIBIGL_WITH_COMISO           "Use CoMiso"         ON)
 option(LIBIGL_WITH_CORK             "Use CORK"           OFF)
@@ -28,7 +28,7 @@ option(LIBIGL_WITH_XML              "Use XML"            ON)
 
 ### libIGL options: decide if you want to use the functionalities that depends on cgal
 if(LIBIGL_WITH_CGAL) # Do not remove or move this block, cgal strange build system fails without it
-  find_package(CGAL REQUIRED)
+  find_package(CGAL REQUIRED COMPONENTS Core)
   set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS TRUE CACHE BOOL "CGAL's CMAKE Setup is super annoying ")
   include(${CGAL_USE_FILE})
 endif()