edge_crossings.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "edge_crossings.h"
  2. #include "list_to_matrix.h"
  3. template <
  4. typename DeriveduE,
  5. typename DerivedS,
  6. typename DerivedT>
  7. void igl::edge_crossings(
  8. const Eigen::MatrixBase<DeriveduE> & uE,
  9. const Eigen::MatrixBase<DerivedS> & S,
  10. const typename DerivedS::Scalar val,
  11. std::unordered_map<int,int> & uE2I,
  12. Eigen::PlainObjectBase<DerivedT> & T)
  13. {
  14. using Scalar = typename DerivedS::Scalar;
  15. {
  16. std::vector<Scalar> vT;
  17. for(int u = 0;u<uE.rows();u++)
  18. {
  19. // Does edge cross isovalue?
  20. const int i = uE(u,0);
  21. const int j = uE(u,1);
  22. const Scalar Si = S(i);
  23. const Scalar Sj = S(j);
  24. // Specifically do not include endpoints
  25. if( (Si-val)*(Sj-val) >= 0)
  26. {
  27. continue;
  28. }
  29. // find crossing point
  30. const Scalar t = (val-Si)/(Sj-Si);
  31. uE2I[u] = vT.size();
  32. vT.emplace_back(t);
  33. }
  34. igl::list_to_matrix(vT,T);
  35. }
  36. }
  37. #ifdef IGL_STATIC_LIBRARY
  38. // Explicit template instantiation
  39. // generated by autoexplicit.sh
  40. template void igl::edge_crossings<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<double, -1, 1, 0, -1, 1>::Scalar, std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, int> > >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
  41. #endif