This commit is contained in:
Efi Fogel 2020-11-04 18:14:03 +02:00
parent 6e3978daf5
commit aaf173b4f6
11 changed files with 122 additions and 231 deletions

View File

@ -3807,7 +3807,7 @@ disjoint line segments, defined in the input file `Europe.dat`.
In the following example we use the predefined In the following example we use the predefined
`Exact_predicates_exact_constructions_kernel` for instantiating our `Exact_predicates_exact_constructions_kernel` for instantiating our
segment-traits class. This kernel use interval arithmetic to filter segment-traits class. This kernel uses interval arithmetic to filter
the exact computations. The program reads a set of line segments with the exact computations. The program reads a set of line segments with
integer coordinates from a file and computes their arrangement. By integer coordinates from a file and computes their arrangement. By
default it opens the `fan_grids.dat` input-file, located in the default it opens the `fan_grids.dat` input-file, located in the

View File

@ -6,13 +6,14 @@
#include <CGAL/Arr_polyline_traits_2.h> #include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arrangement_2.h> #include <CGAL/Arrangement_2.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::FT Number_type; typedef Kernel::FT Number_type;
typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits; typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits;
typedef CGAL::Arr_polyline_traits_2<Segment_traits> Traits; typedef CGAL::Arr_polyline_traits_2<Segment_traits> Traits;
typedef Traits::Point_2 Point; typedef Traits::Point_2 Point;
typedef Traits::Curve_2 Polyline; typedef Traits::Segment_2 Segment;
typedef CGAL::Arrangement_2<Traits> Arrangement; typedef Traits::Curve_2 Polyline;
typedef CGAL::Arrangement_2<Traits> Arrangement;
#endif #endif

View File

@ -48,11 +48,11 @@ int main() {
Bezier_curve B; Bezier_curve B;
in_file >> n_curves; in_file >> n_curves;
unsigned int k; size_t k;
for (k = 0; k < n_curves; ++k) { for (k = 0; k < n_curves; ++k) {
// Read the current curve (specified by its control points). // Read the current curve (specified by its control points).
in_file >> B; in_file >> B;
//convert it into x-monotone bezier curve. // convert it into x-monotone bezier curve.
std::vector<CGAL::Object> obj_vector; std::vector<CGAL::Object> obj_vector;
bezier_traits.make_x_monotone_2_object()(B, std::back_inserter(obj_vector)); bezier_traits.make_x_monotone_2_object()(B, std::back_inserter(obj_vector));
Bezier_x_monotone_curve x_seg = Bezier_x_monotone_curve x_seg =
@ -61,16 +61,9 @@ int main() {
} }
X_mono_polycurve polycurve = ctr_xpolycurve(x_curves.begin(), x_curves.end()); X_mono_polycurve polycurve = ctr_xpolycurve(x_curves.begin(), x_curves.end());
// Construct the arrangement.
Arrangement_2 arr; Arrangement_2 arr;
insert(arr, polycurve); insert(arr, polycurve); // construct the arrangement
print_arrangement_size(arr); // print the arrangement size
// Print the arrangement size.
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
return 0; return 0;
} }

View File

@ -8,6 +8,8 @@
#include <CGAL/Arr_polycurve_basic_traits_2.h> #include <CGAL/Arr_polycurve_basic_traits_2.h>
#include <CGAL/Arrangement_2.h> #include <CGAL/Arrangement_2.h>
#include "arr_print.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Arr_directional_non_caching_segment_basic_traits_2<Kernel> typedef CGAL::Arr_directional_non_caching_segment_basic_traits_2<Kernel>
Subcurve_traits; Subcurve_traits;
@ -40,8 +42,7 @@ int main() {
insert_non_intersecting_curve(arr, pc1); insert_non_intersecting_curve(arr, pc1);
insert_non_intersecting_curve(arr, pc2); insert_non_intersecting_curve(arr, pc2);
std::cout << "# vertices: " << arr.number_of_vertices() << std::endl;; print_arrangement_size(arr); // print the arrangement size
std::cout << "# halfedges: " << arr.number_of_halfedges() << std::endl;;
std::cout << "# faces: " << arr.number_of_faces() << std::endl;;
return 0; return 0;
} }

