writeMESH.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_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. // Templates:
  19. // Scalar type for positions and vectors (will be cast as double)
  20. // Index type for indices (will be cast to int)
  21. // Input:
  22. // mesh_file_name path of .mesh file
  23. // V double matrix of vertex positions #V by 3
  24. // T #T list of tet indices into vertex positions
  25. // F #F list of face indices into vertex positions
  26. //
  27. // Known bugs: Holes and regions are not supported
  28. template <typename Scalar, typename Index>
  29. IGL_INLINE bool writeMESH(
  30. const std::string mesh_file_name,
  31. const std::vector<std::vector<Scalar > > & V,
  32. const std::vector<std::vector<Index > > & T,
  33. const std::vector<std::vector<Index > > & F);
  34. // Templates:
  35. // DerivedV real-value: i.e. from MatrixXd
  36. // DerivedT integer-value: i.e. from MatrixXi
  37. // DerivedF integer-value: i.e. from MatrixXi
  38. // Input:
  39. // mesh_file_name path of .mesh file
  40. // V eigen double matrix #V by 3
  41. // T eigen int matrix #T by 4
  42. // F eigen int matrix #F by 3
  43. template <typename DerivedV, typename DerivedT, typename DerivedF>
  44. IGL_INLINE bool writeMESH(
  45. const std::string str,
  46. const Eigen::PlainObjectBase<DerivedV> & V,
  47. const Eigen::PlainObjectBase<DerivedT> & T,
  48. const Eigen::PlainObjectBase<DerivedF> & F);
  49. }
  50. #ifndef IGL_STATIC_LIBRARY
  51. # include "writeMESH.cpp"
  52. #endif
  53. #endif