read.h 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // IGL Lib - Simple C++ mesh library
  3. //
  4. // Copyright 2011, Daniele Panozzo. All rights reserved.
  5. #ifndef READ_H
  6. #define READ_H
  7. #include <Eigen/Core>
  8. #include <string>
  9. #include <readOBJ.h>
  10. #include <readOFF.h>
  11. namespace igl
  12. {
  13. // read mesh from an ascii file with automatic detection of file format. supported: obj, off)
  14. void read(std::string str, Eigen::MatrixXd& V, Eigen::MatrixXi& F)
  15. {
  16. const char* p;
  17. for (p = str.c_str(); *p != '\0'; p++)
  18. ;
  19. while (*p != '.')
  20. p--;
  21. if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
  22. {
  23. igl::readOBJ(str,V,F);
  24. return;
  25. }
  26. if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
  27. {
  28. igl::readOFF(str,V,F);
  29. return;
  30. }
  31. }
  32. }
  33. #endif