is_border_vertex.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 DerivedF>
  12. IGL_INLINE std::vector<bool> igl::is_border_vertex(
  13. const Eigen::MatrixBase<DerivedF> &F)
  14. {
  15. DerivedF FF;
  16. igl::triangle_triangle_adjacency(F,FF);
  17. std::vector<bool> ret(F.maxCoeff()+1);
  18. for(unsigned i=0; i<ret.size();++i)
  19. ret[i] = false;
  20. for(unsigned i=0; i<F.rows();++i)
  21. for(unsigned j=0;j<F.cols();++j)
  22. if(FF(i,j) == -1)
  23. {
  24. ret[F(i,j)] = true;
  25. ret[F(i,(j+1)%F.cols())] = true;
  26. }
  27. return ret;
  28. }
  29. template <typename DerivedV, typename DerivedF>
  30. IGL_INLINE std::vector<bool> igl::is_border_vertex(
  31. const Eigen::MatrixBase<DerivedV> &/*V*/,
  32. const Eigen::MatrixBase<DerivedF> &F)
  33. {
  34. return igl::is_border_vertex(F);
  35. }
  36. #ifdef IGL_STATIC_LIBRARY
  37. // Explicit template instantiation
  38. 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::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
  39. 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::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  40. 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::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  41. #endif