write.h 777 B

12345678910111213141516171819202122232425262728293031323334
  1. //
  2. // IGL Lib - Simple C++ mesh library
  3. //
  4. // Copyright 2011, Daniele Panozzo. All rights reserved.
  5. #ifndef WRITE_H
  6. #define WRITE_H
  7. #include <Eigen/Core>
  8. #include <string>
  9. #include <writeOBJ.h>
  10. #include <writeOFF.h>
  11. namespace igl
  12. {
  13. // write mesh to an ascii file with automatic detection of file format. supported: obj, off)
  14. inline void write(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. return igl::writeOBJ(str,V,F);
  23. if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
  24. return igl::writeOFF(str,V,F);
  25. }
  26. }
  27. #endif