delaunay_triangulation.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Alec Jacobson
  4. // Copyright (C) 2016 Qingnan Zhou <qnzhou@gmail.com>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla Public License
  7. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  8. // obtain one at http://mozilla.org/MPL/2.0/.
  9. #include "delaunay_triangulation.h"
  10. #include "../../delaunay_triangulation.h"
  11. #include "orient2D.h"
  12. #include "incircle.h"
  13. template<
  14. typename DerivedV,
  15. typename DerivedF>
  16. IGL_INLINE void igl::copyleft::cgal::delaunay_triangulation(
  17. const Eigen::MatrixBase<DerivedV>& V,
  18. Eigen::PlainObjectBase<DerivedF>& F)
  19. {
  20. typedef typename DerivedV::Scalar Scalar;
  21. igl::delaunay_triangulation(V, orient2D<Scalar>, incircle<Scalar>, F);
  22. // This function really exists to test our igl::delaunay_triangulation
  23. //
  24. // It's currently much faster to call cgal's native Delaunay routine
  25. //
  26. //#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
  27. //#include <CGAL/Delaunay_triangulation_2.h>
  28. //#include <CGAL/Triangulation_vertex_base_with_info_2.h>
  29. //#include <vector>
  30. // const auto delaunay =
  31. // [&](const Eigen::MatrixXd & V,Eigen::MatrixXi & F)
  32. // {
  33. // typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
  34. // typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned int, Kernel> Vb;
  35. // typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
  36. // typedef CGAL::Delaunay_triangulation_2<Kernel, Tds> Delaunay;
  37. // typedef Kernel::Point_2 Point;
  38. // std::vector< std::pair<Point,unsigned> > points(V.rows());
  39. // for(int i = 0;i<V.rows();i++)
  40. // {
  41. // points[i] = std::make_pair(Point(V(i,0),V(i,1)),i);
  42. // }
  43. // Delaunay triangulation;
  44. // triangulation.insert(points.begin(),points.end());
  45. // F.resize(triangulation.number_of_faces(),3);
  46. // {
  47. // int j = 0;
  48. // for(Delaunay::Finite_faces_iterator fit = triangulation.finite_faces_begin();
  49. // fit != triangulation.finite_faces_end(); ++fit)
  50. // {
  51. // Delaunay::Face_handle face = fit;
  52. // F(j,0) = face->vertex(0)->info();
  53. // F(j,1) = face->vertex(1)->info();
  54. // F(j,2) = face->vertex(2)->info();
  55. // j++;
  56. // }
  57. // }
  58. // };
  59. }
  60. #ifdef IGL_STATIC_LIBRARY
  61. // Explicit template instantiation
  62. // generated by autoexplicit.sh
  63. template void igl::copyleft::cgal::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  64. #endif