resolve_duplicated_faces.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Qingnan Zhou <qnzhou@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. //
  9. #ifndef IGL_COPYLEFT_RESOLVE_DUPLICATED_FACES
  10. #define IGL_COPYLEFT_RESOLVE_DUPLICATED_FACES
  11. #include "igl_inline.h"
  12. #include <Eigen/Core>
  13. namespace igl {
  14. // Resolve duplicated faces according to the following rules per unique face:
  15. //
  16. // 1. If the number of positively oriented faces equals the number of
  17. // negatively oriented faces, remove all duplicated faces at this triangle.
  18. // 2. If the number of positively oriented faces equals the number of
  19. // negatively oriented faces plus 1, keeps one of the positively oriented
  20. // face.
  21. // 3. If the number of positively oriented faces equals the number of
  22. // negatively oriented faces minus 1, keeps one of the negatively oriented
  23. // face.
  24. // 4. If the number of postively oriented faces differ with the number of
  25. // negativley oriented faces by more than 1, the mesh is not orientable.
  26. // An exception will be thrown.
  27. //
  28. // Inputs:
  29. // F1 #F1 by 3 array of input faces.
  30. //
  31. // Outputs:
  32. // F2 #F2 by 3 array of output faces without duplicated faces.
  33. // J #F2 list of indices into F1.
  34. template<
  35. typename DerivedF1,
  36. typename DerivedF2,
  37. typename DerivedJ >
  38. IGL_INLINE void resolve_duplicated_faces(
  39. const Eigen::PlainObjectBase<DerivedF1>& F1,
  40. Eigen::PlainObjectBase<DerivedF2>& F2,
  41. Eigen::PlainObjectBase<DerivedJ>& J);
  42. }
  43. #ifndef IGL_STATIC_LIBRARY
  44. # include "resolve_duplicated_faces.cpp"
  45. #endif
  46. #endif