hausdorff.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "hausdorff.h"
  2. #include "../../hausdorff.h"
  3. #include <functional>
  4. template <
  5. typename DerivedV,
  6. typename Kernel,
  7. typename Scalar>
  8. IGL_INLINE void igl::copyleft::cgal::hausdorff(
  9. const Eigen::MatrixBase<DerivedV>& V,
  10. const CGAL::AABB_tree<
  11. CGAL::AABB_traits<Kernel,
  12. CGAL::AABB_triangle_primitive<Kernel,
  13. typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
  14. >
  15. >
  16. > & treeB,
  17. const std::vector<CGAL::Triangle_3<Kernel> > & /*TB*/,
  18. Scalar & l,
  19. Scalar & u)
  20. {
  21. // Not sure why using `auto` here doesn't work with the `hausdorff` function
  22. // parameter but explicitly naming the type does...
  23. const std::function<double(const double &,const double &,const double &)>
  24. dist_to_B = [&treeB](
  25. const double & x, const double & y, const double & z)->double
  26. {
  27. CGAL::Point_3<Kernel> query(x,y,z);
  28. typename CGAL::AABB_tree<
  29. CGAL::AABB_traits<Kernel,
  30. CGAL::AABB_triangle_primitive<Kernel,
  31. typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
  32. >
  33. >
  34. >::Point_and_primitive_id pp = treeB.closest_point_and_primitive(query);
  35. return std::sqrt((query-pp.first).squared_length());
  36. };
  37. return igl::hausdorff(V,dist_to_B,l,u);
  38. }