*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.
This commit is contained in:
Sébastien Loriot 2011-01-10 14:32:18 +00:00
parent 81085ed1dd
commit d8745b69e4
2 changed files with 36 additions and 5 deletions

View File

@ -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<DHalfedge*>(NULL):he_left_low) ));
}
//-----------------------------------------------------------------------------

View File

@ -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;