1 // Copyright (c) 2011 Tel-Aviv University (Israel), INRIA Sophia-Antipolis (France). 2 // 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/Arr_rat_arc/Base_rational_arc_ds_1.h $ 7 // $Id: Base_rational_arc_ds_1.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot 8 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial 9 // 10 // Author(s) : Oren Salzman <orenzalz@post.tau.ac.il > 11 // Michael Hemmer <Michael.Hemmer@sophia.inria.fr> 12 13 #ifndef CGAL_BASE_RATIONAL_ARC_DS_D_1_H 14 #define CGAL_BASE_RATIONAL_ARC_DS_D_1_H 15 16 #include <CGAL/license/Arrangement_on_surface_2.h> 17 18 19 #include <vector> 20 #include <ostream> 21 #include <CGAL/Arr_enums.h> 22 #include <CGAL/tags.h> 23 #include <CGAL/Arr_tags.h> 24 25 #include <CGAL/Fraction_traits.h> 26 #include <CGAL/Arithmetic_kernel.h> 27 #include <CGAL/Algebraic_kernel_d_1.h> 28 29 #include <boost/type_traits/is_same.hpp> 30 31 namespace CGAL { 32 namespace Arr_rational_arc { 33 34 template <typename Algebraic_kernel_ > 35 class Base_rational_arc_ds_1 36 { 37 public: 38 typedef Algebraic_kernel_ Algebraic_kernel; 39 typedef Base_rational_arc_ds_1<Algebraic_kernel> Self; 40 41 //typedef typename Algebraic_kernel::Multiplicity_type Multiplicity; 42 typedef unsigned int Multiplicity; 43 typedef typename Algebraic_kernel::Coefficient Coefficient; 44 45 typedef typename Get_arithmetic_kernel<Coefficient>::Arithmetic_kernel 46 Arithmetic_kernel; 47 typedef typename Arithmetic_kernel::Rational Rational; 48 typedef typename Arithmetic_kernel::Integer Integer; 49 typedef typename Algebraic_kernel::Algebraic_real_1 Algebraic_real_1; 50 51 typedef typename Algebraic_kernel::Polynomial_1 Polynomial_1; 52 typedef Polynomial_traits_d<Polynomial_1> Polynomial_traits_1; 53 typedef Fraction_traits<Rational> FT_rat_1; 54 typedef typename Algebraic_kernel::Solve_1 Solve_1; 55 typedef typename Algebraic_kernel::Bound Bound; 56 typedef Algebraic_structure_traits<Polynomial_1> AT_poly; 57 58 typedef Polynomial<Rational> Poly_rat_1; 59 typedef Polynomial_traits_d<Poly_rat_1> PT_rat_1; 60 typedef Fraction_traits <Poly_rat_1> FT_poly_rat_1; 61 typedef std::vector<Algebraic_real_1> Algebraic_vector; 62 typedef std::vector<Multiplicity> Multiplicity_vector; 63 typedef std::vector<std::pair<Algebraic_real_1, Multiplicity> > 64 Root_multiplicity_vector; 65 66 CGAL_static_assertion((boost::is_same<Integer,Coefficient>::value)); 67 CGAL_static_assertion((boost::is_same<Polynomial_1, 68 typename FT_poly_rat_1::Numerator_type>::value)); 69 70 public: 71 72 //--------------------------------------------------------------------- 73 // Print a polynomial nicely. 74 print_polynomial(std::ostream & os,const Polynomial_1 & poly,char var)75 static std::ostream& print_polynomial(std::ostream& os, 76 const Polynomial_1& poly, 77 char var) 78 { 79 // Get the degree. 80 const int deg = CGAL::degree(poly); 81 82 Integer coeff; 83 CGAL::Sign sgn; 84 int k; 85 86 if (deg < 0) 87 { 88 os << '0'; 89 return (os); 90 } 91 92 for (k = deg; k >= 0; k--) 93 { 94 //coeff = pt::Get_coefficient()(poly, k); 95 coeff = CGAL::get_coefficient(poly, k); 96 97 if (k == deg) 98 os << coeff; 99 else if ((sgn = CGAL::sign (coeff)) == POSITIVE) 100 os << " + " << coeff; 101 else if (sgn == NEGATIVE) 102 os << " - " << -coeff; 103 else 104 continue; 105 106 if (k > 1) 107 os << '*' << var << '^' << k; 108 else if (k == 1) 109 os << '*' << var; 110 } 111 112 return (os); 113 } 114 115 }; //Base_rational_arc_ds_1 116 117 } // namespace Arr_rational_arc 118 } //namespace CGAL { 119 120 #endif //CGAL_BASE_RATIONAL_ARC_DS_D_1_H 121