slice_tets.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. // Optional:
  24. // 'Manifold' followed by whether to stitch together triangles into a
  25. // manifold mesh {true}: results in more compact U but slightly slower.
  26. // Outputs:
  27. // U #U by 3 list of triangle mesh vertices along slice
  28. // G #G by 3 list of triangles indices into U
  29. // J #G list of indices into T revealing from which tet each faces comes
  30. // BC #U by #V list of barycentric coordinates (or more generally: linear
  31. // interpolation coordinates) so that U = BC*V
  32. //
  33. template <
  34. typename DerivedV,
  35. typename DerivedT,
  36. typename Derivedplane,
  37. typename DerivedU,
  38. typename DerivedG,
  39. typename DerivedJ,
  40. typename BCType>
  41. IGL_INLINE void slice_tets(
  42. const Eigen::PlainObjectBase<DerivedV>& V,
  43. const Eigen::PlainObjectBase<DerivedT>& T,
  44. const Eigen::PlainObjectBase<Derivedplane> & plane,
  45. Eigen::PlainObjectBase<DerivedU>& U,
  46. Eigen::PlainObjectBase<DerivedG>& G,
  47. Eigen::PlainObjectBase<DerivedJ>& J,
  48. Eigen::SparseMatrix<BCType> & BC);
  49. }
  50. #ifndef IGL_STATIC_LIBRARY
  51. # include "slice_tets.cpp"
  52. #endif
  53. #endif