per_corner_normals.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_PER_CORNER_NORMALS_H
  9. #define IGL_PER_CORNER_NORMALS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. // Compute vertex normals via vertex position list, face list
  16. // Inputs:
  17. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  18. // F #F by 3 eigne Matrix of face (triangle) indices
  19. // corner_threshold threshold in degrees on sharp angles
  20. // Output:
  21. // CN #F*3 by 3 eigen Matrix of mesh vertex 3D normals, where the normal
  22. // for corner F(i,j) is at CN(i*3+j,:)
  23. template <typename DerivedV, typename DerivedF, typename DerivedCN>
  24. IGL_INLINE void per_corner_normals(
  25. const Eigen::PlainObjectBase<DerivedV>& V,
  26. const Eigen::PlainObjectBase<DerivedF>& F,
  27. const double corner_threshold,
  28. Eigen::PlainObjectBase<DerivedCN> & CN);
  29. // Other Inputs:
  30. // FN #F by 3 eigen Matrix of face normals
  31. template <
  32. typename DerivedV,
  33. typename DerivedF,
  34. typename DerivedFN,
  35. typename DerivedCN>
  36. IGL_INLINE void per_corner_normals(
  37. const Eigen::PlainObjectBase<DerivedV>& V,
  38. const Eigen::PlainObjectBase<DerivedF>& F,
  39. const Eigen::PlainObjectBase<DerivedFN>& FN,
  40. const double corner_threshold,
  41. Eigen::PlainObjectBase<DerivedCN> & CN);
  42. // Other Inputs:
  43. // VF map from vertices to list of incident faces
  44. template <
  45. typename DerivedV,
  46. typename DerivedF,
  47. typename DerivedFN,
  48. typename IndexType,
  49. typename DerivedCN>
  50. IGL_INLINE void per_corner_normals(
  51. const Eigen::PlainObjectBase<DerivedV>& V,
  52. const Eigen::PlainObjectBase<DerivedF>& F,
  53. const Eigen::PlainObjectBase<DerivedFN>& FN,
  54. const std::vector<std::vector<IndexType> >& VF,
  55. const double corner_threshold,
  56. Eigen::PlainObjectBase<DerivedCN> & CN);
  57. }
  58. #ifndef IGL_STATIC_LIBRARY
  59. # include "per_corner_normals.cpp"
  60. #endif
  61. #endif