slice_tets.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_SLICE_TETS_H
  9. #define IGL_SLICE_TETS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Dense>
  12. #include <Eigen/Sparse>
  13. #include <vector>
  14. namespace igl
  15. {
  16. // SLICE_TETS Slice through a tet mesh (V,T) along a given plane (via its
  17. // implicit equation).
  18. //
  19. // Inputs:
  20. // V #V by 3 list of tet mesh vertices
  21. // T #T by 4 list of tet indices into V
  22. //// plane list of 4 coefficients in the plane equation: [x y z 1]'*plane = 0
  23. // S #V list of values so that S = 0 is the desired isosurface
  24. // Outputs:
  25. // SV #SV by 3 list of triangle mesh vertices along slice
  26. // SF #SF by 3 list of triangles indices into SV
  27. // J #SF list of indices into T revealing from which tet each faces comes
  28. // BC #SU by #V list of barycentric coordinates (or more generally: linear
  29. // interpolation coordinates) so that SV = BC*V
  30. //
  31. template <
  32. typename DerivedV,
  33. typename DerivedT,
  34. typename DerivedS,
  35. typename DerivedSV,
  36. typename DerivedSF,
  37. typename DerivedJ,
  38. typename BCType>
  39. IGL_INLINE void slice_tets(
  40. const Eigen::MatrixBase<DerivedV>& V,
  41. const Eigen::MatrixBase<DerivedT>& T,
  42. const Eigen::MatrixBase<DerivedS> & S,
  43. Eigen::PlainObjectBase<DerivedSV>& SV,
  44. Eigen::PlainObjectBase<DerivedSF>& SF,
  45. Eigen::PlainObjectBase<DerivedJ>& J,
  46. Eigen::SparseMatrix<BCType> & BC);
  47. template <
  48. typename DerivedV,
  49. typename DerivedT,
  50. typename DerivedS,
  51. typename DerivedSV,
  52. typename DerivedSF,
  53. typename DerivedJ>
  54. IGL_INLINE void slice_tets(
  55. const Eigen::MatrixBase<DerivedV>& V,
  56. const Eigen::MatrixBase<DerivedT>& T,
  57. const Eigen::MatrixBase<DerivedS> & S,
  58. Eigen::PlainObjectBase<DerivedSV>& SV,
  59. Eigen::PlainObjectBase<DerivedSF>& SF,
  60. Eigen::PlainObjectBase<DerivedJ>& J);
  61. // Outputs:
  62. // sE #SV by 2 list of sorted edge indices into V
  63. // lambda #SV by 1 list of parameters along each edge in sE so that:
  64. // SV(i,:) = V(sE(i,1),:)*lambda(i) + V(sE(i,2),:)*(1-lambda(i));
  65. template <
  66. typename DerivedV,
  67. typename DerivedT,
  68. typename DerivedS,
  69. typename DerivedSV,
  70. typename DerivedSF,
  71. typename DerivedJ,
  72. typename DerivedsE,
  73. typename Derivedlambda
  74. >
  75. IGL_INLINE void slice_tets(
  76. const Eigen::MatrixBase<DerivedV>& V,
  77. const Eigen::MatrixBase<DerivedT>& T,
  78. const Eigen::MatrixBase<DerivedS> & S,
  79. Eigen::PlainObjectBase<DerivedSV>& SV,
  80. Eigen::PlainObjectBase<DerivedSF>& SF,
  81. Eigen::PlainObjectBase<DerivedJ>& J,
  82. Eigen::PlainObjectBase<DerivedsE>& sE,
  83. Eigen::PlainObjectBase<Derivedlambda>& lambda);
  84. }
  85. #ifndef IGL_STATIC_LIBRARY
  86. # include "slice_tets.cpp"
  87. #endif
  88. #endif