cut_mesh.h 3.1 KB

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