cut_mesh.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Olga Diamanti <olga.diam@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_CUT_MESH
  9. #define IGL_CUT_MESH
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. // Given a mesh and a list of edges that are to be cut, the function
  16. // generates a new disk-topology mesh that has the cuts at its boundary.
  17. //
  18. // Todo: this combinatorial operation should not depend on the vertex
  19. // positions V.
  20. //
  21. // Known issues: Assumes mesh is edge-manifold.
  22. //
  23. // Inputs:
  24. // V #V by 3 list of the vertex positions
  25. // F #F by 3 list of the faces (must be triangles)
  26. // VF #V list of lists of incident faces (adjacency list), e.g. as
  27. // returned by igl::vertex_triangle_adjacency
  28. // VFi #V list of lists of index of incidence within incident faces listed
  29. // in VF, e.g. as returned by igl::vertex_triangle_adjacency
  30. // TT #F by 3 triangle to triangle adjacent matrix (e.g. computed via
  31. // igl:triangle_triangle_adjacency)
  32. // TTi #F by 3 adjacent matrix, the element i,j is the id of edge of the
  33. // triangle TT(i,j) that is adjacent with triangle i (e.g. computed via
  34. // igl:triangle_triangle_adjacency)
  35. // V_border #V by 1 list of booleans, indicating if the corresponging
  36. // vertex is at the mesh boundary, e.g. as returned by
  37. // igl::is_border_vertex
  38. // cuts #F by 3 list of boolean flags, indicating the edges that need to
  39. // be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  40. // Outputs:
  41. // Vcut #V by 3 list of the vertex positions of the cut mesh. This matrix
  42. // will be similar to the original vertices except some rows will be
  43. // duplicated.
  44. // Fcut #F by 3 list of the faces of the cut mesh(must be triangles). This
  45. // matrix will be similar to the original face matrix except some indices
  46. // will be redirected to point to the newly duplicated vertices.
  47. //
  48. template <
  49. typename DerivedV,
  50. typename DerivedF,
  51. typename VFType,
  52. typename DerivedTT,
  53. typename DerivedC>
  54. IGL_INLINE void cut_mesh(
  55. const Eigen::PlainObjectBase<DerivedV> &V,
  56. const Eigen::PlainObjectBase<DerivedF> &F,
  57. const std::vector<std::vector<VFType> >& VF,
  58. const std::vector<std::vector<VFType> >& VFi,
  59. const Eigen::PlainObjectBase<DerivedTT>& TT,
  60. const Eigen::PlainObjectBase<DerivedTT>& TTi,
  61. const std::vector<bool> &V_border,
  62. const Eigen::PlainObjectBase<DerivedC> &cuts,
  63. Eigen::PlainObjectBase<DerivedV> &Vcut,
  64. Eigen::PlainObjectBase<DerivedF> &Fcut);
  65. //Wrapper of the above with only vertices and faces as mesh input
  66. template <typename DerivedV, typename DerivedF, typename DerivedC>
  67. IGL_INLINE void cut_mesh(
  68. const Eigen::PlainObjectBase<DerivedV> &V,
  69. const Eigen::PlainObjectBase<DerivedF> &F,
  70. const Eigen::PlainObjectBase<DerivedC> &cuts,
  71. Eigen::PlainObjectBase<DerivedV> &Vcut,
  72. Eigen::PlainObjectBase<DerivedF> &Fcut);
  73. };
  74. #ifndef IGL_STATIC_LIBRARY
  75. #include "cut_mesh.cpp"
  76. #endif
  77. #endif