faces_first.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_FACES_FIRST_H
  9. #define IGL_FACES_FIRST_H
  10. #include "igl_inline.h"
  11. namespace igl
  12. {
  13. /// Reorder vertices so that vertices in face list come before
  14. /// vertices that don't appear in the face list. This is especially useful if
  15. /// the face list contains only surface faces and you want surface vertices
  16. /// listed before internal vertices
  17. ///
  18. ///
  19. /// @tparam MatV matrix for vertex positions, e.g. Eigen::MatrixXd
  20. /// @tparam MatF matrix for face indices, e.g. Eigen::MatrixXi
  21. /// @tparam VecI vector for index map, e.g. Eigen::VectorXi
  22. /// @param[in] V # vertices by 3 vertex positions
  23. /// @param[in] F # faces by 3 list of face indices
  24. /// @param[out] RV # vertices by 3 vertex positions, order such that if the jth vertex is
  25. /// some face in F, and the kth vertex is not then j comes before k
  26. /// @param[out] RF # faces by 3 list of face indices, reindexed to use RV
  27. /// @param[out] IM #V by 1 list of indices such that: RF = IM(F) and RT = IM(T)
  28. /// and RV(IM,:) = V
  29. ///
  30. ///
  31. /// #### Example:
  32. /// \code{cpp}
  33. /// // Tet mesh in (V,T,F)
  34. /// faces_first(V,F,IM);
  35. /// T = T.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
  36. /// (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
  37. /// &IM)).eval();
  38. /// \endcode
  39. template <typename MatV, typename MatF, typename VecI>
  40. IGL_INLINE void faces_first(
  41. const MatV & V,
  42. const MatF & F,
  43. MatV & RV,
  44. MatF & RF,
  45. VecI & IM);
  46. /// \overload
  47. template <typename MatV, typename MatF, typename VecI>
  48. IGL_INLINE void faces_first(
  49. MatV & V,
  50. MatF & F,
  51. VecI & IM);
  52. }
  53. #ifndef IGL_STATIC_LIBRARY
  54. # include "faces_first.cpp"
  55. #endif
  56. #endif