CGAL_6_compatibility
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 6 Oct 2024 13:52:13 +0000 (13:52 +0000)
committerFrancesco Ballarin <francesco.ballarin@unicatt.it>
Sun, 6 Oct 2024 13:52:13 +0000 (13:52 +0000)
Gbp-Pq: Name CGAL_6_compatibility.diff

CMakeLists.txt
python/setup.py
src/CSGCGALDomain2D.cpp
src/CSGCGALDomain3D.cpp
src/Polyhedron_utils.h

index 2aef9ece237bcd047e43d55bd242428239c6055c..32855e0d2db877eeaf5eda0af01fe4519d540909 100644 (file)
@@ -14,7 +14,7 @@ endif()
 # CGAL setup
 option(USE_SYSTEM_CGAL "Do not build CGAL, but use an existing build instead." OFF)
 if (USE_SYSTEM_CGAL)
-  find_package(CGAL 5 CONFIG REQUIRED)
+  find_package(CGAL 6 CONFIG REQUIRED)
 endif()
 
 # Borrow some cmake modules from cgal
@@ -43,8 +43,8 @@ MACRO(LIST_CONTAINS var value)
   ENDFOREACH (value2)
 ENDMACRO(LIST_CONTAINS)
 
-# Use C++14 to support std:enable_if used by CGAL 5
-set(CMAKE_CXX_STANDARD 14)
+# Use C++17 as required by CGAL 6
+set(CMAKE_CXX_STANDARD 17)
 
 # Boost
 # This is workaround to avoid that find_package(Boost)
@@ -161,7 +161,7 @@ target_link_libraries( mshr
   )
 
 # CMAKE_CXX_STANDARD is ignored ;( Need to set standard manually here.
-set_property(TARGET mshr PROPERTY CXX_STANDARD 14)
+set_property(TARGET mshr PROPERTY CXX_STANDARD 17)
 
 # install library
 install(TARGETS mshr
@@ -181,7 +181,7 @@ if (ENABLE_MSHRABLE)
     )
 
 # CMAKE_CXX_STANDARD is ignored ;( Need to set standard manually here.
