remove_unreferenced.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. //
  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. // Input:
  22. // V #V by dim list of mesh vertex positions
  23. // F #F by ss list of simplices (Values of -1 are quitely skipped)
  24. // Outputs:
  25. // NV #NV by dim list of mesh vertex positions
  26. // NF #NF by ss list of simplices
  27. // I #V by 1 list of indices such that: NF = IM(F) and NT = IM(T)
  28. // and V(find(IM<=size(NV,1)),:) = NV
  29. // J #NV by 1 list, such that NV = V(J,:)
  30. //
  31. //
  32. template <
  33. typename DerivedV,
  34. typename DerivedF,
  35. typename DerivedNV,
  36. typename DerivedNF,
  37. typename DerivedI>
  38. IGL_INLINE void remove_unreferenced(
  39. const Eigen::MatrixBase<DerivedV> &V,
  40. const Eigen::MatrixBase<DerivedF> &F,
  41. Eigen::PlainObjectBase<DerivedNV> &NV,
  42. Eigen::PlainObjectBase<DerivedNF> &NF,
  43. Eigen::PlainObjectBase<DerivedI> &I);
  44. template <
  45. typename DerivedV,
  46. typename DerivedF,
  47. typename DerivedNV,
  48. typename DerivedNF,
  49. typename DerivedI,
  50. typename DerivedJ>
  51. IGL_INLINE void remove_unreferenced(
  52. const Eigen::MatrixBase<DerivedV> &V,
  53. const Eigen::MatrixBase<DerivedF> &F,
  54. Eigen::PlainObjectBase<DerivedNV> &NV,
  55. Eigen::PlainObjectBase<DerivedNF> &NF,
  56. Eigen::PlainObjectBase<DerivedI> &I,
  57. Eigen::PlainObjectBase<DerivedJ> &J);
  58. // Inputs:
  59. // n number of vertices (possibly greater than F.maxCoeff()+1)
  60. // F #F by ss list of simplices
  61. // Outputs:
  62. // IM #V by 1 list of indices such that: NF = IM(F) and NT = IM(T)
  63. // and V(find(IM<=size(NV,1)),:) = NV
  64. // J #RV by 1 list, such that RV = V(J,:)
  65. //
  66. template <
  67. typename DerivedF,
  68. typename DerivedI,
  69. typename DerivedJ>
  70. IGL_INLINE void remove_unreferenced(
  71. const size_t n,
  72. const Eigen::MatrixBase<DerivedF> &F,
  73. Eigen::PlainObjectBase<DerivedI> &I,
  74. Eigen::PlainObjectBase<DerivedJ> &J);
  75. }
  76. #ifndef IGL_STATIC_LIBRARY
  77. # include "remove_unreferenced.cpp"
  78. #endif
  79. #endif