in_element.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <[email protected]>
  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_IN_ELEMENT_H
  9. #define IGL_IN_ELEMENT_H
  10. #include "igl_inline.h"
  11. #include "AABB.h"
  12. #include <Eigen/Core>
  13. #include <Eigen/Sparse>
  14. namespace igl
  15. {
  16. /// Determine whether each point in a list of points is in the elements of a
  17. /// mesh.
  18. ///
  19. /// @tparam DIM dimension of vertices in V (# of columns)
  20. /// @param[in] V #V by dim list of mesh vertex positions.
  21. /// @param[in] Ele #Ele by dim+1 list of mesh indices into #V.
  22. /// @param[in] Q #Q by dim list of query point positions
  23. /// @param[in] aabb axis-aligned bounding box tree object (see AABB.h)
  24. /// @param[out] I #Q list of indices into Ele of first containing element (-1 means no
  25. /// containing element)
  26. template <typename DerivedV, typename DerivedQ, int DIM>
  27. IGL_INLINE void in_element(
  28. const Eigen::MatrixBase<DerivedV> & V,
  29. const Eigen::MatrixXi & Ele,
  30. const Eigen::MatrixBase<DerivedQ> & Q,
  31. const AABB<DerivedV,DIM> & aabb,
  32. Eigen::VectorXi & I);
  33. /// \overload
  34. ///
  35. /// @param[out] I #Q by #Ele sparse matrix revealing whether each element contains each
  36. /// point: I(q,e) means point q is in element e
  37. template <typename DerivedV, typename DerivedQ, int DIM, typename Scalar>
  38. IGL_INLINE void in_element(
  39. const Eigen::MatrixBase<DerivedV> & V,
  40. const Eigen::MatrixXi & Ele,
  41. const Eigen::MatrixBase<DerivedQ> & Q,
  42. const AABB<DerivedV,DIM> & aabb,
  43. Eigen::SparseMatrix<Scalar> & I);
  44. };
  45. #ifndef IGL_STATIC_LIBRARY
  46. #include "in_element.cpp"
  47. #endif
  48. #endif