readMESH.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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 <Eigen/Core>
  12. #include <string>
  13. #include <vector>
  14. #include <cstdio>
  15. namespace igl
  16. {
  17. /// Load a tetrahedral volume mesh from a .mesh file
  18. ///
  19. /// @tparam Scalar type for positions and vectors (will be read as double and cast
  20. /// to Scalar)
  21. /// @tparam Index type for indices (will be read as int and cast to Index)
  22. /// @param[in] mesh_file_name path of .mesh file
  23. /// @param[out] V double matrix of vertex positions #V by 3
  24. /// @param[out] T #T list of tet indices into vertex positions
  25. /// @param[out] F #F list of face indices into vertex positions
  26. ///
  27. /// \bug Holes and regions are not supported
  28. template <typename DerivedV, typename DerivedF, typename DerivedT>
  29. IGL_INLINE bool readMESH(
  30. const std::string mesh_file_name,
  31. Eigen::PlainObjectBase<DerivedV>& V,
  32. Eigen::PlainObjectBase<DerivedT>& T,
  33. Eigen::PlainObjectBase<DerivedF>& F);
  34. /// \overload
  35. template <typename Scalar, typename Index>
  36. IGL_INLINE bool readMESH(
  37. const std::string mesh_file_name,
  38. std::vector<std::vector<Scalar > > & V,
  39. std::vector<std::vector<Index > > & T,
  40. std::vector<std::vector<Index > > & F);
  41. /// \overload
  42. /// @param[in] pointer to already opened .mesh file (will be closed)
  43. template <typename DerivedV, typename DerivedF, typename DerivedT>
  44. IGL_INLINE bool readMESH(
  45. FILE * mesh_file,
  46. Eigen::PlainObjectBase<DerivedV>& V,
  47. Eigen::PlainObjectBase<DerivedT>& T,
  48. Eigen::PlainObjectBase<DerivedF>& F);
  49. /// \overload
  50. template <typename Scalar, typename Index>
  51. IGL_INLINE bool readMESH(
  52. FILE * mesh_file,
  53. std::vector<std::vector<Scalar > > & V,
  54. std::vector<std::vector<Index > > & T,
  55. std::vector<std::vector<Index > > & F);
  56. }
  57. #ifndef IGL_STATIC_LIBRARY
  58. # include "readMESH.cpp"
  59. #endif
  60. #endif