ramer_douglas_peucker.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef IGL_RAMER_DOUGLAS_PEUCKER_H
  2. #define IGL_RAMER_DOUGLAS_PEUCKER_H
  3. #include "igl_inline.h"
  4. #include <Eigen/Core>
  5. namespace igl
  6. {
  7. /// Ramer-Douglas-Peucker piecewise-linear curve simplification.
  8. ///
  9. /// @param[in] P #P by dim ordered list of vertices along the curve
  10. /// @param[in] tol tolerance (maximal euclidean distance allowed between the new line
  11. /// and a vertex)
  12. /// @param[out] S #S by dim ordered list of points along the curve
  13. /// @param[out] J #S list of indices into P so that S = P(J,:)
  14. template <typename DerivedP, typename DerivedS, typename DerivedJ>
  15. IGL_INLINE void ramer_douglas_peucker(
  16. const Eigen::MatrixBase<DerivedP> & P,
  17. const typename DerivedP::Scalar tol,
  18. Eigen::PlainObjectBase<DerivedS> & S,
  19. Eigen::PlainObjectBase<DerivedJ> & J);
  20. /// \overload
  21. /// \brief Run Ramer-Douglas-Peucker curve simplification but keep track of
  22. /// where every point on the original curve maps to on the simplified curve.
  23. ///
  24. /// @param[out] Q #P by dim list of points mapping along simplified curve
  25. template <
  26. typename DerivedP,
  27. typename DerivedS,
  28. typename DerivedJ,
  29. typename DerivedQ>
  30. IGL_INLINE void ramer_douglas_peucker(
  31. const Eigen::MatrixBase<DerivedP> & P,
  32. const typename DerivedP::Scalar tol,
  33. Eigen::PlainObjectBase<DerivedS> & S,
  34. Eigen::PlainObjectBase<DerivedJ> & J,
  35. Eigen::PlainObjectBase<DerivedQ> & Q);
  36. }
  37. #ifndef IGL_STATIC_LIBRARY
  38. # include "ramer_douglas_peucker.cpp"
  39. #endif
  40. #endif