emersonmx

CGAL_arr_sample

Jan 12th, 2014
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.65 KB | None | 0 0
  1. // Using the global incremental insertion functions.
  2. #include "arr_rational_nt.h"
  3. #include <CGAL/Cartesian.h>
  4. #include <CGAL/Arr_segment_traits_2.h>
  5. #include <CGAL/Arrangement_2.h>
  6. #include <CGAL/Arr_overlay_2.h>
  7. #include <CGAL/Arr_default_overlay_traits.h>
  8. #include "arr_print.h"
  9.  
  10. typedef CGAL::Cartesian<Number_type> Kernel;
  11. typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
  12. typedef Traits_2::Point_2 Point_2;
  13. typedef Traits_2::X_monotone_curve_2 Segment_2;
  14. typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
  15. typedef CGAL::Arr_default_overlay_traits<Arrangement_2> Overlay_traits;
  16.  
  17. int main() {
  18.     // Construct the arrangement of five intersecting segments.
  19.     Arrangement_2 arr1;
  20.     Arrangement_2 arr2;
  21.     Arrangement_2 arr;
  22.     Overlay_traits overlay_traits;
  23.     Segment_2 ss1[] = {
  24.         Segment_2(Point_2(1, 6), Point_2(8, 5)),
  25.         Segment_2(Point_2(8, 5), Point_2(13, 8)),
  26.         Segment_2(Point_2(13, 8), Point_2(11, 11)),
  27.         Segment_2(Point_2(11, 11), Point_2(6, 13)),
  28.         Segment_2(Point_2(6, 13), Point_2(1, 6))
  29.     };
  30.     Segment_2 ss2[] = {
  31.         Segment_2(Point_2(5, 2), Point_2(11, 2)),
  32.         Segment_2(Point_2(11, 2), Point_2(8, 8)),
  33.         Segment_2(Point_2(8, 8), Point_2(5, 2)),
  34.     };
  35.     insert_non_intersecting_curves(arr1, ss1, ss1 + 5);
  36.     insert_non_intersecting_curves(arr2, ss2, ss2 + 3);
  37.     overlay(arr1, arr2, arr, overlay_traits);
  38.  
  39.     Arrangement_2::Vertex_const_iterator vit;
  40.     for (vit = arr.vertices_begin(); vit != arr.vertices_end(); ++vit) {
  41.         if (vit->degree() > 2) {
  42.             print_neighboring_vertices<Arrangement_2>(vit);
  43.         }
  44.     }
  45.  
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment