diff --git a/Surface_mesh_parameterization/include/CGAL/Two_vertices_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Two_vertices_parameterizer_3.h index 096725d3f7c..46dde774643 100644 --- a/Surface_mesh_parameterization/include/CGAL/Two_vertices_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Two_vertices_parameterizer_3.h @@ -123,12 +123,12 @@ Two_vertices_parameterizer_3::parameterize_border(Adaptor& mesh) return Parameterizer_traits_3::ERROR_BORDER_TOO_SHORT; // Get mesh's bounding box - double xmin = 1e30 ; - double ymin = 1e30 ; - double zmin = 1e30 ; - double xmax = -1e30 ; - double ymax = -1e30 ; - double zmax = -1e30 ; + double xmin = (std::numeric_limits::max)() ; + double ymin = (std::numeric_limits::max)() ; + double zmin = (std::numeric_limits::max)() ; + double xmax = (std::numeric_limits::min)() ; + double ymax = (std::numeric_limits::min)() ; + double zmax = (std::numeric_limits::min)() ; for (it = mesh.mesh_vertices_begin(); it != mesh.mesh_vertices_end(); it++) { Point_3 position = mesh.get_vertex_position(it); @@ -220,9 +220,10 @@ Two_vertices_parameterizer_3::parameterize_border(Adaptor& mesh) // Project onto longest bounding box axes, // Set extrema vertices' (u,v) in unit square and mark them as "parameterized" Vertex_handle vxmin = NULL ; - double umin = DBL_MAX ; + double umin = (std::numeric_limits::max)() ; + double vmin = (std::numeric_limits::max)(), vmax= (std::numeric_limits::min)(); Vertex_handle vxmax = NULL ; - double umax = DBL_MIN ; + double umax = (std::numeric_limits::min)() ; for (it = mesh.mesh_vertices_begin(); it != mesh.mesh_vertices_end(); it++) { Point_3 position = mesh.get_vertex_position(it); @@ -240,13 +241,15 @@ Two_vertices_parameterizer_3::parameterize_border(Adaptor& mesh) mesh.set_vertex_uv(it, Point_2(u,v)) ; // useful only for vxmin and vxmax - if(u < umin) { + if(u < umin || (u==umin && v < vmin) ) { vxmin = it ; umin = u ; + vmin = v ; } - if(u > umax) { + if(u > umax || (u==umax && v > vmax) ){ vxmax = it ; umax = u ; + vmax = v ; } } mesh.set_vertex_parameterized(vxmin, true) ;