writeBF.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "writeBF.h"
  2. #include <fstream>
  3. #include <cassert>
  4. template <
  5. typename DerivedWI,
  6. typename DerivedP,
  7. typename DerivedO>
  8. IGL_INLINE bool igl::writeBF(
  9. const std::string & filename,
  10. const Eigen::PlainObjectBase<DerivedWI> & WI,
  11. const Eigen::PlainObjectBase<DerivedP> & P,
  12. const Eigen::PlainObjectBase<DerivedO> & O)
  13. {
  14. using namespace Eigen;
  15. using namespace std;
  16. const int n = WI.rows();
  17. assert(n == WI.rows() && "WI must have n rows");
  18. assert(n == P.rows() && "P must have n rows");
  19. assert(n == O.rows() && "O must have n rows");
  20. MatrixXd WIPO(n,1+1+3);
  21. for(int i = 0;i<n;i++)
  22. {
  23. WIPO(i,0) = WI(i);
  24. WIPO(i,1) = P(i);
  25. WIPO(i,2+0) = O(i,0);
  26. WIPO(i,2+1) = O(i,1);
  27. WIPO(i,2+2) = O(i,2);
  28. }
  29. ofstream s(filename);
  30. if(!s.is_open())
  31. {
  32. fprintf(stderr,"IOError: writeBF() could not open %s\n",filename.c_str());
  33. return false;
  34. }
  35. s<<
  36. WIPO.format(IOFormat(FullPrecision,DontAlignCols," ","\n","","","","\n"));
  37. return true;
  38. }
  39. #ifdef IGL_STATIC_LIBRARY
  40. template bool igl::writeBF<Eigen::Matrix<int, -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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -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&);
  41. #endif