unique_simplices.cpp 856 B

12345678910111213141516171819202122232425262728293031
  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. IGL_INLINE void igl::unique_simplices(
  12. const Eigen::MatrixXi & F,
  13. Eigen::MatrixXi & FF)
  14. {
  15. using namespace Eigen;
  16. using namespace igl;
  17. // Sort each face
  18. MatrixXi sortF, unusedI;
  19. igl::sort(F,2,1,sortF,unusedI);
  20. // Find unique faces
  21. VectorXi IA,IC;
  22. MatrixXi C;
  23. igl::unique_rows(sortF,C,IA,IC);
  24. FF.resize(IA.size(),F.cols());
  25. // Copy into output
  26. for(int i = 0;i<IA.rows();i++)
  27. {
  28. FF.row(i) = F.row(IA(i));
  29. }
  30. }