readDMAT.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_READDMAT_H
  9. #define IGL_READDMAT_H
  10. #include "igl_inline.h"
  11. // .dmat is a simple ascii matrix file type, defined as follows. The first line
  12. // is always:
  13. // <#columns> <#rows>
  14. // Then the coefficients of the matrix are given separated by whitespace with
  15. // columns running fastest.
  16. //
  17. // Example:
  18. // The matrix m = [1 2 3; 4 5 6];
  19. // corresponds to a .dmat file containing:
  20. // 3 2
  21. // 1 4 2 5 3 6
  22. #include <string>
  23. #include <vector>
  24. #ifndef IGL_NO_EIGEN
  25. # include <Eigen/Core>
  26. #endif
  27. namespace igl
  28. {
  29. // Read a matrix from an ascii dmat file
  30. //
  31. // Inputs:
  32. // file_name path to .dmat file
  33. // Outputs:
  34. // W eigen matrix containing read-in coefficients
  35. // Returns true on success, false on error
  36. //
  37. #ifndef IGL_NO_EIGEN
  38. template <typename DerivedW>
  39. IGL_INLINE bool readDMAT(const std::string file_name,
  40. Eigen::PlainObjectBase<DerivedW> & W);
  41. #endif
  42. // Wrapper for vector of vectors
  43. template <typename Scalar>
  44. IGL_INLINE bool readDMAT(
  45. const std::string file_name,
  46. std::vector<std::vector<Scalar> > & W);
  47. }
  48. #ifndef IGL_STATIC_LIBRARY
  49. # include "readDMAT.cpp"
  50. #endif
  51. #endif