mirror of https://github.com/CGAL/cgal
Fixed removal of unbounded & added corresponding tests
This commit is contained in:
parent
eb1ac16965
commit
a7c7a842f7
|
|
@ -3801,12 +3801,16 @@ _is_smaller(const DHalfedge* he1,
|
|||
CGAL_precondition(he2->direction() == ARR_RIGHT_TO_LEFT);
|
||||
CGAL_precondition(he1->vertex() != he2->vertex());
|
||||
|
||||
// If he1 points to the bottom left vertex, then it is the smaller.
|
||||
if ((ps_x1 == ARR_LEFT_BOUNDARY) && (ps_y1 == ARR_BOTTOM_BOUNDARY))
|
||||
/* If he1 points to a vertex on the left or the bottom boundary, then it
|
||||
* is the smaller.
|
||||
*/
|
||||
if ((ps_x1 == ARR_LEFT_BOUNDARY) || (ps_y1 == ARR_BOTTOM_BOUNDARY))
|
||||
return true;
|
||||
|
||||
// If he2 points to the bottom left vertex, then it is the smaller.
|
||||
if ((ps_x2 == ARR_LEFT_BOUNDARY) && (ps_y2 == ARR_BOTTOM_BOUNDARY))
|
||||
/* If he2 points to a vertex on the left or the bottom boundary, then it
|
||||
* is the smaller.
|
||||
*/
|
||||
if ((ps_x2 == ARR_LEFT_BOUNDARY) || (ps_y2 == ARR_BOTTOM_BOUNDARY))
|
||||
return false;
|
||||
|
||||
return _is_smaller(he1->curve(), he1->vertex()->point(), ps_x1, ps_y1,
|
||||
|
|
|
|||
119
Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_unbounded_removal.cpp
Executable file → Normal file
119
Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_unbounded_removal.cpp
Executable file → Normal file
|
|
@ -18,10 +18,49 @@ typedef Traits_2::Line_2 Line_2;
|
|||
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
|
||||
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
|
||||
typedef Arrangement_2::Vertex_handle Vertex_handle;
|
||||
typedef Arrangement_2::Face_handle Face_handle;
|
||||
typedef Arrangement_2::Halfedge_handle Halfedge_handle;
|
||||
|
||||
bool test(const Arrangement_2& arr)
|
||||
{
|
||||
if (arr.number_of_vertices() != 0) {
|
||||
std::cerr << "(A) Number of vertices (" << arr.number_of_vertices()
|
||||
<< ") not 0!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check the validity more thoroughly.
|
||||
if (! CGAL::is_valid(arr)) {
|
||||
std::cerr << "The arrangement is NOT valid!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool test_ray(Arrangement_2& arr, Face_handle f)
|
||||
{
|
||||
Segment_2 s1(Point_2(0, 0), Point_2(1, 0));
|
||||
Halfedge_handle eh1 =
|
||||
arr.insert_in_face_interior(X_monotone_curve_2(s1), f);
|
||||
Vertex_handle vh = eh1->target();
|
||||
Ray_2 ray(Point_2(1, 0), Point_2(2, 0));
|
||||
Halfedge_handle eh2 =
|
||||
arr.insert_from_left_vertex(X_monotone_curve_2(ray), vh);
|
||||
|
||||
// Remove the edges
|
||||
arr.remove_edge(eh2);
|
||||
arr.remove_edge(eh1);
|
||||
|
||||
if (!test(arr)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Arrangement_2 arr;
|
||||
|
||||
// Construct an arrangement of five linear objects.
|
||||
std::vector<X_monotone_curve_2> curves;
|
||||
curves.push_back(Ray_2(Point_2(0, 0), Point_2(0, 1)));
|
||||
|
|
@ -33,7 +72,6 @@ int main()
|
|||
curves.push_back(Ray_2(Point_2(0, 0), Point_2(-1, 1)));
|
||||
curves.push_back(Ray_2(Point_2(0, 0), Point_2(-1, -1)));
|
||||
|
||||
Arrangement_2 arr;
|
||||
std::vector<Halfedge_handle> hhs(curves.size());
|
||||
for (size_t i = 0; i < curves.size(); i++)
|
||||
hhs[i] = insert_non_intersecting_curve(arr, curves[i]);
|
||||
|
|
@ -61,42 +99,63 @@ int main()
|
|||
<< ", E = " << arr.number_of_edges()
|
||||
<< ", F = " << arr.number_of_faces() << std::endl;
|
||||
|
||||
if (arr.number_of_vertices() != 0) {
|
||||
std::cerr << "(A) Number of vertices (" << arr.number_of_vertices()
|
||||
<< ") not 0!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (!test(arr)) return 1;
|
||||
|
||||
// Check the validity more thoroughly.
|
||||
if (! CGAL::is_valid(arr)) {
|
||||
std::cerr << "The arrangement is NOT valid!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
/* Construct another arrangement of a segment connected to a ray.
|
||||
* First remove the ray, then remove the segment.
|
||||
*
|
||||
* o---------------o
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | o--o----|
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* o---------------o
|
||||
*/
|
||||
if (!test_ray(arr, arr.unbounded_face())) return 1;
|
||||
|
||||
// Construct another arrangement of a segment connected to a ray
|
||||
Segment_2 s1(Point_2(0, 0), Point_2(1, 1));
|
||||
/* Construct another arrangement of a segment connected to a ray.
|
||||
* First remove the ray, then remove the segment.
|
||||
*
|
||||
* o---------------o
|
||||
* | |
|
||||
* | |
|
||||
* | |
|
||||
* | o--o----|
|
||||
* | |
|
||||
* o---------------o
|
||||
* | |
|
||||
* o---------------o
|
||||
*/
|
||||
Line_2 l1(Point_2(0, -1), Point_2(1, -1));
|
||||
Halfedge_handle eh1 =
|
||||
arr.insert_in_face_interior(X_monotone_curve_2(s1), arr.unbounded_face());
|
||||
Vertex_handle vh = eh1->target();
|
||||
Ray_2 ray(Point_2(1, 1), Point_2(2, 2));
|
||||
Halfedge_handle eh2 =
|
||||
arr.insert_from_left_vertex(X_monotone_curve_2(ray), vh);
|
||||
arr.insert_in_face_interior(X_monotone_curve_2(l1), arr.unbounded_face());
|
||||
|
||||
// Remove the edges
|
||||
arr.remove_edge(eh2);
|
||||
if (!test_ray(arr, eh1->face())) return 1;
|
||||
arr.remove_edge(eh1);
|
||||
|
||||
if (arr.number_of_vertices() != 0) {
|
||||
std::cerr << "(B) Number of vertices (" << arr.number_of_vertices()
|
||||
<< ") not 0!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
/* Construct another arrangement of a segment connected to a ray.
|
||||
* First remove the ray, then remove the segment.
|
||||
*
|
||||
* o-----o---------o
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* | | o--o----|
|
||||
* | | |
|
||||
* | | |
|
||||
* | | |
|
||||
* o-----o---------o
|
||||
*/
|
||||
Line_2 l2(Point_2(-1, 0), Point_2(-1, 1));
|
||||
Halfedge_handle eh2 =
|
||||
arr.insert_in_face_interior(X_monotone_curve_2(l2), arr.unbounded_face());
|
||||
|
||||
if (! CGAL::is_valid(arr)) {
|
||||
std::cerr << "The arrangement is NOT valid!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (!test_ray(arr, eh2->twin()->face())) return 1;
|
||||
arr.remove_edge(eh2);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue