orient_outward_ao.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_ORIENT_OUTWARD_AO_H
  9. #define IGL_ORIENT_OUTWARD_AO_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. // Orient each component (identified by C) of a mesh (V,F) using ambient occlusion
  15. // such that the front side is less occluded than back side
  16. //
  17. // Inputs:
  18. // V #V by 3 list of vertex positions
  19. // F #F by 3 list of triangle indices
  20. // C #F list of components
  21. // min_num_rays_per_component Each component receives at least this number of rays
  22. // total_num_rays Total number of rays that will be shot
  23. // Outputs:
  24. // FF #F by 3 list of new triangle indices such that FF(~I,:) = F(~I,:) and
  25. // FF(I,:) = fliplr(F(I,:)) (OK if &FF = &F)
  26. // I max(C)+1 list of whether face has been flipped
  27. template <
  28. typename DerivedV,
  29. typename DerivedF,
  30. typename DerivedC,
  31. typename DerivedFF,
  32. typename DerivedI>
  33. IGL_INLINE void orient_outward_ao(
  34. const Eigen::PlainObjectBase<DerivedV> & V,
  35. const Eigen::PlainObjectBase<DerivedF> & F,
  36. const Eigen::PlainObjectBase<DerivedC> & C,
  37. const int min_num_rays_per_component,
  38. const int total_num_rays,
  39. Eigen::PlainObjectBase<DerivedFF> & FF,
  40. Eigen::PlainObjectBase<DerivedI> & I);
  41. // Call with default number of rays
  42. template <
  43. typename DerivedV,
  44. typename DerivedF,
  45. typename DerivedC,
  46. typename DerivedFF,
  47. typename DerivedI>
  48. IGL_INLINE void orient_outward_ao(
  49. const Eigen::PlainObjectBase<DerivedV> & V,
  50. const Eigen::PlainObjectBase<DerivedF> & F,
  51. const Eigen::PlainObjectBase<DerivedC> & C,
  52. Eigen::PlainObjectBase<DerivedFF> & FF,
  53. Eigen::PlainObjectBase<DerivedI> & I);
  54. };
  55. #ifdef IGL_HEADER_ONLY
  56. # include "orient_outward_ao.cpp"
  57. #endif
  58. #endif