1 // Copyright (c) 2005-2006 INRIA Sophia-Antipolis (France). 2 // All rights reserved. 3 // 4 // This file is part of CGAL (www.cgal.org). 5 // 6 // Partially supported by the IST Programme of the EU as a Shared-cost 7 // RTD (FET Open) Project under Contract No IST-2000-26473 8 // (ECG - Effective Computational Geometry for Curves and Surfaces) 9 // and a STREP (FET Open) Project under Contract No IST-006413 10 // (ACS -- Algorithms for Complex Shapes) 11 // 12 // $URL: https://github.com/CGAL/cgal/blob/v5.3/Algebraic_kernel_for_spheres/include/CGAL/Algebraic_kernel_for_spheres/function_objects_on_roots_and_polynomials_2_3.h $ 13 // $Id: function_objects_on_roots_and_polynomials_2_3.h 0779373 2020-03-26T13:31:46+01:00 Sébastien Loriot 14 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial 15 // 16 // Author(s) : Monique Teillaud <Monique.Teillaud@sophia.inria.fr> 17 // Sylvain Pion 18 // Pedro Machado 19 20 #ifndef CGAL_ALGEBRAIC_KERNEL_FOR_SPHERES_FUNCTION_OBJECTS_ON_ROOTS_AND_POLYNOMIALS_3_H 21 #define CGAL_ALGEBRAIC_KERNEL_FOR_SPHERES_FUNCTION_OBJECTS_ON_ROOTS_AND_POLYNOMIALS_3_H 22 23 #include <CGAL/license/Circular_kernel_3.h> 24 25 26 #include <CGAL/Algebraic_kernel_for_spheres/internal_functions_comparison_root_for_spheres_2_3.h> 27 #include <CGAL/Algebraic_kernel_for_spheres/internal_functions_on_roots_and_polynomials_2_3.h> 28 #include <CGAL/Algebraic_kernel_for_spheres/internal_functions_on_roots_and_polynomial_1_3_and_2_3.h> 29 #include <CGAL/Algebraic_kernel_for_spheres/internal_functions_on_roots_and_polynomials_1_3.h> 30 namespace CGAL { 31 32 namespace AlgebraicSphereFunctors { 33 34 template < class AK > 35 class Solve 36 { 37 38 typedef typename AK::Polynomial_for_spheres_2_3 39 Polynomial_for_spheres_2_3; 40 typedef typename AK::Polynomial_1_3 41 Polynomial_1_3; 42 typedef std::pair< 43 Polynomial_for_spheres_2_3, 44 Polynomial_1_3> Equation_Circle; 45 typedef typename AK::Polynomials_for_line_3 Polynomials_for_line_3; 46 47 public: 48 template < class OutputIterator > 49 OutputIterator operator()50 operator() 51 (const Equation_Circle & e1, 52 const Equation_Circle & e2, 53 OutputIterator res) const 54 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 55 56 template < class OutputIterator > 57 OutputIterator operator()58 operator() 59 (const Equation_Circle & e1, 60 const Polynomials_for_line_3 & e2, 61 OutputIterator res) const 62 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 63 64 template < class OutputIterator > 65 OutputIterator operator()66 operator() 67 (const Polynomials_for_line_3 & e1, 68 const Equation_Circle & e2, 69 OutputIterator res) const 70 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 71 72 template < class OutputIterator > 73 OutputIterator operator()74 operator() 75 (const Equation_Circle & e1, 76 const Polynomial_1_3 & e2, 77 OutputIterator res) const 78 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 79 80 template < class OutputIterator > 81 OutputIterator operator()82 operator() 83 (const Polynomial_1_3 & e1, 84 const Equation_Circle & e2, 85 OutputIterator res) const 86 { return AlgebraicSphereFunctors::solve<AK> (e1, e2, res); } 87 88 template < class OutputIterator > 89 OutputIterator operator()90 operator() 91 (const Equation_Circle & e1, 92 const Polynomial_for_spheres_2_3 & e2, 93 OutputIterator res) const 94 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 95 96 template < class OutputIterator > 97 OutputIterator operator()98 operator() 99 (const Polynomial_for_spheres_2_3 & e1, 100 const Equation_Circle & e2, 101 OutputIterator res) const 102 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 103 104 template < class OutputIterator > 105 OutputIterator operator()106 operator() 107 (const Polynomial_for_spheres_2_3 & e1, 108 const Polynomial_1_3 & e2, 109 const Polynomial_1_3 & e3, 110 OutputIterator res) const 111 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 112 113 template < class OutputIterator > 114 OutputIterator operator()115 operator() 116 (const Polynomial_for_spheres_2_3 & e1, 117 const Polynomials_for_line_3 & e2, 118 OutputIterator res) const 119 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 120 121 template < class OutputIterator > 122 OutputIterator operator()123 operator() 124 (const Polynomials_for_line_3 & e1, 125 const Polynomial_for_spheres_2_3 & e2, 126 OutputIterator res) const 127 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, res); } 128 129 template < class OutputIterator > 130 OutputIterator operator()131 operator() 132 (const Polynomial_for_spheres_2_3 & e1, 133 const Polynomial_for_spheres_2_3 & e2, 134 const Polynomial_1_3 & e3, 135 OutputIterator res) const 136 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 137 138 template < class OutputIterator > 139 OutputIterator operator()140 operator() 141 (const Polynomial_1_3 & e1, 142 const Polynomial_for_spheres_2_3 & e2, 143 const Polynomial_for_spheres_2_3 & e3, 144 OutputIterator res) const 145 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 146 147 template < class OutputIterator > 148 OutputIterator operator()149 operator() 150 (const Polynomial_1_3 & e1, 151 const Polynomial_1_3 & e2, 152 const Polynomial_for_spheres_2_3 & e3, 153 OutputIterator res) const 154 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 155 156 template < class OutputIterator > 157 OutputIterator operator()158 operator() 159 (const Polynomial_for_spheres_2_3 & e1, 160 const Polynomial_for_spheres_2_3 & e2, 161 const Polynomial_for_spheres_2_3 & e3, 162 OutputIterator res) const 163 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 164 165 template < class OutputIterator > 166 OutputIterator operator()167 operator() 168 (const Polynomial_1_3 & e1, 169 const Polynomial_1_3 & e2, 170 const Polynomial_1_3 & e3, 171 OutputIterator res) const 172 { return AlgebraicSphereFunctors::solve<AK> ( e1, e2, e3, res); } 173 174 175 176 177 }; 178 179 template < class AK > 180 class Construct_polynomial_for_spheres_2_3 181 { 182 typedef typename AK::RT RT; 183 typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 184 185 public: 186 Polynomial_for_spheres_2_3 operator()187 operator()(const RT& xc, const RT& yc,const RT& zc, const RT& r_sq) const 188 { return Polynomial_for_spheres_2_3(xc, yc, zc, r_sq); } 189 }; 190 191 192 template < class AK > 193 class Construct_polynomial_1_3 194 { 195 typedef typename AK::RT RT; 196 typedef typename AK::Polynomial_1_3 Polynomial_1_3; 197 198 public: 199 Polynomial_1_3 operator()200 operator()(const RT& a, const RT& b,const RT& c, const RT& d) const 201 { return Polynomial_1_3(a, b, c, d); } 202 }; 203 204 template < class AK > 205 class Construct_polynomials_for_line_3 206 { 207 typedef typename AK::FT FT; 208 typedef typename AK::Polynomials_for_line_3 Polynomials_for_line_3; 209 210 public: 211 Polynomials_for_line_3 operator()212 operator()(const FT& a1, const FT& b1, 213 const FT& a2, const FT& b2, 214 const FT& a3, const FT& b3) const 215 { return Polynomials_for_line_3(a1, b1, a2, b2, a3, b3); } 216 }; 217 218 template < class AK > 219 class Sign_at 220 { 221 typedef typename AK::Polynomial_1_3 Polynomial_1_3; 222 typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 223 typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; 224 225 public: 226 typedef CGAL::Sign result_type; 227 228 result_type operator()229 operator()( const Polynomial_for_spheres_2_3 & equation, 230 const Root_for_spheres_2_3 & r ) const 231 { return AlgebraicSphereFunctors::sign_at<AK>(equation, r); } 232 233 result_type operator()234 operator()( const Polynomial_1_3 & equation, 235 const Root_for_spheres_2_3 & r ) const 236 { return AlgebraicSphereFunctors::sign_at<AK>(equation, r); } 237 238 }; 239 240 241 template < class AK > 242 class X_critical_points 243 { 244 typedef typename AK::Root_of_2 Root_of_2; 245 typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; 246 typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 247 typedef typename AK::Polynomial_1_3 Polynomial_1_3; 248 249 public: 250 typedef void result_type; 251 252 Root_for_spheres_2_3 operator()253 operator()(const Polynomial_for_spheres_2_3 & c, 254 bool i) const 255 { return AlgebraicSphereFunctors::x_critical_point<AK>(c,i); } 256 257 template <class OutputIterator> 258 OutputIterator operator()259 operator()(const Polynomial_for_spheres_2_3 & c, 260 OutputIterator res) const 261 { return AlgebraicSphereFunctors::x_critical_points<AK>(c,res); } 262 263 Root_for_spheres_2_3 operator()264 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 265 bool i) const 266 { return AlgebraicSphereFunctors::x_critical_point<AK>(c,i); } 267 268 template <class OutputIterator> 269 OutputIterator operator()270 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 271 OutputIterator res) const 272 { return AlgebraicSphereFunctors::x_critical_points<AK>(c,res); } 273 }; 274 275 template < class AK > 276 class Y_critical_points 277 { 278 typedef typename AK::Root_of_2 Root_of_2; 279 typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; 280 typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 281 typedef typename AK::Polynomial_1_3 Polynomial_1_3; 282 283 public: 284 typedef void result_type; 285 286 Root_for_spheres_2_3 operator()287 operator()(const Polynomial_for_spheres_2_3 & c, 288 bool i) const 289 { return AlgebraicSphereFunctors::y_critical_point<AK>(c,i); } 290 291 template <class OutputIterator> 292 OutputIterator operator()293 operator()(const Polynomial_for_spheres_2_3 & c, 294 OutputIterator res) const 295 { return AlgebraicSphereFunctors::y_critical_points<AK>(c,res); } 296 297 Root_for_spheres_2_3 operator()298 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 299 bool i) const 300 { return AlgebraicSphereFunctors::y_critical_point<AK>(c,i); } 301 302 template <class OutputIterator> 303 OutputIterator operator()304 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 305 OutputIterator res) const 306 { return AlgebraicSphereFunctors::y_critical_points<AK>(c,res); } 307 }; 308 309 template < class AK > 310 class Z_critical_points 311 { 312 typedef typename AK::Root_of_2 Root_of_2; 313 typedef typename AK::Root_for_spheres_2_3 Root_for_spheres_2_3; 314 typedef typename AK::Polynomial_for_spheres_2_3 Polynomial_for_spheres_2_3; 315 typedef typename AK::Polynomial_1_3 Polynomial_1_3; 316 317 public: 318 typedef void result_type; 319 320 Root_for_spheres_2_3 operator()321 operator()(const Polynomial_for_spheres_2_3 & c, 322 bool i) const 323 { return AlgebraicSphereFunctors::z_critical_point<AK>(c,i); } 324 325 template <class OutputIterator> 326 OutputIterator operator()327 operator()(const Polynomial_for_spheres_2_3 & c, 328 OutputIterator res) const 329 { return AlgebraicSphereFunctors::z_critical_points<AK>(c,res); } 330 331 Root_for_spheres_2_3 operator()332 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 333 bool i) const 334 { return AlgebraicSphereFunctors::z_critical_point<AK>(c,i); } 335 336 template <class OutputIterator> 337 OutputIterator operator()338 operator()(const std::pair< Polynomial_for_spheres_2_3, Polynomial_1_3 > & c, 339 OutputIterator res) const 340 { return AlgebraicSphereFunctors::z_critical_points<AK>(c,res); } 341 342 }; 343 344 template <typename RT> 345 class Compare_x 346 { 347 public: 348 Comparison_result operator()349 operator()(const Root_for_spheres_2_3<RT>& r1, 350 const Root_for_spheres_2_3<RT>& r2) const 351 { return AlgebraicSphereFunctors::compare_x<RT>(r1, r2); } 352 353 }; 354 355 template <typename RT> 356 class Compare_y 357 { 358 public: 359 Comparison_result operator()360 operator()(const Root_for_spheres_2_3<RT>& r1, 361 const Root_for_spheres_2_3<RT>& r2) const 362 { return AlgebraicSphereFunctors::compare_y<RT>(r1, r2); } 363 }; 364 365 template <typename RT> 366 class Compare_z 367 { 368 public: 369 Comparison_result operator()370 operator()(const Root_for_spheres_2_3<RT>& r1, 371 const Root_for_spheres_2_3<RT>& r2) const 372 { return AlgebraicSphereFunctors::compare_z<RT>(r1, r2); } 373 }; 374 375 template <typename RT> 376 class Compare_xy 377 { 378 public: 379 Comparison_result operator()380 operator()(const Root_for_spheres_2_3<RT>& r1, 381 const Root_for_spheres_2_3<RT>& r2) const 382 { return AlgebraicSphereFunctors::compare_xy<RT>(r1, r2); } 383 }; 384 385 template <typename RT> 386 class Compare_xyz 387 { 388 public: 389 Comparison_result operator()390 operator()(const Root_for_spheres_2_3<RT>& r1, 391 const Root_for_spheres_2_3<RT>& r2) const 392 { return AlgebraicSphereFunctors::compare_xyz<RT>(r1, r2); } 393 }; 394 395 } // namespace AlgebraicSphereFunctors 396 397 } //namespace CGAL 398 399 #endif // CGAL_ALGEBRAIC_KERNEL_FOR_SPHERES_FUNCTION_OBJECTS_ON_ROOTS_AND_POLYNOMIALS_3_H 400