remove_duplicate_vertices.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef IGL_REMOVE_DUPLICATE_VERTICES_H
  2. #define IGL_REMOVE_DUPLICATE_VERTICES_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Dense>
  5. namespace igl
  6. {
  7. // REMOVE_DUPLICATE_VERTICES Remove duplicate vertices upto a uniqueness
  8. // tolerance (epsilon)
  9. //
  10. // Inputs:
  11. // V #V by dim list of vertex positions
  12. // epsilon uniqueness tolerance (significant digit), can probably think of
  13. // this as a tolerance on L1 distance
  14. // Outputs:
  15. // SV #SV by dim new list of vertex positions
  16. // SVI #V by 1 list of indices so SV = V(SVI,:)
  17. // SVJ #SV by 1 list of indices so V = SV(SVJ,:)
  18. //
  19. // Example:
  20. // % Mesh in (V,F)
  21. // [SV,SVI,SVJ] = remove_duplicate_vertices(V,1e-7);
  22. // % remap faces
  23. // SF = SVJ(F);
  24. //
  25. template <
  26. typename DerivedV,
  27. typename DerivedSV,
  28. typename DerivedSVI,
  29. typename DerivedSVJ>
  30. IGL_INLINE void remove_duplicate_vertices(
  31. const Eigen::PlainObjectBase<DerivedV>& V,
  32. const double epsilon,
  33. Eigen::PlainObjectBase<DerivedSV>& SV,
  34. Eigen::PlainObjectBase<DerivedSVI>& SVI,
  35. Eigen::PlainObjectBase<DerivedSVJ>& SVJ);
  36. // Wrapper that also remaps given faces (F) --> (SF) so that SF index SV
  37. template <
  38. typename DerivedV,
  39. typename DerivedF,
  40. typename DerivedSV,
  41. typename DerivedSVI,
  42. typename DerivedSVJ,
  43. typename DerivedSF>
  44. IGL_INLINE void remove_duplicate_vertices(
  45. const Eigen::PlainObjectBase<DerivedV>& V,
  46. const Eigen::PlainObjectBase<DerivedF>& F,
  47. const double epsilon,
  48. Eigen::PlainObjectBase<DerivedSV>& SV,
  49. Eigen::PlainObjectBase<DerivedSVI>& SVI,
  50. Eigen::PlainObjectBase<DerivedSVJ>& SVJ,
  51. Eigen::PlainObjectBase<DerivedSF>& SF);
  52. }
  53. #ifdef IGL_HEADER_ONLY
  54. # include "remove_duplicate_vertices.cpp"
  55. #endif
  56. #endif