writeMSH.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // high level interface for MshSaver
  2. //
  3. // Copyright (C) 2020 Vladimir Fonov <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla
  6. // Public License v. 2.0. If a copy of the MPL was not distributed
  7. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_WRITE_MSH_H
  9. #define IGL_WRITE_MSH_H
  10. #include "igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <string>
  13. #include <vector>
  14. namespace igl
  15. {
  16. /// write triangle surface mesh and tetrahedral volume mesh to .msh file
  17. ///
  18. /// @param[in] msh - file name
  19. /// @param[in] X eigen double matrix of vertex positions #X by 3
  20. /// @param[in] Tri #Tri eigen integer matrix of triangular faces indices into vertex positions
  21. /// @param[in] Tet #Tet eigen integer matrix of tetrahedral indices into vertex positions
  22. /// @param[in] TriTag #Tri eigen integer vector of tags associated with surface faces {0s}
  23. /// @param[in] TetTag #Tet eigen integer vector of tags associated with volume elements {0s}
  24. /// @param[in] XFields #XFields list of strings with field names associated with nodes
  25. /// @param[in] XF #XFields list of eigen double matrices, fields associated with nodes
  26. /// @param[in] EFields #EFields list of strings with field names associated with elements
  27. /// @param[in] TriF #EFields list of eigen double matrices, fields associated with surface elements
  28. /// @param[in] TetF #EFields list of eigen double matrices, fields associated with volume elements
  29. ///
  30. /// \bug files are always stored in binary format
  31. /// \bug file format is 2.2
  32. /// \bug only triangle surface elements and tetrahedral volumetric elements are supported
  33. /// \bug only 3D information is supported
  34. /// \bug the tag id is duplicated for physical (0) and elementary (1)
  35. /// \bug same element fields are expected to be associated with surface elements and volumetric elements
  36. template <
  37. typename DerivedX,
  38. typename DerivedTri,
  39. typename DerivedTet,
  40. typename DerivedTriTag,
  41. typename DerivedTetTag,
  42. typename MatrixXF,
  43. typename MatrixTriF,
  44. typename MatrixTetF
  45. >
  46. IGL_INLINE bool writeMSH(
  47. const std::string &msh,
  48. const Eigen::MatrixBase<DerivedX> &X,
  49. const Eigen::MatrixBase<DerivedTri> &Tri,
  50. const Eigen::MatrixBase<DerivedTet> &Tet,
  51. const Eigen::MatrixBase<DerivedTriTag> &TriTag,
  52. const Eigen::MatrixBase<DerivedTetTag> &TetTag,
  53. const std::vector<std::string> &XFields,
  54. const std::vector<MatrixXF> &XF,
  55. const std::vector<std::string> &EFields,
  56. const std::vector<MatrixTriF> &TriF,
  57. const std::vector<MatrixTetF> &TetF);
  58. }
  59. #ifndef IGL_STATIC_LIBRARY
  60. # include "writeMSH.cpp"
  61. #endif
  62. #endif //IGL_WRITE_MSH_H