From fa2c23b145904f85d29781015b69d46a43b2ca41 Mon Sep 17 00:00:00 2001 From: Debian Science Team Date: Sun, 6 Oct 2024 13:52:13 +0000 Subject: [PATCH] CGAL_6_compatibility Gbp-Pq: Name CGAL_6_compatibility.diff --- CMakeLists.txt | 10 ++++----- python/setup.py | 4 ++-- src/CSGCGALDomain2D.cpp | 18 ++++++++------- src/CSGCGALDomain3D.cpp | 5 +++-- src/Polyhedron_utils.h | 49 ++++++++++++++++++++++++++--------------- 5 files changed, 51 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aef9ec..32855e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/python/setup.py b/python/setup.py index ed512f8..7aa60b7 100644 --- a/python/setup.py +++ b/python/setup.py @@ -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', diff --git a/src/CSGCGALDomain2D.cpp b/src/CSGCGALDomain2D.cpp index 2bfa192..82006d6 100644 --- a/src/CSGCGALDomain2D.cpp +++ b/src/CSGCGALDomain2D.cpp @@ -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(&*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(&*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; } } diff --git a/src/CSGCGALDomain3D.cpp b/src/CSGCGALDomain3D.cpp index a07a1d6..5f1790f 100644 --- a/src/CSGCGALDomain3D.cpp +++ b/src/CSGCGALDomain3D.cpp @@ -1727,9 +1727,10 @@ namespace auto result = intersection(t, ray); if(result) { - if (const Exact_Point_3* p = boost::get(&*result)) + Exact_Point_3 p; + if (CGAL::assign(p, result)) { - points.insert(*p); + points.insert(p); } } } diff --git a/src/Polyhedron_utils.h b/src/Polyhedron_utils.h index e7e834a..1fa4283 100644 --- a/src/Polyhedron_utils.h +++ b/src/Polyhedron_utils.h @@ -1057,7 +1057,9 @@ class PolyhedronUtils if (intersection) { - if (boost::get(&*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(&*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(&*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(&*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(&*result)) + Point_3 p; + Segment_3 s; + Triangle_3 t; + std::vector 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(&*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(&*result)) + else if (CGAL::assign(t, result)) return true; - else if (const std::vector* v = boost::get >(&*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(&*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(&*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(&*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(&*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(&*result)) + else if (CGAL::assign(t, result)) { - ss << "Triangle: " << *t << std::endl; + ss << "Triangle: " << t << std::endl; } else { -- 2.30.2