point_areas.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2018 Gavin Barill <gavinpcb@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_AREAS_H
  9. #define IGL_POINT_AREAS_H
  10. #include "../../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. namespace copyleft
  15. {
  16. namespace cgal
  17. {
  18. // Given a 3D set of points P, each with a list of k-nearest-neighbours,
  19. // estimate the geodesic voronoi area associated with each point.
  20. //
  21. // The k nearest neighbours may be known from running igl::knn_octree on
  22. // the output data from igl::octree. We reccomend using a k value
  23. // between 15 and 20 inclusive for accurate area estimation.
  24. //
  25. // N is used filter the neighbours, to ensure area estimation only occurs
  26. // using neighbors that are on the same side of the surface (ie for thin
  27. // sheets), as well as to solve the orientation ambiguity of the tangent
  28. // plane normal.
  29. //
  30. // Note: This function *should* be implemented by pre-filtering I, rather
  31. // than filtering in this function using N. In this case, the function
  32. // would only take P and I as input.
  33. //
  34. // Inputs:
  35. // P #P by 3 list of point locations
  36. // I #P by k list of k-nearest-neighbor indices into P
  37. // N #P by 3 list of point normals
  38. // Outputs:
  39. // A #P list of estimated areas
  40. template <typename DerivedP, typename DerivedI, typename DerivedN,
  41. typename DerivedA>
  42. IGL_INLINE void point_areas(
  43. const Eigen::MatrixBase<DerivedP>& P,
  44. const Eigen::MatrixBase<DerivedI>& I,
  45. const Eigen::MatrixBase<DerivedN>& N,
  46. Eigen::PlainObjectBase<DerivedA> & A);
  47. // This version can be used to output the tangent plane normal at each
  48. // point. Since we area already fitting a plane to each point's neighbour
  49. // set, the tangent plane normals come "for free"
  50. //
  51. // Inputs:
  52. // P #P by 3 list of point locations
  53. // I #P by k list of k-nearest-neighbor indices into P
  54. // N #P by 3 list of point normals
  55. // Outputs:
  56. // A #P list of estimated areas
  57. // T #P by 3 list of tangent plane normals for each point
  58. template <typename DerivedP, typename DerivedI, typename DerivedN,
  59. typename DerivedA, typename DerivedT>
  60. IGL_INLINE void point_areas(
  61. const Eigen::MatrixBase<DerivedP>& P,
  62. const Eigen::MatrixBase<DerivedI>& I,
  63. const Eigen::MatrixBase<DerivedN>& N,
  64. Eigen::PlainObjectBase<DerivedA> & A,
  65. Eigen::PlainObjectBase<DerivedT> & T);
  66. }
  67. }
  68. }
  69. #ifndef IGL_STATIC_LIBRARY
  70. # include "point_areas.cpp"
  71. #endif
  72. #endif