unique_simplices.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include "unique_simplices.h"
  9. #include "sort.h"
  10. #include "unique.h"
  11. template <
  12. typename DerivedF,
  13. typename DerivedFF,
  14. typename DerivedIA,
  15. typename DerivedIC>
  16. IGL_INLINE void igl::unique_simplices(
  17. const Eigen::PlainObjectBase<DerivedF>& F,
  18. Eigen::PlainObjectBase<DerivedFF>& FF,
  19. Eigen::PlainObjectBase<DerivedIA>& IA,
  20. Eigen::PlainObjectBase<DerivedIC>& IC)
  21. {
  22. using namespace Eigen;
  23. using namespace igl;
  24. // Sort each face
  25. MatrixXi sortF, unusedI;
  26. igl::sort(F,2,true,sortF,unusedI);
  27. // Find unique faces
  28. MatrixXi C;
  29. igl::unique_rows(sortF,C,IA,IC);
  30. FF.resize(IA.size(),F.cols());
  31. // Copy into output
  32. for(int i = 0;i<IA.rows();i++)
  33. {
  34. FF.row(i) = F.row(IA(i));
  35. }
  36. }
  37. template <
  38. typename DerivedF,
  39. typename DerivedFF>
  40. IGL_INLINE void igl::unique_simplices(
  41. const Eigen::PlainObjectBase<DerivedF>& F,
  42. Eigen::PlainObjectBase<DerivedFF>& FF)
  43. {
  44. Eigen::VectorXi IA,IC;
  45. return unique_simplices(F,FF,IA,IC);
  46. }
  47. #ifdef IGL_STATIC_LIBRARY
  48. // Explicit template instanciations
  49. template void igl::unique_simplices<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
  50. #endif