From 77805fde8db454395f9d35597d8ecee4e87f4feb Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Thu, 25 Jan 2024 09:24:12 +0100 Subject: [PATCH] [smooth] do not forget cells_to_update in pre-collapse max cos and reorganize post-collapse conditions --- .../internal/collapse_short_edges.h | 26 +++++++++---------- .../internal/tetrahedral_remeshing_helpers.h | 15 +++++++++++ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index 788445118b7..467a54a08ab 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -218,12 +218,8 @@ public: #ifdef PROTECT_ANGLES_FROM_COLLAPSE const Dihedral_angle_cosine acceptable_max_cos(0.995); // 0.995 cos <=> 5.7 degrees Dihedral_angle_cosine curr_max_cos - = max_cos_dihedral_angle(triangulation, cells_to_remove[0]); - for (std::size_t i = 1; i < cells_to_remove.size(); ++i) - { - curr_max_cos = (std::max)(curr_max_cos, - max_cos_dihedral_angle(triangulation, cells_to_remove[i])); - } + = (std::max)(max_cos_dihedral_angle_in_range(triangulation, cells_to_remove, false), + max_cos_dihedral_angle_in_range(triangulation, cells_to_update, false)); #endif vh0->set_point(Point_3(v0_new_pos.x(), v0_new_pos.y(), v0_new_pos.z())); @@ -280,16 +276,18 @@ public: return ORIENTATION_PROBLEM; if (!triangulation.tds().is_valid(cit, true)) return C_PROBLEM; -#ifdef PROTECT_ANGLES_FROM_COLLAPSE - - auto max_cos_after_collapse = max_cos_dihedral_angle(triangulation, cit); - - if ( curr_max_cos < max_cos_after_collapse // angles decreased - && acceptable_max_cos < max_cos_after_collapse) // && angles go below acceptable bound - return ANGLE_PROBLEM; -#endif } +#ifdef PROTECT_ANGLES_FROM_COLLAPSE + for (Cell_handle cit : triangulation.finite_cell_handles()) + { + auto max_cos_after_collapse = max_cos_dihedral_angle(triangulation, cit, false); + if ( curr_max_cos < max_cos_after_collapse // angles decreased + && acceptable_max_cos < max_cos_after_collapse) // && angles go below acceptable bound + return ANGLE_PROBLEM; + } +#endif + for (Vertex_handle vit : triangulation.finite_vertex_handles()) { if (!triangulation.tds().is_valid(vit, true)) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h index 935a4a73dc3..bfb005b9c08 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h @@ -379,6 +379,21 @@ Dihedral_angle_cosine max_cos_dihedral_angle(const Tr& tr, return cos_dh; } +template +Dihedral_angle_cosine max_cos_dihedral_angle_in_range(const Tr& tr, + const CellRange& cells, + const bool use_cache = true) +{ + Dihedral_angle_cosine max_cos_dh = cosine_of_90_degrees(); + for (const auto c : cells) + { + const Dihedral_angle_cosine cos_dh = max_cos_dihedral_angle(tr, c, use_cache); + if (max_cos_dh < cos_dh) + max_cos_dh = cos_dh; + } + return max_cos_dh; +} + template bool is_peelable(const C3t3& c3t3, const typename C3t3::Cell_handle ch,