cut_mesh.h 3.6 KB

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