remove_duplicate_vertices.h 2.1 KB

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