cdt.h 2.1 KB

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