hausdorff.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. }
  39. #ifdef IGL_STATIC_LIBRARY
  40. // Explicit template instantiation
  41. template void igl::copyleft::cgal::hausdorff<Eigen::Matrix<double, -1, -1, 0, -1, -1>, CGAL::Simple_cartesian<double>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Simple_cartesian<double>, CGAL::AABB_triangle_primitive<CGAL::Simple_cartesian<double>, std::vector<CGAL::Triangle_3<CGAL::Simple_cartesian<double> >, std::allocator<CGAL::Triangle_3<CGAL::Simple_cartesian<double> > > >::iterator, CGAL::Boolean_tag<false> >, CGAL::Default> > const&, std::vector<CGAL::Triangle_3<CGAL::Simple_cartesian<double> >, std::allocator<CGAL::Triangle_3<CGAL::Simple_cartesian<double> > > > const&, double&, double&);
  42. #endif