remove_unreferenced.h 2.4 KB

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