-set_property(TARGET mshrable PROPERTY CXX_STANDARD 14)
+set_property(TARGET mshrable PROPERTY CXX_STANDARD 17)
 
   # install app
   install(TARGETS mshrable
index ed512f89fc593d177be2ae50bfc2ff16be8e2595..7aa60b7d34507843f3bf65d6f081e31cedbff710 100644 (file)
@@ -36,8 +36,8 @@ mshr_ext = Extension('mshr.cpp',
                      include_dirs=include_dirs,
                      library_dirs=config['mshr']['lib_dirs'].split(";"),
                      libraries=config['mshr']['libs'].split(";"),
-                     extra_compile_args=['-std=c++14'],
-                     language='c++14')
+                     extra_compile_args=['-std=c++17'],
+                     language='c++17')
 
 
 setup(name             = 'mshr',
index 2bfa1927eb1603f1f2268285185c5afea02df676..82006d614cc6f0d8afa68a78017d1958db532b52 100644 (file)
@@ -109,35 +109,37 @@ Point_2 point_in_polygon(const Polygon_2& p)
     auto ii = CGAL::intersection(r, *eit);
     if (ii)
     {
-      if (const Point_2* pt = boost::get<Point_2>(&*ii))
+      Point_2 pt;
+      Segment_2 s;
+      if (CGAL::assign(pt, ii))
       {
-        const FT squared_distance = CGAL::squared_distance(source, *pt);
+        const FT squared_distance = CGAL::squared_distance(source, pt);
         if (squared_distance < min_squared_distance)
         {
-          closest = *pt;
+          closest = pt;
           min_squared_distance = squared_distance;
         }
       }
-      else if (const Segment_2* s = boost::get<Segment_2>(&*ii))
+      else if (CGAL::assign(s, ii))
       {
         // If the intersection is a segment, an edge in the polygon is paralell
         // to the ray. Simply check both the source and the target point of the
         // segment.
 
         {
-          const FT squared_distance = CGAL::squared_distance(source, s->source());
+          const FT squared_distance = CGAL::squared_distance(source, s.source());
           if (squared_distance < min_squared_distance)
           {
-            closest = s->source();
+            closest = s.source();
             min_squared_distance = squared_distance;
           }
         }
 
         {
-          const FT squared_distance = CGAL::squared_distance(source, s->target());
+          const FT squared_distance = CGAL::squared_distance(source, s.target());
           if (squared_distance < min_squared_distance)
           {
-            closest = s->target();
+            closest = s.target();
             min_squared_distance = squared_distance;
           }
         }
index a07a1d667d1958c2cfaaed725beadeab0659af64..5f1790fc64bdbe9808b31a2cd595de2187dd9e56 100644 (file)
@@ -1727,9 +1727,10 @@ namespace
         auto result = intersection(t, ray);
         if(result)
         {
-          if (const Exact_Point_3* p = boost::get<Exact_Point_3>(&*result))
+          Exact_Point_3 p;
+          if (CGAL::assign(p, result))
           {
-            points.insert(*p);
+            points.insert(p);
           }
         }
       }
index e7e834a1c03c9a9188913f9b29490b9cb0f45b4b..1fa4283da2c7a7a8e0207fb9d7315634b3e2e282 100644 (file)
@@ -1057,7 +1057,9 @@ class PolyhedronUtils
 
           if (intersection)
           {
-            if (boost::get<InexactPoint_2>(&*intersection))
+            InexactPoint_2 pt;
+            InexactSegment_2 s;
+            if (CGAL::assign(pt, intersection))
             {
               if (j != i+1 && i != (j+1)%vertices.size())
               {
@@ -1067,7 +1069,7 @@ class PolyhedronUtils
                 return false;
               }
             }
-            else if (boost::get<InexactSegment_2>(&*intersection))
+            else if (CGAL::assign(s, intersection))
             {
               std::cout << "Intersects in segment" << std::endl;
               return false;
@@ -1730,14 +1732,16 @@ class PolyhedronUtils
     if (!result)
       return false;
 
-    if (const Point_3* p = boost::get<Point_3>(&*result))
+    Point_3 p;
+    Segment_3 s_;
+    if (CGAL::assign(p, result))
     {
-      if (*p == t[0] || *p == t[1] || *p == t[2])
+      if (p == t[0] || p == t[1] || p == t[2])
         return false;
       else
         return true;
     }
-    else if (const Segment_3* s_ = boost::get<Segment_3>(&*result))
+    else if (CGAL::assign(s_, result))
     {
       if ( (s.source() == t[0] || s.source() == t[1] || s.source() == t[2]) &&
            (s.target() == t[0] || s.target() == t[1] || s.target() == t[2]) )
@@ -1769,7 +1773,11 @@ class PolyhedronUtils
     if (!result)
       return false;
 
-    if (const Point_3* p = boost::get<Point_3>(&*result))
+    Point_3 p;
+    Segment_3 s;
+    Triangle_3 t;
+    std::vector<Point_3> v;
+    if (CGAL::assign(p, result))
     {
       if (t1[0] == t2[0] || t1[0] == t2[1] || t1[0] == t2[2] ||
           t1[1] == t2[0] || t1[1] == t2[1] || t1[1] == t2[2] ||
@@ -1778,7 +1786,7 @@ class PolyhedronUtils
       else
         return true;
     }
-    else if (const Segment_3* s = boost::get<Segment_3>(&*result))
+    else if (CGAL::assign(s, result))
     {
       std::size_t common_vertices = 0;
       if (t1[0] == t2[0] || t1[0] == t2[1] || t1[0] == t2[2])
@@ -1795,9 +1803,9 @@ class PolyhedronUtils
       else
         return true;
     }
-    else if (const Triangle_3* t = boost::get<Triangle_3>(&*result))
+    else if (CGAL::assign(t, result))
       return true;
-    else if (const std::vector<Point_3>* v = boost::get<std::vector<Point_3> >(&*result))
+    else if (CGAL::assign(v, result))
       return true;
 
     dolfin_assert(false);
@@ -2382,11 +2390,13 @@ class PolyhedronUtils
         auto result = CGAL::intersection(t, s);
         dolfin_assert(result);
 
-        if (const Point_3* p = boost::get<Point_3>(&*result))
+       Point_3 p;
+       Segment_3 s;
+        if (CGAL::assign(p, result))
         {
-          dolfin_assert(*p == s.source() || *p == s.target());
+          dolfin_assert(p == s.source() || p == s.target());
         }
-        else if (const Segment_3* s = boost::get<Segment_3>(&*result))
+        else if (CGAL::assign(s, result))
         {
           return true;
         }
@@ -2438,17 +2448,20 @@ class PolyhedronUtils
       const auto result = CGAL::intersection(t1, t2);
 
       dolfin_assert(result);
-      if (const Segment_3* s = boost::get<Segment_3>(&*result))
+      Segment_3 s;
+      Point_3 p;
+      Triangle_3 t;
+      if (CGAL::assign(s, result))
       {
-        ss << "Segment: " << *s << std::endl;
+        ss << "Segment: " << s << std::endl;
       }
-      else if (const Point_3* p = boost::get<Point_3>(&*result))
+      else if (CGAL::assign(p, result))
       {
-        ss << "Point: " << *p << std::endl;
+        ss << "Point: " << p << std::endl;
       }
-      else if (const Triangle_3* t = boost::get<Triangle_3>(&*result))
+      else if (CGAL::assign(t, result))
       {
-        ss << "Triangle: " << *t << std::endl;
+        ss << "Triangle: " << t << std::endl;
       }
       else
       {