readDMAT.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef IGL_READDMAT_H
  2. #define IGL_READDMAT_H
  3. #include "igl_inline.h"
  4. // .dmat is a simple ascii matrix file type, defined as follows. The first line
  5. // is always:
  6. // <#columns> <#rows>
  7. // Then the coefficients of the matrix are given separated by whitespace with
  8. // columns running fastest.
  9. //
  10. // Example:
  11. // The matrix m = [1 2 3; 4 5 6];
  12. // corresponds to a .dmat file containing:
  13. // 3 2
  14. // 1 4 2 5 3 6
  15. #include <string>
  16. #include <vector>
  17. #ifndef IGL_NO_EIGEN
  18. # include <Eigen/Core>
  19. #endif
  20. namespace igl
  21. {
  22. // Read a matrix from an ascii dmat file
  23. //
  24. // Inputs:
  25. // file_name path to .dmat file
  26. // Outputs:
  27. // W eigen matrix containing read-in coefficients
  28. // Returns true on success, false on error
  29. //
  30. #ifndef IGL_NO_EIGEN
  31. template <typename DerivedW>
  32. IGL_INLINE bool readDMAT(const std::string file_name,
  33. Eigen::PlainObjectBase<DerivedW> & W);
  34. #endif
  35. // Wrapper for vector of vectors
  36. template <typename Scalar>
  37. IGL_INLINE bool readDMAT(
  38. const std::string file_name,
  39. std::vector<std::vector<Scalar> > & W);
  40. }
  41. #ifdef IGL_HEADER_ONLY
  42. # include "readDMAT.cpp"
  43. #endif
  44. #endif