assign_scalar.h 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. namespace igl
  15. {
  16. namespace copyleft
  17. {
  18. namespace cgal
  19. {
  20. /// Conduct the casting copy:
  21. /// lhs = rhs
  22. /// using `slow_and_more_precise` rounding if more desired.
  23. ///
  24. /// @tparam RHS right-hand side scalar type
  25. /// @tparam LHS left-hand side scalar type
  26. /// @param[in] rhs right-hand side scalar
  27. /// @param[in] slow_and_more_precise when appropriate use more elaborate rounding
  28. /// guaranteed to find a closest lhs value in an absolute value sense.
  29. /// Think of `slow_and_more_precise=true` as "round to closest number"
  30. /// and `slow_and_more_precise=false` as "round down/up". CGAL's number
  31. /// types are bit mysterious about how exactly rounding is conducted.
  32. /// For example, the rationals created during remesh_intersections on
  33. /// floating point input appear to be tightly rounded up or down so the
  34. /// difference with the `slow_and_more_precise=true` will be exactly
  35. /// zero 50% of the time and "one floating point unit" (at whatever
  36. /// scale) the other 50% of the time.
  37. /// @param[out] lhs left-hand side scalar
  38. template <typename RHS, typename LHS>
  39. IGL_INLINE void assign_scalar(
  40. const RHS & rhs,
  41. const bool & slow_and_more_precise,
  42. LHS & lhs);
  43. /// \overload
  44. /// \brief For legacy reasons, all of these overload uses
  45. /// `slow_and_more_precise=true`. This is subject to change if we determine
  46. /// it is sufficiently overkill. In that case, we'd create a new
  47. /// non-overloaded function.
  48. IGL_INLINE void assign_scalar(
  49. const CGAL::Epeck::FT & cgal,
  50. CGAL::Epeck::FT & d);
  51. /// \overload
  52. IGL_INLINE void assign_scalar(
  53. const CGAL::Epeck::FT & cgal,
  54. double & d);
  55. /// \overload
  56. IGL_INLINE void assign_scalar(
  57. /// \overload
  58. const CGAL::Epeck::FT & cgal,
  59. float& d);
  60. IGL_INLINE void assign_scalar(
  61. /// \overload
  62. const double & c,
  63. double & d);
  64. /// \overload
  65. IGL_INLINE void assign_scalar(
  66. const float& c,
  67. float & d);
  68. /// \overload
  69. IGL_INLINE void assign_scalar(
  70. const float& c,
  71. double& d);
  72. /// \overload
  73. IGL_INLINE void assign_scalar(
  74. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  75. CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & d);
  76. /// \overload
  77. IGL_INLINE void assign_scalar(
  78. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  79. double & d);
  80. /// \overload
  81. IGL_INLINE void assign_scalar(
  82. const CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt::FT & cgal,
  83. float& d);
  84. }
  85. }
  86. }
  87. #ifndef IGL_STATIC_LIBRARY
  88. # include "assign_scalar.cpp"
  89. #endif
  90. #endif