View File

@ -7,58 +7,42 @@
#include "arr_polylines.h" #include "arr_polylines.h"
#include "arr_print.h" #include "arr_print.h"
/* Define the Arrangement traits class to be used. You can either use some user
* defined kernel and Segment_traits_2 or the defaults.
*/
// Instantiate the traits class using a user-defined kernel and Segment_traits_2.
// Identical instantiation can be achieved using the default Kernel:
// typedef CGAL::Arr_polyline_traits_2<> Geom_traits_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Arr_segment_traits_2<Kernel> Segment_traits_2;
typedef CGAL::Arr_polyline_traits_2<Segment_traits_2> Geom_traits_2;
typedef Geom_traits_2::Point_2 Point_2;
typedef Geom_traits_2::Segment_2 Segment_2;
typedef Geom_traits_2::Curve_2 Polyline_2;
typedef CGAL::Arrangement_2<Geom_traits_2> Arrangement_2;
int main() { int main() {
Geom_traits_2 traits; Traits traits;
Arrangement_2 arr(&traits); Arrangement arr(&traits);
auto polyline_construct = traits.construct_curve_2_object(); auto polyline_construct = traits.construct_curve_2_object();
Point_2 points1[5]; Point points1[5];
points1[0] = Point_2(0, 0); points1[0] = Point(0, 0);
points1[1] = Point_2(2, 4); points1[1] = Point(2, 4);
points1[2] = Point_2(3, 0); points1[2] = Point(3, 0);
points1[3] = Point_2(4, 4); points1[3] = Point(4, 4);
points1[4] = Point_2(6, 0); points1[4] = Point(6, 0);
Polyline_2 pi1 = polyline_construct(&points1[0], &points1[5]); Polyline pi1 = polyline_construct(&points1[0], &points1[5]);
std::list<Point_2> points2; std::list<Point> points2;
points2.push_back(Point_2(1, 3)); points2.push_back(Point(1, 3));
points2.push_back(Point_2(0, 2)); points2.push_back(Point(0, 2));
points2.push_back(Point_2(1, 0)); points2.push_back(Point(1, 0));
points2.push_back(Point_2(2, 1)); points2.push_back(Point(2, 1));
points2.push_back(Point_2(3, 0)); points2.push_back(Point(3, 0));
points2.push_back(Point_2(4, 1)); points2.push_back(Point(4, 1));
points2.push_back(Point_2(5, 0)); points2.push_back(Point(5, 0));
points2.push_back(Point_2(6, 2)); points2.push_back(Point(6, 2));
points2.push_back(Point_2(5, 3)); points2.push_back(Point(5, 3));
points2.push_back(Point_2(4, 2)); points2.push_back(Point(4, 2));
Polyline_2 pi2 = polyline_construct(points2.begin(), points2.end()); Polyline pi2 = polyline_construct(points2.begin(), points2.end());
std::vector<Segment_2> segs; std::vector<Segment> segs;
segs.push_back(Segment_2(Point_2(0, 2), Point_2(1, 2))); segs.push_back(Segment(Point(0, 2), Point(1, 2)));
segs.push_back(Segment_2(Point_2(1, 2), Point_2(3, 6))); segs.push_back(Segment(Point(1, 2), Point(3, 6)));
segs.push_back(Segment_2(Point_2(3, 6), Point_2(5, 2))); segs.push_back(Segment(Point(3, 6), Point(5, 2)));
Polyline_2 pi3 = polyline_construct(segs.begin(), segs.end()); Polyline pi3 = polyline_construct(segs.begin(), segs.end());
insert(arr, pi1); insert(arr, pi1);
insert(arr, pi2); insert(arr, pi2);
insert(arr, pi3); insert(arr, pi3);
print_arrangement(arr); print_arrangement_size(arr); // print the arrangement size
return 0; return 0;
} }

View File

