cut_mesh.h 3.1 KB

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