volume.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 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_VOLUME_H
  9. #define IGL_VOLUME_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Compute volume for all tets of a given tet mesh (V,T)
  15. ///
  16. /// @param[in] V #V by dim list of vertex positions
  17. /// @param[in] T #T by 4 list of tet indices
  18. /// @param[out] vol #T list of tetrahedron volumes
  19. ///
  20. template <
  21. typename DerivedV,
  22. typename DerivedT,
  23. typename Derivedvol>
  24. IGL_INLINE void volume(
  25. const Eigen::MatrixBase<DerivedV>& V,
  26. const Eigen::MatrixBase<DerivedT>& T,
  27. Eigen::PlainObjectBase<Derivedvol>& vol);
  28. /// \overload
  29. /// @param[in] A #V by dim list of first corner position
  30. /// @param[in] B #V by dim list of second corner position
  31. /// @param[in] C #V by dim list of third corner position
  32. /// @param[in] D #V by dim list of fourth corner position
  33. template <
  34. typename DerivedA,
  35. typename DerivedB,
  36. typename DerivedC,
  37. typename DerivedD,
  38. typename Derivedvol>
  39. IGL_INLINE void volume(
  40. const Eigen::MatrixBase<DerivedA> & A,
  41. const Eigen::MatrixBase<DerivedB> & B,
  42. const Eigen::MatrixBase<DerivedC> & C,
  43. const Eigen::MatrixBase<DerivedD> & D,
  44. Eigen::PlainObjectBase<Derivedvol> & vol);
  45. /// \overload
  46. /// \brief Single tet
  47. template <
  48. typename VecA,
  49. typename VecB,
  50. typename VecC,
  51. typename VecD>
  52. IGL_INLINE typename VecA::Scalar volume_single(
  53. const VecA & a,
  54. const VecB & b,
  55. const VecC & c,
  56. const VecD & d);
  57. /// \overload
  58. /// \brief Intrinsic version:
  59. ///
  60. /// @param[in] L #V by 6 list of edge lengths (see edge_lengths)
  61. template <
  62. typename DerivedL,
  63. typename Derivedvol>
  64. IGL_INLINE void volume(
  65. const Eigen::MatrixBase<DerivedL>& L,
  66. Eigen::PlainObjectBase<Derivedvol>& vol);
  67. }
  68. #ifndef IGL_STATIC_LIBRARY
  69. # include "volume.cpp"
  70. #endif
  71. #endif