cut_mesh.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. // Inputs:
  22. // V #V by 3 list of the vertex positions
  23. // F #F by 3 list of the faces (must be triangles)
  24. // VF #V list of lists of incident faces (adjacency list), e.g. as
  25. // returned by igl::vertex_triangle_adjacency
  26. // VFi #V list of lists of index of incidence within incident faces listed
  27. // in VF, e.g. as returned by igl::vertex_triangle_adjacency
  28. // TT #F by 3 triangle to triangle adjacent matrix (e.g. computed via
  29. // igl:triangle_triangle_adjacency)
  30. // TTi #F by 3 adjacent matrix, the element i,j is the id of edge of the
  31. // triangle TT(i,j) that is adjacent with triangle i (e.g. computed via
  32. // igl:triangle_triangle_adjacency)
  33. // V_border #V by 1 list of booleans, indicating if the corresponging
  34. // vertex is at the mesh boundary, e.g. as returned by
  35. // igl::is_border_vertex
  36. // cuts #F by 3 list of boolean flags, indicating the edges that need to
  37. // be cut (has 1 at the face edges that are to be cut, 0 otherwise)
  38. // Outputs:
  39. // Vcut #V by 3 list of the vertex positions of the cut mesh. This matrix
  40. // will be similar to the original vertices except some rows will be
  41. // duplicated.
  42. // Fcut #F by 3 list of the faces of the cut mesh(must be triangles). This
  43. // matrix will be similar to the original face matrix except some indices
  44. // will be redirected to point to the newly duplicated vertices.
  45. //
  46. template <
  47. typename DerivedV,
  48. typename DerivedF,
  49. typename VFType,
  50. typename DerivedTT,
  51. typename DerivedC>
  52. IGL_INLINE void cut_mesh(
  53. const Eigen::PlainObjectBase<DerivedV> &V,
  54. const Eigen::PlainObjectBase<DerivedF> &F,
  55. const std::vector<std::vector<VFType> >& VF,
  56. const std::vector<std::vector<VFType> >& VFi,
  57. const Eigen::PlainObjectBase<DerivedTT>& TT,
  58. const Eigen::PlainObjectBase<DerivedTT>& TTi,
  59. const std::vector<bool> &V_border,
  60. const Eigen::PlainObjectBase<DerivedC> &cuts,
  61. Eigen::PlainObjectBase<DerivedV> &Vcut,
  62. Eigen::PlainObjectBase<DerivedF> &Fcut);
  63. //Wrapper of the above with only vertices and faces as mesh input
  64. template <typename DerivedV, typename DerivedF, typename DerivedC>
  65. IGL_INLINE void cut_mesh(
  66. const Eigen::PlainObjectBase<DerivedV> &V,
  67. const Eigen::PlainObjectBase<DerivedF> &F,
  68. const Eigen::PlainObjectBase<DerivedC> &cuts,
  69. Eigen::PlainObjectBase<DerivedV> &Vcut,
  70. Eigen::PlainObjectBase<DerivedF> &Fcut);
  71. };
  72. #ifndef IGL_STATIC_LIBRARY
  73. #include "cut_mesh.cpp"
  74. #endif
  75. #endif