euler_characteristic.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2016 Michael Rabinovich <michaelrabinovich27@gmail.com@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 <igl/edge_topology.h>
  10. template <typename Scalar, typename Index>
  11. IGL_INLINE int igl::euler_characteristic(
  12. const Eigen::PlainObjectBase<Scalar> & V,
  13. const Eigen::PlainObjectBase<Index> & F)
  14. {
  15. int euler_v = V.rows();
  16. Eigen::MatrixXi EV, FE, EF;
  17. igl::edge_topology(V, F, EV, FE, EF);
  18. int euler_e = EV.rows();
  19. int euler_f = F.rows();
  20. int euler_char = euler_v - euler_e + euler_f;
  21. return euler_char;
  22. }
  23. #ifdef IGL_STATIC_LIBRARY
  24. // Explicit template specialization
  25. // generated by autoexplicit.sh
  26. template int igl::euler_characteristic<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&);
  27. #endif