list_to_matrix.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_LIST_TO_MATRIX_H
  9. #define IGL_LIST_TO_MATRIX_H
  10. #include "igl_inline.h"
  11. #include <vector>
  12. namespace igl
  13. {
  14. // Convert a list (std::vector) of row vectors of the same length to a matrix
  15. // Template:
  16. // T type that can be safely cast to type in Mat via '='
  17. // Mat Matrix type, must implement:
  18. // .resize(m,n)
  19. // .row(i) = Row
  20. // Inputs:
  21. // V a m-long list of vectors of size n
  22. // Outputs:
  23. // M an m by n matrix
  24. // Returns true on success, false on errors
  25. template <typename T, class Mat>
  26. IGL_INLINE bool list_to_matrix(
  27. const std::vector<std::vector<T > > & V,
  28. Mat & M);
  29. // Vector wrapper
  30. template <typename T, class Mat>
  31. IGL_INLINE bool list_to_matrix(const std::vector<T > & V,Mat & M);
  32. }
  33. #ifdef IGL_HEADER_ONLY
  34. # include "list_to_matrix.cpp"
  35. #endif
  36. #endif