is_border_vertex.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "is_border_vertex.h"
  9. #include <vector>
  10. #include "triangle_triangle_adjacency.h"
  11. template <typename DerivedV, typename DerivedF>
  12. IGL_INLINE std::vector<bool> igl::is_border_vertex(
  13. const Eigen::PlainObjectBase<DerivedV> &V,
  14. const Eigen::PlainObjectBase<DerivedF> &F)
  15. {
  16. DerivedF FF;
  17. igl::triangle_triangle_adjacency(F,FF);
  18. std::vector<bool> ret(V.rows());
  19. for(unsigned i=0; i<ret.size();++i)
  20. ret[i] = false;
  21. for(unsigned i=0; i<F.rows();++i)
  22. for(unsigned j=0;j<F.cols();++j)
  23. if(FF(i,j) == -1)
  24. {
  25. ret[F(i,j)] = true;
  26. ret[F(i,(j+1)%F.cols())] = true;
  27. }
  28. return ret;
  29. }
  30. #ifdef IGL_STATIC_LIBRARY
  31. // Explicit template specialization
  32. template std::vector<bool, std::allocator<bool> > igl::is_border_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&);
  33. template std::vector<bool, std::allocator<bool> > igl::is_border_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&);
  34. template std::vector<bool, std::allocator<bool> > igl::is_border_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&);
  35. #endif