|
@@ -1,9 +1,9 @@
|
|
|
// This file is part of libigl, a simple c++ geometry processing library.
|
|
|
-//
|
|
|
+//
|
|
|
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
|
|
-//
|
|
|
-// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
|
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
+//
|
|
|
+// This Source Code Form is subject to the terms of the Mozilla Public License
|
|
|
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
|
|
// obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
#include "writeOBJ.h"
|
|
|
|
|
@@ -32,7 +32,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
{
|
|
|
s << "v " << V(i,0) << " " << V(i,1) << " " << V(i,2) << std::endl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
for(int i=0;i<(int)F.rows();++i)
|
|
|
{
|
|
|
s << "f ";
|
|
@@ -46,7 +46,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
}
|
|
|
s<<std::endl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
s.close();
|
|
|
return true;
|
|
|
}
|
|
@@ -65,7 +65,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
if(NULL==obj_file)
|
|
|
{
|
|
|
printf("IOError: %s could not be opened for writing...",str.c_str());
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
// Loop over V
|
|
|
for(int i = 0;i<(int)V.rows();i++)
|
|
@@ -77,7 +77,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
);
|
|
|
}
|
|
|
bool write_N = CN.rows() >0;
|
|
|
-
|
|
|
+
|
|
|
if(write_N)
|
|
|
{
|
|
|
for(int i = 0;i<(int)CN.rows();i++)
|
|
@@ -90,9 +90,9 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
}
|
|
|
fprintf(obj_file,"\n");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
bool write_texture_coords = TC.rows() >0;
|
|
|
-
|
|
|
+
|
|
|
if(write_texture_coords)
|
|
|
{
|
|
|
for(int i = 0;i<(int)TC.rows();i++)
|
|
@@ -101,7 +101,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
}
|
|
|
fprintf(obj_file,"\n");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// loop over F
|
|
|
for(int i = 0;i<(int)F.rows();++i)
|
|
|
{
|
|
@@ -110,7 +110,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
{
|
|
|
// OBJ is 1-indexed
|
|
|
fprintf(obj_file," %u",F(i,j)+1);
|
|
|
-
|
|
|
+
|
|
|
if(write_texture_coords)
|
|
|
fprintf(obj_file,"/%u",FTC(i,j)+1);
|
|
|
if(write_N)
|
|
@@ -124,7 +124,7 @@ IGL_INLINE bool igl::writeOBJ(
|
|
|
fprintf(obj_file,"\n");
|
|
|
}
|
|
|
fclose(obj_file);
|
|
|
- return true;
|
|
|
+ return true;
|
|
|
}
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
// Explicit template specialization
|
|
@@ -134,4 +134,5 @@ template bool igl::writeOBJ<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matri
|
|
|
template bool igl::writeOBJ<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1>, Eigen::Matrix<float, -1, 2, 1, -1, 2> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 2, 1, -1, 2> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&);
|
|
|
template bool igl::writeOBJ<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
|
|
|
template bool igl::writeOBJ<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
|
|
|
+template bool igl::writeOBJ<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&);
|
|
|
#endif
|