writeOBJ.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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_WRITEOBJ_H
  9. #define IGL_WRITEOBJ_H
  10. #include "igl_inline.h"
  11. // History:
  12. // return type changed from void to bool Alec 20 Sept 2011
  13. #include <Eigen/Core>
  14. #include <string>
  15. #include <vector>
  16. namespace igl
  17. {
  18. /// Write a mesh in an ascii obj file
  19. ///
  20. /// @param[in] str path to outputfile
  21. /// @param[in] V #V by 3 mesh vertex positions
  22. /// @param[in] F #F by 3|4 mesh indices into V
  23. /// @param[in] CN #CN by 3 normal vectors
  24. /// @param[in] FN #F by 3|4 corner normal indices into CN
  25. /// @param[in] TC #TC by 2|3 texture coordinates
  26. /// @param[in] FTC #F by 3|4 corner texture coord indices into TC
  27. /// @return true on success, false on error
  28. ///
  29. /// \bug Horrifyingly, this does not have the same order of parameters as
  30. /// readOBJ.
  31. ///
  32. /// \see readOBJ
  33. template <
  34. typename DerivedV,
  35. typename DerivedF,
  36. typename DerivedCN,
  37. typename DerivedFN,
  38. typename DerivedTC,
  39. typename DerivedFTC>
  40. IGL_INLINE bool writeOBJ(
  41. const std::string str,
  42. const Eigen::MatrixBase<DerivedV>& V,
  43. const Eigen::MatrixBase<DerivedF>& F,
  44. const Eigen::MatrixBase<DerivedCN>& CN,
  45. const Eigen::MatrixBase<DerivedFN>& FN,
  46. const Eigen::MatrixBase<DerivedTC>& TC,
  47. const Eigen::MatrixBase<DerivedFTC>& FTC);
  48. /// \overload
  49. template <typename DerivedV, typename DerivedF>
  50. IGL_INLINE bool writeOBJ(
  51. const std::string str,
  52. const Eigen::MatrixBase<DerivedV>& V,
  53. const Eigen::MatrixBase<DerivedF>& F);
  54. /// Write a mesh of mixed tris and quads to an ascii obj file
  55. ///
  56. /// @param[in] str path to outputfile
  57. /// @param[in] V #V by 3 mesh vertex positions
  58. /// @param[in] F #F std::vector of std::vector<Index> of size 3 or 4 mesh indices into V
  59. /// @return true on success, false on error
  60. template <typename DerivedV, typename T>
  61. IGL_INLINE bool writeOBJ(
  62. const std::string &str,
  63. const Eigen::MatrixBase<DerivedV>& V,
  64. const std::vector<std::vector<T> >& F);
  65. }
  66. #ifndef IGL_STATIC_LIBRARY
  67. # include "writeOBJ.cpp"
  68. #endif
  69. #endif