selfintersect.h 1.8 KB

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