1 // Copyright (c) 2004-2008, 2010 Max-Planck-Institute Saarbruecken (Germany), 2 // and Tel-Aviv University (Israel). All rights reserved. 3 // 4 // This file is part of CGAL (www.cgal.org) 5 // 6 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h $ 7 // $Id: simple_models.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot 8 // SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial 9 // 10 // 11 // Author(s) : Pavel Emeliyanenko <asm@mpi-sb.mpg.de> 12 13 #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_TEST_SIMPLE_MODELS_H 14 #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_TEST_SIMPLE_MODELS_H 15 16 /*!\file include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h 17 * \brief defines dummy implementations satisfying Curve_kernel_2 18 * concept requirenments 19 */ 20 21 #include <CGAL/config.h> 22 23 #include <CGAL/Arithmetic_kernel.h> 24 25 #include <CGAL/Polynomial.h> 26 27 #include <CGAL/Algebraic_kernel_d_1.h> 28 29 #include <CGAL/Arr_enums.h> 30 31 namespace CGAL { 32 33 ////////////////////////////////////////////////////////////////////////////// 34 35 namespace internal { 36 37 struct Curve_2_model_rep { 38 int i_; 39 40 typedef CGAL::Polynomial< CGAL::Polynomial < int > > Poly_d; 41 Poly_d f_; 42 43 // DefaultConstructible Curve_2_model_repCurve_2_model_rep44 Curve_2_model_rep() : 45 i_(0) { 46 } 47 Curve_2_model_repCurve_2_model_rep48 Curve_2_model_rep(int i) : 49 i_(i) { 50 } 51 }; 52 53 struct Curve_2_model : 54 public ::CGAL::Handle_with_policy< Curve_2_model_rep > { 55 56 typedef Curve_2_model_rep Rep; 57 typedef ::CGAL::Handle_with_policy< Rep > Base; 58 59 typedef CGAL::Algebraic_kernel_d_1< CGAL::Arithmetic_kernel::Integer > AK_1; 60 61 typedef AK_1::Algebraic_real_1 Algebraic_real_1; 62 63 typedef double Bound; 64 65 typedef int Coefficient; 66 67 typedef CGAL::Polynomial< CGAL::Polynomial < int > > Poly_d; 68 69 typedef CGAL::Handle_id_less_than< Curve_2_model > Less_than; 70 71 // for total_degree (find smaller curve if two are available) fCurve_2_model72 Poly_d f() const { 73 return ptr()->f_; 74 } 75 num_eventsCurve_2_model76 int num_events() const { 77 return 0; 78 } 79 x_to_indexCurve_2_model80 void x_to_index(Algebraic_real_1 x, int& idx, bool& event) const { 81 return; 82 } 83 boundary_value_in_intervalCurve_2_model84 Bound boundary_value_in_interval(int i) { 85 return Bound(0); 86 } 87 y_atCurve_2_model88 Algebraic_real_1 y_at(Bound r, int arcno){ 89 return Algebraic_real_1(); 90 } 91 arcs_over_intervalCurve_2_model92 int arcs_over_interval(int id) const { 93 // this values are needed for the Event1_info.C test 94 if ((id % 2) == 0) { 95 return 10; 96 } else { 97 return 11; 98 } 99 } 100 101 template < class OutputIterator > decomposeCurve_2_model102 static bool decompose(Curve_2_model f, Curve_2_model g, 103 OutputIterator parts_of_f, 104 OutputIterator parts_of_g) { 105 return true; 106 } 107 108 bool operator== (const Curve_2_model& c) { 109 return id() == c.id(); 110 } 111 }; 112 113 std::ostream& operator<< (std::ostream& os, Curve_2_model c) { 114 return os; 115 } 116 117 std::istream& operator>> (std::istream& is, Curve_2_model& c) { 118 return is; 119 } 120 121 ///////////////////////////////////////////////////////////////////////////////// Curve_pair_2 122 123 template < class Curve_ > 124 struct Curve_pair_2_model; 125 126 template < class Curve_ > 127 struct Curve_pair_2_model_rep { 128 129 typedef Curve_ Curve; 130 131 typedef Curve Algebraic_curve_2; 132 133 //typedef SoX::Event2_slice< Curve_pair_2< Curve > > Event2_slice; 134 135 Curve c1_; 136 Curve c2_; 137 138 // DefaultConstructible Curve_pair_2_model_repCurve_pair_2_model_rep139 Curve_pair_2_model_rep() : 140 c1_(), c2_() { 141 } 142 Curve_pair_2_model_repCurve_pair_2_model_rep143 Curve_pair_2_model_rep(Curve c1, Curve c2) : 144 c1_(c1), c2_(c2) { 145 } 146 147 std::vector< int > slices_; 148 }; 149 150 template < class Curve_ > 151 struct Curve_pair_2_model : 152 public ::CGAL::Handle_with_policy< Curve_pair_2_model_rep< Curve_ > > { 153 154 typedef Curve_ Curve; 155 156 typedef Curve Algebraic_curve_2; 157 158 typedef Curve_pair_2_model_rep< Curve > Rep; 159 typedef ::CGAL::Handle_with_policy< Rep > Base; 160 161 //typedef SoX::Event2_slice< Curve_pair_2< Curve > > Event2_slice; 162 163 // DefaultConstructible Curve_pair_2_modelCurve_pair_2_model164 Curve_pair_2_model() : 165 Base(Rep()) { 166 }; 167 168 // Assignable 169 170 // Constructable from two curves Curve_pair_2_modelCurve_pair_2_model171 Curve_pair_2_model(Curve c1, Curve c2) : 172 Base(Rep(c1, c2)) { 173 } 174 curve1Curve_pair_2_model175 Curve curve1() const { 176 return this->ptr()->c1_; 177 } 178 curve2Curve_pair_2_model179 Curve curve2() const { 180 return this->ptr()->c2_; 181 } 182 num_eventsCurve_pair_2_model183 int num_events() const { 184 return 0; 185 } 186 event_xCurve_pair_2_model187 int event_x(int i) const { 188 return -1; 189 } 190 x_to_indexCurve_pair_2_model191 void x_to_index(typename Algebraic_curve_2::Algebraic_real_1 x, 192 int& idx, bool& event) const { 193 return; 194 } 195 }; 196 197 ///////////////////////////////////////////////////////////////////////////// 198 199 template < class AlgebraicCurveKernel_2> 200 class Xy_coordinate_2; 201 202 template < class AlgebraicCurveKernel_2 > 203 class Xy_coordinate_2_rep { 204 205 public: 206 // this first template argument 207 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 208 209 // myself 210 typedef Xy_coordinate_2_rep<Algebraic_curve_kernel_2> Self; 211 212 typedef typename Algebraic_curve_kernel_2::Curve_analysis_2 213 Curve_analysis_2; 214 215 typedef typename Curve_analysis_2::Algebraic_real_1 Algebraic_real_1; 216 217 // constructors 218 public: 219 // default constructor () Xy_coordinate_2_rep()220 Xy_coordinate_2_rep() 221 { } 222 223 // data 224 // x-coordinate 225 Algebraic_real_1 _m_x; 226 227 // supporting curve 228 mutable Curve_analysis_2 _m_curve; 229 230 // arc number on curve 231 mutable int _m_arcno; 232 233 // befriending the handle 234 friend class Xy_coordinate_2<Algebraic_curve_kernel_2>; 235 }; 236 237 template <class AlgebraicCurveKernel_2> 238 class Xy_coordinate_2 : 239 public 240 ::CGAL::Handle_with_policy<Xy_coordinate_2_rep<AlgebraicCurveKernel_2> > 241 { 242 public: 243 //! \name public typedefs 244 //!@{ 245 246 //! this instance's first template parameter 247 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 248 249 //! this instance's second template parameter 250 typedef Xy_coordinate_2_rep<AlgebraicCurveKernel_2> Rep; 251 252 //! this instance itself 253 typedef Xy_coordinate_2<Algebraic_curve_kernel_2> Self; 254 255 //! type of an algabraic curve 256 typedef typename Algebraic_curve_kernel_2::Curve_analysis_2 257 Curve_analysis_2; 258 259 //! type of Algebraic_real_1 260 typedef typename Curve_analysis_2::Algebraic_real_1 Algebraic_real_1; 261 262 //! the handle superclass 263 typedef ::CGAL::Handle_with_policy<Rep> Base; 264 265 //! type for approximation boundaries 266 typedef typename Algebraic_curve_kernel_2::Bound Bound; 267 268 //! type for boundary intervals 269 typedef std::pair<Bound, Bound> Bound_interval; 270 271 //!@} 272 public: 273 //!\name Constructors 274 //!@{ 275 Xy_coordinate_2()276 Xy_coordinate_2() : 277 Base(Rep()) { 278 } 279 Xy_coordinate_2(const Self & p)280 Xy_coordinate_2(const Self& p) : 281 Base(static_cast<const Base&>(p)) { 282 } 283 Xy_coordinate_2(const Algebraic_real_1 &,const Curve_analysis_2 &,int)284 Xy_coordinate_2(const Algebraic_real_1&, const Curve_analysis_2&, int) : 285 Base(Rep()) { 286 } 287 Xy_coordinate_2(Rep rep)288 Xy_coordinate_2(Rep rep) : 289 Base(rep) { 290 } 291 292 public: 293 x()294 const Algebraic_real_1& x() const { 295 return this->ptr()->_m_x; 296 } 297 y()298 Algebraic_real_1 y() const { 299 return this->ptr()->_m_x; 300 } 301 curve()302 Curve_analysis_2 curve() const { 303 return this->ptr()->_m_curve; 304 } 305 arcno()306 int arcno() const { 307 return -1; 308 } 309 310 //!@} 311 public: 312 //!\name comparison predicates 313 //!@{ 314 compare_x(const Self & q)315 CGAL::Comparison_result compare_x(const Self& q) const { 316 return CGAL::ZERO; 317 } 318 319 CGAL::Comparison_result compare_xy(const Self& q, 320 bool equal_x = false) const { 321 return CGAL::ZERO; 322 } 323 324 //! equality 325 bool operator == (const Self& q) const {return false;} 326 327 //! inequality 328 bool operator != (const Self& q) const {return false;} 329 330 //! less than in (x,y) lexicographic order 331 bool operator < (const Self& q) const {return false;} 332 333 //! less-equal in (x,y) lexicographic order 334 bool operator <= (const Self& q) const {return false;} 335 336 //! greater than in (x,y) lexicographic order 337 bool operator > (const Self& q) const {return false;} 338 339 //! greater-equal in (x,y) lexicographic order 340 bool operator >= (const Self& q) const {return false;} 341 342 public: 343 is_x_zero()344 bool is_x_zero() const { 345 return false; 346 } 347 is_y_zero()348 bool is_y_zero() const { 349 return false; 350 } 351 to_double()352 std::pair<double, double> to_double() const { 353 return std::make_pair(0.0, 0.0); 354 } 355 get_approximation_x()356 Bound_interval get_approximation_x() const { 357 return Bound_interval(0.0, 0.0); 358 } 359 get_approximation_y()360 Bound_interval get_approximation_y() const { 361 return Bound_interval(0.0, 0.0); 362 } 363 refine_x()364 void refine_x() const { 365 } 366 refine_x(int rel_prec)367 void refine_x(int rel_prec) { 368 } 369 refine_y()370 void refine_y() const { 371 } 372 373 //!@} 374 375 }; // class Xy_coordinate_2 376 377 template < class AlgebraicCurveKernel_2> 378 std::ostream& operator<< (std::ostream& os, 379 const Xy_coordinate_2<AlgebraicCurveKernel_2>& pt) { 380 return os; 381 } 382 383 /////////////////////////////////////////////////////////////////////////////// 384 385 template < class CurveAnalysis_2> 386 class Status_line_CA_1; 387 388 template < class CurveAnalysis_2 > 389 class Status_line_CA_1_rep { 390 391 // this template argument 392 typedef CurveAnalysis_2 Curve_analysis_2; 393 394 // myself 395 typedef Status_line_CA_1_rep<Curve_analysis_2> Self; 396 397 // type of x-coordinate 398 typedef typename Curve_analysis_2::Algebraic_real_1 399 Algebraic_real_1; 400 401 // an instance of a size type 402 typedef typename Curve_analysis_2::size_type size_type; 403 404 // constructors 405 public: 406 // default constructor () Status_line_CA_1_rep()407 Status_line_CA_1_rep() 408 { } 409 410 //! x-coordinate of event info 411 mutable Algebraic_real_1 _m_x; 412 413 //! this status line id (# of event or # of interval depending on whether 414 //! or not this status line encodes an event) 415 size_type _m_index; 416 417 //! underlying curve analysis 418 Curve_analysis_2 _m_ca; 419 420 // befriending the handle 421 friend class Status_line_CA_1<Curve_analysis_2>; 422 }; 423 424 template <class CurveAnalysis_2> 425 class Status_line_CA_1 426 : public ::CGAL::Handle_with_policy< 427 Status_line_CA_1_rep<CurveAnalysis_2> > { 428 public: 429 //!@{ 430 //!\name typedefs 431 432 //! this instance's first template parameter 433 //! model of AlgebraicKernel_d_2::CurveAnalysis_2 434 typedef CurveAnalysis_2 Curve_analysis_2; 435 436 //! this instance's second template parameter 437 typedef Status_line_CA_1_rep<CurveAnalysis_2> Rep; 438 439 //! this instance itself 440 typedef Status_line_CA_1<Curve_analysis_2> Self; 441 442 //! type of x-coordinate 443 typedef typename Curve_analysis_2::Algebraic_real_1 Algebraic_real_1; 444 445 typedef typename Curve_analysis_2::Xy_coordinate_2 Xy_coordinate_2; 446 447 typedef typename Curve_analysis_2::size_type size_type; 448 449 //! encodes number of arcs to the left and to the right 450 typedef std::pair<size_type, size_type> Arc_pair; 451 452 //! the handle superclass 453 typedef ::CGAL::Handle_with_policy< Rep > Base; 454 455 //!@} 456 public: 457 //!\name constructors 458 //!@{ 459 460 /*!\brief 461 * Default constructor 462 */ Status_line_CA_1()463 Status_line_CA_1() : 464 Base(Rep()) { 465 } 466 467 /*!\brief 468 * copy constructor 469 */ Status_line_CA_1(const Self & p)470 Status_line_CA_1(const Self& p) : 471 Base(static_cast<const Base&>(p)) { 472 } 473 474 /*!\brief 475 * constructs from a given represenation 476 */ Status_line_CA_1(Rep rep)477 Status_line_CA_1(Rep rep) : 478 Base(rep) { 479 } 480 481 //!@} 482 x()483 Algebraic_real_1 x() const { 484 return Algebraic_real_1(); 485 } 486 curve_analysis_2()487 Curve_analysis_2 curve_analysis_2() const { 488 return Curve_analysis_2(); 489 } 490 index()491 size_type index() const { 492 return static_cast<size_type>(0); 493 } 494 covers_line()495 bool covers_line() const { 496 return false; 497 } 498 has_f_fy_intersection()499 bool has_f_fy_intersection() const { 500 return false; 501 } 502 is_event()503 bool is_event() const { 504 return false; 505 } 506 number_of_events()507 size_type number_of_events() const { 508 return static_cast<size_type>(0); 509 } 510 algebraic_real_2(size_type j)511 Xy_coordinate_2 algebraic_real_2(size_type j) const { 512 return Xy_coordinate_2(); 513 } 514 xy_coordinate_2(size_type j)515 Xy_coordinate_2 xy_coordinate_2(size_type j) const { 516 return algebraic_real_2(j); 517 } 518 number_of_incident_branches(int j)519 Arc_pair number_of_incident_branches(int j) const { 520 return Arc_pair(0, 0); 521 } 522 number_of_branches_approaching_minus_infinity()523 Arc_pair number_of_branches_approaching_minus_infinity() const { 524 return Arc_pair(0, 0); 525 } 526 number_of_branches_approaching_plus_infinity()527 Arc_pair number_of_branches_approaching_plus_infinity() const { 528 return Arc_pair(0, 0); 529 } 530 531 }; // class Status_line_CA_1 532 533 template <class CurveAnalysis_2> 534 std::ostream& operator<< (std::ostream& os, const 535 Status_line_CA_1<CurveAnalysis_2>& cp_line) { 536 return os; 537 } 538 539 /////////////////////////////////////////////////////////////////////////////// 540 541 template < class AlgebraicCurveKernel_2> 542 class Curve_analysis_2; 543 544 template < class AlgebraicCurveKernel_2 > 545 class Curve_analysis_2_rep { 546 547 public: 548 // this first template argument 549 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 550 551 // myself 552 typedef Curve_analysis_2_rep<Algebraic_curve_kernel_2> Self; 553 554 typedef typename Algebraic_curve_kernel_2::Polynomial_2 555 Polynomial_2; 556 557 // constructors 558 public: 559 // default constructor () Curve_analysis_2_rep()560 Curve_analysis_2_rep() 561 { } 562 563 // standard constructor Curve_analysis_2_rep(const Polynomial_2 & curve)564 Curve_analysis_2_rep(const Polynomial_2& curve) { 565 } 566 567 mutable Polynomial_2 _m_curve; 568 569 // befriending the handle 570 friend class Curve_analysis_2<Algebraic_curve_kernel_2>; 571 }; 572 573 template <class AlgebraicCurveKernel_2> 574 class Curve_analysis_2 : 575 public ::CGAL::Handle_with_policy< 576 Curve_analysis_2_rep<AlgebraicCurveKernel_2> > { 577 public: 578 //!@{ 579 //! \name typedefs 580 581 //! this instance's first template parameter 582 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 583 584 //! this instance's second template parameter 585 typedef Curve_analysis_2_rep<AlgebraicCurveKernel_2> Rep; 586 587 //! x-coordinate type 588 typedef typename Algebraic_curve_kernel_2::Algebraic_real_1 Algebraic_real_1; 589 590 //! x-coordinate type 591 typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2; 592 593 //! type of a curve 594 typedef typename Algebraic_curve_kernel_2::Polynomial_2 Polynomial_2; 595 596 //! myself 597 typedef Curve_analysis_2<Algebraic_curve_kernel_2> Self; 598 599 //! an instance of a size type 600 typedef int size_type; 601 602 //! type of a vertical line 603 typedef internal::Status_line_CA_1<Self> Status_line_1; 604 605 //! the handle superclass 606 typedef ::CGAL::Handle_with_policy<Rep> Base; 607 608 //!@} 609 public: 610 //!\name Constructors 611 //!@{ 612 613 //! \brief default constructor Curve_analysis_2()614 Curve_analysis_2() : 615 Base(Rep()) { 616 } 617 618 /*!\brief 619 * copy constructor 620 */ Curve_analysis_2(const Self & p)621 Curve_analysis_2(const Self& p) : 622 Base(static_cast<const Base&>(p)) { 623 } 624 625 //! \brief constructs a curve analysis from a given \c Curve_2 object 626 //! 627 //! for safety purposes implicit conversion from \c Curve_2 is disabled Curve_analysis_2(const Polynomial_2 & c)628 explicit Curve_analysis_2(const Polynomial_2& c) : 629 Base(Rep(c)) { 630 } 631 632 /*!\brief 633 * constructsa curve analysis from a given represenation 634 */ Curve_analysis_2(Rep rep)635 Curve_analysis_2(Rep rep) : 636 Base(rep) { 637 } 638 639 //!@} 640 public: 641 //!\name Access functions 642 //!@{ 643 644 //! \brief returns the defining polynomial of the analysis polynomial_2()645 Polynomial_2 polynomial_2() const { 646 return this->ptr()->_m_curve; 647 } 648 649 //! \brief alias for \c polynomial_2() curve_2()650 Polynomial_2 curve_2() const 651 { 652 return polynomial_2(); 653 } 654 655 //! \brief returns number of vertical lines that encode an event number_of_status_lines_with_event()656 size_type number_of_status_lines_with_event() const { 657 return 0; 658 } 659 status_line_at_event(size_type i)660 Status_line_1 status_line_at_event(size_type i) const { 661 return Status_line_1(); 662 } 663 status_line_of_interval(size_type i)664 Status_line_1 status_line_of_interval(size_type i) const { 665 return Status_line_1(); 666 } 667 668 Status_line_1 status_line_for_x(Algebraic_real_1 x, 669 CGAL::Sign perturb = CGAL::ZERO) const { 670 return Status_line_1(); 671 } 672 status_line_at_exact_x(Algebraic_real_1 x)673 Status_line_1 status_line_at_exact_x(Algebraic_real_1 x) const { 674 return Status_line_1(); 675 } 676 677 /*!\brief 678 * returns a \c CGAL::Object that encodes the asymptotic value of a 679 * curve-arc approaching the left or the right boundary \c loc of the 680 * underlying parameter space. 681 * 682 * Allowed instantiations of the \c CGAL::Object are \c Algebraic_real_1 , 683 * in case the x-asympote of the arc is finite, or 684 * \c CGAL::ARR_BOTTOM_BOUNDARY and \c CGAL::ARR_TOP_BOUNDARY in case 685 * the defined arc approaches the respective corners of the parameter 686 * space. 687 * 688 * \pre \c loc is either \c CGAL::ARR_LEFT_BOUNDARY or 689 * \c CGAL::ARR_RIGHT_BOUNDARY 690 */ asymptotic_value_of_arc(CGAL::Arr_parameter_space loc,size_type arcno)691 CGAL::Object asymptotic_value_of_arc(CGAL::Arr_parameter_space loc, 692 size_type arcno) const { 693 694 return CGAL::Object(); 695 } 696 697 698 //!@} 699 }; // class Curve_analysis_2 700 701 ////////////////////////////////////////////////////////////////////////////// 702 703 template < class CurvePairAnalysis_2, class Rep_ > 704 class Status_line_CPA_1; 705 706 template <class CurvePairAnalysis_2, class Rep> 707 std::ostream& operator<< (std::ostream&, 708 const Status_line_CPA_1<CurvePairAnalysis_2, Rep>&); 709 710 template < class CurvePairAnalysis_2 > 711 class Status_line_CPA_1_rep { 712 713 // this template argument 714 typedef CurvePairAnalysis_2 Curve_pair_analysis_2; 715 716 // myself 717 typedef Status_line_CPA_1_rep<Curve_pair_analysis_2> Self; 718 719 // an instance of a size type 720 typedef typename Curve_pair_analysis_2::size_type size_type; 721 722 // constructors 723 public: 724 // default constructor () Status_line_CPA_1_rep()725 Status_line_CPA_1_rep() 726 { } 727 728 // stores this status line interval or event index of a curve pair 729 size_type _m_index; 730 731 // befriending the handle 732 friend class Status_line_CPA_1<Curve_pair_analysis_2, Self>; 733 }; 734 735 template <class CurvePairAnalysis_2, 736 class Rep_ = internal::Status_line_CPA_1_rep<CurvePairAnalysis_2> > 737 class Status_line_CPA_1 : 738 public ::CGAL::Handle_with_policy< Rep_ > 739 { 740 public: 741 //!@{ 742 //!\name typedefs 743 744 //! this instance's first template parameter 745 typedef CurvePairAnalysis_2 Curve_pair_analysis_2; 746 747 //! this instance's second template parameter 748 typedef Rep_ Rep; 749 750 //! this instance itself 751 typedef Status_line_CPA_1<Curve_pair_analysis_2, Rep> Self; 752 753 //! type of x-coordinate 754 typedef typename Curve_pair_analysis_2::Algebraic_real_1 Algebraic_real_1; 755 756 //! an instance of a size type 757 typedef typename Curve_pair_analysis_2::size_type size_type; 758 759 //! encodes number of arcs to the left and to the right 760 typedef std::pair<size_type, size_type> Arc_pair; 761 762 //! the handle superclass 763 typedef ::CGAL::Handle_with_policy< Rep > Base; 764 765 //!@} 766 public: 767 //!\name constructors 768 //!@{ 769 Status_line_CPA_1()770 Status_line_CPA_1() : 771 Base(Rep()) { 772 } 773 Status_line_CPA_1(const Self & p)774 Status_line_CPA_1(const Self& p) : 775 Base(static_cast<const Base&>(p)) { 776 } 777 778 /*!\brief 779 * constructs from a given represenation 780 */ Status_line_CPA_1(Rep rep)781 Status_line_CPA_1(Rep rep) : 782 Base(rep) { 783 } 784 x()785 Algebraic_real_1 x() const { 786 return Algebraic_real_1(); 787 } 788 789 //! returns this vertical line's index (event or interval index) index()790 size_type index() const { 791 return this->ptr()->_m_index; 792 } 793 number_of_events()794 size_type number_of_events() const { 795 return static_cast<size_type>(0); 796 } 797 event_of_curve(size_type k,bool c)798 size_type event_of_curve(size_type k, bool c) const { 799 return static_cast<size_type>(0); 800 } 801 multiplicity_of_intersection(size_type j)802 size_type multiplicity_of_intersection(size_type j) const { 803 return static_cast<size_type>(0); 804 } 805 curves_at_event(size_type j)806 Arc_pair curves_at_event(size_type j) const { 807 return Arc_pair(0, 0); 808 } 809 is_event()810 bool is_event() const { 811 return false; 812 } 813 is_intersection()814 bool is_intersection() const { 815 return false; 816 } 817 818 //!@} 819 }; // class Status_line_CPA_1 820 821 template <class CurvePairAnalysis_2, class Rep> 822 std::ostream& operator<< (std::ostream& os, 823 const internal::Status_line_CPA_1<CurvePairAnalysis_2, Rep>& cpv_line) { 824 825 return os; 826 } 827 828 /////////////////////////////////////////////////////////////////////////////// 829 830 template < class AlgebraicCurveKernel_2, class Rep_ > 831 class Curve_pair_analysis_2; 832 833 template < class AlgebraicCurveKernel_2 > 834 class Curve_pair_analysis_2_rep { 835 836 public: 837 // this first template argument 838 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 839 840 // myself 841 typedef Curve_pair_analysis_2_rep<Algebraic_curve_kernel_2> Self; 842 843 // type of 1-curve analysis 844 typedef typename Algebraic_curve_kernel_2::Curve_analysis_2 845 Curve_analysis_2; 846 847 // constructors 848 public: 849 // default constructor () Curve_pair_analysis_2_rep()850 Curve_pair_analysis_2_rep() 851 { } 852 853 // data 854 Curve_analysis_2 _m_ca1, _m_ca2; 855 856 // befriending the handle 857 friend class Curve_pair_analysis_2<Algebraic_curve_kernel_2, Self>; 858 }; 859 860 template <class AlgebraicCurveKernel_2, 861 class Rep_ = internal::Curve_pair_analysis_2_rep<AlgebraicCurveKernel_2> > 862 class Curve_pair_analysis_2 : public ::CGAL::Handle_with_policy< Rep_ > 863 { 864 public: 865 //!@{ 866 //! \name typedefs 867 868 //! this instance's first template parameter 869 typedef AlgebraicCurveKernel_2 Algebraic_curve_kernel_2; 870 871 //! this instance's second template parameter 872 typedef Rep_ Rep; 873 874 //! x-coordinate type 875 typedef typename Algebraic_curve_kernel_2::Algebraic_real_1 Algebraic_real_1; 876 877 //! type of a curve point 878 typedef typename Algebraic_curve_kernel_2::Xy_coordinate_2 Xy_coordinate_2; 879 880 //! type of 1-curve analysis 881 typedef typename Algebraic_curve_kernel_2::Curve_analysis_2 882 Curve_analysis_2; 883 884 //! an instance of a size type 885 typedef typename Curve_analysis_2::size_type size_type; 886 887 //! myself 888 typedef Curve_pair_analysis_2<Algebraic_curve_kernel_2, Rep> Self; 889 890 //! type of a vertical line 891 typedef internal::Status_line_CPA_1<Self> Status_line_1; 892 893 //! the handle superclass 894 typedef ::CGAL::Handle_with_policy<Rep> Base; 895 896 //!@} 897 public: 898 //!\name Constructors 899 //!@{ 900 901 //! \brief default constructor Curve_pair_analysis_2()902 Curve_pair_analysis_2() : 903 Base(Rep()) { 904 } 905 906 /*!\brief 907 * copy constructor 908 */ Curve_pair_analysis_2(const Self & p)909 Curve_pair_analysis_2(const Self& p) : 910 Base(static_cast<const Base&>(p)) { 911 } 912 Curve_pair_analysis_2(const Curve_analysis_2 & ca1,const Curve_analysis_2 & ca2)913 Curve_pair_analysis_2(const Curve_analysis_2& ca1, 914 const Curve_analysis_2& ca2) : 915 Base(Rep()) { 916 } 917 Curve_pair_analysis_2(Rep rep)918 Curve_pair_analysis_2(Rep rep) : 919 Base(rep) { 920 } 921 curve_analysis(bool c)922 Curve_analysis_2 curve_analysis(bool c) const { 923 return this->ptr()->_m_ca1; 924 } 925 number_of_status_lines_with_event()926 size_type number_of_status_lines_with_event() const { 927 return static_cast<size_type>(0); 928 } 929 event_of_curve_analysis(size_type i,bool c)930 size_type event_of_curve_analysis(size_type i, bool c) const { 931 return static_cast<size_type>(0); 932 } 933 status_line_at_event(size_type i)934 Status_line_1 status_line_at_event(size_type i) const { 935 return Status_line_1(); 936 } 937 status_line_of_interval(size_type i)938 Status_line_1 status_line_of_interval(size_type i) const { 939 return Status_line_1(); 940 } 941 942 Status_line_1 status_line_for_x(Algebraic_real_1 x, 943 CGAL::Sign perturb = CGAL::ZERO) const { 944 return Status_line_1(); 945 } 946 status_line_at_exact_x(Algebraic_real_1 x)947 Status_line_1& status_line_at_exact_x(Algebraic_real_1 x) const { 948 return Status_line_1(); 949 } 950 951 //!@} 952 }; // class Curve_pair_analysis_2 953 954 } // namespace internal 955 956 ////////////////////////////////////////////////////////////////////////////// 957 958 class Simple_algebraic_kernel_2 { 959 960 // for each predicate functor defines a member function returning an instance 961 // of this predicate 962 #define CGAL_Algebraic_Kernel_pred(Y,Z) \ 963 Y Z() const { return Y(); } 964 965 // the same for construction functors 966 #define CGAL_Algebraic_Kernel_cons(Y,Z) CGAL_Algebraic_Kernel_pred(Y,Z) 967 968 private: 969 public: 970 //! \name wrapping types 971 //!@{ 972 973 //! type of an internal curve 974 typedef internal::Curve_2_model Internal_curve_2; 975 976 //! type of an internal curve pair 977 typedef internal::Curve_pair_2_model< Internal_curve_2 > 978 Internal_curve_pair_2; 979 980 //! type of internal x_coordinate 981 typedef Internal_curve_2::Algebraic_real_1 Internal_x_coordinate; 982 983 //! type of internal coefficient 984 typedef Internal_curve_2::Coefficient Internal_coefficient; 985 986 //!@} 987 public: 988 //! \name types and functors for \c ACK_2< > 989 //!@{ 990 991 //! myself 992 typedef Simple_algebraic_kernel_2 Self; 993 994 //! univariate polynomial type 995 typedef CGAL::Polynomial<int> Polynomial_1; 996 997 //! bivariate polynomial type 998 typedef CGAL::Polynomial<Polynomial_1> Polynomial_2; 999 1000 //! type of x-coordinate 1001 typedef Internal_x_coordinate Algebraic_real_1; 1002 1003 //! type of bivariate coordinate 1004 typedef internal::Xy_coordinate_2< Self > Algebraic_real_2; 1005 1006 //! type of Bound 1007 typedef Internal_curve_2::Bound Bound; 1008 1009 //! type of Coordinate_1 1010 typedef Algebraic_real_1 Coordinate_1; 1011 1012 //! type of Coordinate_2 1013 typedef Algebraic_real_2 Coordinate_2; 1014 1015 //!@} 1016 1017 public: 1018 //! \name types and functors for \c GPA_2< both > 1019 //!@{ 1020 1021 //! type of 1-curve analysis 1022 typedef internal::Curve_analysis_2<Self> Curve_analysis_2; 1023 1024 //! type of 2-curve analysis 1025 typedef internal::Curve_pair_analysis_2<Self> Curve_pair_analysis_2; 1026 1027 //!@} 1028 1029 //! \name public functors and predicates 1030 //!@{ 1031 1032 //! \brief default constructor Simple_algebraic_kernel_2()1033 Simple_algebraic_kernel_2() 1034 { } 1035 1036 //! \brief constructs \c Curve_analysis_2 object, uses caching if appropriate 1037 struct Construct_curve_2 : 1038 public CGAL::cpp98::unary_function< Polynomial_2, Curve_analysis_2 > 1039 { 1040 //! \brief constructs an object from \c Algebraic_curve_kernel_2 type 1041 //! no default constructor provided Construct_curve_2Construct_curve_21042 Construct_curve_2(/*Self *pkernel_2*/) 1043 { } 1044 operatorConstruct_curve_21045 Curve_analysis_2 operator()(const Polynomial_2& f) const 1046 { 1047 return Curve_analysis_2(); 1048 } 1049 }; 1050 CGAL_Algebraic_Kernel_cons(Construct_curve_2, construct_curve_2_object); 1051 1052 /*! \brief 1053 * constructs \c Curve_pair_analysis_2 from pair of 1-curve analysis, 1054 * caching is used when appropriate 1055 */ 1056 struct Construct_curve_pair_2 : 1057 public CGAL::cpp98::binary_function<Curve_analysis_2, Curve_analysis_2, 1058 Curve_pair_analysis_2> { 1059 operatorConstruct_curve_pair_21060 Curve_pair_analysis_2 operator() 1061 (const Curve_analysis_2& ca1, const Curve_analysis_2& ca2) const { 1062 1063 Curve_pair_analysis_2 cpa_2(ca1,ca2); 1064 return cpa_2; 1065 } 1066 }; 1067 CGAL_Algebraic_Kernel_cons(Construct_curve_pair_2, 1068 construct_curve_pair_2_object); 1069 1070 //! type of a curve point 1071 typedef internal::Xy_coordinate_2<Self> Xy_coordinate_2; 1072 1073 //! returns the first coordinate of \c Xy_coordinate_2 1074 struct Get_x_2 : 1075 public CGAL::cpp98::unary_function<Xy_coordinate_2, Algebraic_real_1> { 1076 operatorGet_x_21077 Algebraic_real_1 operator()(const Xy_coordinate_2& xy) const { 1078 return xy.x(); 1079 } 1080 }; 1081 CGAL_Algebraic_Kernel_cons(Get_x_2, Get_x_2_object); 1082 1083 //! returns the second coordinate of \c Xy_coordinate_2 1084 struct Get_y_2 : 1085 public CGAL::cpp98::unary_function<Xy_coordinate_2, Algebraic_real_1> { 1086 operatorGet_y_21087 Algebraic_real_1 operator()(const Xy_coordinate_2& xy) const { 1088 return xy.y(); 1089 } 1090 }; 1091 CGAL_Algebraic_Kernel_cons(Get_y_2, Get_y_2_object); 1092 1093 struct Refine_x_2 : 1094 public CGAL::cpp98::unary_function<Xy_coordinate_2, void> { 1095 operatorRefine_x_21096 void operator()(const Xy_coordinate_2& r) const { } 1097 operatorRefine_x_21098 void operator()(Xy_coordinate_2& r, int rel_prec) const { } 1099 }; 1100 CGAL_Algebraic_Kernel_pred(Refine_x_2, refine_x_2_object); 1101 1102 struct Refine_y_2 : 1103 public CGAL::cpp98::unary_function<Xy_coordinate_2, void> { 1104 operatorRefine_y_21105 void operator()(const Xy_coordinate_2& r) const { } 1106 operatorRefine_y_21107 void operator()(Xy_coordinate_2& r, int rel_prec) const { } 1108 }; 1109 CGAL_Algebraic_Kernel_pred(Refine_y_2, refine_y_2_object); 1110 1111 //! computes the current lower boundary of the first coordinate of \c r 1112 struct Lower_boundary_x_2 { 1113 1114 typedef Xy_coordinate_2 agrument_type; 1115 typedef Bound result_type; 1116 operatorLower_boundary_x_21117 result_type operator()(const Xy_coordinate_2& r) { 1118 return static_cast<result_type>(0); 1119 } 1120 }; 1121 CGAL_Algebraic_Kernel_cons(Lower_boundary_x_2, lower_boundary_x_2_object); 1122 1123 //! computes the current upper boundary of the first coordinate of \c r 1124 struct Upper_boundary_x_2 { 1125 1126 typedef Xy_coordinate_2 agrument_type; 1127 typedef Bound result_type; 1128 operatorUpper_boundary_x_21129 result_type operator()(const Xy_coordinate_2& r) { 1130 return static_cast<result_type>(0); 1131 } 1132 }; 1133 CGAL_Algebraic_Kernel_cons(Upper_boundary_x_2, upper_boundary_x_2_object); 1134 1135 //! computes the current lower boundary of the second coordinate of \c r 1136 struct Lower_boundary_y_2 { 1137 1138 typedef Xy_coordinate_2 agrument_type; 1139 typedef Bound result_type; 1140 operatorLower_boundary_y_21141 result_type operator()(const Xy_coordinate_2& r) { 1142 return static_cast<result_type>(0); 1143 } 1144 }; 1145 CGAL_Algebraic_Kernel_cons(Lower_boundary_y_2, lower_boundary_y_2_object); 1146 1147 //! computes the current lower boundary of the second coordinate of \c r 1148 struct Upper_boundary_y_2 { 1149 1150 typedef Xy_coordinate_2 agrument_type; 1151 typedef Bound result_type; 1152 operatorUpper_boundary_y_21153 result_type operator()(const Xy_coordinate_2& r) { 1154 return static_cast<result_type>(0); 1155 } 1156 }; 1157 CGAL_Algebraic_Kernel_cons(Upper_boundary_y_2, upper_boundary_y_2_object); 1158 1159 //! returns the number of boundary type in-between x-coordinates of two 1160 //! Xy_coordinate_2 objects 1161 struct Bound_between_x_2 { 1162 1163 typedef Xy_coordinate_2 first_agrument_type; 1164 typedef Xy_coordinate_2 second_agrument_type; 1165 typedef Bound result_type; 1166 operatorBound_between_x_21167 result_type operator()(const Xy_coordinate_2& r1, 1168 const Xy_coordinate_2& r2) const { 1169 return static_cast<result_type>(0); 1170 } 1171 }; 1172 CGAL_Algebraic_Kernel_cons(Bound_between_x_2, 1173 boundary_between_x_2_object); 1174 1175 //! returns the number of boundary type in-between y-coordinates of two 1176 //! Xy_coordinate_2 objects 1177 struct Bound_between_y_2 { 1178 1179 typedef Xy_coordinate_2 first_agrument_type; 1180 typedef Xy_coordinate_2 second_agrument_type; 1181 typedef Bound result_type; 1182 operatorBound_between_y_21183 result_type operator()(const Xy_coordinate_2& r1, 1184 const Xy_coordinate_2& r2) const { 1185 return static_cast<result_type>(0); 1186 } 1187 }; 1188 CGAL_Algebraic_Kernel_cons(Bound_between_y_2, 1189 boundary_between_y_2_object); 1190 1191 //! \brief comparison of x-coordinates 1192 struct Compare_x_2 : 1193 public CGAL::cpp98::binary_function<Algebraic_real_1, Algebraic_real_1, 1194 Comparison_result > { 1195 operatorCompare_x_21196 Comparison_result operator()(const Algebraic_real_1& x1, 1197 const Algebraic_real_1& x2) const { 1198 return CGAL::EQUAL; 1199 } operatorCompare_x_21200 Comparison_result operator()(const Xy_coordinate_2& xy1, 1201 const Xy_coordinate_2& xy2) const { 1202 return CGAL::EQUAL; 1203 } 1204 }; 1205 CGAL_Algebraic_Kernel_pred(Compare_x_2, compare_x_2_object); 1206 1207 //! \brief comparison of y-coordinates of two points 1208 struct Compare_y_2 : 1209 public CGAL::cpp98::binary_function< Xy_coordinate_2, Xy_coordinate_2, 1210 Comparison_result > { 1211 operatorCompare_y_21212 Comparison_result operator()(const Xy_coordinate_2& xy1, 1213 const Xy_coordinate_2& xy2) const { 1214 return CGAL::EQUAL; 1215 } 1216 }; 1217 CGAL_Algebraic_Kernel_pred(Compare_y_2, compare_y_2_object); 1218 1219 //! lexicographical comparison of two objects of type \c Xy_coordinate_2 1220 //! 1221 //! \c equal_x specifies that only y-coordinates need to be compared 1222 struct Compare_xy_2 : 1223 public CGAL::cpp98::binary_function<Xy_coordinate_2, Xy_coordinate_2, 1224 Comparison_result > 1225 { operatorCompare_xy_21226 Comparison_result operator()(const Xy_coordinate_2& xy1, 1227 const Xy_coordinate_2& xy2, bool equal_x = false) const { 1228 1229 return CGAL::EQUAL; 1230 } 1231 }; 1232 CGAL_Algebraic_Kernel_pred(Compare_xy_2, compare_xy_2_object); 1233 1234 //! \brief checks whether curve has only finitely many self-intersection 1235 //! points, i.e., it has no self-overlapped continuous parts 1236 //! 1237 //! for algerbaic curves this means that supporting polynomial is 1238 //! square-free 1239 struct Has_finite_number_of_self_intersections_2 : 1240 public CGAL::cpp98::unary_function< Polynomial_2, bool > { 1241 operatorHas_finite_number_of_self_intersections_21242 bool operator()(const Polynomial_2& p) const { 1243 return true; //is_square_free(p); 1244 } 1245 }; 1246 CGAL_Algebraic_Kernel_pred(Has_finite_number_of_self_intersections_2, 1247 has_finite_number_of_self_intersections_2_object); 1248 1249 //! \brief checks whether a curve pair has finitely many intersections, 1250 //! in other words, whether two curves have no continuous common part 1251 //! 1252 //! in case of algerbaic curves: checks whether supporting polynomials are 1253 //! coprime 1254 struct Has_finite_number_of_intersections_2 : 1255 public CGAL::cpp98::binary_function< Curve_analysis_2, Curve_analysis_2, bool > { 1256 operatorHas_finite_number_of_intersections_21257 bool operator()(const Curve_analysis_2& c1, 1258 const Curve_analysis_2& c2) const { 1259 return true; 1260 } 1261 }; 1262 CGAL_Algebraic_Kernel_pred(Has_finite_number_of_intersections_2, 1263 has_finite_number_of_intersections_2_object); 1264 1265 //! set of various curve and curve pair decomposition functions 1266 struct Decompose_2 { 1267 1268 //! default constructor Decompose_2Decompose_21269 Decompose_2(/*Self *pkernel_2*/) 1270 { } 1271 operatorDecompose_21272 Polynomial_2 operator()(const Polynomial_2& p) { 1273 return p; 1274 } 1275 1276 template< class OutputIterator1, class OutputIterator2 > operatorDecompose_21277 int operator()( const Curve_analysis_2& c, OutputIterator1 fit, 1278 OutputIterator2 mit ) const { 1279 1280 return 0; 1281 } 1282 1283 template < class OutputIterator > operatorDecompose_21284 bool operator()(const Curve_analysis_2& c1, 1285 const Curve_analysis_2& c2, 1286 OutputIterator oi1, OutputIterator oi2, OutputIterator oib) { 1287 1288 return false; 1289 } 1290 private: 1291 //! pointer to Algebraic_curve_kernel_2 (for caching issues) 1292 /*Self *_m_pkernel_2; */ 1293 }; 1294 CGAL_Algebraic_Kernel_cons(Decompose_2, decompose_2_object); 1295 1296 //!@} 1297 public: 1298 //! \name types and functors for \c GPA_2<Algebraic_kernel_d_2> 1299 //!@{ 1300 1301 typedef Construct_curve_2 Construct_polynomial_2_; 1302 1303 typedef Has_finite_number_of_self_intersections_2 Is_square_free_2; 1304 typedef Has_finite_number_of_intersections_2 Is_coprime_2; 1305 1306 typedef Decompose_2 Make_square_free_2; 1307 typedef Decompose_2 Square_free_factorize; 1308 typedef Decompose_2 Make_coprime_2; 1309 1310 //! \brief computes the derivative w.r.t. the first (innermost) variable 1311 struct Derivative_x_2 : 1312 public CGAL::cpp98::unary_function< Polynomial_2, Polynomial_2 > { 1313 operatorDerivative_x_21314 Polynomial_2 operator()(const Polynomial_2& p) const { 1315 return p; 1316 } 1317 }; 1318 CGAL_Algebraic_Kernel_cons(Derivative_x_2, derivative_x_2_object); 1319 1320 //! \brief computes the derivative w.r.t. the first (outermost) variable 1321 struct Derivative_y_2 : 1322 public CGAL::cpp98::unary_function< Polynomial_2, Polynomial_2 > { 1323 operatorDerivative_y_21324 Polynomial_2 operator()(const Polynomial_2& p) const { 1325 return p; 1326 } 1327 }; 1328 CGAL_Algebraic_Kernel_cons(Derivative_y_2, derivative_y_2_object); 1329 1330 struct X_critical_points_2 { 1331 1332 template <class OutputIterator> operatorX_critical_points_21333 OutputIterator operator()(const Polynomial_2& p, 1334 OutputIterator oi) const { 1335 return oi; 1336 } 1337 1338 //! \brief computes the ith x-critical point of polynomial \c p operatorX_critical_points_21339 Xy_coordinate_2 operator()(const Polynomial_2& p, int i) const { 1340 return Xy_coordinate_2(); 1341 } 1342 }; 1343 CGAL_Algebraic_Kernel_cons(X_critical_points_2, 1344 x_critical_points_2_object); 1345 1346 struct Y_critical_points_2 { 1347 1348 //! \brief copies in the output iterator the y-critical points of 1349 //! polynomial \c p as objects of type \c Xy_coordinate_2 1350 template <class OutputIterator> operatorY_critical_points_21351 OutputIterator operator()(const Polynomial_2& p, 1352 OutputIterator oi) const { 1353 return oi; 1354 } 1355 1356 //! \brief computes the ith y-critical point of polynomial \c p operatorY_critical_points_21357 Xy_coordinate_2 operator()(const Polynomial_2& p, int i) const { 1358 return Xy_coordinate_2(); 1359 } 1360 }; 1361 CGAL_Algebraic_Kernel_cons(Y_critical_points_2, 1362 y_critical_points_2_object); 1363 1364 /*!\brief 1365 * computes the sign of a bivariate polynomial \c p evaluated at the root 1366 * \c r of a system of two bivariate polynomial equations 1367 * 1368 * returns a value convertible to \c CGAL::Sign 1369 */ 1370 struct Sign_at_2 : 1371 public CGAL::cpp98::binary_function< Polynomial_2, Xy_coordinate_2, Sign > { 1372 operatorSign_at_21373 Sign operator()(const Polynomial_2& p, const Xy_coordinate_2& r) const 1374 { 1375 return CGAL::ZERO; 1376 } 1377 }; 1378 CGAL_Algebraic_Kernel_pred(Sign_at_2, sign_at_2_object); 1379 1380 struct Solve_2 { 1381 1382 template <class OutputIteratorRoots, class OutputIteratorMult> 1383 std::pair<OutputIteratorRoots, OutputIteratorMult> operatorSolve_21384 operator()(const Polynomial_2& p1, const Polynomial_2& p2, 1385 OutputIteratorRoots roots, OutputIteratorMult mults) const 1386 { 1387 return std::make_pair(roots, mults); 1388 } 1389 }; 1390 CGAL_Algebraic_Kernel_cons(Solve_2, solve_2_object); 1391 1392 #undef CGAL_Algebraic_Kernel_pred 1393 #undef CGAL_Algebraic_Kernel_cons 1394 1395 //!@} 1396 1397 }; // class Algebraic_curve_kernel_2 1398 1399 } //namespace CGAL 1400 1401 #endif // CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_TEST_SIMPLE_MODELS_H 1402 // EOF 1403