New example programs for constructing arrangements of unbounded curves.

This commit is contained in:
Ron Wein 2006-06-04 15:07:56 +00:00
parent c779522075
commit c44035aa57
4 changed files with 217 additions and 0 deletions

3
.gitattributes vendored
View File

@ -248,6 +248,9 @@ Arrangement_2/doc_tex/Arrangement_2/fig/triangle.pstex_t -text
Arrangement_2/doc_tex/Sweep_line_2/sl_simple.gif -text svneol=unset#unset
Arrangement_2/doc_tex/Sweep_line_2/sl_simple.pdf -text svneol=unset#unset
Arrangement_2/doc_tex/Sweep_line_2/sl_simple.ps -text
Arrangement_2/examples/Arrangement_2/ex_infinite_edge_insertion.C -text
Arrangement_2/examples/Arrangement_2/ex_infinite_insert.C -text
Arrangement_2/examples/Arrangement_2/ex_infinite_non_intersecting.C -text
Benchmark/examples/Benchmark/bbox/Makefile.mak -text
Benchmark/examples/Benchmark/bbox/bbox.C -text
Benchmark/examples/Benchmark/leftturn/Makefile.mak -text

View File

@ -0,0 +1,86 @@
//! \file examples/Arrangement_2/ex_infinite_edge_insertion.C
// Constructing an arrangement of unbounded linear objects using the simple
// edge-insertion functions.
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_naive_point_location.h>
typedef int Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_linear_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Segment_2 Segment_2;
typedef Traits_2::Ray_2 Ray_2;
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::Halfedge_handle Halfedge_handle;
typedef CGAL::Arr_naive_point_location<Arrangement_2> Naive_pl;
int main ()
{
Arrangement_2 arr;
Naive_pl naive_pl (arr);
Ray_2 ray1 (Point_2 (0, 1), Point_2 (0, 2));
X_monotone_curve_2 cv1 (ray1);
Line_2 line2 (Point_2 (0, 0), Point_2 (1, 1));
X_monotone_curve_2 cv2 (line2);
Ray_2 ray3 (Point_2 (0, 1), Point_2 (1, 2));
X_monotone_curve_2 cv3 (ray3);
Ray_2 ray4 (Point_2 (0, 1), Point_2 (-1, 2));
X_monotone_curve_2 cv4 (ray4);
Halfedge_handle e1 = arr.insert_in_face_interior (cv1,
arr.unbounded_face());
Vertex_handle v1 = e1->source();
Halfedge_handle e2 = arr.insert_in_face_interior (cv2,
arr.unbounded_face());
Halfedge_handle e3 = arr.insert_from_left_vertex (cv3, v1);
Halfedge_handle e4 = arr.insert_from_right_vertex (cv4, v1);
// Print out the size of the resulting arrangement.
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< " (" << arr.number_of_vertices_at_infinity()
<< " at infinity)"
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
CGAL::Object obj;
Arrangement_2::Face_const_handle f;
Arrangement_2::Ccb_halfedge_const_circulator first, circ;
obj = naive_pl.locate (Point_2 (1, 3));
if (CGAL::assign (f ,obj))
{
std::cout << "Face is " << (f->is_unbounded() ? "unbounded." : "bounded.")
<< std::endl;
first = circ = f->outer_ccb();
do
{
if (! circ->is_fictitious())
std::cout << " " << circ->curve() << std::endl;
++circ;
} while (circ != first);
}
obj = naive_pl.locate (Point_2 (3, -3));
if (CGAL::assign (f ,obj))
{
std::cout << "Face is " << (f->is_unbounded() ? "unbounded." : "bounded.")
<< std::endl;
first = circ = f->outer_ccb();
do
{
if (! circ->is_fictitious())
std::cout << " " << circ->curve() << std::endl;
++circ;
} while (circ != first);
}
return (0);
}

View File

