From 270a2398d6ab397a72fd881f108ebf6724ff136c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 10 Feb 2024 20:40:17 +0100 Subject: [PATCH] Use 'if' rather than % --- Triangulation/include/CGAL/Triangulation.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Triangulation/include/CGAL/Triangulation.h b/Triangulation/include/CGAL/Triangulation.h index 1c1bff783702..dc6a0a3e81f4 100644 --- a/Triangulation/include/CGAL/Triangulation.h +++ b/Triangulation/include/CGAL/Triangulation.h @@ -993,7 +993,7 @@ ::insert_outside_affine_hull(const Point & p) // Otherwise, let's find the right infinite cell else { - inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) % 2); + inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) & 1); inf_v_index = inf_v_cell->index(infinite_vertex()); // Is "inf_v_cell" the right infinite cell? // Then inf_v_index should be 1 @@ -1096,9 +1096,14 @@ ::do_locate(const Point & p, // query point // For the remembering stochastic walk, we need to start trying // with a random index: int j, i = rng_.get_int(0, cur_dim); - // we check |p| against all the full_cell's hyperplanes in turn - for(j = 0; j <= cur_dim; ++j, i = (i + 1) % (cur_dim + 1) ) + // i = (i + 1) % m where 0 <= i < m + auto incr_mod = [] (int&i, int m) { + if( ++i >= m ) i = 0; // >= or == + }; + + // we check |p| against all the full_cell's hyperplanes in turn + for(j = 0; j <= cur_dim; ++j, incr_mod(i, cur_dim + 1)) { Full_cell_handle next = s->neighbor(i); if( previous == next ) @@ -1127,6 +1132,9 @@ ::do_locate(const Point & p, // query point // full_cell because orientation_[i] == NEGATIVE previous = s; s = next; + // We only need to test is_infinite(next->vertex(next->index(previous))) + // or equivalently is_infinite(next->vertex(previous->mirror_index(i))) + // but it does not seem to help, even when storing mirror indices. if( is_infinite(next) ) { // we have arrived OUTSIDE the convex hull of the triangulation, // so we stop the search