face_areas.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "face_areas.h"
  2. #include "edge_lengths.h"
  3. #include "doublearea.h"
  4. template <typename DerivedV, typename DerivedT, typename DerivedA>
  5. IGL_INLINE void igl::face_areas(
  6. const Eigen::PlainObjectBase<DerivedV>& V,
  7. const Eigen::PlainObjectBase<DerivedT>& T,
  8. Eigen::PlainObjectBase<DerivedA>& A)
  9. {
  10. assert(T.cols() == 4);
  11. typename Eigen::PlainObjectBase<DerivedA> L;
  12. edge_lengths(V,T,L);
  13. return face_areas(L,A);
  14. }
  15. template <typename DerivedL, typename DerivedA>
  16. IGL_INLINE void igl::face_areas(
  17. const Eigen::PlainObjectBase<DerivedL>& L,
  18. Eigen::PlainObjectBase<DerivedA>& A)
  19. {
  20. using namespace Eigen;
  21. assert(L.cols() == 6);
  22. const int m = L.rows();
  23. // (unsigned) face Areas (opposite vertices: 1 2 3 4)
  24. Matrix<typename DerivedA::Scalar,Dynamic,1>
  25. A0(m,1), A1(m,1), A2(m,1), A3(m,1);
  26. Matrix<typename DerivedA::Scalar,Dynamic,3>
  27. L0(m,3), L1(m,3), L2(m,3), L3(m,3);
  28. L0<<L.col(1),L.col(2),L.col(3);
  29. L1<<L.col(0),L.col(2),L.col(4);
  30. L2<<L.col(0),L.col(1),L.col(5);
  31. L3<<L.col(3),L.col(4),L.col(5);
  32. doublearea(L0,A0);
  33. doublearea(L1,A1);
  34. doublearea(L2,A2);
  35. doublearea(L3,A3);
  36. A.resize(m,4);
  37. A.col(0) = 0.5*A0;
  38. A.col(1) = 0.5*A1;
  39. A.col(2) = 0.5*A2;
  40. A.col(3) = 0.5*A3;
  41. }
  42. #ifndef IGL_HEADER_ONLY
  43. // Explicit template specialization
  44. // generated by autoexplicit.sh
  45. template void igl::face_areas<Eigen::Matrix<double, -1, 6, 0, -1, 6>, Eigen::Matrix<double, -1, 4, 0, -1, 4> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 6, 0, -1, 6> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 4, 0, -1, 4> >&);
  46. #endif