euler_characteristic.cpp 963 B

123456789101112131415161718192021222324252627
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Michael Rabinovich <[email protected]@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 "euler_characteristic.h"
  9. #include "edge_topology.h"
  10. #include "edges.h"
  11. template <typename DerivedF>
  12. IGL_INLINE int igl::euler_characteristic(
  13. const Eigen::MatrixBase<DerivedF> & F)
  14. {
  15. const int nf = F.rows();
  16. const int nv = F.maxCoeff()+1;
  17. Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,2> E;
  18. edges(F,E);
  19. const int ne = E.rows();
  20. return nv - ne + nf;
  21. }
  22. #ifdef IGL_STATIC_LIBRARY
  23. // Explicit template instantiation
  24. template int igl::euler_characteristic<Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  25. #endif