faces_first.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef IGL_FACES_FIRST_H
  2. #define IGL_FACES_FIRST_H
  3. #include "igl_inline.h"
  4. namespace igl
  5. {
  6. // FACES_FIRST Reorder vertices so that vertices in face list come before
  7. // vertices that don't appear in the face list. This is especially useful if
  8. // the face list contains only surface faces and you want surface vertices
  9. // listed before internal vertices
  10. //
  11. // [RV,RT,RF,IM] = faces_first(V,T,F);
  12. //
  13. // Templates:
  14. // MatV matrix for vertex positions, e.g. MatrixXd
  15. // MatF matrix for face indices, e.g. MatrixXi
  16. // VecI vector for index map, e.g. VectorXi
  17. // Input:
  18. // V # vertices by 3 vertex positions
  19. // F # faces by 3 list of face indices
  20. // Output:
  21. // RV # vertices by 3 vertex positions, order such that if the jth vertex is
  22. // some face in F, and the kth vertex is not then j comes before k
  23. // RF # faces by 3 list of face indices, reindexed to use RV
  24. // IM #V by 1 list of indices such that: RF = IM(F) and RT = IM(T)
  25. // and RV(IM,:) = V
  26. //
  27. //
  28. // Example:
  29. // // Tet mesh in (V,T,F)
  30. // faces_first(V,F,IM);
  31. // T = T.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
  32. // (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
  33. // &IM)).eval();
  34. template <typename MatV, typename MatF, typename VecI>
  35. IGL_INLINE void faces_first(
  36. const MatV & V,
  37. const MatF & F,
  38. MatV & RV,
  39. MatF & RF,
  40. VecI & IM);
  41. // Virtual "in place" wrapper
  42. template <typename MatV, typename MatF, typename VecI>
  43. IGL_INLINE void faces_first(
  44. MatV & V,
  45. MatF & F,
  46. VecI & IM);
  47. }
  48. #ifdef IGL_HEADER_ONLY
  49. # include "faces_first.cpp"
  50. #endif
  51. #endif