per_vertex_normals.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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_PER_VERTEX_NORMALS_H
  9. #define IGL_PER_VERTEX_NORMALS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. /// Weighting schemes for computing per-vertex normals
  15. ///
  16. /// \note It would be nice to support more or all of the methods here:
  17. /// "A comparison of algorithms for vertex normal computation"
  18. enum PerVertexNormalsWeightingType
  19. {
  20. /// Incident face normals have uniform influence on vertex normal
  21. PER_VERTEX_NORMALS_WEIGHTING_TYPE_UNIFORM = 0,
  22. /// Incident face normals are averaged weighted by area
  23. PER_VERTEX_NORMALS_WEIGHTING_TYPE_AREA = 1,
  24. /// Incident face normals are averaged weighted by incident angle of vertex
  25. PER_VERTEX_NORMALS_WEIGHTING_TYPE_ANGLE = 2,
  26. /// Area weights
  27. PER_VERTEX_NORMALS_WEIGHTING_TYPE_DEFAULT = 3,
  28. /// Total number of weighting types
  29. NUM_PER_VERTEX_NORMALS_WEIGHTING_TYPE = 4
  30. };
  31. /// Compute vertex normals via vertex position list, face list
  32. ///
  33. /// @param[in] V #V by 3 eigen Matrix of mesh vertex 3D positions
  34. /// @param[in] F #F by 3 eigen Matrix of face (triangle) indices
  35. /// @param[in] weighting Weighting type
  36. /// @param[out] N #V by 3 eigen Matrix of mesh vertex 3D normals
  37. template <
  38. typename DerivedV,
  39. typename DerivedF,
  40. typename DerivedN>
  41. IGL_INLINE void per_vertex_normals(
  42. const Eigen::MatrixBase<DerivedV>& V,
  43. const Eigen::MatrixBase<DerivedF>& F,
  44. const igl::PerVertexNormalsWeightingType weighting,
  45. Eigen::PlainObjectBase<DerivedN> & N);
  46. /// \overload
  47. template <
  48. typename DerivedV,
  49. typename DerivedF,
  50. typename DerivedN>
  51. IGL_INLINE void per_vertex_normals(
  52. const Eigen::MatrixBase<DerivedV>& V,
  53. const Eigen::MatrixBase<DerivedF>& F,
  54. Eigen::PlainObjectBase<DerivedN> & N);
  55. /// \overload
  56. ///
  57. /// @param[in] FN #F by 3 matrix of face (triangle) normals
  58. template <typename DerivedV, typename DerivedF, typename DerivedFN, typename DerivedN>
  59. IGL_INLINE void per_vertex_normals(
  60. const Eigen::MatrixBase<DerivedV>& V,
  61. const Eigen::MatrixBase<DerivedF>& F,
  62. const PerVertexNormalsWeightingType weighting,
  63. const Eigen::MatrixBase<DerivedFN>& FN,
  64. Eigen::PlainObjectBase<DerivedN> & N);
  65. /// \overload
  66. template <
  67. typename DerivedV,
  68. typename DerivedF,
  69. typename DerivedFN,
  70. typename DerivedN>
  71. IGL_INLINE void per_vertex_normals(
  72. const Eigen::MatrixBase<DerivedV>& V,
  73. const Eigen::MatrixBase<DerivedF>& F,
  74. const Eigen::MatrixBase<DerivedFN>& FN,
  75. Eigen::PlainObjectBase<DerivedN> & N);
  76. }
  77. #ifndef IGL_STATIC_LIBRARY
  78. # include "per_vertex_normals.cpp"
  79. #endif
  80. #endif