From 8dab6907f73af63d9b2c3b1ebfac443ded3d3935 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Mon, 4 Jan 2016 15:03:41 +0100 Subject: [PATCH] Improve readability by introducing a "infinity()" method to AFSR --- .../boundaries.cpp | 6 ++-- .../reconstruction_fct.cpp | 6 ++-- .../Advancing_front_surface_reconstruction.h | 30 ++++++++++--------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/boundaries.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/boundaries.cpp index 4fc949e8956..7e4d85e2371 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/boundaries.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/boundaries.cpp @@ -26,13 +26,13 @@ struct Perimeter { double d = 0; d = sqrt(squared_distance(c->vertex((index+1)%4)->point(), c->vertex((index+2)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); d += sqrt(squared_distance(c->vertex((index+2)%4)->point(), c->vertex((index+3)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); d += sqrt(squared_distance(c->vertex((index+1)%4)->point(), c->vertex((index+3)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); // Otherwise, return usual priority value: smallest radius of // delaunay sphere diff --git a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_fct.cpp b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_fct.cpp index 98aa13bc2bb..b9f31a3707f 100644 --- a/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_fct.cpp +++ b/Advancing_front_surface_reconstruction/examples/Advancing_front_surface_reconstruction/reconstruction_fct.cpp @@ -42,13 +42,13 @@ struct Perimeter { double d = 0; d = sqrt(squared_distance(c->vertex((index+1)%4)->point(), c->vertex((index+2)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); d += sqrt(squared_distance(c->vertex((index+2)%4)->point(), c->vertex((index+3)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); d += sqrt(squared_distance(c->vertex((index+1)%4)->point(), c->vertex((index+3)%4)->point())); - if(d>bound) return std::numeric_limits::infinity(); + if(d>bound) return adv.infinity(); // Otherwise, return usual priority value: smallest radius of // delaunay sphere diff --git a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h index 590b110dddd..8bfc1649c59 100644 --- a/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h +++ b/Advancing_front_surface_reconstruction/include/CGAL/Advancing_front_surface_reconstruction.h @@ -185,7 +185,7 @@ namespace CGAL { \tparam P must be a functor with `double operator()(AdvancingFront,Cell_handle,int)` returning the priority of the facet `(Cell_handle,int)`. This functor enables the user to choose how candidate triangles are prioritized. If a facet should not appear in the output, - `std::numeric_limits::infinity()` must be returned. It defaults to a functor that returns the + `infinity()` must be returned. It defaults to a functor that returns the smallest radius of the Delaunay sphere. */ @@ -663,7 +663,7 @@ namespace CGAL { Advancing_front_surface_reconstruction(Triangulation_3& dt, Priority priority = Priority()) : T(dt), _number_of_border(1), COS_ALPHA_SLIVER(-0.86), - NB_BORDER_MAX(15), DELTA(.86), min_K(std::numeric_limits::infinity()), + NB_BORDER_MAX(15), DELTA(.86), min_K(infinity()), eps(1e-7), inv_eps_2(coord_type(1)/(eps*eps)), eps_3(eps*eps*eps), STANDBY_CANDIDATE(3), STANDBY_CANDIDATE_BIS(STANDBY_CANDIDATE+1), NOT_VALID_CANDIDATE(STANDBY_CANDIDATE+2), @@ -1174,6 +1174,8 @@ namespace CGAL { //===================================================================== + coord_type infinity() const { return std::numeric_limits::infinity(); } + coord_type smallest_radius_delaunay_sphere(const Cell_handle& c, const int& index) const @@ -1184,7 +1186,7 @@ namespace CGAL { || (c->vertex((index+2) & 3) == added_vertex) || (c->vertex((index+3) & 3) == added_vertex) )) { - return std::numeric_limits::infinity(); + return infinity(); } Cell_handle n = c->neighbor(index); // lazy evaluation ... @@ -1211,7 +1213,7 @@ namespace CGAL { (c_is_plane && n_is_infinite)|| (n_is_plane && c_is_infinite)|| my_collinear(cp1, cp2, cp3)) - value = std::numeric_limits::infinity(); + value = infinity(); else { if (c_is_infinite||n_is_infinite||c_is_plane||n_is_plane) @@ -1305,7 +1307,7 @@ namespace CGAL { Cell_handle c_predone = predone.first.first; coord_type min_valueP = NOT_VALID_CANDIDATE, - min_valueA = std::numeric_limits::infinity(); + min_valueA = infinity(); Facet min_facet, min_facetA; bool border_facet(false); @@ -1343,7 +1345,7 @@ namespace CGAL { Edge_like el1(neigh->vertex(n_i1),neigh->vertex(n_i3)), el2(neigh->vertex(n_i2),neigh->vertex(n_i3)); - if ((tmp != std::numeric_limits::infinity())&& + if ((tmp != infinity())&& neigh->vertex(n_i3)->not_interior()&& (!is_interior_edge(el1))&&(!is_interior_edge(el2))) { @@ -1391,7 +1393,7 @@ namespace CGAL { criteria value; - if ((min_valueA == std::numeric_limits::infinity()) || border_facet) // bad facets case + if ((min_valueA == infinity()) || border_facet) // bad facets case { min_facet = Facet(c, i); // !!! sans aucune signification.... value = NOT_VALID_CANDIDATE; // Attention a ne pas inserer dans PQ @@ -1445,7 +1447,7 @@ namespace CGAL { { init_timer.start(); Facet min_facet; - coord_type min_value = std::numeric_limits::infinity(); + coord_type min_value = infinity(); int i1, i2, i3; if (!re_init){ @@ -1477,7 +1479,7 @@ namespace CGAL { coord_type value = priority (*this, c, index); // we might not want the triangle, for example because it is too large - if(value == std::numeric_limits::infinity()){ + if(value == infinity()){ value = min_value; } @@ -1490,7 +1492,7 @@ namespace CGAL { } } - if (min_value != std::numeric_limits::infinity()) + if (min_value != infinity()) { Cell_handle c_min = min_facet.first; @@ -1980,7 +1982,7 @@ namespace CGAL { } do { - min_K = std::numeric_limits::infinity(); // pour retenir le prochain K necessaire pour progresser... + min_K = infinity(); // pour retenir le prochain K necessaire pour progresser... do { @@ -2042,10 +2044,10 @@ namespace CGAL { // on augmente progressivement le K mais on a deja rempli sans // faire des betises auparavant... } - while((!_ordered_border.empty())&&(K <= K)&&(min_K != std::numeric_limits::infinity())); + while((!_ordered_border.empty())&&(K <= K)&&(min_K != infinity())); #ifdef VERBOSE - if ((min_K < std::numeric_limits::infinity())&&(!_ordered_border.empty())) { + if ((min_K < infinity())&&(!_ordered_border.empty())) { std::cout << " [ next K required = " << min_K << " ]" << std::endl; } #endif // VERBOSE @@ -2406,7 +2408,7 @@ namespace CGAL { return false; } - min_K = std::numeric_limits::infinity(); + min_K = infinity(); // fin-- // if (_postprocessing_counter < 5) // return true;