point_mesh_squared_distance.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_POINT_MESH_SQUARED_DISTANCE_H
  9. #define IGL_POINT_MESH_SQUARED_DISTANCE_H
  10. #include <igl/igl_inline.h>
  11. #include <Eigen/Core>
  12. #include "CGAL_includes.hpp"
  13. namespace igl
  14. {
  15. // Compute distances from a set of points P to a triangle mesh (V,F)
  16. //
  17. // Templates:
  18. // Kernal CGAL computation and construction kernel (e.g.
  19. // CGAL::Simple_cartesian<double>)
  20. // Inputs:
  21. // P #P by 3 list of query point positions
  22. // V #V by 3 list of vertex positions
  23. // F #F by 3 list of triangle indices
  24. // Outputs:
  25. // sqrD #P list of smallest squared distances
  26. // I #P list of facet indices corresponding to smallest distances
  27. // C #P by 3 list of closest points
  28. //
  29. // Known bugs: This only computes distances to triangles. So unreferenced
  30. // vertices are ignored.
  31. template <typename Kernel>
  32. IGL_INLINE void point_mesh_squared_distance(
  33. const Eigen::MatrixXd & P,
  34. const Eigen::MatrixXd & V,
  35. const Eigen::MatrixXi & F,
  36. Eigen::VectorXd & sqrD,
  37. Eigen::VectorXi & I,
  38. Eigen::MatrixXd & C);
  39. }
  40. #ifndef IGL_STATIC_LIBRARY
  41. # include "point_mesh_squared_distance.cpp"
  42. #endif
  43. #endif