CGAL 5.1 - 2D Arrangements
Arrangement_on_surface_2/overlay.cpp
// A simple overlay of two arrangements.
#include <CGAL/Cartesian.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Arr_overlay_2.h>
#include <CGAL/Arr_default_overlay_traits.h>
typedef Traits_2::Point_2 Point_2;
typedef Traits_2::X_monotone_curve_2 Segment_2;
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2;
int main ()
{
// Construct the first arrangement, containing a square-shaped face.
Arrangement_2 arr1;
Segment_2 s1 (Point_2(2, 2), Point_2(6, 2));
Segment_2 s2 (Point_2(6, 2), Point_2(6, 6));
Segment_2 s3 (Point_2(6, 6), Point_2(2, 6));
Segment_2 s4 (Point_2(2, 6), Point_2(2, 2));
// Construct the second arrangement, containing a rhombus-shaped face.
Arrangement_2 arr2;
Segment_2 t1 (Point_2(4, 1), Point_2(7, 4));
Segment_2 t2 (Point_2(7, 4), Point_2(4, 7));
Segment_2 t3 (Point_2(4, 7), Point_2(1, 4));
Segment_2 t4 (Point_2(1, 4), Point_2(4, 1));
// Compute the overlay of the two arrangements.
Arrangement_2 overlay_arr;
Overlay_traits overlay_traits;
overlay (arr1, arr2, overlay_arr, overlay_traits);
// Print the size of the overlaid arrangement.
std::cout << "The overlaid arrangement size:" << std::endl
<< " V = " << overlay_arr.number_of_vertices()
<< ", E = " << overlay_arr.number_of_edges()
<< ", F = " << overlay_arr.number_of_faces() << std::endl;
return 0;
}
CGAL::Cartesian
Exact_rational.h
CGAL::Arr_default_overlay_traits
Definition: Arr_default_overlay_traits.h:19
CGAL::insert_non_intersecting_curve
Arrangement_2< Traits, Dcel >::Halfedge_handle insert_non_intersecting_curve(Arrangement_2< Traits, Dcel > &arr, const typename Traits::X_monotone_curve_2 &xc, const PointLocation &pl=walk_pl)
Kernel
CGAL::Arrangement_2
Definition: Arrangement_2.h:56
CGAL::Arr_segment_traits_2
Definition: Arr_segment_traits_2.h:64
CGAL::overlay
void overlay(const Arrangement_2< GeomTraitsA, TopTraitsA > &arr1, const Arrangement_2< GeomTraitsB, TopTraitsB > &arr2, Arrangement_2< GeomTraitsRes, TopTraitsRes > &arr_res, OverlayTraits &ovl_tr)
Computes the overlay of two arrangements arr1 and arr2, and sets the output arrangement res to repres...