write.h 939 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. //
  2. // IGL Lib - Simple C++ mesh library
  3. //
  4. // Copyright 2011, Daniele Panozzo. All rights reserved.
  5. #ifndef IGL_WRITE_H
  6. #define IGL_WRITE_H
  7. #include <Eigen/Core>
  8. #include <string>
  9. namespace igl
  10. {
  11. // write mesh to an ascii file with automatic detection of file format. supported: obj, off)
  12. // Known Bugs:
  13. // Does not correctly find file extensions: myfile.foo.off
  14. inline bool write(
  15. const std::string str,
  16. const Eigen::MatrixXd& V,
  17. const Eigen::MatrixXi& F);
  18. }
  19. // Implementation
  20. #include <writeOBJ.h>
  21. #include <writeOFF.h>
  22. inline bool igl::write(
  23. const std::string str,
  24. const Eigen::MatrixXd& V,
  25. const Eigen::MatrixXi& F)
  26. {
  27. const char* p;
  28. for (p = str.c_str(); *p != '\0'; p++)
  29. ;
  30. while (*p != '.')
  31. p--;
  32. if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
  33. return igl::writeOBJ(str,V,F);
  34. if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
  35. return igl::writeOFF(str,V,F);
  36. }
  37. #endif