writePLY.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #ifndef IGL_WRITEPLY_H
  2. #define IGL_WRITEPLY_H
  3. #include "igl_inline.h"
  4. #include "FileEncoding.h"
  5. #include <string>
  6. #include <iostream>
  7. #include <vector>
  8. #include <Eigen/Core>
  9. namespace igl
  10. {
  11. /// write triangular mesh to ply file
  12. ///
  13. /// @tparam Derived from Eigen matrix parameters
  14. /// @param[in] ply_stream ply file output stream
  15. /// @param[in] V (#V,3) matrix of vertex positions
  16. /// @param[in] F (#F,3) list of face indices into vertex positions
  17. /// @param[in] E (#E,2) list of edge indices into vertex positions
  18. /// @param[in] N (#V,3) list of normals
  19. /// @param[in] UV (#V,2) list of texture coordinates
  20. /// @param[in] VD (#V,*) additional vertex data
  21. /// @param[in] Vheader (#V) list of vertex data headers
  22. /// @param[in] FD (#F,*) additional face data
  23. /// @param[in] Fheader (#F) list of face data headers
  24. /// @param[in] ED (#E,*) additional edge data
  25. /// @param[in] Eheader (#E) list of edge data headers
  26. /// @param[in] comments (*) file comments
  27. /// @param[in] encoding - enum, to set binary or ascii file format
  28. /// @return true on success, false on errors
  29. template <
  30. typename DerivedV,
  31. typename DerivedF,
  32. typename DerivedE,
  33. typename DerivedN,
  34. typename DerivedUV,
  35. typename DerivedVD,
  36. typename DerivedFD,
  37. typename DerivedED
  38. >
  39. bool writePLY(
  40. std::ostream & ply_stream,
  41. const Eigen::MatrixBase<DerivedV> & V,
  42. const Eigen::MatrixBase<DerivedF> & F,
  43. const Eigen::MatrixBase<DerivedE> & E,
  44. const Eigen::MatrixBase<DerivedN> & N,
  45. const Eigen::MatrixBase<DerivedUV> & UV,
  46. const Eigen::MatrixBase<DerivedVD> & VD,
  47. const std::vector<std::string> & VDheader,
  48. const Eigen::MatrixBase<DerivedFD> & FD,
  49. const std::vector<std::string> & FDheader,
  50. const Eigen::MatrixBase<DerivedED> & ED,
  51. const std::vector<std::string> & EDheader,
  52. const std::vector<std::string> & comments,
  53. FileEncoding encoding
  54. );
  55. /// \overload
  56. /// \param[in] filename path to .ply file
  57. template <
  58. typename DerivedV,
  59. typename DerivedF,
  60. typename DerivedE,
  61. typename DerivedN,
  62. typename DerivedUV,
  63. typename DerivedVD,
  64. typename DerivedFD,
  65. typename DerivedED
  66. >
  67. bool writePLY(
  68. const std::string & filename,
  69. const Eigen::MatrixBase<DerivedV> & V,
  70. const Eigen::MatrixBase<DerivedF> & F,
  71. const Eigen::MatrixBase<DerivedE> & E,
  72. const Eigen::MatrixBase<DerivedN> & N,
  73. const Eigen::MatrixBase<DerivedUV> & UV,
  74. const Eigen::MatrixBase<DerivedVD> & VD,
  75. const std::vector<std::string> & VDheader,
  76. const Eigen::MatrixBase<DerivedFD> & FD,
  77. const std::vector<std::string> & FDheader,
  78. const Eigen::MatrixBase<DerivedED> & ED,
  79. const std::vector<std::string> & EDheader,
  80. const std::vector<std::string> & comments,
  81. FileEncoding encoding);
  82. /// \overload
  83. template <
  84. typename DerivedV,
  85. typename DerivedF
  86. >
  87. bool writePLY(
  88. const std::string & filename,
  89. const Eigen::MatrixBase<DerivedV> & V,
  90. const Eigen::MatrixBase<DerivedF> & F
  91. );
  92. /// \overload
  93. template <
  94. typename DerivedV,
  95. typename DerivedF,
  96. typename DerivedE
  97. >
  98. bool writePLY(
  99. const std::string & filename,
  100. const Eigen::MatrixBase<DerivedV> & V,
  101. const Eigen::MatrixBase<DerivedF> & F,
  102. const Eigen::MatrixBase<DerivedE> & E
  103. );
  104. /// \overload
  105. template <
  106. typename DerivedV,
  107. typename DerivedF,
  108. typename DerivedN,
  109. typename DerivedUV
  110. >
  111. bool writePLY(
  112. const std::string & filename,
  113. const Eigen::MatrixBase<DerivedV> & V,
  114. const Eigen::MatrixBase<DerivedF> & F,
  115. const Eigen::MatrixBase<DerivedN> & N,
  116. const Eigen::MatrixBase<DerivedUV> & UV
  117. );
  118. /// \overload
  119. template <
  120. typename DerivedV,
  121. typename DerivedF,
  122. typename DerivedE,
  123. typename DerivedN,
  124. typename DerivedUV
  125. >
  126. bool writePLY(
  127. const std::string & filename,
  128. const Eigen::MatrixBase<DerivedV> & V,
  129. const Eigen::MatrixBase<DerivedF> & F,
  130. const Eigen::MatrixBase<DerivedE> & E,
  131. const Eigen::MatrixBase<DerivedN> & N,
  132. const Eigen::MatrixBase<DerivedUV> & UV
  133. );
  134. /// \overload
  135. template <
  136. typename DerivedV,
  137. typename DerivedF
  138. >
  139. bool writePLY(
  140. const std::string & filename,
  141. const Eigen::MatrixBase<DerivedV> & V,
  142. const Eigen::MatrixBase<DerivedF> & F,
  143. FileEncoding encoding
  144. );
  145. /// \overload
  146. template <
  147. typename DerivedV,
  148. typename DerivedF,
  149. typename DerivedE
  150. >
  151. bool writePLY(
  152. const std::string & filename,
  153. const Eigen::MatrixBase<DerivedV> & V,
  154. const Eigen::MatrixBase<DerivedF> & F,
  155. const Eigen::MatrixBase<DerivedE> & E,
  156. FileEncoding encoding
  157. );
  158. /// \overload
  159. template <
  160. typename DerivedV,
  161. typename DerivedF,
  162. typename DerivedN,
  163. typename DerivedUV,
  164. typename DerivedVD
  165. >
  166. bool writePLY(
  167. const std::string & filename,
  168. const Eigen::MatrixBase<DerivedV> & V,
  169. const Eigen::MatrixBase<DerivedF> & F,
  170. const Eigen::MatrixBase<DerivedN> & N,
  171. const Eigen::MatrixBase<DerivedUV> & UV,
  172. const Eigen::MatrixBase<DerivedVD> & VD=Eigen::MatrixXd(0,0),
  173. const std::vector<std::string> & VDheader={},
  174. const std::vector<std::string> & comments={}
  175. );
  176. /// \overload
  177. template <
  178. typename DerivedV,
  179. typename DerivedF,
  180. typename DerivedE,
  181. typename DerivedN,
  182. typename DerivedUV,
  183. typename DerivedVD
  184. >
  185. bool writePLY(
  186. const std::string & filename,
  187. const Eigen::MatrixBase<DerivedV> & V,
  188. const Eigen::MatrixBase<DerivedF> & F,
  189. const Eigen::MatrixBase<DerivedE> & E,
  190. const Eigen::MatrixBase<DerivedN> & N,
  191. const Eigen::MatrixBase<DerivedUV> & UV,
  192. const Eigen::MatrixBase<DerivedVD> & VD=Eigen::MatrixXd(0,0),
  193. const std::vector<std::string> & VDheader={},
  194. const std::vector<std::string> & comments={}
  195. );
  196. }
  197. #ifndef IGL_STATIC_LIBRARY
  198. # include "writePLY.cpp"
  199. #endif
  200. #endif