read.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "read.h"
  2. #include "readOBJ.h"
  3. #include "readOFF.h"
  4. #include <cstdio>
  5. template <typename DerivedV, typename DerivedF>
  6. IGL_INLINE bool igl::read(
  7. const std::string str,
  8. Eigen::PlainObjectBase<DerivedV>& V,
  9. Eigen::PlainObjectBase<DerivedF>& F)
  10. {
  11. const char* p;
  12. for (p = str.c_str(); *p != '\0'; p++)
  13. ;
  14. while (*p != '.')
  15. p--;
  16. if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
  17. {
  18. return igl::readOBJ(str,V,F);
  19. }else if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
  20. {
  21. return igl::readOFF(str,V,F);
  22. }
  23. else
  24. {
  25. fprintf(stderr,"read() does not recognize extension: %s\n",p);
  26. return false;
  27. }
  28. }
  29. #ifndef IGL_HEADER_ONLY
  30. // Explicit template specialization
  31. // generated by autoexplicit.sh
  32. template bool igl::read<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
  33. #endif