selfintersect.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Alec Jacobson <alecjacobson@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_SELFINTERSECT_H
  9. #define IGL_SELFINTERSECT_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Dense>
  12. #ifdef MEX
  13. # include <mex.h>
  14. # include <cassert>
  15. # undef assert
  16. # define assert( isOK ) ( (isOK) ? (void)0 : (void) mexErrMsgTxt(C_STR(__FILE__<<":"<<__LINE__<<": failed assertion `"<<#isOK<<"'"<<std::endl) ) )
  17. #endif
  18. namespace igl
  19. {
  20. // Optional Parameters
  21. // DetectOnly Only compute IF, leave VV and FF alone
  22. struct SelfintersectParam
  23. {
  24. bool detect_only;
  25. bool first_only;
  26. SelfintersectParam():detect_only(false),first_only(false){};
  27. };
  28. // Given a triangle mesh (V,F) compute a new mesh (VV,FF) which is the same as
  29. // (V,F) except that any self-intersecting triangles in (V,F) have been
  30. // subdivided (new vertices and face created) so that the self-intersection
  31. // contour lies exactly on edges in (VV,FF). New vertices will appear in
  32. // original faces or on original edges. New vertices on edges are "merged" only
  33. // across original faces sharing that edge. This means that if the input
  34. // triangle mesh is a closed manifold the output will be too.
  35. //
  36. // Inputs:
  37. // V #V by 3 list of vertex positions
  38. // F #F by 3 list of triangle indices into V
  39. // params struct of optional parameters
  40. // Outputs:
  41. // VV #VV by 3 list of vertex positions
  42. // FF #FF by 3 list of triangle indices into V
  43. // IF #intersecting face pairs by 2 list of intersecting face pairs,
  44. // indexing F
  45. IGL_INLINE void selfintersect(
  46. const Eigen::MatrixXd & V,
  47. const Eigen::MatrixXi & F,
  48. const SelfintersectParam & params,
  49. Eigen::MatrixXd & VV,
  50. Eigen::MatrixXi & FF,
  51. Eigen::MatrixXi & IF);
  52. }
  53. #ifdef IGL_HEADER_ONLY
  54. # include "selfintersect.cpp"
  55. #endif
  56. #endif