From e1b7c4726edcef250e1ff84579f90ba97e8941f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Thu, 16 Jan 2025 13:40:48 +0100 Subject: [PATCH 1/2] Replace boost::optional with std::optional See https://github.com/CGAL/cgal/pull/7526 --- .../internal/peel_slivers.h | 12 +++++++----- .../CGAL/Triangulation_segment_traverser_3.h | 17 +++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h index a4ae96383cd..cbd7d528719 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h @@ -18,6 +18,8 @@ #include #include +#include + namespace CGAL { namespace Tetrahedral_remeshing @@ -70,16 +72,16 @@ std::size_t peel_slivers(C3T3& c3t3, Cell_handle c = c_i.first; const std::array& f_on_surface = c_i.second; - boost::optional patch; + std::optional patch; for (int i = 0; i < 4; ++i) { if (f_on_surface[i]) { Surface_patch_index spi = c3t3.surface_patch_index(c, i); - if (patch != boost::none && patch.get() != spi) + if (patch.has_value() && patch.value() != spi) { //there are 2 different patches - patch = boost::none; + patch = std::nullopt; break; } else @@ -88,7 +90,7 @@ std::size_t peel_slivers(C3T3& c3t3, } } } - if (patch == boost::none) + if (!patch.has_value()) continue; for (int i = 0; i < 4; ++i) @@ -96,7 +98,7 @@ std::size_t peel_slivers(C3T3& c3t3, if (f_on_surface[i]) c3t3.remove_from_complex(c, i); else - c3t3.add_to_complex(c, i, patch.get()); + c3t3.add_to_complex(c, i, patch.value()); } c3t3.remove_from_complex(c); diff --git a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h index 6f25e793fda..d52f68c5646 100644 --- a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h @@ -26,7 +26,7 @@ #include #include -#include +#include // If defined, type casting is done statically, // reducing type-safety overhead. @@ -789,8 +789,8 @@ class Triangulation_segment_simplex_iterator_3 } } else { auto facet_opt = shared_facet(get_edge(), e_prev); - if(static_cast(facet_opt)) { - _curr_simplex = *facet_opt; + if(facet_opt.has_value()) { + _curr_simplex = facet_opt.value(); } else { _curr_simplex = shared_cell(get_edge(), e_prev); @@ -1002,7 +1002,7 @@ class Triangulation_segment_simplex_iterator_3 return f1 == f2 || triangulation().mirror_facet(f1) == f2; } - boost::optional shared_vertex(const Edge& e1, const Edge& e2) const + std::optional shared_vertex(const Edge& e1, const Edge& e2) const { Vertex_handle v1a = e1.first->vertex(e1.second); Vertex_handle v1b = e1.first->vertex(e1.third); @@ -1017,14 +1017,15 @@ class Triangulation_segment_simplex_iterator_3 return {}; } - boost::optional shared_facet(const Edge& e1, const Edge& e2) const + std::optional shared_facet(const Edge& e1, const Edge& e2) const { Vertex_handle v2a = e2.first->vertex(e2.second); Vertex_handle v2b = e2.first->vertex(e2.third); auto sv_opt = shared_vertex(e1, e2); - if(!sv_opt) return {}; - Vertex_handle sv = *sv_opt; + if(!sv_opt.has_value()) + return {}; + Vertex_handle sv = sv_opt.value(); Vertex_handle nsv2 = (sv == v2a) ? v2b : v2a; typename Tr::Facet_circulator circ @@ -1091,7 +1092,7 @@ class Triangulation_segment_simplex_iterator_3 } Cell_handle shared_cell(const Edge e1, const Edge e2) const { - auto facet = shared_facet(e1, e2.first->vertex(e2.second)); + Facet facet = shared_facet(e1, e2.first->vertex(e2.second)); return shared_cell(facet, e2.first->vertex(e2.third)); } From 72520db3a86ac7a76454e1b517249636127100c0 Mon Sep 17 00:00:00 2001 From: Mael Date: Fri, 17 Jan 2025 09:15:36 +0100 Subject: [PATCH 2/2] Use std::optional::reset Co-authored-by: Anirudh Lakhanpal <91114837+SharonIV0x86@users.noreply.github.com> --- .../include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h index cbd7d528719..00d0e16f0a1 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/peel_slivers.h @@ -81,7 +81,7 @@ std::size_t peel_slivers(C3T3& c3t3, if (patch.has_value() && patch.value() != spi) { //there are 2 different patches - patch = std::nullopt; + patch.reset(); break; } else