|
@@ -2,15 +2,46 @@
|
|
|
|
|
|
#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 std::string str,
|
|
|
+ Eigen::PlainObjectBase<DerivedV>& V,
|
|
|
+ Eigen::PlainObjectBase<DerivedF>& F)
|
|
|
{
|
|
|
const char* p;
|
|
|
for (p = str.c_str(); *p != '\0'; p++)
|
|
@@ -31,9 +62,11 @@ IGL_INLINE bool igl::read(
|
|
|
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
|