1 //! \file examples/Arrangement_on_surface_2/polylines.cpp
2 // Constructing an arrangement of polylines.
3
4 #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
5 #include <CGAL/Arr_directional_non_caching_segment_basic_traits_2.h>
6 #include <CGAL/Arr_polycurve_basic_traits_2.h>
7 #include <CGAL/Arrangement_2.h>
8 #include <vector>
9 #include <list>
10
11 typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
12 typedef CGAL::Arr_directional_non_caching_segment_basic_traits_2<Kernel>
13 Subcurve_traits_2;
14 typedef CGAL::Arr_polycurve_basic_traits_2<Subcurve_traits_2>
15 Geom_traits_2;
16 typedef Geom_traits_2::Point_2 Point_2;
17 typedef Subcurve_traits_2::X_monotone_curve_2 X_monotone_subcurve_2;
18 typedef Geom_traits_2::X_monotone_curve_2 X_monotone_curve_2;
19 typedef CGAL::Arrangement_2<Geom_traits_2> Arrangement_2;
20
main()21 int main()
22 {
23 Geom_traits_2 traits;
24 Arrangement_2 arr(&traits);
25
26 Geom_traits_2::Construct_x_monotone_curve_2 ctr =
27 traits.construct_x_monotone_curve_2_object();
28
29 std::vector<X_monotone_subcurve_2> segs1;
30 segs1.push_back(X_monotone_subcurve_2(Point_2(0, 0), Point_2(1, 1)));
31 segs1.push_back(X_monotone_subcurve_2(Point_2(1, 1), Point_2(2, 2)));
32 segs1.push_back(X_monotone_subcurve_2(Point_2(2, 2), Point_2(3, 1)));
33 segs1.push_back(X_monotone_subcurve_2(Point_2(3, 1), Point_2(4, 0)));
34 X_monotone_curve_2 pc1 = ctr(segs1.begin(), segs1.end());
35
36 std::vector<X_monotone_subcurve_2> segs2;
37 segs2.push_back(X_monotone_subcurve_2(Point_2(0, 0), Point_2(1, 1)));
38 segs2.push_back(X_monotone_subcurve_2(Point_2(1, 1), Point_2(2, 2)));
39 segs2.push_back(X_monotone_subcurve_2(Point_2(2, 2), Point_2(3, 1)));
40 segs2.push_back(X_monotone_subcurve_2(Point_2(3, 1), Point_2(4, 0)));
41 X_monotone_curve_2 pc2 = ctr(segs2.begin(), segs2.end());
42
43 insert_non_intersecting_curve(arr, pc1);
44 insert_non_intersecting_curve(arr, pc2);
45
46 std::cout << "# vertices: " << arr.number_of_vertices() << std::endl;;
47 std::cout << "# halfedges: " << arr.number_of_halfedges() << std::endl;;
48 std::cout << "# faces: " << arr.number_of_faces() << std::endl;;
49 return 0;
50 }
51