selfintersect.h 1.7 KB

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