per_edge_normals.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_PER_EDGE_NORMALS_H
  9. #define IGL_PER_EDGE_NORMALS_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. enum PerEdgeNormalsWeightingType
  15. {
  16. // Incident face normals have uniform influence on edge normal
  17. PER_EDGE_NORMALS_WEIGHTING_TYPE_UNIFORM = 0,
  18. // Incident face normals are averaged weighted by area
  19. PER_EDGE_NORMALS_WEIGHTING_TYPE_AREA = 1,
  20. // Area weights
  21. PER_EDGE_NORMALS_WEIGHTING_TYPE_DEFAULT = 2,
  22. NUM_PER_EDGE_NORMALS_WEIGHTING_TYPE = 3
  23. };
  24. // Compute face normals via vertex position list, face list
  25. // Inputs:
  26. // V #V by 3 eigen Matrix of mesh vertex 3D positions
  27. // F #F by 3 eigen Matrix of face (triangle) indices
  28. // weight weighting type
  29. // FN #F by 3 matrix of 3D face normals per face
  30. // Output:
  31. // N #2 by 3 matrix of mesh edge 3D normals per row
  32. // E #E by 2 matrix of edge indices per row
  33. // EMAP #E by 1 matrix of indices from all edges to E
  34. //
  35. template <
  36. typename DerivedV,
  37. typename DerivedF,
  38. typename DerivedFN,
  39. typename DerivedN,
  40. typename DerivedE,
  41. typename DerivedEMAP>
  42. IGL_INLINE void per_edge_normals(
  43. const Eigen::PlainObjectBase<DerivedV>& V,
  44. const Eigen::PlainObjectBase<DerivedF>& F,
  45. const PerEdgeNormalsWeightingType weight,
  46. const Eigen::PlainObjectBase<DerivedFN>& FN,
  47. Eigen::PlainObjectBase<DerivedN> & N,
  48. Eigen::PlainObjectBase<DerivedE> & E,
  49. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  50. template <
  51. typename DerivedV,
  52. typename DerivedF,
  53. typename DerivedN,
  54. typename DerivedE,
  55. typename DerivedEMAP>
  56. IGL_INLINE void per_edge_normals(
  57. const Eigen::PlainObjectBase<DerivedV>& V,
  58. const Eigen::PlainObjectBase<DerivedF>& F,
  59. const PerEdgeNormalsWeightingType weight,
  60. Eigen::PlainObjectBase<DerivedN> & N,
  61. Eigen::PlainObjectBase<DerivedE> & E,
  62. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  63. template <
  64. typename DerivedV,
  65. typename DerivedF,
  66. typename DerivedN,
  67. typename DerivedE,
  68. typename DerivedEMAP>
  69. IGL_INLINE void per_edge_normals(
  70. const Eigen::PlainObjectBase<DerivedV>& V,
  71. const Eigen::PlainObjectBase<DerivedF>& F,
  72. Eigen::PlainObjectBase<DerivedN> & N,
  73. Eigen::PlainObjectBase<DerivedE> & E,
  74. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  75. }
  76. #ifndef IGL_STATIC_LIBRARY
  77. # include "per_edge_normals.cpp"
  78. #endif
  79. #endif