File: global_removal.cpp

package info (click to toggle)
cgal 4.13-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 101,504 kB
  • sloc: cpp: 703,154; ansic: 163,044; sh: 674; fortran: 616; python: 411; makefile: 115
file content (48 lines) | stat: -rw-r--r-- 1,814 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! \file examples/Arrangement_on_surface_2/global_removal.cpp
// Using the global removal functions.

#include <CGAL/Cartesian.h>
#include <CGAL/Arr_linear_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_naive_point_location.h>

#include "arr_print.h"

typedef int                                           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::X_monotone_curve_2                  Segment_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 ()
{
  // Create an arrangement of four line segments forming an H-shape:
  Arrangement_2   arr;

  Segment_2       s1 (Point_2(1, 3), Point_2(4, 3));
  Halfedge_handle e1 = arr.insert_in_face_interior (s1, arr.unbounded_face());
  Segment_2       s2 (Point_2(1, 4), Point_2(4, 4));
  Halfedge_handle e2 = arr.insert_in_face_interior (s2, arr.unbounded_face());
  insert(arr, Segment_2(Point_2(1, 1), Point_2(1, 6)));
  insert(arr, Segment_2(Point_2(4, 1), Point_2(4, 6)));

  std::cout << "The initial arrangement:" << std::endl;
  print_arrangement (arr);

  // Remove e1 and its incident vertices using the function remove_edge().
  Vertex_handle   v1 = e1->source(), v2 = e1->target();
  arr.remove_edge(e1);
  remove_vertex(arr, v1);
  remove_vertex(arr, v2);

  // Remove e2 using the free remove_edge() function.
  remove_edge (arr, e2);

  std::cout << "The final arrangement:" << std::endl;
  print_arrangement (arr);
  return 0;
}