@ -2,19 +2,14 @@
// Constructing an arrangement of intersecting line segments using the // Constructing an arrangement of intersecting line segments using the
// predefined kernel with exact constructions and exact predicates. // predefined kernel with exact constructions and exact predicates.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Arr_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/Timer.h>
#include <list> #include <list>
#include <fstream>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; #include <CGAL/basic.h>
typedef Kernel::FT Number_type; #include <CGAL/Timer.h>
typedef CGAL::Arr_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Point_2 Point_2; #include "arr_exact_construction_segments.h"
typedef Traits_2::X_monotone_curve_2 Segment_2; #include "arr_print.h"
typedef CGAL::Arrangement_2<Traits_2> Arrangement_2; #include "read_objects.h"
int main (int argc, char* argv[]) { int main (int argc, char* argv[]) {
// Get the name of the input file from the command line, or use the default // Get the name of the input file from the command line, or use the default
@ -23,48 +18,26 @@ int main (int argc, char* argv[]) {
// Open the input file. // Open the input file.
std::ifstream in_file(filename); std::ifstream in_file(filename);
if (! in_file.is_open()) { if (! in_file.is_open()) {
std::cerr << "Failed to open " << filename << " ..." << std::endl; std::cerr << "Failed to open " << filename << " ..." << std::endl;
return (1); return (1);
} }
// Read the segments from the file. std::list<Segment> segments;
// The input file format should be (all coordinate values are integers): read_objects<Segment>(filename, std::back_inserter(segments));
// <n> // number of segments.
// <sx_1> <sy_1> <tx_1> <ty_1> // source and target of segment #1.
// <sx_2> <sy_2> <tx_2> <ty_2> // source and target of segment #2.
// : : : :
// <sx_n> <sy_n> <tx_n> <ty_n> // source and target of segment #n.
std::list<Segment_2> segments;
unsigned int n;
in_file >> n;
unsigned int i;
for (i = 0; i < n; ++i) {
int sx, sy, tx, ty;
in_file >> sx >> sy >> tx >> ty;
segments.push_back (Segment_2 (Point_2 (Number_type(sx), Number_type(sy)),
Point_2 (Number_type(tx), Number_type(ty))));
}
in_file.close();
// Construct the arrangement by aggregately inserting all segments. // Construct the arrangement by aggregately inserting all segments.
Arrangement_2 arr; Arrangement arr;
CGAL::Timer timer; CGAL::Timer timer;
std::cout << "Performing aggregated insertion of " std::cout << "Performing aggregated insertion of "
<< n << " segments." << std::endl; << segments.size() << " segments." << std::endl;
timer.start(); timer.start();
insert(arr, segments.begin(), segments.end()); insert(arr, segments.begin(), segments.end());
timer.stop(); timer.stop();
// Print the arrangement dimensions. print_arrangement_size(arr);
std::cout << "V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
std::cout << "Construction took " << timer.time() std::cout << "Construction took " << timer.time()
<< " seconds." << std::endl; << " seconds." << std::endl;

View File

@ -1,75 +1,52 @@
//! \file examples/Arrangement_on_surface_2/aggregated_insertion.cpp //! \file examples/Arrangement_on_surface_2/aggregated_insertion.cpp
// Using the global aggregated insertion functions. // Using the global aggregated insertion functions.
#include <list> #include "arr_geodesic_on_sphere.h"
#include "arr_print.h"
#include <CGAL/basic.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h>
typedef CGAL::Exact_rational Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel> Geom_traits_2;
typedef Geom_traits_2::Point_2 Point_2;
typedef Geom_traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::Arr_spherical_topology_traits_2<Geom_traits_2> Topol_traits_2;
typedef CGAL::Arrangement_on_surface_2<Geom_traits_2, Topol_traits_2>
Arrangement_2;
typedef Arrangement_2::Vertex_handle Vertex_handle;
int main() { int main() {
Geom_traits_2 traits; Geom_traits traits;
Geom_traits_2::Construct_point_2 ctr_p = traits.construct_point_2_object(); auto ctr_p = traits.construct_point_2_object();
Geom_traits_2::Construct_x_monotone_curve_2 ctr_xcv = auto ctr_xcv = traits.construct_x_monotone_curve_2_object();
traits.construct_x_monotone_curve_2_object();
Arrangement_2 arr(&traits); Arrangement arr(&traits);
Point_2 sp = ctr_p(0, 0, -1); Point sp = ctr_p(0, 0, -1);
Point_2 np = ctr_p(0, 0, 1); Point np = ctr_p(0, 0, 1);
Vertex_handle spv = arr.insert_in_face_interior(sp, arr.reference_face()); Vertex_handle spv = arr.insert_in_face_interior(sp, arr.reference_face());
Vertex_handle npv = arr.insert_in_face_interior(np, arr.reference_face()); Vertex_handle npv = arr.insert_in_face_interior(np, arr.reference_face());
#if 1 #if 1
Point_2 p1 = ctr_p(-1, 0, 0); Point p1 = ctr_p(-1, 0, 0);
#else #else
Point_2 p1 = ctr_p(-1, -1, 0); Point p1 = ctr_p(-1, -1, 0);
#endif #endif
Point_2 p2 = ctr_p( 0, -1, 0); Point p2 = ctr_p( 0, -1, 0);
Point_2 p3 = ctr_p( 1, 0, 0); Point p3 = ctr_p( 1, 0, 0);
Vertex_handle v1 = arr.insert_in_face_interior(p1, arr.reference_face()); Vertex_handle v1 = arr.insert_in_face_interior(p1, arr.reference_face());
Vertex_handle v2 = arr.insert_in_face_interior(p2, arr.reference_face()); Vertex_handle v2 = arr.insert_in_face_interior(p2, arr.reference_face());
Vertex_handle v3 = arr.insert_in_face_interior(p3, arr.reference_face()); Vertex_handle v3 = arr.insert_in_face_interior(p3, arr.reference_face());
X_monotone_curve_2 xcv_sp1 = ctr_xcv(sp, p1); X_monotone_curve xcv_sp1 = ctr_xcv(sp, p1);
X_monotone_curve_2 xcv_sp2 = ctr_xcv(sp, p2); X_monotone_curve xcv_sp2 = ctr_xcv(sp, p2);
X_monotone_curve_2 xcv_sp3 = ctr_xcv(sp, p3); X_monotone_curve xcv_sp3 = ctr_xcv(sp, p3);
arr.insert_at_vertices(xcv_sp1, spv, v1); arr.insert_at_vertices(xcv_sp1, spv, v1);
arr.insert_at_vertices(xcv_sp2, spv, v2); arr.insert_at_vertices(xcv_sp2, spv, v2);
arr.insert_at_vertices(xcv_sp3, spv, v3); arr.insert_at_vertices(xcv_sp3, spv, v3);
X_monotone_curve_2 xcv_np1 = ctr_xcv(np, p1); X_monotone_curve xcv_np1 = ctr_xcv(np, p1);
X_monotone_curve_2 xcv_np2 = ctr_xcv(np, p2); X_monotone_curve xcv_np2 = ctr_xcv(np, p2);
X_monotone_curve_2 xcv_np3 = ctr_xcv(np, p3); X_monotone_curve xcv_np3 = ctr_xcv(np, p3);
arr.insert_at_vertices(xcv_np1, npv, v1); arr.insert_at_vertices(xcv_np1, npv, v1);
arr.insert_at_vertices(xcv_np2, npv, v2); arr.insert_at_vertices(xcv_np2, npv, v2);
arr.insert_at_vertices(xcv_np3, npv, v3); arr.insert_at_vertices(xcv_np3, npv, v3);
X_monotone_curve_2 xcv_12 = ctr_xcv(p1, p2); X_monotone_curve xcv_12 = ctr_xcv(p1, p2);
X_monotone_curve_2 xcv_23 = ctr_xcv(p2, p3); X_monotone_curve xcv_23 = ctr_xcv(p2, p3);
arr.insert_at_vertices(xcv_12, v1, v2); arr.insert_at_vertices(xcv_12, v1, v2);
arr.insert_at_vertices(xcv_23, v2, v3); arr.insert_at_vertices(xcv_23, v2, v3);
// Print the size of the arrangement. print_arrangement_size(arr); // print the arrangement size
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
// std::cout << "arr: " << arr << std::endl;
return 0; return 0;
} }

View File

@ -4,61 +4,39 @@
// #define CGAL_IDENTIFICATION_XY CGAL_X_MINUS_11_Y_7 // #define CGAL_IDENTIFICATION_XY CGAL_X_MINUS_11_Y_7
// #define CGAL_ARRANGEMENT_ON_SURFACE_INSERT_VERBOSE 1 // #define CGAL_ARRANGEMENT_ON_SURFACE_INSERT_VERBOSE 1
#include <list> #include "arr_geodesic_on_sphere.h"
#include "arr_print.h"
#include <CGAL/basic.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h>
typedef CGAL::Exact_rational Number_type;
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel> Geom_traits_2;
typedef Geom_traits_2::Point_2 Point_2;
typedef Geom_traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::Arr_spherical_topology_traits_2<Geom_traits_2> Topol_traits_2;
typedef CGAL::Arrangement_on_surface_2<Geom_traits_2, Topol_traits_2>
Arrangement_2;
typedef Arrangement_2::Vertex_handle Vertex_handle;
int main() { int main() {
Geom_traits_2 traits; Geom_traits traits;
auto ctr_p = traits.construct_point_2_object(); auto ctr_p = traits.construct_point_2_object();
auto ctr_xcv = traits.construct_x_monotone_curve_2_object(); auto ctr_xcv = traits.construct_x_monotone_curve_2_object();
Arrangement_2 arr(&traits); Arrangement arr(&traits);
Point_2 sp = ctr_p(0, 0, -1); Point sp = ctr_p(0, 0, -1);
Point_2 np = ctr_p(0, 0, 1); Point np = ctr_p(0, 0, 1);
Point_2 p1 = ctr_p(-1, 0, -1); Point p1 = ctr_p(-1, 0, -1);
Point_2 p2 = ctr_p(-1, 0, 1); Point p2 = ctr_p(-1, 0, 1);
X_monotone_curve_2 xcv_sp_p2 = ctr_xcv(sp, p2); X_monotone_curve xcv_sp_p2 = ctr_xcv(sp, p2);
X_monotone_curve_2 xcv_np_p1 = ctr_xcv(np, p1); X_monotone_curve xcv_np_p1 = ctr_xcv(np, p1);
// std::cout << "Inserting " << xcv_sp_p2 << std::endl; // std::cout << "Inserting " << xcv_sp_p2 << std::endl;
insert(arr, xcv_sp_p2); insert(arr, xcv_sp_p2);
// std::cout << "Inserting " << xcv_np_p1 << std::endl; // std::cout << "Inserting " << xcv_np_p1 << std::endl;
insert(arr, xcv_np_p1); insert(arr, xcv_np_p1);
Point_2 q1 = ctr_p(-1, -1, -1); Point q1 = ctr_p(-1, -1, -1);
Point_2 q2 = ctr_p(-1, -1, 1); Point q2 = ctr_p(-1, -1, 1);
X_monotone_curve_2 xcv_sp_q2 = ctr_xcv(sp, q2); X_monotone_curve xcv_sp_q2 = ctr_xcv(sp, q2);
X_monotone_curve_2 xcv_np_q1 = ctr_xcv(np, q1); X_monotone_curve xcv_np_q1 = ctr_xcv(np, q1);
insert(arr, xcv_sp_q2); insert(arr, xcv_sp_q2);
insert(arr, xcv_np_q1); insert(arr, xcv_np_q1);
X_monotone_curve_2 xcv_p1_q1 = ctr_xcv(p1, q1); X_monotone_curve xcv_p1_q1 = ctr_xcv(p1, q1);
X_monotone_curve_2 xcv_p2_q2 = ctr_xcv(p2, q2); X_monotone_curve xcv_p2_q2 = ctr_xcv(p2, q2);
insert(arr, xcv_p1_q1); insert(arr, xcv_p1_q1);
insert(arr, xcv_p2_q2); insert(arr, xcv_p2_q2);
// Print the size of the arrangement. print_arrangement_size(arr); // print the arrangement size
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
// std::cout << "arr: " << arr << std::endl;
return 0; return 0;
} }

View File

@ -7,15 +7,14 @@
#include <vector> #include <vector>
#include <CGAL/config.h> #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Exact_rational.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Arrangement_on_surface_2.h> #include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h> #include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h> #include <CGAL/Arr_spherical_topology_traits_2.h>
typedef CGAL::Exact_rational Number_type; #include "arr_print.h"
typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
#if 0 #if 0
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -8, 6> Geom_traits_2; typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -8, 6> Geom_traits_2;
@ -125,11 +124,7 @@ int main() {
CGAL::insert_empty(arr, xcvs_sub.begin(), xcvs_sub.end(), CGAL::insert_empty(arr, xcvs_sub.begin(), xcvs_sub.end(),
points_sub.begin(), points_sub.end()); points_sub.begin(), points_sub.end());
// Print the size of the arrangement. print_arrangement_size(arr); // print the arrangement size
std::cout << "The arrangement size:" << std::endl
<< " V = " << arr.number_of_vertices()
<< ", E = " << arr.number_of_edges()
<< ", F = " << arr.number_of_faces() << std::endl;
std::cout << "=======================================================" std::cout << "======================================================="
<< std::endl << std::endl << std::endl; << std::endl << std::endl << std::endl;

View File

@ -10,19 +10,17 @@
#include "arr_print.h" #include "arr_print.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -11, 7> typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel, -11, 7> Geom_traits;
Geom_traits_2; typedef Geom_traits::Point_2 Point;
typedef Geom_traits_2::Point_2 Point_2; typedef Geom_traits::Curve_2 Curve;
typedef Geom_traits_2::Curve_2 Curve_2; typedef CGAL::Arr_spherical_topology_traits_2<Geom_traits> Topol_traits;
typedef CGAL::Arr_spherical_topology_traits_2<Geom_traits_2> Topol_traits_2; typedef CGAL::Arrangement_on_surface_2<Geom_traits, Topol_traits> Arrangement;
typedef CGAL::Arrangement_on_surface_2<Geom_traits_2, Topol_traits_2>
Arrangement_2;
int main() { int main() {
// Construct the arrangement from 12 geodesic arcs. // Construct the arrangement from 12 geodesic arcs.
Geom_traits_2 traits; Geom_traits traits;
Arrangement_2 arr(&traits); Arrangement arr(&traits);
auto ctr_p = traits.construct_point_2_object(); auto ctr_p = traits.construct_point_2_object();
auto ctr_cv = traits.construct_curve_2_object(); auto ctr_cv = traits.construct_curve_2_object();
@ -31,7 +29,7 @@ int main() {
// point (-11, 7, 0). The curve (-1,0,0),(0,1,0) intersects the identification // point (-11, 7, 0). The curve (-1,0,0),(0,1,0) intersects the identification
// curve. // curve.
std::list<Curve_2> arcs; std::list<Curve> arcs;
arcs.push_back(ctr_cv(ctr_p(1, 0, 0), ctr_p(0, 0, -1))); arcs.push_back(ctr_cv(ctr_p(1, 0, 0), ctr_p(0, 0, -1)));
arcs.push_back(ctr_cv(ctr_p(1, 0, 0), ctr_p(0, 0, 1))); arcs.push_back(ctr_cv(ctr_p(1, 0, 0), ctr_p(0, 0, 1)));
@ -47,7 +45,7 @@ int main() {
arcs.push_back(ctr_cv(ctr_p(-1, 0, 0), ctr_p(0, -1, 0))); arcs.push_back(ctr_cv(ctr_p(-1, 0, 0), ctr_p(0, -1, 0)));
CGAL::insert(arr, arcs.begin(), arcs.end()); CGAL::insert(arr, arcs.begin(), arcs.end());
print_arrangement_size(arr); print_arrangement_size(arr); // print the arrangement size
print_arrangement(arr); print_arrangement(arr);
return 0; return 0;

View File

@ -1,47 +1,38 @@
//! \file examples/Arrangement_on_surface_2/spherical_overlay.cpp //! \file examples/Arrangement_on_surface_2/spherical_overlay.cpp
// Overlay of two arrangements embedded on the sphere. // Overlay of two arrangements embedded on the sphere.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h> #include <CGAL/basic.h>
#include <CGAL/Arrangement_on_surface_2.h>
#include <CGAL/Arr_geodesic_arc_on_sphere_traits_2.h>
#include <CGAL/Arr_spherical_topology_traits_2.h>
#include <CGAL/Arr_overlay_2.h> #include <CGAL/Arr_overlay_2.h>
#include <CGAL/Arr_default_overlay_traits.h> #include <CGAL/Arr_default_overlay_traits.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; #include "arr_geodesic_on_sphere.h"
typedef CGAL::Arr_geodesic_arc_on_sphere_traits_2<Kernel> Geom_traits_2;
typedef Geom_traits_2::Point_2 Point_2; typedef CGAL::Arr_default_overlay_traits<Arrangement> Overlay_traits;
typedef Geom_traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::Arr_spherical_topology_traits_2<Geom_traits_2> Topol_traits_2;
typedef CGAL::Arrangement_on_surface_2<Geom_traits_2, Topol_traits_2>
Arrangement_2;
typedef CGAL::Arr_default_overlay_traits<Arrangement_2> Overlay_traits;
int main() { int main() {
Geom_traits_2 traits; Geom_traits traits;
Geom_traits_2::Construct_point_2 ctr_p = traits.construct_point_2_object(); auto ctr_p = traits.construct_point_2_object();
Geom_traits_2::Construct_x_monotone_curve_2 ctr_xcv = auto ctr_xcv = traits.construct_x_monotone_curve_2_object();
traits.construct_x_monotone_curve_2_object();
Kernel::Direction_3 dir1(0, 0, 1); Kernel::Direction_3 dir1(0, 0, 1);
X_monotone_curve_2 g11 = ctr_xcv(ctr_p(-1, 0, 0), ctr_p(0, -1, 0), dir1); X_monotone_curve g11 = ctr_xcv(ctr_p(-1, 0, 0), ctr_p(0, -1, 0), dir1);
X_monotone_curve_2 g12 = ctr_xcv(ctr_p(0, -1, 0), ctr_p(-1, 0, 0), dir1); X_monotone_curve g12 = ctr_xcv(ctr_p(0, -1, 0), ctr_p(-1, 0, 0), dir1);
Arrangement_2 arr1(&traits); Arrangement arr1(&traits);
CGAL::insert(arr1, g11); CGAL::insert(arr1, g11);
CGAL::insert(arr1, g12); CGAL::insert(arr1, g12);
std::cout << "No. of vertices: " << arr1.number_of_vertices() << std::endl; std::cout << "No. of vertices: " << arr1.number_of_vertices() << std::endl;
Kernel::Direction_3 dir2(0, 0, -1); Kernel::Direction_3 dir2(0, 0, -1);
X_monotone_curve_2 g21 = ctr_xcv(ctr_p(-1, 0, 0), ctr_p(0, 1, 0), dir2); X_monotone_curve g21 = ctr_xcv(ctr_p(-1, 0, 0), ctr_p(0, 1, 0), dir2);
X_monotone_curve_2 g22 = ctr_xcv(ctr_p(0, 1, 0), ctr_p(-1, 0, 0), dir2); X_monotone_curve g22 = ctr_xcv(ctr_p(0, 1, 0), ctr_p(-1, 0, 0), dir2);
Arrangement_2 arr2(&traits); Arrangement arr2(&traits);
CGAL::insert(arr2, g21); CGAL::insert(arr2, g21);
CGAL::insert(arr2, g22); CGAL::insert(arr2, g22);
std::cout << "No. of vertices: " << arr2.number_of_vertices() << std::endl; std::cout << "No. of vertices: " << arr2.number_of_vertices() << std::endl;
Arrangement_2 overlay_arr; Arrangement overlay_arr;
Overlay_traits overlay_traits; Overlay_traits overlay_traits;
overlay(arr1, arr2, overlay_arr, overlay_traits); overlay(arr1, arr2, overlay_arr, overlay_traits);
std::cout << "No. of vertices: " << overlay_arr.number_of_vertices() std::cout << "No. of vertices: " << overlay_arr.number_of_vertices()