in_element.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. namespace igl
  14. {
  15. // Determine whether each point in a list of points is in the elements of a
  16. // mesh.
  17. //
  18. // templates:
  19. // DIM dimension of vertices in V (# of columns)
  20. // Inputs:
  21. // V #V by dim list of mesh vertex positions.
  22. // Ele #Ele by dim+1 list of mesh indices into #V.
  23. // Q #Q by dim list of query point positions
  24. // aabb axis-aligned bounding box tree object (see AABB.h)
  25. // Outputs:
  26. // I #Q list of indices into Ele of first containing element (-1 means no
  27. // containing element)
  28. template <typename DerivedV, typename DerivedQ, int DIM>
  29. IGL_INLINE void in_element(
  30. const Eigen::PlainObjectBase<DerivedV> & V,
  31. const Eigen::MatrixXi & Ele,
  32. const Eigen::PlainObjectBase<DerivedQ> & Q,
  33. const AABB<DerivedV,DIM> & aabb,
  34. Eigen::VectorXi & I);
  35. // Outputs:
  36. // I #Q by #Ele sparse matrix revealing whether each element contains each
  37. // point: I(q,e) means point q is in element e
  38. template <typename DerivedV, typename DerivedQ, int DIM, typename Scalar>
  39. IGL_INLINE void in_element(
  40. const Eigen::PlainObjectBase<DerivedV> & V,
  41. const Eigen::MatrixXi & Ele,
  42. const Eigen::PlainObjectBase<DerivedQ> & Q,
  43. const AABB<DerivedV,DIM> & aabb,
  44. Eigen::SparseMatrix<Scalar> & I);
  45. //
  46. // Example:
  47. // InElementAABB aabb;
  48. // aabb.init(V,Ele);
  49. };
  50. #ifndef IGL_STATIC_LIBRARY
  51. #include "in_element.cpp"
  52. #endif
  53. #endif