CReplaced legacy CGAL::Object with modern variant

This commit is contained in:
Efi Fogel 2020-07-04 20:54:23 +03:00
parent 956841e877
commit 37131f9b8b
2 changed files with 155 additions and 191 deletions

View File

@ -1,64 +1,48 @@
// Constructing an arrangement of polycurves.
#include <CGAL/config.h>
#ifndef CGAL_USE_CORE
#include <iostream>
int main()
{
std::cout << "Sorry, this example needs CORE ..." << std::endl;
return 0;
}
#else
#include <CGAL/Cartesian.h>
#include <CGAL/Quotient.h>
#include <CGAL/MP_Float.h>
#include <CGAL/CORE_algebraic_number_traits.h>
#include <vector> #include <vector>
#include <list> #include <list>
#include <CGAL/config.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Quotient.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Arr_polyline_traits_2.h> #include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arr_circle_segment_traits_2.h> #include <CGAL/Arr_circle_segment_traits_2.h>
#include <CGAL/Arrangement_2.h>
/////////////// ///////////////
//circle segment traits //circle segment traits
////////////// //////////////
typedef CGAL::Quotient<CGAL::MP_Float> Number_type; typedef CGAL::Quotient<CGAL::MP_Float> Number_type;
typedef CGAL::Cartesian<Number_type> Kernel; typedef CGAL::Cartesian<Number_type> Kernel;
typedef CGAL::Arr_circle_segment_traits_2<Kernel> Arc_traits_2; typedef CGAL::Arr_circle_segment_traits_2<Kernel> Sub_traits_2;
typedef CGAL::Arr_polyline_traits_2<Arc_traits_2> Polycurve_arc_traits_2; typedef CGAL::Arr_polyline_traits_2<Sub_traits_2> Traits_2;
typedef Arc_traits_2::CoordNT CoordNT; typedef Sub_traits_2::CoordNT CoordNT;
typedef Arc_traits_2::Point_2 Arc_point_2; typedef Sub_traits_2::Point_2 Point_2;
typedef Arc_traits_2::Curve_2 Arc_section_2; typedef Sub_traits_2::Curve_2 Subcurve_2;
typedef Arc_traits_2::X_monotone_curve_2 Arc_section_x_monotone_2; typedef Sub_traits_2::X_monotone_curve_2 Subcurve_x_monotone_2;
typedef CGAL::Arrangement_2<Polycurve_arc_traits_2> Arc_arrangment_2; typedef boost::variant<Point_2, Subcurve_x_monotone_2>
Make_sub_x_monotone_result;
void check_equal() void check_equal()
{ {
Polycurve_arc_traits_2 Polycurve_traits_2; Traits_2 Polycurve_traits_2;
Polycurve_arc_traits_2::Equal_2 equal_2 = Polycurve_traits_2.equal_2_object(); auto equal_2 = Polycurve_traits_2.equal_2_object();
Polycurve_arc_traits_2::Construct_x_monotone_curve_2 auto construct_x_monotone_curve_2 =
construct_x_monotone_curve_2 =
Polycurve_traits_2.construct_x_monotone_curve_2_object(); Polycurve_traits_2.construct_x_monotone_curve_2_object();
Arc_section_2 curve1, curve2, curve3; Subcurve_2 curve1, curve2, curve3;
Kernel::Point_2 p1 = Kernel::Point_2(-5, 0); Kernel::Point_2 p1 = Kernel::Point_2(-5, 0);
Kernel::Point_2 mid = Kernel::Point_2(0, 5); Kernel::Point_2 mid = Kernel::Point_2(0, 5);
Kernel::Point_2 p2 = Kernel::Point_2(5, 0); Kernel::Point_2 p2 = Kernel::Point_2(5, 0);
curve1= Arc_section_2(p1, mid, p2); curve1= Subcurve_2(p1, mid, p2);
curve2= Arc_section_2(p1, mid, p2); curve2= Subcurve_2(p1, mid, p2);
// //make x_monotone // //make x_monotone
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc1 = // Traits_2::X_monotone_curve_2 xmc1 =
// construct_x_monotone_curve_2(curve1); // construct_x_monotone_curve_2(curve1);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc2 = // Traits_2::X_monotone_curve_2 xmc2 =
// construct_x_monotone_curve_2(curve2); // construct_x_monotone_curve_2(curve2);
// Polycurve_arc_traits_2::X_monotone_curve_2 xmc3 = // Traits_2::X_monotone_curve_2 xmc3 =
// construct_x_monotone_curve_2(curve3); // construct_x_monotone_curve_2(curve3);
// //simple equal // //simple equal
@ -71,11 +55,11 @@ void check_equal()
// << ((Are_equal) ? "Equal" : "Not equal") << std::endl; // << ((Are_equal) ? "Equal" : "Not equal") << std::endl;
} }
void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2 void check_intersect(Traits_2::Make_x_monotone_2
make_x_monotone_2, make_x_monotone_2,
Polycurve_arc_traits_2::Intersect_2 intersect_2) Traits_2::Intersect_2 intersect_2)
{ {
Arc_section_2 curve1, curve2, curve3; Subcurve_2 curve1, curve2, curve3;
// Create a circular arc that correspond to the upper half of the // Create a circular arc that correspond to the upper half of the
// circle centered at (1,1) with squared radius 3. We create the // circle centered at (1,1) with squared radius 3. We create the
@ -85,24 +69,22 @@ void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE); Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3); CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3); CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1)); Point_2 s1 = Point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1)); Point_2 t1 = Point_2(one_plus_sqrt_3, CoordNT(1));
curve1 = Arc_section_2(circ1, s1, t1); curve1 = Subcurve_2(circ1, s1, t1);
curve2 = Arc_section_2(circ1, s1, t1); curve2 = Subcurve_2(circ1, s1, t1);
//push the same semi circle again //push the same semi circle again
//curves.push_back(Arc_section_2(circ1, s1, t1)); //curves.push_back(Subcurve_2(circ1, s1, t1));
//make x_monotone //make x_monotone
std::vector<CGAL::Object> X_monotone_curves; std::vector<Make_sub_x_monotone_result> x_monotone_curves;
make_x_monotone_2(curve1, std::back_inserter(X_monotone_curves)); make_x_monotone_2(curve1, std::back_inserter(x_monotone_curves));
make_x_monotone_2(curve2, std::back_inserter(X_monotone_curves)); make_x_monotone_2(curve2, std::back_inserter(x_monotone_curves));
Arc_section_x_monotone_2 X_monotone_curve1, X_monotone_curve2, const auto* x_curve1 = boost::get<Subcurve_x_monotone_2>(curves[0]);
X_monotone_curve3 ; const auto* x_curve2 = boost::get<Subcurve_x_monotone_2>(curves[1]);
CGAL::assign(X_monotone_curve1, X_monotone_curves[0]);
CGAL::assign(X_monotone_curve2, X_monotone_curves[1]);
std::vector<CGAL::Object> Points_of_intersection; std::vector<Intersection_result> Points_of_intersection;
//intersect_2(X_monotone_curve1, X_monotone_curve2, //intersect_2(X_monotone_curve1, X_monotone_curve2,
// std::back_inserter(Points_of_intersection)); // std::back_inserter(Points_of_intersection));
@ -113,12 +95,12 @@ void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2
Kernel::Point_2 c6 = Kernel::Point_2(0, 0); Kernel::Point_2 c6 = Kernel::Point_2(0, 0);
CoordNT sqrt_3_div_2 = CoordNT sqrt_3_div_2 =
CoordNT(Number_type(0), Number_type(1,2), Number_type(3)); CoordNT(Number_type(0), Number_type(1,2), Number_type(3));
Arc_point_2 s6 = Arc_point_2(Number_type(-1, 2), sqrt_3_div_2); Point_2 s6 = Point_2(Number_type(-1, 2), sqrt_3_div_2);
Arc_point_2 t6 = Arc_point_2(Number_type(1, 2), sqrt_3_div_2); Point_2 t6 = Point_2(Number_type(1, 2), sqrt_3_div_2);
curve3 = Arc_section_2(c6, 1, CGAL::CLOCKWISE, s6, t6); curve3 = Subcurve_2(c6, 1, CGAL::CLOCKWISE, s6, t6);
make_x_monotone_2(curve3, std::back_inserter(X_monotone_curves)); make_x_monotone_2(curve3, std::back_inserter(x_curves));
CGAL::assign(X_monotone_curve2, X_monotone_curves[2]); const auto* x_curve2 = boost::get<>(&x_curves[2]);
Points_of_intersection.clear(); Points_of_intersection.clear();
//intersect_2(X_monotone_curve1, X_monotone_curve2, //intersect_2(X_monotone_curve1, X_monotone_curve2,
@ -126,12 +108,12 @@ void check_intersect(Polycurve_arc_traits_2::Make_x_monotone_2
} }
void void
check_compare_end_points_xy_2(Polycurve_arc_traits_2::Compare_endpoints_xy_2 check_compare_end_points_xy_2(Traits_2::Compare_endpoints_xy_2
compare_endpoints_xy_2, compare_endpoints_xy_2,
Polycurve_arc_traits_2::Make_x_monotone_2 Traits_2::Make_x_monotone_2
make_x_monotone_2) make_x_monotone_2)
{ {
Arc_section_2 curve1, curve2; Subcurve_2 curve1, curve2;
// Create a circular arc that correspond to the upper half of the // Create a circular arc that correspond to the upper half of the
// circle centered at (1,1) with squared radius 3. We create the // circle centered at (1,1) with squared radius 3. We create the
@ -141,39 +123,37 @@ check_compare_end_points_xy_2(Polycurve_arc_traits_2::Compare_endpoints_xy_2
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE); Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3); CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3); CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1)); Point_2 s1 = Point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1)); Point_2 t1 = Point_2(one_plus_sqrt_3, CoordNT(1));
curve1= Arc_section_2(circ1, s1, t1); curve1= Subcurve_2(circ1, s1, t1);
//make x_monotone //make x_monotone
std::vector<CGAL::Object> X_monotone_curves; std::vector<Make_sub_x_monotone_result> x_curves;
make_x_monotone_2(curve1, std::back_inserter(X_monotone_curves)); make_x_monotone_2(curve1, std::back_inserter(x_curves));
Arc_section_x_monotone_2 X_monotone_curve1, X_monotone_curve2 ; const auto* x_curve1 = boost::get<Subcurve_x_monotone_2>(&x_curves[0]);
CGAL::assign(X_monotone_curve1, X_monotone_curves[ 0 ]); const auto* x_curve2 = boost::get<Subcurve_x_monotone_2>(&x_curves[1]);
int res = compare_endpoints_xy_2(X_monotone_curve1);
auto res = compare_endpoints_xy_2(x_curve1);
std::cout<< "The first result is: " << res << std::endl; std::cout<< "The first result is: " << res << std::endl;
Kernel::Point_2 c2 = Kernel::Point_2(1, 1); Kernel::Point_2 c2 = Kernel::Point_2(1, 1);
Kernel::Circle_2 circ2 = Kernel::Circle_2(c2, 3, CGAL::COUNTERCLOCKWISE); Kernel::Circle_2 circ2 = Kernel::Circle_2(c2, 3, CGAL::COUNTERCLOCKWISE);
Arc_point_2 t2 = Arc_point_2(one_minus_sqrt_3, CoordNT(1)); Point_2 t2 = Point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 s2 = Arc_point_2(one_plus_sqrt_3, CoordNT(1)); Point_2 s2 = Point_2(one_plus_sqrt_3, CoordNT(1));
curve2= Arc_section_2(circ2, s1, t1); curve2 = Subcurve_2(circ2, s1, t1);
make_x_monotone_2(curve2, std::back_inserter(x_curves));
const auto* x_curve2 = boost::get<Subcurve_x_monotone_2>(&x_curves[1]);
make_x_monotone_2(curve2, std::back_inserter(X_monotone_curves)); res = compare_endpoints_xy_2(x_curve2);
CGAL::assign(X_monotone_curve2, X_monotone_curves[ 1 ]);
res = compare_endpoints_xy_2(X_monotone_curve2);
std::cout<< "The second result is: " << res << std::endl; std::cout<< "The second result is: " << res << std::endl;
} }
void check_split(Polycurve_arc_traits_2::Split_2 split_2, void check_split(Traits_2::Split_2 split_2,
Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2) Traits_2::Make_x_monotone_2 make_x_monotone_2)
{ {
Arc_section_2 curve; Subcurve_2 curve;
// Create a circular arc that correspond to the upper half of the // Create a circular arc that correspond to the upper half of the
// circle centered at (1,1) with squared radius 3. We create the // circle centered at (1,1) with squared radius 3. We create the
@ -183,64 +163,59 @@ void check_split(Polycurve_arc_traits_2::Split_2 split_2,
Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE); Kernel::Circle_2 circ1 = Kernel::Circle_2(c1, 3, CGAL::CLOCKWISE);
CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3); CoordNT one_minus_sqrt_3 = CoordNT(1, -1, 3);
CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3); CoordNT one_plus_sqrt_3 = CoordNT(1, 1, 3);
Arc_point_2 s1 = Arc_point_2(one_minus_sqrt_3, CoordNT(1)); Point_2 s1 = Point_2(one_minus_sqrt_3, CoordNT(1));
Arc_point_2 t1 = Arc_point_2(one_plus_sqrt_3, CoordNT(1)); Point_2 t1 = Point_2(one_plus_sqrt_3, CoordNT(1));
curve= Arc_section_2(circ1, s1, t1); curve= Subcurve_2(circ1, s1, t1);
//make x_monotone //make x_monotone
std::vector<CGAL::Object> X_monotone_curves; std::vector<Make_sub_x_monotone_result> x_curves;
make_x_monotone_2(curve, std::back_inserter(X_monotone_curves)); make_x_monotone_2(curve, std::back_inserter(x_curves));
const auto* x_curve1 = boost::get<Subcurve_x_monotone_2>(&x_curves[0]);
Arc_section_x_monotone_2 X_monotone_curve, split_x_monotone_curve1,
split_x_monotone_curve2 ;
CGAL::assign(X_monotone_curve, X_monotone_curves[0]);
// Subcurve_x_monotone_2 split_x_monotone_curve1, split_x_monotone_curve2 ;
//split_2(X_monotone_curve, Kernel::Point_2::Kernel::Point_2(1, 4), //split_2(X_monotone_curve, Kernel::Point_2::Kernel::Point_2(1, 4),
// split_x_monotone_curve1, split_x_monotone_curve2); // split_x_monotone_curve1, split_x_monotone_curve2);
} }
void check_is_vertical(Polycurve_arc_traits_2::Make_x_monotone_2 void check_is_vertical(Traits_2::Make_x_monotone_2
make_x_monotone_2, make_x_monotone_2,
Polycurve_arc_traits_2::Is_vertical_2 is_vertical) Traits_2::Is_vertical_2 is_vertical)
{ {
std::vector<Arc_section_2> curves; std::vector<Subcurve_2> curves;
// Create a circular arc defined by two endpoints and a midpoint, // Create a circular arc defined by two endpoints and a midpoint,
// all having rational coordinates. This arc is the upper-right // all having rational coordinates. This arc is the upper-right
// quarter of a circle centered at the origin with radius 5. // quarter of a circle centered at the origin with radius 5.
Kernel::Point_2 p1 = Kernel::Point_2(0, 5); Kernel::Point_2 p1 = Kernel::Point_2(0, 5);
Kernel::Point_2 mid = Kernel::Point_2(3, 4); Kernel::Point_2 mid = Kernel::Point_2(3, 4);
Kernel::Point_2 p2 = Kernel::Point_2(5, 0); Kernel::Point_2 p2 = Kernel::Point_2(5, 0);
Kernel::Point_2 p3 = Kernel::Point_2(0, -5); Kernel::Point_2 p3 = Kernel::Point_2(0, -5);
curves.push_back(Arc_section_2(p1, mid, p2)); //quarter of a circle curves.push_back(Subcurve_2(p1, mid, p2)); //quarter of a circle
curves.push_back(Arc_section_2(p1, mid, p3)); //semi-circle curves.push_back(Subcurve_2(p1, mid, p3)); //semi-circle
//convert all curves to x-monotone curves //convert all curves to x-monotone curves
std::vector<CGAL::Object> X_monotone_curves; std::vector<Make_sub_x_monotone_result> x_curves;
for(int i = 0; i < curves.size(); ++i) for (const auto& cv : curves)
make_x_monotone_2(curves[i], std::back_inserter(X_monotone_curves)); make_x_monotone_2(cv, std::back_inserter(x_curves));
//std::vector<Arc_section_x_monotone_2> x_monotone_polycurves; //std::vector<Subcurve_x_monotone_2> x_monotone_polycurves;
Arc_section_x_monotone_2 x_monotone_polycurve1, x_monotone_polycurve2; const auto* x_polycurve1 = boost::get<Subcurve_x_monotone_2>(&x_curves[0]);
CGAL::assign(x_monotone_polycurve1, X_monotone_curves[0]); const auto* x_polycurve2 = boost::get<Subcurve_x_monotone_2>(&x_curves[1]);
CGAL::assign(x_monotone_polycurve2, X_monotone_curves[1]);
bool res = is_vertical(x_monotone_polycurve1); bool res = is_vertical(x_polycurve1);
std::cout << "Is_verticle:: The xmonotone curve (quarter circle) is : " std::cout << "Is_verticle:: The xmonotone curve (quarter circle) is : "
<< ((res)? "vertical" : "not vertical") << std::endl; << ((res)? "vertical" : "not vertical") << std::endl;
res = is_vertical(x_monotone_polycurve2); res = is_vertical(x_polycurve2);
std::cout << "Is_verticle:: The xmonotone curve (Smi-circle) is : " std::cout << "Is_verticle:: The xmonotone curve (Smi-circle) is : "
<< ((res)? "vertical" : "not vertical") << std::endl; << ((res)? "vertical" : "not vertical") << std::endl;
} }
void check_compare_y_at_x_2(Polycurve_arc_traits_2::Make_x_monotone_2 void check_compare_y_at_x_2(Traits_2::Make_x_monotone_2 make_x_monotone_2,
make_x_monotone_2, Traits_2::Compare_y_at_x_2 cmp_y_at_x_2)
Polycurve_arc_traits_2::Compare_y_at_x_2
cmp_y_at_x_2)
{ {
std::vector<Arc_section_2> curves; std::vector<Subcurve_2> curves;
// Create a circular arc defined by two endpoints and a midpoint, // Create a circular arc defined by two endpoints and a midpoint,
// all having rational coordinates. This arc is the upper-right // all having rational coordinates. This arc is the upper-right
@ -249,30 +224,29 @@ void check_compare_y_at_x_2(Polycurve_arc_traits_2::Make_x_monotone_2
Kernel::Point_2 mid = Kernel::Point_2(4, 4); Kernel::Point_2 mid = Kernel::Point_2(4, 4);
Kernel::Point_2 p2 = Kernel::Point_2(7, 1); Kernel::Point_2 p2 = Kernel::Point_2(7, 1);
Kernel::Point_2 p3 = Kernel::Point_2(1, 4); Kernel::Point_2 p3 = Kernel::Point_2(1, 4);
curves.push_back(Arc_section_2(p1, mid, p2)); //quarter of a circle curves.push_back(Subcurve_2(p1, mid, p2)); //quarter of a circle
curves.push_back(Arc_section_2(p1, mid, p3)); //semi-circle curves.push_back(Subcurve_2(p1, mid, p3)); //semi-circle
//convert all curves to x-monotone curves //convert all curves to x-monotone curves
std::vector<CGAL::Object> X_monotone_curves; std::vector<Make_sub_x_monotone_result> x_curves;
for (int i = 0; i < curves.size(); ++i) for (const auto& cv : curves)
make_x_monotone_2(curves[i], std::back_inserter(X_monotone_curves)); make_x_monotone_2(cv, std::back_inserter(x_curves));
Arc_section_x_monotone_2 x_monotone_polycurve1, x_monotone_polycurve2; const auto* x_polycurve1 = boost::get<Subcurve_x_monotone_2>(&x_curves[0]);
CGAL::assign(x_monotone_polycurve1, X_monotone_curves[ 0 ]); const auto* x_polycurve2 = boost::get<Subcurve_x_monotone_2>(&x_curves[1]);
CGAL::assign(x_monotone_polycurve2, X_monotone_curves[ 1 ]);
Kernel::Point_2 p_test = Kernel::Point_2(3, 1); Kernel::Point_2 p_test = Kernel::Point_2(3, 1);
// int res = cmp_y_at_x_2(p_test, x_monotone_polycurve1); // int res = cmp_y_at_x_2(p_test, x_monotone_polycurve1);
// cmp_y_at_x_2(x_monotone_polycurve1, CGAL::ARR_MIN_END, // cmp_y_at_x_2(x_monotone_polycurve1, CGAL::ARR_MIN_END,
// x_monotone_polycurve2); // x_monotone_polycurve2);
} }
void check_push_back(Polycurve_arc_traits_2::Make_x_monotone_2 void check_push_back(Traits_2::Make_x_monotone_2
make_x_monotone_2, make_x_monotone_2,
Polycurve_arc_traits_2::Push_back_2 push_back_2) Traits_2::Push_back_2 push_back_2)
{ {
std::vector<Arc_section_2> curves; std::vector<Subcurve_2> curves;
//check if segment is pushed in empty curve. //check if segment is pushed in empty curve.
Kernel::Point_2 p1 = Kernel::Point_2(1, 1); Kernel::Point_2 p1 = Kernel::Point_2(1, 1);
@ -282,10 +256,10 @@ void check_push_back(Polycurve_arc_traits_2::Make_x_monotone_2
Kernel::Point_2 mid2 = Kernel::Point_2(10, 3); Kernel::Point_2 mid2 = Kernel::Point_2(10, 3);
Kernel::Point_2 p3 = Kernel::Point_2(7, 7); Kernel::Point_2 p3 = Kernel::Point_2(7, 7);
curves.push_back(Arc_section_2(p1, mid, p2)); curves.push_back(Subcurve_2(p1, mid, p2));
curves.push_back(Arc_section_2(p2, mid2, p3)); curves.push_back(Subcurve_2(p2, mid2, p3));
CGAL::internal::Polycurve_2<Arc_section_2, Arc_point_2> polycurve; CGAL::internal::Polycurve_2<Subcurve_2, Point_2> polycurve;
////pushing segments in polycurve ////pushing segments in polycurve
push_back_2(polycurve, curves[0]); push_back_2(polycurve, curves[0]);
@ -300,87 +274,70 @@ void check_push_back(Polycurve_arc_traits_2::Make_x_monotone_2
int main() int main()
{ {
Polycurve_arc_traits_2 Polycurve_traits_2; Traits_2 Polycurve_traits_2;
// Compare_x_2 // Compare_x_2
// Polycurve_arc_traits_2::Compare_x_2 compare_x_2 = // Traits_2::Compare_x_2 compare_x_2 =
// Polycurve_traits_2.compare_xy_2_object(); // Polycurve_traits_2.compare_xy_2_object();
// number of points // number of points
// Polycurve_arc_traits_2::Number_of_points_2 num_of_points = // Traits_2::Number_of_points_2 num_of_points =
// Polycurve_traits_2.number_of_points_2_object(); // Polycurve_traits_2.number_of_points_2_object();
//construct min vertex //construct min vertex
Polycurve_arc_traits_2::Construct_min_vertex_2 cnst_min_vertex = auto cnst_min_vertex = Polycurve_traits_2.construct_min_vertex_2_object();
Polycurve_traits_2.construct_min_vertex_2_object();
//construct max vertex //construct max vertex
Polycurve_arc_traits_2::Construct_max_vertex_2 cnst_max_vertex_2 = auto cnst_max_vertex_2 = Polycurve_traits_2.construct_max_vertex_2_object();
Polycurve_traits_2.construct_max_vertex_2_object();
//is vertical (return bool) //is vertical (return bool)
Polycurve_arc_traits_2::Is_vertical_2 is_vertical = auto is_vertical = Polycurve_traits_2.is_vertical_2_object();
Polycurve_traits_2.is_vertical_2_object();
//Compare y at x 2 (return comparison_result) //Compare y at x 2 (return comparison_result)
Polycurve_arc_traits_2::Compare_y_at_x_2 cmp_y_at_x_2 = auto cmp_y_at_x_2 = Polycurve_traits_2.compare_y_at_x_2_object();
Polycurve_traits_2.compare_y_at_x_2_object();
//compare y at x left //compare y at x left
Polycurve_arc_traits_2::Compare_y_at_x_left_2 cmp_y_at_x_left_2 = auto cmp_y_at_x_left_2 = Polycurve_traits_2.compare_y_at_x_left_2_object();
Polycurve_traits_2.compare_y_at_x_left_2_object();
//compare y at x right //compare y at x right
Polycurve_arc_traits_2::Compare_y_at_x_right_2 cmp_y_at_x_right_2 = auto cmp_y_at_x_right_2 = Polycurve_traits_2.compare_y_at_x_right_2_object();
Polycurve_traits_2.compare_y_at_x_right_2_object();
//equal_2 //equal_2
Polycurve_arc_traits_2::Equal_2 equal_2 = auto equal_2 = Polycurve_traits_2.equal_2_object();
Polycurve_traits_2.equal_2_object();
//compare end points xy_2 //compare end points xy_2
Polycurve_arc_traits_2::Compare_endpoints_xy_2 compare_endpoints_xy_2 = auto compare_endpoints_xy_2 =
Polycurve_traits_2.compare_endpoints_xy_2_object(); Polycurve_traits_2.compare_endpoints_xy_2_object();
//construct opposite //construct opposite
Polycurve_arc_traits_2::Construct_opposite_2 construct_opposite_2 = auto construct_opposite_2 = Polycurve_traits_2.construct_opposite_2_object();
Polycurve_traits_2.construct_opposite_2_object();
//make x_monotone //make x_monotone
Polycurve_arc_traits_2::Make_x_monotone_2 make_x_monotone_2 = auto make_x_monotone_2 = Polycurve_traits_2.make_x_monotone_2_object();
Polycurve_traits_2.make_x_monotone_2_object();
//push back //push back
Polycurve_arc_traits_2::Push_back_2 push_back_2 = auto push_back_2 = Polycurve_traits_2.push_back_2_object();
Polycurve_traits_2.push_back_2_object();
//push front //push front
Polycurve_arc_traits_2::Push_front_2 push_front_2 = auto push_front_2 = Polycurve_traits_2.push_front_2_object();
Polycurve_traits_2.push_front_2_object();
//split_2 //split_2
Polycurve_arc_traits_2::Split_2 split_2 = auto split_2 = Polycurve_traits_2.split_2_object();
Polycurve_traits_2.split_2_object();
//Intersect_2 //Intersect_2
Polycurve_arc_traits_2::Intersect_2 intersect_2 = auto intersect_2 = Polycurve_traits_2.intersect_2_object();
Polycurve_traits_2.intersect_2_object();
//Are_mergable //Are_mergable
Polycurve_arc_traits_2::Are_mergeable_2 are_mergeable_2 = auto are_mergeable_2 = Polycurve_traits_2.are_mergeable_2_object();
Polycurve_traits_2.are_mergeable_2_object();
//Merge_2 //Merge_2
Polycurve_arc_traits_2::Merge_2 merge_2 = auto merge_2 = Polycurve_traits_2.merge_2_object();
Polycurve_traits_2.merge_2_object();
//construct_curve_2 //construct_curve_2
Polycurve_arc_traits_2::Construct_curve_2 construct_curve_2 = auto construct_curve_2 = Polycurve_traits_2.construct_curve_2_object();
Polycurve_traits_2.construct_curve_2_object();
//construct x_monotone curve_2 //construct x_monotone curve_2
Polycurve_arc_traits_2::Construct_x_monotone_curve_2 auto construct_x_monotone_curve_2 =
construct_x_monotone_curve_2 =
Polycurve_traits_2.construct_x_monotone_curve_2_object(); Polycurve_traits_2.construct_x_monotone_curve_2_object();
//check_equal(); //check_equal();
@ -393,4 +350,3 @@ int main()
return 0; return 0;
} }
#endif

View File

@ -11,19 +11,19 @@ int main()
#else #else
#include <vector>
#include <list>
#include <boost/type_traits/is_same.hpp>
#include <CGAL/Cartesian.h> #include <CGAL/Cartesian.h>
#include <CGAL/Quotient.h> #include <CGAL/Quotient.h>
#include <CGAL/MP_Float.h> #include <CGAL/MP_Float.h>
#include <CGAL/CORE_algebraic_number_traits.h> #include <CGAL/CORE_algebraic_number_traits.h>
#include <vector>
#include <list>
#include <CGAL/Arr_polyline_traits_2.h> #include <CGAL/Arr_polyline_traits_2.h>
#include <CGAL/Arr_conic_traits_2.h> #include <CGAL/Arr_conic_traits_2.h>
#include <CGAL/Arrangement_2.h>
#include <CGAL/tags.h> #include <CGAL/tags.h>
#include <CGAL/Arr_tags.h> #include <CGAL/Arr_tags.h>
#include <boost/type_traits/is_same.hpp>
//////////////////// ////////////////////
//conic traits //conic traits
@ -102,28 +102,36 @@ void check_equal()
<< ((are_equal) ? "equal" : "Not equal") << std::endl; << ((are_equal) ? "equal" : "Not equal") << std::endl;
} }
template <typename curve_type> template <typename Traits>
void check_intersect(curve_type &xcv1, curve_type &xcv2) void check_intersect(typename Traits::X_monotone_curve_2& xcv1,
typename Traits::X_monotone_curve_2& xcv2,
const Traits& traits)
{ {
Polycurve_conic_traits_2 traits; typedef typename Traits::Multiplicity Multiplicity;
std::vector<CGAL::Object> intersection_points; typedef typename Traits::Point_2 Point_2;
traits.intersect_2_object()(xcv1, xcv2, typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2;
std::back_inserter(intersection_points)); typedef std::pair<Multiplicity, Point_2> Intersection_point;
std::cout<< "Number of intersection Points: " << intersection_points.size() typedef boost::variant<Intersection_point, X_monotone_curve_2>
<< std::endl; Intersection_result;
//dynamic cast the cgal_objects std::vector<Intersection_result> intersection_points;
// std::vector< std::pair<Polycurve_conic_traits_2::Point_2, traits.intersect_2_object()(xcv1, xcv2,
// Polycurve_conic_traits_2::Multiplicity> > pm_vector; std::back_inserter(intersection_points));
// for(int i=0; i<intersection_points.size(); i++) std::cout<< "Number of intersection Points: " << intersection_points.size()
// { << std::endl;
// std::pair<Polycurve_conic_traits_2::Point_2,
// Polycurve_conic_traits_2::Multiplicity> pm = //dynamic cast the cgal_objects
// CGAL::object_cast<std::pair<Polycurve_conic_traits_2::Point_2, // std::vector< std::pair<Polycurve_conic_traits_2::Point_2,
// Polycurve_conic_traits_2::Multiplicity> > // Polycurve_conic_traits_2::Multiplicity> > pm_vector;
// (&(intersection_points[i])); // for(int i=0; i<intersection_points.size(); i++)
// pm_vector.push_back(pm); // {
// } // std::pair<Polycurve_conic_traits_2::Point_2,
// Polycurve_conic_traits_2::Multiplicity> pm =
// CGAL::object_cast<std::pair<Polycurve_conic_traits_2::Point_2,
// Polycurve_conic_traits_2::Multiplicity> >
// (&(intersection_points[i]));
// pm_vector.push_back(pm);
// }
} }
void check_compare_end_points_xy_2() void check_compare_end_points_xy_2()