is_irregular_vertex.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Daniele Panozzo <daniele.panozzo@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 "is_irregular_vertex.h"
  9. #include <vector>
  10. #include "is_border_vertex.h"
  11. template <typename DerivedV, typename DerivedF>
  12. IGL_INLINE std::vector<bool> igl::is_irregular_vertex(const Eigen::PlainObjectBase<DerivedV> &V, const Eigen::PlainObjectBase<DerivedF> &F)
  13. {
  14. Eigen::VectorXi count = Eigen::VectorXi::Zero(F.maxCoeff());
  15. for(unsigned i=0; i<F.rows();++i)
  16. {
  17. for(unsigned j=0; j<F.cols();++j)
  18. {
  19. if (F(i,j) < F(i,(j+1)%F.cols())) // avoid duplicate edges
  20. {
  21. count(F(i,j )) += 1;
  22. count(F(i,(j+1)%F.cols())) += 1;
  23. }
  24. }
  25. }
  26. std::vector<bool> border = is_border_vertex(V,F);
  27. std::vector<bool> res(count.size());
  28. for (unsigned i=0; i<res.size(); ++i)
  29. res[i] = !border[i] && count[i] != (F.cols() == 3 ? 6 : 4 );
  30. return res;
  31. }
  32. #ifdef IGL_STATIC_LIBRARY
  33. // Explicit template specialization
  34. template std::vector<bool, std::allocator<bool> > igl::is_irregular_vertex<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
  35. template std::vector<bool, std::allocator<bool> > igl::is_irregular_vertex<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  36. #endif