is_border_vertex.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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. assert(F.cols() == 3 && "Only triangle meshes are supported");
  16. Eigen::Matrix<typename DerivedF::Scalar, Eigen::Dynamic, Eigen::Dynamic> FF;
  17. igl::triangle_triangle_adjacency(F,FF);
  18. std::vector<bool> ret(F.maxCoeff()+1);
  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 instantiation
  32. template std::vector<bool, std::allocator<bool> > igl::is_border_vertex<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  33. template std::vector<bool, std::allocator<bool> > igl::is_border_vertex<Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
  34. #endif