diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_alpha_shape_2.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_alpha_shape_2.C index 95d2754f149..cefe455e87f 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_alpha_shape_2.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_alpha_shape_2.C @@ -2,13 +2,13 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_constrained_triang_2.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_constrained_triang_2.C index cdf841d74ea..807fd204860 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_constrained_triang_2.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_constrained_triang_2.C @@ -1,7 +1,7 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_2.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_2.C index 90cafb28720..0870e46fe4f 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_2.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_2.C @@ -1,12 +1,12 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_3.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_3.C index 69b7e916d87..0505fb241e6 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_3.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_convex_hull_3.C @@ -4,13 +4,13 @@ #define CGAL_PROVIDE_LEDA_RAT_KERNEL_TRAITS_3 #include -#if (!defined(CGAL_USE_LEDA) || (__LEDA__ < 430)) +#if (!defined(CGAL_USE_LEDA) || (__LEDA__ < 420)) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else @@ -93,8 +93,8 @@ void show_d3_points(geo_scene sc, leda_d3_window& W, GRAPH& H for (; hit != Pol.halfedges_end(); hit++) { Vertex_handle v1 = hit->vertex(); Vertex_handle v2 = hit->opposite()->vertex(); - d3_point ps = (v1->point()).to_float(); - d3_point pt = (v2->point()).to_float(); + leda_d3_point ps = (v1->point()).to_float(); + leda_d3_point pt = (v2->point()).to_float(); leda_node n1= H.new_node(ps); leda_node n2= H.new_node(pt); @@ -104,8 +104,8 @@ void show_d3_points(geo_scene sc, leda_d3_window& W, GRAPH& H } else if (CGAL::assign(segment, ch_object) ){ - d3_point ps = (segment.source()).to_float(); - d3_point pt = (segment.target()).to_float(); + leda_d3_point ps = (segment.source()).to_float(); + leda_d3_point pt = (segment.target()).to_float(); leda_node n1= H.new_node(ps); leda_node n2= H.new_node(pt); @@ -113,9 +113,9 @@ void show_d3_points(geo_scene sc, leda_d3_window& W, GRAPH& H H.set_reversal(e1,e2); } else if (CGAL::assign(triangle, ch_object) ){ - d3_point ps = triangle.point1().to_float(); - d3_point pt = triangle.point2().to_float(); - d3_point pu = triangle.point3().to_float(); + leda_d3_point ps = triangle.point1().to_float(); + leda_d3_point pt = triangle.point2().to_float(); + leda_d3_point pu = triangle.point3().to_float(); leda_node n1= H.new_node(ps); leda_node n2= H.new_node(pt); @@ -128,7 +128,7 @@ void show_d3_points(geo_scene sc, leda_d3_window& W, GRAPH& H H.set_reversal(e5,e6); } else if (CGAL::assign(lpoint, ch_object) ){ - d3_point p = lpoint.to_float(); + leda_d3_point p = lpoint.to_float(); H.new_node(p); } diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_segment_intersection_2.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_segment_intersection_2.C index b1838b1c2b4..48e40936f31 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_segment_intersection_2.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/CGAL_segment_intersection_2.C @@ -1,13 +1,13 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/graham_anim.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/graham_anim.C index f5ce9677de5..d284a135889 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/graham_anim.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/graham_anim.C @@ -8,13 +8,13 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else @@ -41,7 +41,7 @@ typedef K::Point_2 Point; typedef K::Segment_2 Segment; -void new_redraw(window* wp, double x0, double y0, double x1, double y1) +void new_redraw(leda_window* wp, double x0, double y0, double x1, double y1) { } class geo_hull : public geowin_update, std::list > @@ -50,13 +50,13 @@ public: CGAL::event_item left_turn_it; CGAL::event_item less_xy_it; GeoWin& gw; - window& w; + leda_window& w; std::list current_hull; Point p_left, p_right; std::list out; - point_style pold; + leda_point_style pold; const std::list* input_set; bool first_scan; int algorithm_phase; // 0 ... sorting; 1 ... lower hull; 2 - upper hull @@ -73,7 +73,7 @@ public: void user_interaction() { w.read_mouse(); } void draw_points() - { point_style ps = w.set_point_style(cross_point); + { leda_point_style ps = w.set_point_style(leda_cross_point); std::list::const_iterator it= input_set->begin(); for(;it != input_set->end(); it++) w.draw_point(it->to_float()); w.set_point_style(ps); @@ -87,19 +87,19 @@ public: Point plast; bool first = true; for(;cit != out.end(); cit++){ - w.draw_point((*cit).to_float(), green); - if (! first) w.draw_segment((*cit).to_float(), plast.to_float(), black); + w.draw_point((*cit).to_float(), leda_green); + if (! first) w.draw_segment((*cit).to_float(), plast.to_float(), leda_black); plast = *cit; first= false; } - w.draw_segment(p_right.to_float(), plast.to_float(), black); - w.draw_line(p_left.to_float(), p_right.to_float(), blue); + w.draw_segment(p_right.to_float(), plast.to_float(), leda_black); + w.draw_line(p_left.to_float(), p_right.to_float(), leda_blue); } void left_turn_occurence(const Point& p1, const Point& p2, const Point& p3) { // compute result ... - bool result = leda::left_turn(p1,p2,p3); + bool result = LEDA_NAMESPACE_NAME::left_turn(p1,p2,p3); std::cout << "left_turn:" << p1 << " " << p2 << " " << p3 << " - result:" << result << "\n"; if (first_scan) { // first left_turn call ... @@ -110,7 +110,7 @@ public: p_left = p2; // line separating upper and lower hull ... - w.draw_line(p1.to_float(), p2.to_float(), blue); + w.draw_line(p1.to_float(), p2.to_float(), leda_blue); } else { if (algorithm_phase == 1 && identical(p2, p_right)) { @@ -121,13 +121,13 @@ public: } if (result) { - w.draw_segment(p1.to_float(), p2.to_float(), black); - w.draw_arrow(p2.to_float(), p3.to_float(), black); + w.draw_segment(p1.to_float(), p2.to_float(), leda_black); + w.draw_arrow(p2.to_float(), p3.to_float(), leda_black); } else { - w.draw_arrow(p1.to_float(), p2.to_float(), green); - w.draw_arrow(p2.to_float(), p3.to_float(), green); - w.draw_point(p3.to_float(), red); + w.draw_arrow(p1.to_float(), p2.to_float(), leda_green); + w.draw_arrow(p2.to_float(), p3.to_float(), leda_green); + w.draw_point(p3.to_float(), leda_red); } user_interaction(); } @@ -148,7 +148,7 @@ public: first_scan = true; algorithm_phase = 0; current_hull.clear(); - pold = w.set_point_style(disc_point); + pold = w.set_point_style(leda_disc_point); } void reset_visualization() { diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/jarvis_anim.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/jarvis_anim.C index e85f1b8d8e6..47279b4d37e 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/jarvis_anim.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/jarvis_anim.C @@ -13,13 +13,13 @@ #include -#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 430) +#if !defined(CGAL_USE_LEDA) || (__LEDA__ < 420) #include int main(int argc, char *argv[]) { - std::cout << "No LEDA 4.3 or higher installed!\n"; - std::cout << "A LEDA version >= 4.3 is required !\n"; + std::cout << "No LEDA 4.2 or higher installed!\n"; + std::cout << "A LEDA version >= 4.2 is required !\n"; return 0; } #else @@ -49,7 +49,7 @@ typedef K::Point_2 Point; typedef K::Segment_2 Segment; -void new_redraw(window* wp, double x0, double y0, double x1, double y1) +void new_redraw(leda_window* wp, double x0, double y0, double x1, double y1) { } class geo_hull : public geowin_update, std::list > @@ -60,10 +60,10 @@ public: int less_rotate_ccw_counter; int less_xy_counter; GeoWin& gw; - window& w; + leda_window& w; std::list current_hull; - point_style pold; + leda_point_style pold; const std::list* input_set; geo_hull(GeoWin& g) : gw(g), w(g.get_window()) @@ -78,7 +78,7 @@ public: void user_interaction() { w.read_mouse(); } void draw_points() - { point_style ps = w.set_point_style(cross_point); + { leda_point_style ps = w.set_point_style(leda_cross_point); std::list::const_iterator it= input_set->begin(); for(;it != input_set->end(); it++) w.draw_point(it->to_float()); w.set_point_style(ps); @@ -92,8 +92,8 @@ public: Point plast; bool first = true; for(;cit != current_hull.end(); cit++){ - w.draw_point((*cit).to_float(), green); - if (! first) w.draw_segment((*cit).to_float(), plast.to_float(), green); + w.draw_point((*cit).to_float(), leda_green); + if (! first) w.draw_segment((*cit).to_float(), plast.to_float(), leda_green); plast = *cit; first= false; } @@ -124,9 +124,9 @@ public: if (result) { gw.msg_clear(); - gw.msg_open(string("less_rotate_ccw - new point found ...")); - w.draw_ray(p1.to_float(), p2.to_float(), blue); - w.draw_arrow(p2.to_float(), p3.to_float(), black); + gw.msg_open(leda_string("less_rotate_ccw - new point found ...")); + w.draw_ray(p1.to_float(), p2.to_float(), leda_blue); + w.draw_arrow(p2.to_float(), p3.to_float(), leda_black); user_interaction(); } } @@ -137,11 +137,11 @@ public: bool result = (leda_rat_point::cmp_xy(p1,p2) < 0); if (less_xy_counter == 0) // draw start point ... - w.draw_point(p1.to_float(), red); + w.draw_point(p1.to_float(), leda_red); if (result) { - w.draw_point(p1.to_float(), red); + w.draw_point(p1.to_float(), leda_red); gw.msg_clear(); - gw.msg_open(string("new minimum point (xy-lexicographically) found ...")); + gw.msg_open(leda_string("new minimum point (xy-lexicographically) found ...")); user_interaction(); } less_xy_counter++; @@ -159,7 +159,7 @@ public: input_set = &L; draw_points(); current_hull.clear(); - pold = w.set_point_style(disc_point); + pold = w.set_point_style(leda_disc_point); } void reset_visualization() { diff --git a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/triangulation_anim.C b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/triangulation_anim.C index 5a04d34090c..709a8980868 100644 --- a/Extension_Packages/Leda_rat_kernel/demo/leda_traits/triangulation_anim.C +++ b/Extension_Packages/Leda_rat_kernel/demo/leda_traits/triangulation_anim.C @@ -31,7 +31,7 @@ typedef CGAL::Triangulation_2 Triangulation_2; typedef Triangulation_2::Edge Edge; typedef Triangulation_2::Edge_iterator Edge_iterator; -void new_redraw(window* wp, double x0, double y0, double x1, double y1) +void new_redraw(leda_window* wp, double x0, double y0, double x1, double y1) { } struct geo_triang : public geowin_update, std::list > @@ -42,7 +42,7 @@ struct geo_triang : public geowin_update, std::list > CGAL::event_item orientation_it; GeoWin& gw; - window& w; + leda_window& w; geo_triang(GeoWin& g) : gw(g), w(g.get_window()) { } @@ -63,8 +63,8 @@ struct geo_triang : public geowin_update, std::list > draw_points(); Edge_iterator eit = tr.edges_begin(); for(;eit != tr.edges_end();eit++) w.draw_segment(tr.segment(*eit).to_float(),leda_blue2); - w.draw_arrow(p1.to_float(),p2.to_float(),green); - w.draw_arrow(p2.to_float(),p3.to_float(),green); + w.draw_arrow(p1.to_float(),p2.to_float(),leda_green); + w.draw_arrow(p2.to_float(),p3.to_float(),leda_green); user_interaction(); } diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/constructions_2.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/constructions_2.h index deb80efc6a6..ad50cbcaecb 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/constructions_2.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/constructions_2.h @@ -966,10 +966,21 @@ public: if (ori == CGAL::COUNTERCLOCKWISE) { - return v.rotate90(1); +#if (__LEDA__ <= 420) + v = v.rotate90(); +#else + v = v.rotate90(1); +#endif } else { // clockwise ... - return v.rotate90(-1); +#if (__LEDA__ <= 420) + Vector_2 hlp = v.rotate90(); + hlp = hlp.rotate90(); + hlp = hlp.rotate90(); + v = hlp; +#else + v = v.rotate90(-1); +#endif } // collinear is not allowed @@ -1003,10 +1014,21 @@ public: if (ori == CGAL::COUNTERCLOCKWISE) { +#if (__LEDA__ <= 420) + return v.rotate90(); +#else return v.rotate90(1); +#endif } else { // clockwise ... +#if (__LEDA__ <= 420) + Vector_2 hlp = v.rotate90(); + hlp = hlp.rotate90(); + hlp = hlp.rotate90(); + return hlp; +#else return v.rotate90(-1); +#endif } // collinear is not allowed @@ -1041,10 +1063,18 @@ public: #endif // construct perp. line through p; rotation ccw by 90 degrees +#if (__LEDA__ <= 420) + int ori = ::orientation(l,p); +#else int ori = l.side_of(p); +#endif if (ori == 0) { // special case: collinear +#if (__LEDA__ <= 420) + return l.rotate90(p); +#else return l.rotate90(p,1); +#endif } Segment_2 s = l.perpendicular(p); diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/extension_predicates_2.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/extension_predicates_2.h index 0da4dbfe7a7..481f13bcb6d 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/extension_predicates_2.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/extension_predicates_2.h @@ -50,14 +50,24 @@ bool operator()(const __My_Segment_2& s1, const __My_Segment_2& s2, // add check ? // is p in or left from the x_range of both segments s1, s2 ??? - // do we have an intersection ? + // do we have an intersection ? +#if (__LEDA__ <= 420) + int o1 = ::orientation(s1,c); + int o2 = ::orientation(s1,d); +#else int o1 = s1.orientation(c); int o2 = s1.orientation(d); +#endif if (o1 == o2 && o1 != 0) return false; // we have no intersection point ... - + +#if (__LEDA__ <= 420) + int o3 = ::orientation(s2,a); + int o4 = ::orientation(s2,b); +#else int o3 = s2.orientation(a); int o4 = s2.orientation(b); +#endif if (o3 == o4 && o3 != 0) return false; // we have no intersection point ... @@ -220,14 +230,24 @@ bool operator()(const __My_Segment_2& s1, const __My_Segment_2& s2, // add check ? // is p in or left from the x_range of both segments s1, s2 ??? // do we have an intersection ? - + +#if (__LEDA__ <= 420) + int o1 = ::orientation(s1,c); + int o2 = ::orientation(s1,d); +#else int o1 = s1.orientation(c); int o2 = s1.orientation(d); +#endif if (o1 == o2 && o1 != 0) return false; // we have no intersection point ... - + +#if (__LEDA__ <= 420) + int o3 = ::orientation(s2,a); + int o4 = ::orientation(s2,b); +#else int o3 = s2.orientation(a); int o4 = s2.orientation(b); +#endif if (o3 == o4 && o3 != 0) return false; // we have no intersection point ... diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_2.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_2.h index 5c752d9a793..fe4eba3cbb3 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_2.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_2.h @@ -196,7 +196,11 @@ public: #if defined(CGAL_GEOMETRY_EVENTS) CGAL::occur(Predicate_leda_rat_equal_2::ev_leda_rat_triangle, t1, t2); #endif +#if (__LEDA__ <= 420) + return ( ((Triangle_2&) t1) == ((Triangle_2&) t2)); +#else return (t1 == t2); +#endif } bool operator()(const Iso_rectangle_2& r1, const Iso_rectangle_2& r2) const @@ -533,7 +537,11 @@ public: #if defined(CGAL_GEOMETRY_EVENTS) CGAL::occur(Predicate_leda_rat_compare_x_at_y_2::ev_leda_rat_point_line, p, l); #endif +#if (__LEDA__ <= 420) + int ori = - ::orientation(l,p); +#else int ori = - l.side_of(p); +#endif // has point1 larger y - coord than point2 ???? if (__My_Point_2::cmp_y(l.point1(),l.point2()) == 1) ori = -ori; @@ -572,7 +580,11 @@ public: l1.intersection(l2,inter); // compare result ... +#if (__LEDA__ <= 420) + int ori = - ::orientation(h, inter); +#else int ori = - h.side_of(inter); +#endif // has point1 larger y - coord than point2 ???? if (__My_Point_2::cmp_y(h.point1(),h.point2()) == 1) ori = -ori; @@ -861,8 +873,11 @@ public: (Predicate_leda_rat_compare_y_at_x_2::ev_leda_rat_point_line, p, l); #endif // add - here ?? - +#if (__LEDA__ <= 420) + int ori = ::orientation(l,p); +#else int ori = l.side_of(p); +#endif // has point1 larger x - coord than point2 ???? if (__My_Point_2::cmp_x(l.point1(),l.point2()) == 1) ori = -ori; @@ -893,8 +908,11 @@ public: Point_2 p; l1.intersection(l2, p); - +#if (__LEDA__ <= 420) + int ori = ::orientation(l3,p); +#else int ori = l3.side_of(p); +#endif // has point1 larger x - coord than point2 ???? if (__My_Point_2::cmp_x(l3.point1(),l3.point2()) == 1) ori = -ori; @@ -1910,8 +1928,13 @@ public: #if defined(CGAL_GEOMETRY_EVENTS) CGAL::occur \ (Predicate_leda_rat_has_on_positive_side_2::ev_leda_rat_line_point, l, p); -#endif - return (l.side_of(p) == 1); +#endif + +#if (__LEDA__ <= 420) + return (::orientation(l,p) == 1); +#else + return (l.side_of(p) == 1); +#endif } bool operator()(const Triangle_2& t, const Point_2& p) const @@ -1988,7 +2011,11 @@ public: CGAL::occur \ (Predicate_leda_rat_has_on_negative_side_2::ev_leda_rat_line_point, l, p); #endif - return (l.side_of(p) == -1); +#if (__LEDA__ <= 420) + return (::orientation(l,p) == -1); +#else + return (l.side_of(p) == -1); +#endif } bool operator()(const Triangle_2& t, const Point_2& p) const @@ -2068,8 +2095,12 @@ public: #if defined(CGAL_GEOMETRY_EVENTS) CGAL::occur \ (Predicate_leda_rat_oriented_side_2::ev_leda_rat_line_point, l, p); -#endif - return (CGAL::Oriented_side) l.side_of(p); +#endif +#if (__LEDA__ <= 420) + return (CGAL::Oriented_side) ::orientation(l,p); +#else + return (CGAL::Oriented_side) l.side_of(p); +#endif } CGAL::Oriented_side operator()(const Triangle_2& t, const Point_2& p) const @@ -2415,8 +2446,13 @@ public: bool operator()(const Line_2& l, const Ray_2& r) const { +#if (__LEDA__ <= 420) + int o1 = ::orientation(l, r.point1()); + int o2 = ::orientation(l, r.point2()); +#else int o1 = l.side_of(r.point1()); int o2 = l.side_of(r.point2()); +#endif if (o1 != o2 || o1==0 || o2==0) return true; diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_3.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_3.h index f604efed0cf..299179904d5 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_3.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/generalized_predicates_3.h @@ -9,6 +9,22 @@ // 3d generalized predicates ... +#if (__LEDA__ == 420) +// fix a linker problem (undefined reference) +leda_rat_vector::leda_rat_vector(leda_rational a, leda_rational b, leda_rational c) +{ + leda_integer a_num = a.numerator(); + leda_integer b_num = b.numerator(); + leda_integer c_num = c.numerator(); + leda_integer a_den = a.denominator(); + leda_integer b_den = b.denominator(); + leda_integer c_den = c.denominator(); + + PTR = new geo_rep(a_num*b_den*c_den, b_num*a_den*c_den, c_num*a_den*b_den, + a_den*b_den*c_den); +} +#endif + CGAL_BEGIN_NAMESPACE template @@ -109,7 +125,11 @@ public: bool operator()(const Line_3& l1, const Line_3& l2) const { +#if (__LEDA__ <= 420) + if (! ((Line_3&)l1 == (Line_3&)l2)) return false; +#else if (! (l1 == l2)) return false; +#endif // same direction ??? Vector_3 v1 = l1.to_vector(); @@ -167,7 +187,11 @@ public: bool operator()(const Triangle_3& t1, const Triangle_3& t2) const { +#if (__LEDA__ <= 420) + return ((Triangle_3&)t1 == (Triangle_3&)t2); +#else return (t1 == t2); +#endif } bool operator()(const Tetrahedron_3& s1, @@ -724,7 +748,8 @@ class Predicate_leda_d3_rat_is_degenerate { typedef typename K::Triangle_3 Triangle_3; typedef typename K::Tetrahedron_3 Tetrahedron_3; typedef typename K::Segment_3 Segment_3; - typedef typename K::Iso_cuboid_3 Iso_cuboid_3; + typedef typename K::Iso_cuboid_3 Iso_cuboid_3; + typedef typename K::Vector_3 Vector_3; public: typedef Arity_tag< 1 > Arity; diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/intersections_2.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/intersections_2.h index 7eb6aec6954..6b6c8f426d1 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/intersections_2.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/LEDA_RATKERNEL/intersections_2.h @@ -15,6 +15,9 @@ #include #include #include +#include + +//#include "improved_rat_segment_intersection.h" // undefine the LEDA vector and list definition // (this was only present in older LEDA versions) @@ -47,35 +50,139 @@ public: // computations of 2d intersections ... // attention - we need the correct conversion for special segments ... -template +template class CGAL_intersect_leda_rat_2 { public: typedef Arity_tag< 2 > Arity; typedef CGAL::Object result_type; + // kernel types ... + typedef typename K::Line_2 Line_2; + typedef typename K::Ray_2 Ray_2; + typedef typename K::Segment_2 Segment_2; + typedef typename K::Triangle_2 Triangle_2; + typedef typename K::Iso_rectangle_2 Iso_rectangle_2; + + // help kernel functor ... typedef typename HELP_KERNEL::Intersect_2 Intersect_2; +#if defined(LEDA_SEGMENT_INTERSECTION_RESULT_CACHE) + // experimental: we use a map2 to cache intersection results ... + + static leda_map2 intersection_result; +#endif + + CGAL::Object rat_segment_intersection(const leda_rat_segment& s, + const leda_rat_segment& t) const + { + CGAL::Object obj; + + if ( s.is_trivial() ) + { + if ( t.contains( s.source()) ) + { return CGAL::make_object(s.source()); } + else + return obj; + } + if ( t.is_trivial() ) + { + if ( s.contains(t.source()) ) + { return CGAL::make_object(t.source()); } + else + return obj; + } + + int o1 = s.orientation(t.start()); + int o2 = s.orientation(t.end()); + + //int o1 = LEDA_NAMESPACE_NAME::orientation(s.start(), s.end(), t.start()); + //int o2 = LEDA_NAMESPACE_NAME::orientation(s.start(), s.end(), t.end()); + + // two orientation tests were moved ... + + // special case : collinearity ... + if ( o1 == 0 && o2 == 0 ) + { leda_rat_point sa = s.source(); + leda_rat_point sb = s.target(); + if ( LEDA_NAMESPACE_NAME::compare(sa,sb) > 0 ) + { leda_rat_point h = sa; sa = sb; sb = h; } + + leda_rat_point ta = t.source(); + leda_rat_point tb = t.target(); + + if ( LEDA_NAMESPACE_NAME::compare (ta,tb) > 0 ) + { leda_rat_point h = ta; ta = tb; tb = h; } + + leda_rat_point a = sa; + if (LEDA_NAMESPACE_NAME::compare(sa,ta) < 0) a = ta; + + leda_rat_point b = tb; + if (LEDA_NAMESPACE_NAME::compare(sb,tb) < 0) b = sb; + + if ( LEDA_NAMESPACE_NAME::compare(a,b) <= 0 ) + { leda_rat_segment I = leda_rat_segment(a,b); + if (a == b) return CGAL::make_object(a); + else return CGAL::make_object(I); + } + return obj; + } + + if ( o1 != o2){ // was && ... + // moved ... + int o3 = t.orientation(s.start()); + int o4 = t.orientation(s.end()); + //int o3 = LEDA_NAMESPACE_NAME::orientation(t.start(),t.end(),s.start()); + //int o4 = LEDA_NAMESPACE_NAME::orientation(t.start(),t.end(),s.end()); + + if ( o3 != o4 ) + { leda_integer w = s.dy()*t.dx() - t.dy()*s.dx(); + leda_integer c1 = s.X2()*s.Y1() - s.X1()*s.Y2(); + leda_integer c2 = t.X2()*t.Y1() - t.X1()*t.Y2(); + + leda_rat_point p(c2*s.dx()-c1*t.dx(), c2*s.dy()-c1*t.dy(), w); + return CGAL::make_object(p); + } + } + return obj; + } + + // for segments (uses LEDA directly) ... CGAL::Object operator()(const leda_rat_segment& s1, const leda_rat_segment& s2) const { +/* CGAL::Object obj; - leda_rat_segment result; - bool bi = s1.intersection(s2, result); + leda_rat_segment result; + bool bi = s1.intersection(s2, result); if (bi) { - //result.normalize(); - if (result.start() == result.end()) { obj = CGAL::make_object(result.start()); // only a point ... } else obj = CGAL::make_object(result); // segment ... - } + } return obj; +*/ + +#if defined(LEDA_SEGMENT_INTERSECTION_RESULT_CACHE) + // look up the result in the cache ... + if (intersection_result.defined(s1,s2)){ // (s2,s1) ? + return intersection_result(s1,s2); + } + else { + CGAL::Object obj = this->rat_segment_intersection(s1,s2); + intersection_result(s1,s2) = obj; + intersection_result(s2,s1) = obj; + return obj; + } +#else + return this->rat_segment_intersection(s1,s2); +#endif } // this one uses the CGAL kernel ... template - CGAL::Object operator()(const T1& obj1, const T2& obj2) const + CGAL::Object compute_intersection_result(const T1& obj1, const T2& obj2) const { leda_to_cgal_2 conv; Intersect_2 inter; @@ -91,10 +198,87 @@ public: cgal_to_leda_2 conv_back; return conv_back(result); - } + } + + // these functors call the member template ... + // we cannot use a member template directly (because of VC 6) + CGAL::Object operator()(const Line_2& obj1, const Line_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Line_2& obj1, const Ray_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Line_2& obj1, const Segment_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Line_2& obj1, const Triangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Line_2& obj1, const Iso_rectangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Ray_2& obj1, const Line_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Ray_2& obj1, const Ray_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Ray_2& obj1, const Segment_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Ray_2& obj1, const Triangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Ray_2& obj1, const Iso_rectangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Segment_2& obj1, const Line_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Segment_2& obj1, const Ray_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Segment_2& obj1, const Triangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Segment_2& obj1, const Iso_rectangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Triangle_2& obj1, const Line_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Triangle_2& obj1, const Ray_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Triangle_2& obj1, const Segment_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Triangle_2& obj1, const Triangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Triangle_2& obj1, const Iso_rectangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Iso_rectangle_2& obj1, const Line_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Iso_rectangle_2& obj1, const Ray_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Iso_rectangle_2& obj1, const Segment_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Iso_rectangle_2& obj1, const Triangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } + + CGAL::Object operator()(const Iso_rectangle_2& obj1, const Iso_rectangle_2& obj2) const + { return compute_intersection_result(obj1,obj2); } }; - +#if defined(LEDA_SEGMENT_INTERSECTION_RESULT_CACHE) +template +leda_map2 CGAL_intersect_leda_rat_2::intersection_result; +#endif /* class Intersect_leda_rat_2 { diff --git a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/leda_rat_kernel_traits.h b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/leda_rat_kernel_traits.h index a99f89d4ecc..b8b4cb4356a 100644 --- a/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/leda_rat_kernel_traits.h +++ b/Extension_Packages/Leda_rat_kernel/include/CEP/Leda_rat_kernel/leda_rat_kernel_traits.h @@ -112,6 +112,11 @@ int log(const leda_integer& i) CGAL_BEGIN_NAMESPACE +// kernel tag for the rational LEDA kernel traits + +struct Leda_rational_kernel_tag { }; + + class leda_rat_R { public: typedef leda_rational FT; @@ -129,6 +134,9 @@ public: typedef leda_rat_kernel_traits Self; typedef leda_rat_R R; + + //tag type ... + typedef Leda_rational_kernel_tag Kernel_tag; // types ... typedef leda_rational FT; @@ -234,8 +242,8 @@ public: typedef Construct_leda_rat_opposite_vector_2 Construct_opposite_vector_2; // 2d intersections and related things - typedef Assign_leda_rat_2 Assign_2; - typedef CGAL_intersect_leda_rat_2 Intersect_2; + typedef Assign_leda_rat_2 Assign_2; + typedef CGAL_intersect_leda_rat_2 Intersect_2; // 2d computations typedef CGAL_compute_leda_rat_squared_distance_2 Compute_squared_distance_2; diff --git a/Extension_Packages/Leda_rat_kernel/test/leda_traits/extensions_2.C b/Extension_Packages/Leda_rat_kernel/test/leda_traits/extensions_2.C index 44adb30dee0..04c36538e21 100644 --- a/Extension_Packages/Leda_rat_kernel/test/leda_traits/extensions_2.C +++ b/Extension_Packages/Leda_rat_kernel/test/leda_traits/extensions_2.C @@ -49,7 +49,7 @@ bool cgal_do_intersect_to_left(const leda_rat_segment& c1, const leda_rat_segmen return ( (leda_rat_point::cmp_xy(seg.start(), pt) == -1) || (leda_rat_point::cmp_xy(seg.end(), pt) == -1) ); } -void my_random_point_in_square(rat_point& p, int maxc) +void my_random_point_in_square(leda_rat_point& p, int maxc) { random_point_in_square(p, maxc); @@ -72,7 +72,7 @@ int main() Do_intersect_to_left_2 do_intersect_to_left; for(i=0; i