signed_distance.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_SIGNED_DISTANCE_H
  9. #define IGL_SIGNED_DISTANCE_H
  10. #include <igl/igl_inline.h>
  11. #include <igl/WindingNumberAABB.h>
  12. #include <Eigen/Core>
  13. #include <vector>
  14. #include "CGAL_includes.hpp"
  15. namespace igl
  16. {
  17. enum SignedDistanceType
  18. {
  19. SIGNED_DISTANCE_TYPE_PSEUDONORMAL = 0,
  20. SIGNED_DISTANCE_TYPE_WINDING_NUMBER = 1,
  21. SIGNED_DISTANCE_TYPE_DEFAULT = 2,
  22. NUM_SIGNED_DISTANCE_TYPE = 3
  23. };
  24. // Computes signed distance to mesh
  25. //
  26. // Templates:
  27. // Kernal CGAL computation and construction kernel (e.g.
  28. // CGAL::Simple_cartesian<double>)
  29. // Inputs:
  30. // tree AABB acceleration tree (see point_mesh_squared_distance.h)
  31. // T #F list of CGAL triangles (see point_mesh_squared_distance.h)
  32. // F #F by 3 list of triangle indices
  33. // FN #F by 3 list of triangle normals
  34. // VN #V by 3 list of vertex normals (ANGLE WEIGHTING)
  35. // EN #E by 3 list of edge normals (UNIFORM WEIGHTING)
  36. // EMAP #F*3 mapping edges in F to E
  37. // q Query point
  38. // Returns signed distance to mesh
  39. //
  40. template <typename Kernel>
  41. IGL_INLINE typename Kernel::FT signed_distance_pseudonormal(
  42. const CGAL::AABB_tree<
  43. CGAL::AABB_traits<Kernel,
  44. CGAL::AABB_triangle_primitive<Kernel,
  45. typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
  46. >
  47. >
  48. > & tree,
  49. const std::vector<CGAL::Triangle_3<Kernel> > & T,
  50. const Eigen::MatrixXi & F,
  51. const Eigen::MatrixXd & FN,
  52. const Eigen::MatrixXd & VN,
  53. const Eigen::MatrixXd & EN,
  54. const Eigen::VectorXi & EMAP,
  55. const typename Kernel::Point_3 & q);
  56. // Inputs:
  57. // tree AABB acceleration tree (see point_mesh_squared_distance.h)
  58. // hier Winding number evaluation hierarchy
  59. // q Query point
  60. // Returns signed distance to mesh
  61. template <typename Kernel>
  62. IGL_INLINE typename Kernel::FT signed_distance_winding_number(
  63. const CGAL::AABB_tree<
  64. CGAL::AABB_traits<Kernel,
  65. CGAL::AABB_triangle_primitive<Kernel,
  66. typename std::vector<CGAL::Triangle_3<Kernel> >::iterator
  67. >
  68. >
  69. > & tree,
  70. const igl::WindingNumberAABB<Eigen::Vector3d> & hier,
  71. const typename Kernel::Point_3 & q);
  72. }
  73. #ifndef IGL_STATIC_LIBRARY
  74. # include "signed_distance.cpp"
  75. #endif
  76. #endif