component_inside_component.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 COMONENT_INSIDE_COMPONENT
  9. #define COMONENT_INSIDE_COMPONENT
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl {
  14. namespace cgal {
  15. // Determine if connected facet component (V1, F1, I1) is inside of
  16. // connected facet component (V2, F2, I2).
  17. //
  18. // Precondition:
  19. // Both components must represent closed, self-intersection free,
  20. // non-degenerated surfaces that are the boundary of 3D volumes. In
  21. // addition, (V1, F1, I1) must not intersect with (V2, F2, I2).
  22. //
  23. // Inputs:
  24. // V1 #V1 by 3 list of vertex position of mesh 1
  25. // F1 #F1 by 3 list of triangles indices into V1
  26. // I1 #I1 list of indices into F1, indicate the facets of component
  27. // V2 #V2 by 3 list of vertex position of mesh 2
  28. // F2 #F2 by 3 list of triangles indices into V2
  29. // I2 #I2 list of indices into F2, indicate the facets of component
  30. //
  31. // Outputs:
  32. // return true iff (V1, F1, I1) is entirely inside of (V2, F2, I2).
  33. template<typename DerivedV, typename DerivedF, typename DerivedI>
  34. IGL_INLINE bool component_inside_component(
  35. const Eigen::PlainObjectBase<DerivedV>& V1,
  36. const Eigen::PlainObjectBase<DerivedF>& F1,
  37. const Eigen::PlainObjectBase<DerivedI>& I1,
  38. const Eigen::PlainObjectBase<DerivedV>& V2,
  39. const Eigen::PlainObjectBase<DerivedF>& F2,
  40. const Eigen::PlainObjectBase<DerivedI>& I2);
  41. // Determine if mesh (V1, F1) is inside of mesh (V2, F2).
  42. //
  43. // Precondition:
  44. // Both meshes must be closed, self-intersection free, non-degenerated
  45. // surfaces that are the boundary of 3D volumes. They should not
  46. // intersect each other.
  47. //
  48. // Inputs:
  49. // V1 #V1 by 3 list of vertex position of mesh 1
  50. // F1 #F1 by 3 list of triangles indices into V1
  51. // V2 #V2 by 3 list of vertex position of mesh 2
  52. // F2 #F2 by 3 list of triangles indices into V2
  53. //
  54. // Outputs:
  55. // return true iff (V1, F1) is entirely inside of (V2, F2).
  56. template<typename DerivedV, typename DerivedF>
  57. IGL_INLINE bool component_inside_component(
  58. const Eigen::PlainObjectBase<DerivedV>& V1,
  59. const Eigen::PlainObjectBase<DerivedF>& F1,
  60. const Eigen::PlainObjectBase<DerivedV>& V2,
  61. const Eigen::PlainObjectBase<DerivedF>& F2);
  62. }
  63. }
  64. #ifndef IGL_STATIC_LIBRARY
  65. #include "component_inside_component.cpp"
  66. #endif
  67. #endif