From d8745b69e44e14b543bfa4e2d3596ec985df9658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 10 Jan 2011 14:32:18 +0000 Subject: [PATCH] *another patch to _find_leftmost_vertex_on_open_loop. In the case the lowest incident halfedge is he_before, we should return NULL (I removed the test he!=he_before as if he he_left_low is updated several time with the same v_min, the fat that he_before==he_left_low can be detected). *update testsuite to test this case. --- .../Arrangement_on_surface_2_impl.h | 6 ++-- .../test_insertion.cpp | 35 +++++++++++++++++-- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h index dfcfda6fdab..02b09356178 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_impl.h @@ -3616,10 +3616,10 @@ _find_leftmost_vertex_on_open_loop (const DHalfedge *he_before, bool v_min_updated = v_min!=he->vertex(); v_min = he->vertex(); - if ( he!=he_before && (v_min_updated || he_left_low ==NULL || + if ( v_min_updated || he_left_low ==NULL || compare_y_at_x_right_2(he_left_low->curve(), he->curve(), - v_min->point() ) == LARGER ) ) + v_min->point() ) == LARGER ) { // If we need to compute the lowest halfedge incident to the leftmost // vertex, update it now. Note that we may visit the smallest vertex @@ -3640,7 +3640,7 @@ _find_leftmost_vertex_on_open_loop (const DHalfedge *he_before, is_perimetric = (x_cross_count % 2 == 1) || (y_cross_count % 2 == 1); // Return the leftmost vertex and its index (with respect to he_before). - return (std::make_pair (v_min, he_left_low)); + return (std::make_pair (v_min, (he_left_low==he_before ? static_cast(NULL):he_left_low) )); } //----------------------------------------------------------------------------- diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_insertion.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_insertion.cpp index 9db5629b74d..a3b0f6c35b6 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_insertion.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_insertion.cpp @@ -17,8 +17,8 @@ typedef Arrangement_2::Vertex_handle Vertex_handle; #define N_SEGMENTS 26 //test from a bug report when inserting a segment closing a hole -bool test_insert_at_vertices(){ - Arrangement_2 arr; +bool test_insert_at_vertices_1(){ + Arrangement_2 arr; Vertex_handle v_x0y3 = arr.insert_in_face_interior(Point_2(Number_type(0), Number_type(3)), arr.unbounded_face()); Vertex_handle v_x1y6 = arr.insert_in_face_interior(Point_2(Number_type(1), Number_type(6)), arr.unbounded_face()); @@ -45,6 +45,37 @@ bool test_insert_at_vertices(){ return is_valid(arr); } +bool test_insert_at_vertices_2(){ + Arrangement_2 arr; + + Vertex_handle v_x0y3 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(0), Kernel::FT(3)), arr.unbounded_face()); + Vertex_handle v_x1y6 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(1), Kernel::FT(6)), arr.unbounded_face()); + Vertex_handle v_x1y3 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(1), Kernel::FT(3)), arr.unbounded_face()); + Vertex_handle v_x2y3 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(2), Kernel::FT(3)), arr.unbounded_face()); + Vertex_handle v_x3y6 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(3), Kernel::FT(6)), arr.unbounded_face()); + Vertex_handle v_x3y0 = arr.insert_in_face_interior(Kernel::Point_2(Kernel::FT(3), Kernel::FT(0)), arr.unbounded_face()); + + arr.insert_at_vertices(Segment_2(v_x0y3->point(), v_x1y6->point()), v_x0y3, v_x1y6); + arr.insert_at_vertices(Segment_2(v_x0y3->point(), v_x1y3->point()), v_x0y3, v_x1y3); + arr.insert_at_vertices(Segment_2(v_x1y3->point(), v_x2y3->point()), v_x1y3, v_x2y3); + arr.insert_at_vertices(Segment_2(v_x0y3->point(), v_x3y6->point()), v_x0y3, v_x3y6); + arr.insert_at_vertices(Segment_2(v_x3y6->point(), v_x3y0->point()), v_x3y6, v_x3y0); + + Halfedge_handle he = arr.insert_at_vertices(Segment_2(v_x3y0->point(), v_x0y3->point()), v_x3y0, v_x0y3); + + if (he->face() != arr.unbounded_face()) + { + std::cerr << "Error: he->face() must be the unbounded face!" << std::endl; + return false; + } + + return is_valid(arr); +} + +bool test_insert_at_vertices(){ + return test_insert_at_vertices_1() && test_insert_at_vertices_2(); +} + int main () { Arrangement_2 arr;