write.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "write.h"
  9. #include "writeOBJ.h"
  10. #include "writeOFF.h"
  11. #include <iostream>
  12. template <typename DerivedV, typename DerivedF>
  13. IGL_INLINE bool igl::write(
  14. const std::string str,
  15. const Eigen::PlainObjectBase<DerivedV>& V,
  16. const Eigen::PlainObjectBase<DerivedF>& F)
  17. {
  18. using namespace std;
  19. const char* p;
  20. for (p = str.c_str(); *p != '\0'; p++)
  21. ;
  22. while (*p != '.')
  23. p--;
  24. if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
  25. return igl::writeOBJ(str,V,F);
  26. if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
  27. return igl::writeOFF(str,V,F);
  28. cerr<<"^write Unsupported extension: "<<string(p)<<endl;
  29. return false;
  30. }
  31. #ifndef IGL_HEADER_ONLY
  32. // Explicit template specialization
  33. // generated by autoexplicit.sh
  34. template bool igl::write<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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
  35. #endif