outer_element.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingan 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_OUTER_ELEMENT_H
  9. #define IGL_OUTER_ELEMENT_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Find a vertex that is reachable from infinite without crossing any faces.
  15. // Such vertex is called "outer vertex."
  16. //
  17. // Precondition: The input mesh must have all self-intersection resolved and
  18. // no duplicated vertices. See cgal::remesh_self_intersections.h for how to
  19. // obtain such input.
  20. //
  21. // Inputs:
  22. // V #V by 3 list of vertex positions
  23. // F #F by 3 list of triangle indices into V
  24. // I #I list of facets to consider
  25. // Outputs:
  26. // v_index index of outer vertex
  27. // A #A list of facets incident to the outer vertex
  28. template <
  29. typename DerivedV,
  30. typename DerivedF,
  31. typename DerivedI,
  32. typename IndexType,
  33. typename DerivedA
  34. >
  35. IGL_INLINE void outer_vertex(
  36. const Eigen::PlainObjectBase<DerivedV> & V,
  37. const Eigen::PlainObjectBase<DerivedF> & F,
  38. const Eigen::PlainObjectBase<DerivedI> & I,
  39. IndexType & v_index,
  40. Eigen::PlainObjectBase<DerivedA> & A);
  41. // Find an edge that is reachable from infinity without crossing any faces.
  42. // Such edge is called "outer edge."
  43. //
  44. // Precondition: The input mesh must have all self-intersection resolved and
  45. // no duplicated vertices. The correctness of the output depends on the fact
  46. // that there is no edge overlap. See cgal::remesh_self_intersections.h for
  47. // how to obtain such input.
  48. //
  49. // Inputs:
  50. // V #V by 3 list of vertex positions
  51. // F #F by 3 list of triangle indices into V
  52. // I #I list of facets to consider
  53. // Outputs:
  54. // v1 index of the first end point of outer edge
  55. // v2 index of the second end point of outer edge
  56. // A #A list of facets incident to the outer edge
  57. template<
  58. typename DerivedV,
  59. typename DerivedF,
  60. typename DerivedI,
  61. typename IndexType,
  62. typename DerivedA
  63. >
  64. IGL_INLINE void outer_edge(
  65. const Eigen::PlainObjectBase<DerivedV> & V,
  66. const Eigen::PlainObjectBase<DerivedF> & F,
  67. const Eigen::PlainObjectBase<DerivedI> & I,
  68. IndexType & v1,
  69. IndexType & v2,
  70. Eigen::PlainObjectBase<DerivedA> & A);
  71. // Find a facet that is reachable from infinity without crossing any faces.
  72. // Such facet is called "outer facet."
  73. //
  74. // Precondition: The input mesh must have all self-intersection resolved. I.e
  75. // there is no duplicated vertices, no overlapping edge and no intersecting
  76. // faces (the only exception is there could be topologically duplicated faces).
  77. // See cgal::remesh_self_intersections.h for how to obtain such input.
  78. //
  79. // Inputs:
  80. // V #V by 3 list of vertex positions
  81. // F #F by 3 list of triangle indices into V
  82. // N #N by 3 list of face normals
  83. // I #I list of facets to consider
  84. // Outputs:
  85. // f Index of the outer facet.
  86. // flipped true iff the normal of f points inwards.
  87. template<
  88. typename DerivedV,
  89. typename DerivedF,
  90. typename DerivedN,
  91. typename DerivedI,
  92. typename IndexType
  93. >
  94. IGL_INLINE void outer_facet(
  95. const Eigen::PlainObjectBase<DerivedV> & V,
  96. const Eigen::PlainObjectBase<DerivedF> & F,
  97. const Eigen::PlainObjectBase<DerivedN> & N,
  98. const Eigen::PlainObjectBase<DerivedI> & I,
  99. IndexType & f,
  100. bool & flipped);
  101. }
  102. #ifndef IGL_STATIC_LIBRARY
  103. # include "outer_element.cpp"
  104. #endif
  105. #endif