per_edge_normals.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // weighting weighting type
  29. // Output:
  30. // N #2 by 3 matrix of mesh edge 3D normals per row
  31. // E #E by 2 matrix of edge indices per row
  32. // EMAP #E by 1 matrix of indices from all edges to E
  33. //
  34. template <
  35. typename DerivedV,
  36. typename DerivedF,
  37. typename DerivedN,
  38. typename DerivedE,
  39. typename DerivedEMAP>
  40. IGL_INLINE void per_edge_normals(
  41. const Eigen::PlainObjectBase<DerivedV>& V,
  42. const Eigen::PlainObjectBase<DerivedF>& F,
  43. const PerEdgeNormalsWeightingType weight,
  44. Eigen::PlainObjectBase<DerivedN> & N,
  45. Eigen::PlainObjectBase<DerivedE> & E,
  46. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  47. template <
  48. typename DerivedV,
  49. typename DerivedF,
  50. typename DerivedN,
  51. typename DerivedE,
  52. typename DerivedEMAP>
  53. IGL_INLINE void per_edge_normals(
  54. const Eigen::PlainObjectBase<DerivedV>& V,
  55. const Eigen::PlainObjectBase<DerivedF>& F,
  56. Eigen::PlainObjectBase<DerivedN> & N,
  57. Eigen::PlainObjectBase<DerivedE> & E,
  58. Eigen::PlainObjectBase<DerivedEMAP> & EMAP);
  59. }
  60. #ifndef IGL_STATIC_LIBRARY
  61. # include "per_edge_normals.cpp"
  62. #endif
  63. #endif