cut_mesh.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2019 Hanxiao Shen <[email protected]>
  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_CUT_MESH_H
  9. #define IGL_CUT_MESH_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Given a mesh and a list of edges that are to be cut, the function
  15. /// generates a new disk-topology mesh that has the cuts at its boundary.
  16. ///
  17. ///
  18. /// \note Assumes mesh is edge-manifold.
  19. ///
  20. /// @param[in,out] V #V by 3 list of the vertex positions
  21. /// @param[in,out] F #F by 3 list of the faces
  22. /// @param[in] cuts #F by 3 list of boolean flags, so that cuts(i,j)
  23. /// indicates that the edge from F(i,j) to F(i,j+1%3) should be cut. A true
  24. /// value on either incident face will result in a cut.
  25. /// @param[out] I #V by 1 list of the map between Vn to original V index.
  26. ///
  27. /// \note `cuts` assumes the ordering convention from the array-based
  28. /// triangle_triangle_adjacency which is DIFFERENT from
  29. /// cotmatrix_entries,edge_lengths/etc.
  30. ///
  31. /// \bug `V.conservativeResize(…)` is called. So, although this appears to
  32. /// edit in place it's likely O(N) even if the number of cuts is O(1); the way
  33. /// the cuts are specified, just reading them is already O(N)
  34. template <typename DerivedV, typename DerivedF, typename DerivedC, typename DerivedI>
  35. IGL_INLINE void cut_mesh(
  36. Eigen::PlainObjectBase<DerivedV>& V,
  37. Eigen::PlainObjectBase<DerivedF>& F,
  38. const Eigen::MatrixBase<DerivedC>& cuts,
  39. Eigen::PlainObjectBase<DerivedI>& I
  40. );
  41. /// Given a mesh and a list of edges that are to be cut, the function
  42. /// generates a new disk-topology mesh that has the cuts at its boundary.
  43. ///
  44. ///
  45. /// \note Assumes mesh is edge-manifold.
  46. ///
  47. /// @param[in,out] FF #F by #3 adjacent matrix, the element i,j is the id of the triangle
  48. /// adjacent to the j edge of triangle i
  49. /// @param[in,out] FFi #F by #3 adjacent matrix, the element i,j is the id of edge of the
  50. /// triangle TT(i,j) that is adjacent with triangle i
  51. ///
  52. /// \see triangle_triangle_adjacency
  53. template <typename DerivedV, typename DerivedF, typename DerivedFF, typename DerivedFFi, typename DerivedC, typename DerivedI>
  54. IGL_INLINE void cut_mesh(
  55. Eigen::PlainObjectBase<DerivedV>& V,
  56. Eigen::PlainObjectBase<DerivedF>& F,
  57. Eigen::MatrixBase<DerivedFF>& FF,
  58. Eigen::MatrixBase<DerivedFFi>& FFi,
  59. const Eigen::MatrixBase<DerivedC>& C,
  60. Eigen::PlainObjectBase<DerivedI>& I
  61. );
  62. /// Given a mesh and a list of edges that are to be cut, the function
  63. /// generates a new disk-topology mesh that has the cuts at its boundary.
  64. ///
  65. ///
  66. /// \note Assumes mesh is edge-manifold.
  67. /// @param[out] Vn #V by 3 list of the vertex positions of the cut mesh. This matrix
  68. /// will be similar to the original vertices except some rows will be
  69. /// duplicated.
  70. /// @param[out] Fn #F by 3 list of the faces of the cut mesh(must be triangles). This
  71. /// matrix will be similar to the original face matrix except some indices
  72. /// will be redirected to point to the newly duplicated vertices.
  73. template <typename DerivedV, typename DerivedF, typename DerivedC>
  74. IGL_INLINE void cut_mesh(
  75. const Eigen::MatrixBase<DerivedV>& V,
  76. const Eigen::MatrixBase<DerivedF>& F,
  77. const Eigen::MatrixBase<DerivedC>& cuts,
  78. Eigen::PlainObjectBase<DerivedV>& Vn,
  79. Eigen::PlainObjectBase<DerivedF>& Fn
  80. );
  81. /// Given a mesh and a list of edges that are to be cut, the function
  82. /// generates a new disk-topology mesh that has the cuts at its boundary.
  83. ///
  84. ///
  85. /// \note Assumes mesh is edge-manifold.
  86. /// @param[in,out] V #V by 3 list of the vertex positions
  87. /// @param[in,out] F #F by 3 list of the faces
  88. /// @param[in] cuts #F by 3 list of boolean flags, indicating the edges that need to
  89. /// be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  90. /// @param[out] Vn #V by 3 list of the vertex positions of the cut mesh. This matrix
  91. /// will be similar to the original vertices except some rows will be
  92. /// duplicated.
  93. /// @param[out] Fn #F by 3 list of the faces of the cut mesh(must be triangles). This
  94. /// matrix will be similar to the original face matrix except some indices
  95. /// will be redirected to point to the newly duplicated vertices.
  96. /// @param[out] I #V by 1 list of the map between Vn to original V index.
  97. template <
  98. typename DerivedV,
  99. typename DerivedF,
  100. typename DerivedC,
  101. typename DerivedVn,
  102. typename DerivedFn,
  103. typename DerivedI>
  104. IGL_INLINE void cut_mesh(
  105. const Eigen::MatrixBase<DerivedV>& V,
  106. const Eigen::MatrixBase<DerivedF>& F,
  107. const Eigen::MatrixBase<DerivedC>& cuts,
  108. Eigen::PlainObjectBase<DerivedVn>& Vn,
  109. Eigen::PlainObjectBase<DerivedFn>& Fn,
  110. Eigen::PlainObjectBase<DerivedI>& I);
  111. }
  112. #ifndef IGL_STATIC_LIBRARY
  113. #include "cut_mesh.cpp"
  114. #endif
  115. #endif