cdt.h 2.0 KB

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