writeOBJ.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_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. // Inputs:
  20. // str path to outputfile
  21. // V #V by 3 mesh vertex positions
  22. // F #F by 3|4 mesh indices into V
  23. // CN #CN by 3 normal vectors
  24. // FN #F by 3|4 corner normal indices into CN
  25. // TC #TC by 2|3 texture coordinates
  26. // FTC #F by 3|4 corner texture coord indices into TC
  27. // Returns true on success, false on error
  28. //
  29. // Known issues: Horrifyingly, this does not have the same order of
  30. // parameters as readOBJ.
  31. template <
  32. typename DerivedV,
  33. typename DerivedF,
  34. typename DerivedCN,
  35. typename DerivedFN,
  36. typename DerivedTC,
  37. typename DerivedFTC>
  38. IGL_INLINE bool writeOBJ(
  39. const std::string str,
  40. const Eigen::MatrixBase<DerivedV>& V,
  41. const Eigen::MatrixBase<DerivedF>& F,
  42. const Eigen::MatrixBase<DerivedCN>& CN,
  43. const Eigen::MatrixBase<DerivedFN>& FN,
  44. const Eigen::MatrixBase<DerivedTC>& TC,
  45. const Eigen::MatrixBase<DerivedFTC>& FTC);
  46. template <typename DerivedV, typename DerivedF>
  47. IGL_INLINE bool writeOBJ(
  48. const std::string str,
  49. const Eigen::MatrixBase<DerivedV>& V,
  50. const Eigen::MatrixBase<DerivedF>& F);
  51. // Write a mesh of mixed tris and quads to an ascii obj file
  52. // Inputs:
  53. // str path to outputfile
  54. // V #V by 3 mesh vertex positions
  55. // F #F std::vector of std::vector<Index> of size 3 or 4 mesh indices into V
  56. // Returns true on success, false on error
  57. template <typename DerivedV, typename T>
  58. IGL_INLINE bool writeOBJ(
  59. const std::string &str,
  60. const Eigen::MatrixBase<DerivedV>& V,
  61. const std::vector<std::vector<T> >& F);
  62. }
  63. #ifndef IGL_STATIC_LIBRARY
  64. # include "writeOBJ.cpp"
  65. #endif
  66. #endif