remove_unreferenced.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. //
  9. // remove_unreferenced.h
  10. // Preview3D
  11. //
  12. // Created by Daniele Panozzo on 17/11/11.
  13. #ifndef IGL_REMOVE_UNREFERENCED_H
  14. #define IGL_REMOVE_UNREFERENCED_H
  15. #include "igl_inline.h"
  16. #include <Eigen/Core>
  17. namespace igl
  18. {
  19. /// Remove unreferenced vertices from V, updating F accordingly
  20. ///
  21. /// @param[in] V #V by dim list of mesh vertex positions
  22. /// @param[in] F #F by ss list of simplices (Values of -1 are quitely skipped)
  23. /// @param[out] NV #NV by dim list of mesh vertex positions
  24. /// @param[out] NF #NF by ss list of simplices
  25. /// @param[out] I #V by 1 list of indices such that: NF = IM(F) and NT = IM(T)
  26. /// and V(find(IM<=size(NV,1)),:) = NV
  27. /// @param[out] J #NV by 1 list, such that NV = V(J,:)
  28. template <
  29. typename DerivedV,
  30. typename DerivedF,
  31. typename DerivedNV,
  32. typename DerivedNF,
  33. typename DerivedI,
  34. typename DerivedJ>
  35. IGL_INLINE void remove_unreferenced(
  36. const Eigen::MatrixBase<DerivedV> &V,
  37. const Eigen::MatrixBase<DerivedF> &F,
  38. Eigen::PlainObjectBase<DerivedNV> &NV,
  39. Eigen::PlainObjectBase<DerivedNF> &NF,
  40. Eigen::PlainObjectBase<DerivedI> &I,
  41. Eigen::PlainObjectBase<DerivedJ> &J);
  42. /// \overload
  43. template <
  44. typename DerivedV,
  45. typename DerivedF,
  46. typename DerivedNV,
  47. typename DerivedNF,
  48. typename DerivedI>
  49. IGL_INLINE void remove_unreferenced(
  50. const Eigen::MatrixBase<DerivedV> &V,
  51. const Eigen::MatrixBase<DerivedF> &F,
  52. Eigen::PlainObjectBase<DerivedNV> &NV,
  53. Eigen::PlainObjectBase<DerivedNF> &NF,
  54. Eigen::PlainObjectBase<DerivedI> &I);
  55. /// \overload
  56. /// @param[in] n number of vertices (possibly greater than F.maxCoeff()+1)
  57. template <
  58. typename DerivedF,
  59. typename DerivedI,
  60. typename DerivedJ>
  61. IGL_INLINE void remove_unreferenced(
  62. const size_t n,
  63. const Eigen::MatrixBase<DerivedF> &F,
  64. Eigen::PlainObjectBase<DerivedI> &I,
  65. Eigen::PlainObjectBase<DerivedJ> &J);
  66. }
  67. #ifndef IGL_STATIC_LIBRARY
  68. # include "remove_unreferenced.cpp"
  69. #endif
  70. #endif