123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #include "read.h"
- #include "readOBJ.h"
- #include "readOFF.h"
- #include "pathinfo.h"
- #include <cstdio>
- #include <iostream>
- template <typename Scalar, typename Index>
- IGL_INLINE bool igl::read(
- const std::string str,
- std::vector<std::vector<Scalar> > & V,
- std::vector<std::vector<Index> > & F)
- {
- using namespace std;
- using namespace igl;
- // dirname, basename, extension and filename
- string d,b,e,f;
- pathinfo(str,d,b,e,f);
- // Convert extension to lower case
- std::transform(e.begin(), e.end(), e.begin(), ::tolower);
- vector<vector<Scalar> > TC, N;
- vector<vector<Index> > FTC, FN;
- if(e == "obj")
- {
- return readOBJ(str,V,TC,N,F,FTC,FN);
- }else if(e == "off")
- {
- return readOFF(str,V,F,N);
- }
- cerr<<"Error: "<<__FUNCTION__<<": "<<
- str<<" is not a recognized mesh file format."<<endl;
- return false;
- }
- #ifndef IGL_NO_EIGN
- template <typename DerivedV, typename DerivedF>
- IGL_INLINE bool igl::read(
- const std::string str,
- Eigen::PlainObjectBase<DerivedV>& V,
- Eigen::PlainObjectBase<DerivedF>& F)
- {
- const char* p;
- for (p = str.c_str(); *p != '\0'; p++)
- ;
- while (*p != '.')
- p--;
-
- if (!strcmp(p, ".obj") || !strcmp(p, ".OBJ"))
- {
- return igl::readOBJ(str,V,F);
- }else if (!strcmp(p, ".off") || !strcmp(p, ".OFF"))
- {
- return igl::readOFF(str,V,F);
- }
- else
- {
- fprintf(stderr,"read() does not recognize extension: %s\n",p);
- return false;
- }
- }
- #endif
- #ifndef IGL_HEADER_ONLY
- // Explicit template specialization
- // generated by autoexplicit.sh
- 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> >&);
- template bool igl::read<double, int>(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
- #endif
|