delaunay_triangulation.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2022 Alec Jacobson <[email protected]>
  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. #include "delaunay_triangulation.h"
  9. #include "predicates.h"
  10. #include "orient2d.h"
  11. #include "incircle.h"
  12. #include "../delaunay_triangulation.h"
  13. template<
  14. typename DerivedV,
  15. typename DerivedF
  16. >
  17. IGL_INLINE void igl::predicates::delaunay_triangulation(
  18. const Eigen::MatrixBase<DerivedV>& V,
  19. Eigen::PlainObjectBase<DerivedF>& F)
  20. {
  21. const auto orient2d =
  22. [](const double *pa, const double *pb, const double *pc)
  23. {
  24. Eigen::Vector2d pav; pav << pa[0], pa[1];
  25. Eigen::Vector2d pbv; pbv << pb[0], pb[1];
  26. Eigen::Vector2d pcv; pcv << pc[0], pc[1];
  27. return int(igl::predicates::orient2d(pav, pbv, pcv));
  28. };
  29. const auto incircle =
  30. [](const double *pa, const double *pb, const double *pc, const double *pd)
  31. {
  32. Eigen::Vector2d pav; pav << pa[0], pa[1];
  33. Eigen::Vector2d pbv; pbv << pb[0], pb[1];
  34. Eigen::Vector2d pcv; pcv << pc[0], pc[1];
  35. Eigen::Vector2d pdv; pdv << pd[0], pd[1];
  36. return int(igl::predicates::incircle(pav, pbv, pcv, pdv));
  37. };
  38. igl::delaunay_triangulation(V, orient2d, incircle, F);
  39. }
  40. #ifdef STATIC_LIBRARY
  41. template igl::predicates::delaunay_triangulation<Eigen::MatrixXd,Eigen::MatrixXi>(const Eigen::MatrixXd &, Eigen::MatrixXi &);
  42. #endif