cut_mesh.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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, indicating the edges that need to
  23. /// be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  24. /// @param[out] I #V by 1 list of the map between Vn to original V index.
  25. template <typename DerivedV, typename DerivedF, typename DerivedC, typename DerivedI>
  26. IGL_INLINE void cut_mesh(
  27. Eigen::PlainObjectBase<DerivedV>& V,
  28. Eigen::PlainObjectBase<DerivedF>& F,
  29. const Eigen::MatrixBase<DerivedC>& cuts,
  30. Eigen::PlainObjectBase<DerivedI>& I
  31. );
  32. /// Given a mesh and a list of edges that are to be cut, the function
  33. /// generates a new disk-topology mesh that has the cuts at its boundary.
  34. ///
  35. ///
  36. /// \note Assumes mesh is edge-manifold.
  37. ///
  38. /// @param[in,out] V #V by 3 list of the vertex positions
  39. /// @param[in,out] F #F by 3 list of the faces
  40. /// @param[in,out] FF #F by #3 adjacent matrix, the element i,j is the id of the triangle
  41. /// adjacent to the j edge of triangle i
  42. /// @param[in,out] FFi #F by #3 adjacent matrix, the element i,j is the id of edge of the
  43. /// triangle TT(i,j) that is adjacent with triangle i
  44. /// @param[in] C #F by 3 list of boolean flags, indicating the edges that need to
  45. /// be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  46. /// @param[out] I #V by 1 list of the map between Vn to original V index.
  47. ///
  48. /// \see triangle_triangle_adjacency
  49. template <typename DerivedV, typename DerivedF, typename DerivedFF, typename DerivedFFi, typename DerivedC, typename DerivedI>
  50. IGL_INLINE void cut_mesh(
  51. Eigen::PlainObjectBase<DerivedV>& V,
  52. Eigen::PlainObjectBase<DerivedF>& F,
  53. Eigen::MatrixBase<DerivedFF>& FF,
  54. Eigen::MatrixBase<DerivedFFi>& FFi,
  55. const Eigen::MatrixBase<DerivedC>& C,
  56. Eigen::PlainObjectBase<DerivedI>& I
  57. );
  58. /// Given a mesh and a list of edges that are to be cut, the function
  59. /// generates a new disk-topology mesh that has the cuts at its boundary.
  60. ///
  61. ///
  62. /// \note Assumes mesh is edge-manifold.
  63. /// @param[in,out] V #V by 3 list of the vertex positions
  64. /// @param[in,out] F #F by 3 list of the faces
  65. /// @param[in] cuts #F by 3 list of boolean flags, indicating the edges that need to
  66. /// be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  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 <typename DerivedV, typename DerivedF, typename DerivedC, typename DerivedI>
  98. IGL_INLINE void cut_mesh(
  99. const Eigen::MatrixBase<DerivedV>& V,
  100. const Eigen::MatrixBase<DerivedF>& F,
  101. const Eigen::MatrixBase<DerivedC>& cuts,
  102. Eigen::PlainObjectBase<DerivedV>& Vn,
  103. Eigen::PlainObjectBase<DerivedF>& Fn,
  104. Eigen::PlainObjectBase<DerivedI>& I
  105. );
  106. }
  107. #ifndef IGL_STATIC_LIBRARY
  108. #include "cut_mesh.cpp"
  109. #endif
  110. #endif