readMESH.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_READMESH_H
  9. #define IGL_READMESH_H
  10. #include "igl_inline.h"
  11. #include <string>
  12. #include <vector>
  13. #include <Eigen/Core>
  14. namespace igl
  15. {
  16. // load a tetrahedral volume mesh from a .mesh file
  17. //
  18. // Templates:
  19. // Scalar type for positions and vectors (will be read as double and cast
  20. // to Scalar)
  21. // Index type for indices (will be read as int and cast to Index)
  22. // Input:
  23. // mesh_file_name path of .mesh file
  24. // Outputs:
  25. // V double matrix of vertex positions #V by 3
  26. // T #T list of tet indices into vertex positions
  27. // F #F list of face indices into vertex positions
  28. //
  29. // Known bugs: Holes and regions are not supported
  30. template <typename Scalar, typename Index>
  31. IGL_INLINE bool readMESH(
  32. const std::string mesh_file_name,
  33. std::vector<std::vector<Scalar > > & V,
  34. std::vector<std::vector<Index > > & T,
  35. std::vector<std::vector<Index > > & F);
  36. // Input:
  37. // mesh_file_name path of .mesh file
  38. // Outputs:
  39. // V eigen double matrix #V by 3
  40. // T eigen int matrix #T by 4
  41. // F eigen int matrix #F by 3
  42. template <typename DerivedV, typename DerivedF, typename DerivedT>
  43. IGL_INLINE bool readMESH(
  44. const std::string mesh_file_name,
  45. Eigen::PlainObjectBase<DerivedV>& V,
  46. Eigen::PlainObjectBase<DerivedT>& T,
  47. Eigen::PlainObjectBase<DerivedF>& F);
  48. }
  49. #ifndef IGL_STATIC_LIBRARY
  50. # include "readMESH.cpp"
  51. #endif
  52. #endif