points_inside_component.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS
  9. #define IGL_COPYLEFT_CGAL_POINTS_INSIDE_COMPONENTS
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl {
  14. namespace copyleft
  15. {
  16. namespace cgal {
  17. // Determine if queries points P are inside of connected facet component
  18. // (V, F, I), where I indicates a subset of facets that forms the
  19. // component.
  20. //
  21. // Precondition:
  22. // The input mesh must be a closed, self-intersection free,
  23. // non-degenerated surface. Queries points must be either inside or
  24. // outside of the mesh (i.e. not on the surface of the mesh).
  25. //
  26. // Inputs:
  27. // V #V by 3 array of vertex positions.
  28. // F #F by 3 array of triangles.
  29. // I #I list of triangle indices to consider.
  30. // P #P by 3 array of query points.
  31. //
  32. // Outputs:
  33. // inside #P list of booleans that is true iff the corresponding
  34. // query point is inside of the mesh.
  35. template<
  36. typename DerivedV,
  37. typename DerivedF,
  38. typename DerivedI,
  39. typename DerivedP,
  40. typename DerivedB>
  41. IGL_INLINE void points_inside_component(
  42. const Eigen::PlainObjectBase<DerivedV>& V,
  43. const Eigen::PlainObjectBase<DerivedF>& F,
  44. const Eigen::PlainObjectBase<DerivedI>& I,
  45. const Eigen::PlainObjectBase<DerivedP>& P,
  46. Eigen::PlainObjectBase<DerivedB>& inside);
  47. // Determine if query points P is inside of the mesh (V, F).
  48. // See above for precondition and I/O specs.
  49. template<
  50. typename DerivedV,
  51. typename DerivedF,
  52. typename DerivedP,
  53. typename DerivedB>
  54. IGL_INLINE void points_inside_component(
  55. const Eigen::PlainObjectBase<DerivedV>& V,
  56. const Eigen::PlainObjectBase<DerivedF>& F,
  57. const Eigen::PlainObjectBase<DerivedP>& P,
  58. Eigen::PlainObjectBase<DerivedB>& inside);
  59. }
  60. }
  61. }
  62. #ifndef IGL_STATIC_LIBRARY
  63. #include "points_inside_component.cpp"
  64. #endif
  65. #endif