readMESH.h 1.4 KB

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