in_element.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 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_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. // templates:
  20. // DIM dimension of vertices in V (# of columns)
  21. // Inputs:
  22. // V #V by dim list of mesh vertex positions.
  23. // Ele #Ele by dim+1 list of mesh indices into #V.
  24. // Q #Q by dim list of query point positions
  25. // aabb axis-aligned bounding box tree object (see AABB.h)
  26. // Outputs:
  27. // I #Q list of indices into Ele of first containing element (-1 means no
  28. // containing element)
  29. template <typename DerivedV, typename DerivedQ, int DIM>
  30. IGL_INLINE void in_element(
  31. const Eigen::PlainObjectBase<DerivedV> & V,
  32. const Eigen::MatrixXi & Ele,
  33. const Eigen::PlainObjectBase<DerivedQ> & Q,
  34. const AABB<DerivedV,DIM> & aabb,
  35. Eigen::VectorXi & I);
  36. // Outputs:
  37. // I #Q by #Ele sparse matrix revealing whether each element contains each
  38. // point: I(q,e) means point q is in element e
  39. template <typename DerivedV, typename DerivedQ, int DIM, typename Scalar>
  40. IGL_INLINE void in_element(
  41. const Eigen::PlainObjectBase<DerivedV> & V,
  42. const Eigen::MatrixXi & Ele,
  43. const Eigen::PlainObjectBase<DerivedQ> & Q,
  44. const AABB<DerivedV,DIM> & aabb,
  45. Eigen::SparseMatrix<Scalar> & I);
  46. };
  47. #ifndef IGL_STATIC_LIBRARY
  48. #include "in_element.cpp"
  49. #endif
  50. #endif