variable_radius_offset.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2025 Alec Jacobson <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_VARIABLE_RADIUS_OFFSET_H
  9. #define IGL_VARIABLE_RADIUS_OFFSET_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. #include <functional>
  14. namespace igl
  15. {
  16. template <typename Scalar>
  17. class SphereMeshWedge;
  18. /// Compute the variable radius offset (see, e.g., "Variable-Radius Offset
  19. /// Curves and Surfaces" [Lin & Rokne 1997]) of a triangle mesh with a
  20. /// pieceiwse linear radius function.
  21. ///
  22. /// @param[in] V #V by 3 list of vertex positions
  23. /// @param[in] F #F by 3 list of triangle indices into V
  24. /// @param[in] R #V list of radii for each vertex
  25. /// @param[in] origin 3-vector origin of octree used for mesh extraction
  26. /// @param[in] h0 side length of octree root cell
  27. /// @param[in] max_depth maximum depth of octree used for mesh extraction
  28. /// (root is depth=0)
  29. /// @param[out] mV #mV by 3 list of vertex positions of the offset mesh
  30. /// @param[out] mF #mF by 3 list of triangle indices into mV
  31. template <
  32. typename DerivedV,
  33. typename DerivedF,
  34. typename DerivedR,
  35. typename Derivedorigin,
  36. typename DerivedmV,
  37. typename DerivedmF>
  38. void variable_radius_offset(
  39. const Eigen::MatrixBase<DerivedV> & V,
  40. const Eigen::MatrixBase<DerivedF> & F,
  41. const Eigen::MatrixBase<DerivedR> & R,
  42. const Eigen::MatrixBase<Derivedorigin> & origin,
  43. const typename Derivedorigin::Scalar h0,
  44. const int max_depth,
  45. Eigen::PlainObjectBase<DerivedmV> & mV,
  46. Eigen::PlainObjectBase<DerivedmF> & mF);
  47. /// \brief Overload which prepares data for a eytzinger_aabb_sdf callable sdf
  48. /// function.
  49. ///
  50. /// @param[in] V #V by 3 list of vertex positions
  51. /// @param[in] F #F by 3 list of triangle indices into V
  52. /// @param[in] R #V list of radii for each vertex
  53. /// @param[out] PB1 #F by 3 list of minimum corners of each offset
  54. /// triangle's axis aligned bounding box
  55. /// @param[out] PB2 #F by 3 list of maximum corners of each offset
  56. /// triangle's axis aligned bounding box
  57. /// @param[out] #F list of precomputed sphere-mesh wedge data
  58. /// @param[out] primitive function handle that takes as input a point and
  59. /// primitive index as input and outputs the corresponding signed distance.
  60. /// This function assumes that `data` will remain alive.
  61. template <
  62. typename DerivedV,
  63. typename DerivedF,
  64. typename DerivedR,
  65. typename DerivedPB1,
  66. typename DerivedPB2,
  67. typename Scalar>
  68. void variable_radius_offset(
  69. const Eigen::MatrixBase<DerivedV> & V,
  70. const Eigen::MatrixBase<DerivedF> & F,
  71. const Eigen::MatrixBase<DerivedR> & R,
  72. Eigen::PlainObjectBase<DerivedPB1> & PB1,
  73. Eigen::PlainObjectBase<DerivedPB2> & PB2,
  74. std::vector<igl::SphereMeshWedge<Scalar>> & data,
  75. std::function<Scalar(const Eigen::Matrix<Scalar,1,3> &,const int i)> &
  76. primitive);
  77. ///// \brief Overload using precomputed data.
  78. template <
  79. typename DerivedPB1,
  80. typename DerivedPB2,
  81. typename Scalar,
  82. typename Derivedorigin,
  83. typename DerivedmV,
  84. typename DerivedmF>
  85. void variable_radius_offset(
  86. const Eigen::MatrixBase<DerivedPB1> & PB1,
  87. const Eigen::MatrixBase<DerivedPB2> & PB2,
  88. const std::vector<igl::SphereMeshWedge<Scalar>> & data,
  89. const std::function<Scalar(const Eigen::Matrix<Scalar,1,3> &,const int i)> &
  90. primitive,
  91. const Eigen::MatrixBase<Derivedorigin> & origin,
  92. const Scalar h0,
  93. const int max_depth,
  94. Eigen::PlainObjectBase<DerivedmV> & mV,
  95. Eigen::PlainObjectBase<DerivedmF> & mF);
  96. }
  97. #ifndef IGL_STATIC_LIBRARY
  98. # include "variable_radius_offset.cpp"
  99. #endif
  100. #endif