doublearea.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  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_DOUBLEAREA_H
  9. #define IGL_DOUBLEAREA_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. namespace igl
  13. {
  14. // DOUBLEAREA computes twice the area for each input triangle
  15. //
  16. // Templates:
  17. // DerivedV derived type of eigen matrix for V (e.g. derived from
  18. // MatrixXd)
  19. // DerivedF derived type of eigen matrix for F (e.g. derived from
  20. // MatrixXi)
  21. // DeriveddblA derived type of eigen matrix for dblA (e.g. derived from
  22. // MatrixXd)
  23. // Inputs:
  24. // V #V by dim list of mesh vertex positions
  25. // F #F by simplex_size list of mesh faces (must be triangles)
  26. // Outputs:
  27. // dblA #F list of triangle double areas (SIGNED only for 2D input)
  28. //
  29. template <typename DerivedV, typename DerivedF, typename DeriveddblA>
  30. IGL_INLINE void doublearea(
  31. const Eigen::PlainObjectBase<DerivedV> & V,
  32. const Eigen::PlainObjectBase<DerivedF> & F,
  33. Eigen::PlainObjectBase<DeriveddblA> & dblA);
  34. // Stream of triangles
  35. template <
  36. typename DerivedA,
  37. typename DerivedB,
  38. typename DerivedC,
  39. typename DerivedD>
  40. IGL_INLINE void doublearea(
  41. const Eigen::PlainObjectBase<DerivedA> & A,
  42. const Eigen::PlainObjectBase<DerivedB> & B,
  43. const Eigen::PlainObjectBase<DerivedC> & C,
  44. Eigen::PlainObjectBase<DerivedD> & D);
  45. // Single triangle in 2D!
  46. //
  47. // This should handle streams of corners not just single corners
  48. template <
  49. typename DerivedA,
  50. typename DerivedB,
  51. typename DerivedC>
  52. IGL_INLINE typename DerivedA::Scalar doublearea_single(
  53. const Eigen::PlainObjectBase<DerivedA> & A,
  54. const Eigen::PlainObjectBase<DerivedB> & B,
  55. const Eigen::PlainObjectBase<DerivedC> & C);
  56. // Same as above but use instrinsic edge lengths rather than (V,F) mesh
  57. // Templates:
  58. // DerivedV derived type of eigen matrix for V (e.g. derived from
  59. // MatrixXd)
  60. // DerivedF derived type of eigen matrix for F (e.g. derived from
  61. // MatrixXi)
  62. // DeriveddblA derived type of eigen matrix for dblA (e.g. derived from
  63. // MatrixXd)
  64. // Inputs:
  65. // l #F by dim list of edge lengths using
  66. // for triangles, columns correspond to edges 23,31,12
  67. // Outputs:
  68. // dblA #F list of triangle double areas
  69. template <typename Derivedl, typename DeriveddblA>
  70. IGL_INLINE void doublearea(
  71. const Eigen::PlainObjectBase<Derivedl> & l,
  72. Eigen::PlainObjectBase<DeriveddblA> & dblA);
  73. }
  74. #ifndef IGL_STATIC_LIBRARY
  75. # include "doublearea.cpp"
  76. #endif
  77. #endif