cdt.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_CDT_H
  9. #define IGL_CDT_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <string>
  13. #ifndef TETLIBRARY
  14. #define TETLIBRARY
  15. #endif
  16. #include "tetgen.h" // Defined REAL
  17. namespace igl
  18. {
  19. struct CDTParam
  20. {
  21. // Tetgen can compute mesh of convex hull of input (i.e. "c") but often
  22. // chokes. One workaround is to force it to mesh the entire bounding box.
  23. // {false}
  24. bool use_bounding_box = false;
  25. // Scale the bounding box a bit so that vertices near it do not give tetgen
  26. // problems. {1.01}
  27. double bounding_box_scale = 1.01;
  28. // Flags to tetgen. Do not include the "c" flag here! {"Y"}
  29. std::string flags = "Y";
  30. };
  31. // Create a constrained delaunay tesselation containing convex hull of the
  32. // given **non-selfintersecting** mesh.
  33. //
  34. // Inputs:
  35. // V #V by 3 list of input mesh vertices
  36. // F #F by 3 list of input mesh facets
  37. // param see above
  38. // TV #TV by 3 list of output mesh vertices (V come first)
  39. // TT #TT by 3 list of tetrahedra indices into TV.
  40. // TF #TF by 3 list of facets from F potentially subdivided.
  41. //
  42. template <
  43. typename DerivedV,
  44. typename DerivedF,
  45. typename DerivedTV,
  46. typename DerivedTT,
  47. typename DerivedTF>
  48. IGL_INLINE bool cdt(
  49. const Eigen::PlainObjectBase<DerivedV>& V,
  50. const Eigen::PlainObjectBase<DerivedF>& F,
  51. const igl::CDTParam & param,
  52. Eigen::PlainObjectBase<DerivedTV>& TV,
  53. Eigen::PlainObjectBase<DerivedTT>& TT,
  54. Eigen::PlainObjectBase<DerivedTF>& TF);
  55. }
  56. #ifndef IGL_STATIC_LIBRARY
  57. # include "cdt.cpp"
  58. #endif
  59. #endif