avg_edge_length.cpp 1010 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 "read_eigen_from_CSV.h"
  9. #include <sstream>
  10. #include <string>
  11. #include <fstream>
  12. #include <vector>
  13. namespace igl
  14. {
  15. template <typename DerivedV, typename DerivedF>
  16. double avg_edge_length(
  17. const Eigen::PlainObjectBase<DerivedV>& V,
  18. const Eigen::PlainObjectBase<DerivedF>& F)
  19. {
  20. double avg = 0;
  21. long int count = 0;
  22. for (unsigned i=0;i<F.rows();++i)
  23. {
  24. for (unsigned j=0;j<3;++j)
  25. {
  26. ++count;
  27. avg += (V.row(F(i,j)) - V.row(F(i,(j+1)%3))).norm();
  28. }
  29. }
  30. return avg / (double) count;
  31. }
  32. }
  33. #ifndef IGL_HEADER_ONLY
  34. // Explicit template specialization
  35. // generated by autoexplicit.sh
  36. #endif