faces_first.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_FACES_FIRST_H
  9. #define IGL_FACES_FIRST_H
  10. #include "igl_inline.h"
  11. namespace igl
  12. {
  13. // FACES_FIRST 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. // [RV,RT,RF,IM] = faces_first(V,T,F);
  19. //
  20. // Templates:
  21. // MatV matrix for vertex positions, e.g. MatrixXd
  22. // MatF matrix for face indices, e.g. MatrixXi
  23. // VecI vector for index map, e.g. VectorXi
  24. // Input:
  25. // V # vertices by 3 vertex positions
  26. // F # faces by 3 list of face indices
  27. // Output:
  28. // RV # vertices by 3 vertex positions, order such that if the jth vertex is
  29. // some face in F, and the kth vertex is not then j comes before k
  30. // RF # faces by 3 list of face indices, reindexed to use RV
  31. // IM #V by 1 list of indices such that: RF = IM(F) and RT = IM(T)
  32. // and RV(IM,:) = V
  33. //
  34. //
  35. // Example:
  36. // // Tet mesh in (V,T,F)
  37. // faces_first(V,F,IM);
  38. // T = T.unaryExpr(bind1st(mem_fun( static_cast<VectorXi::Scalar&
  39. // (VectorXi::*)(VectorXi::Index)>(&VectorXi::operator())),
  40. // &IM)).eval();
  41. template <typename MatV, typename MatF, typename VecI>
  42. IGL_INLINE void faces_first(
  43. const MatV & V,
  44. const MatF & F,
  45. MatV & RV,
  46. MatF & RF,
  47. VecI & IM);
  48. // Virtual "in place" wrapper
  49. template <typename MatV, typename MatF, typename VecI>
  50. IGL_INLINE void faces_first(
  51. MatV & V,
  52. MatF & F,
  53. VecI & IM);
  54. }
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "faces_first.cpp"
  57. #endif
  58. #endif