writeMESH.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_WRITEMESH_H
  9. #define IGL_WRITEMESH_H
  10. #include "igl_inline.h"
  11. #include <string>
  12. #include <vector>
  13. #include <Eigen/Core>
  14. namespace igl
  15. {
  16. /// save a tetrahedral volume mesh to a .mesh file
  17. ///
  18. /// @tparam Scalar type for positions and vectors (will be cast as double)
  19. /// @tparam Index type for indices (will be cast to int)
  20. /// @param[in] mesh_file_name path of .mesh file
  21. /// @param[in] V double matrix of vertex positions #V by 3
  22. /// @param[in] T #T list of tet indices into vertex positions
  23. /// @param[in] F #F list of face indices into vertex positions
  24. /// @return true on success, false on errors
  25. ///
  26. /// \bug Holes and regions are not supported
  27. template <typename Scalar, typename Index>
  28. IGL_INLINE bool writeMESH(
  29. const std::string mesh_file_name,
  30. const std::vector<std::vector<Scalar > > & V,
  31. const std::vector<std::vector<Index > > & T,
  32. const std::vector<std::vector<Index > > & F);
  33. /// save a tetrahedral volume mesh to a .mesh file
  34. ///
  35. /// @tparam DerivedV real-value: i.e. from Eigen::MatrixXd
  36. /// @tparam DerivedT integer-value: i.e. from Eigen::MatrixXi
  37. /// @tparam DerivedF integer-value: i.e. from Eigen::MatrixXi
  38. /// @param[in] mesh_file_name path of .mesh file
  39. /// @param[in] V eigen double matrix #V by 3
  40. /// @param[in] T eigen int matrix #T by 4
  41. /// @param[in] F eigen int matrix #F by 3
  42. /// @return true on success, false on errors
  43. template <typename DerivedV, typename DerivedT, typename DerivedF>
  44. IGL_INLINE bool writeMESH(
  45. const std::string str,
  46. const Eigen::MatrixBase<DerivedV> & V,
  47. const Eigen::MatrixBase<DerivedT> & T,
  48. const Eigen::MatrixBase<DerivedF> & F);
  49. }
  50. #ifndef IGL_STATIC_LIBRARY
  51. # include "writeMESH.cpp"
  52. #endif
  53. #endif