1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- #include "writeOFF.h"
- #include <cstdio>
- // write mesh to an ascii off file
- template <typename DerivedV, typename DerivedF>
- IGL_INLINE bool igl::writeOFF(
- const std::string fname,
- const Eigen::PlainObjectBase<DerivedV>& V,
- const Eigen::PlainObjectBase<DerivedF>& F)
- {
- FILE *fp = fopen (fname.c_str(), "w");
-
-
- if (!fp)
- {
- fprintf (stderr, "writeOFF(): could not open file %s", fname.c_str());
- return false;
- }
-
- fprintf (fp, "OFF\n%d %d 0\n", (int) V.rows(), (int) F.rows());
-
- for (int i = 0; i < V.rows(); i++)
- {
- fprintf(
- fp,
- "%0.17g %0.17g %0.17g\n",
- (double)V(i,0),
- (double)V(i,1),
- (double)V(i,2));
- }
-
- for (int i = 0; i < F.rows(); i++)
- fprintf (fp, "3 %d %d %d\n", F(i,0), F(i,1), F(i,2));
-
- fclose (fp);
- return true;
- }
- #ifndef IGL_HEADER_ONLY
- // Explicit template specialization
- // generated by autoexplicit.sh
- template bool igl::writeOFF<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&);
- template bool igl::writeOFF<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> > const&);
- template bool igl::writeOFF<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<unsigned int, -1, -1, 1, -1, -1> >(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&);
- #endif
|