assign_scalar.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  4. // Copyright (C) 2021 Alec Jacobson <[email protected]>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. #ifndef IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
  10. #define IGL_COPYLEFT_CGAL_ASSIGN_SCALAR_H
  11. #include "../../igl_inline.h"
  12. #include <CGAL/Exact_predicates_exact_constructions_kernel.h>
  13. #include <CGAL/Exact_predicates_exact_constructions_kernel_with_sqrt.h>
  14. #ifndef WIN32
  15. #include <CGAL/gmpxx.h>
  16. #endif
  17. namespace igl
  18. {
  19. namespace copyleft
  20. {
  21. namespace cgal
  22. {
  23. /// Conduct the casting copy:
  24. /// lhs = rhs
  25. /// using `slow_and_more_precise` rounding if more desired.
  26. ///
  27. /// @tparam RHS right-hand side scalar type
  28. /// @tparam LHS left-hand side scalar type
  29. /// @param[in] rhs right-hand side scalar
  30. /// @param[in] slow_and_more_precise when appropriate use more elaborate rounding
  31. /// guaranteed to find a closest lhs value in an absolute value sense.
  32. /// Think of `slow_and_more_precise=true` as "round to closest number"
  33. /// and `slow_and_more_precise=false` as "round down/up". CGAL's number
  34. /// types are bit mysterious about how exactly rounding is conducted.
  35. /// For example, the rationals created during remesh_intersections on
  36. /// floating point input appear to be tightly rounded up or down so the
  37. /// difference with the `slow_and_more_precise=true` will be exactly
  38. /// zero 50% of the time and "one floating point unit" (at whatever
  39. /// scale) the other 50% of the time.
  40. /// @param[out] lhs left-hand side scalar
  41. template <typename RHS, typename LHS>
  42. IGL_INLINE void assign_scalar(
  43. const RHS & rhs,
  44. const bool & slow_and_more_precise,
  45. LHS & lhs);
  46. /// \overload
  47. /// \brief For legacy reasons, all of these overload uses
  48. /// `slow_and_more_precise=true`. This is subject to change if we determine
  49. /// it is sufficiently overkill. In that case, we'd create a new
  50. /// non-overloaded function.
  51. IGL_INLINE void assign_scalar(
  52. const CGAL::Epeck::FT & cgal,
  53. CGAL::Epeck::FT & d);
  54. /// \overload
  55. IGL_INLINE void assign_scalar(
  56. const CGAL::Epeck::FT & cgal,
  57. double & d);
  58. /// \overload
  59. IGL_INLINE void assign_scalar(
  60. /// \overload
  61. const CGAL::Epeck::FT & cgal,
  62. float& d);
  63. IGL_INLINE void assign_scalar(
  64. /// \overload
  65. const double & c,
  66. double & d);
  67. /// \overload
  68. IGL_INLINE void assign_scalar(
  69. const float& c,
  70. float & d);
  71. /// \overload
  72. IGL_INLINE void assign_scalar(
  73. const float& c,
  74. double& d);
  75. /// \overload
  76. IGL_INLINE void assign_scalar(
  77. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  78. CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & d);
  79. /// \overload
  80. IGL_INLINE void assign_scalar(
  81. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  82. double & d);
  83. /// \overload
  84. IGL_INLINE void assign_scalar(
  85. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  86. float& d);
  87. #ifndef WIN32
  88. /// \overload
  89. IGL_INLINE void assign_scalar(
  90. const CGAL::Simple_cartesian<mpq_class>::FT & cgal,
  91. CGAL::Simple_cartesian<mpq_class>::FT & d);
  92. /// \overload
  93. IGL_INLINE void assign_scalar(
  94. const CGAL::Simple_cartesian<mpq_class>::FT & cgal,
  95. double & d);
  96. /// \overload
  97. IGL_INLINE void assign_scalar(
  98. const CGAL::Simple_cartesian<mpq_class>::FT & cgal,
  99. float& d);
  100. #endif
  101. }
  102. }
  103. }
  104. #ifndef IGL_STATIC_LIBRARY
  105. # include "assign_scalar.cpp"
  106. #endif
  107. #endif