@ -0,0 +1,74 @@
//! \file examples/Arrangement_2/ex_infinite_non_intersecting.C
// Constructing an arrangement of unbounded linear objects using the insertion
// function for non-intersecting curves.
#include <CGAL/Gmpq.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_naive_point_location.h>
#include <CGAL/Arr_walk_along_line_point_location.h>
typedef CGAL::Gmpq Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_linear_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Segment_2 Segment_2;
typedef Traits_2::Ray_2 Ray_2;
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 CGAL::Arr_naive_point_location<Arrangement_2> Naive_pl;
typedef CGAL::Arr_walk_along_line_point_location<Arrangement_2> Walk_pl;
int main ()
{
// Construct 3 lines and 2 rays.
const int n_curves = 5;
X_monotone_curve_2 curves[5];
curves[0] = Line_2 (Point_2 (0, 0), Point_2 (2, 1));
curves[1] = Line_2 (Point_2 (0, 0), Point_2 (-2, 1));
curves[2] = Ray_2 (Point_2 (0, 2), Point_2 (-2, 0));
curves[3] = Ray_2 (Point_2 (0, 2), Point_2 (2, 0));
curves[4] = Line_2 (Point_2 (-1, 4), Point_2 (1, 4));
// Construct the arrangement by inserting the curves incermentally.
Arrangement_2 arr;
// Naive_pl naive_pl (arr);
Walk_pl walk_pl (arr);
int k;
for (k = 0; k < n_curves; k++)
{
std::cout << "Inserting curve no. " << k + 1 << std::endl;
insert_x_monotone_curve (arr, curves[k], walk_pl);
}
// Print out the size of the resulting arrangement.
Arrangement_2::Face_const_iterator fit;
unsigned int n_unb_faces = 0;
for (fit = arr.faces_begin(); fit != arr.faces_end(); ++fit)
{
if (fit->is_unbounded())
n_unb_faces++;
}
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< " (" << arr.number_of_vertices_at_infinity()
<< " at infinity)"
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces()
<< " (" << n_unb_faces << " unbounded)" << std::endl;
// Print the vertices.
Arrangement_2::Vertex_const_iterator vit;
std::cout << "The vertices:" << std::endl;
for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit)
std::cout << " (" << vit->point() << ")" << std::endl;
return (0);
}

View File

@ -0,0 +1,54 @@
//! \file examples/Arrangement_2/ex_infinite_non_intersecting.C
// Constructing an arrangement of unbounded linear objects using the insertion
// function for non-intersecting curves.
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_naive_point_location.h>
typedef int Number_type;
typedef CGAL::Simple_cartesian<Number_type> Kernel;
typedef CGAL::Arr_linear_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::Segment_2 Segment_2;
typedef Traits_2::Ray_2 Ray_2;
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 CGAL::Arr_naive_point_location<Arrangement_2> Naive_pl;
int main ()
{
// Construct 3 rays and 6 line segments.
const int n_curves = 9;
X_monotone_curve_2 curves[9];
curves[0] = Ray_2 (Point_2 (-5, -1), Point_2 (-6, -2));
curves[1] = Segment_2 (Point_2 (-5, -1), Point_2 (5, -1));
curves[2] = Segment_2 (Point_2 (-5, -1), Point_2 (0, 8));
curves[3] = Segment_2 (Point_2 (-1, 2), Point_2 (1, 2));
curves[4] = Segment_2 (Point_2 (-1, 2), Point_2 (0, 0));
curves[5] = Segment_2 (Point_2 (0, 0), Point_2 (1, 2));
curves[6] = Ray_2 (Point_2 (0, 8), Point_2 (0, 9));
curves[7] = Segment_2 (Point_2 (0, 8), Point_2 (5, -1));
curves[8] = Ray_2 (Point_2 (5, -1), Point_2 (6, -2));
// Construct the arrangement by inserting the curves incermentally.
Arrangement_2 arr;
Naive_pl naive_pl (arr);
int k;
for (k = 0; k < n_curves; k++)
insert_non_intersecting_curve (arr, curves[k], naive_pl);
// Print out the size of the resulting arrangement.
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< " (" << arr.number_of_vertices_at_infinity()
<< " at infinity)"
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
return (0);
}