Skip to content

Commit

Permalink
Use 'if' rather than %
Browse files Browse the repository at this point in the history
  • Loading branch information
mglisse committed Feb 10, 2024
1 parent 96f698c commit 270a239
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Triangulation/include/CGAL/Triangulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 270a239

Please sign in to comment.