writeSTL.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_WRITESTL_H
  9. #define IGL_WRITESTL_H
  10. #include "igl_inline.h"
  11. #include "FileEncoding.h"
  12. #ifndef IGL_NO_EIGEN
  13. # include <Eigen/Core>
  14. #endif
  15. #include <string>
  16. #include <vector>
  17. namespace igl
  18. {
  19. /// Write a mesh to an stl file.
  20. ///
  21. /// @tparam Scalar type for positions and vectors (will be read as double and cast
  22. /// to Scalar)
  23. /// @param[in] filename path to .obj file
  24. /// @param[in] V double matrix of vertex positions #F*3 by 3
  25. /// @param[in] F index matrix of triangle indices #F by 3
  26. /// @param[in] N double matrix of vertex positions #F by 3
  27. /// @param[in] encoding enum to set file encoding (ascii by default)
  28. /// @return true on success, false on errors
  29. ///
  30. template <typename DerivedV, typename DerivedF, typename DerivedN>
  31. IGL_INLINE bool writeSTL(
  32. const std::string & filename,
  33. const Eigen::MatrixBase<DerivedV> & V,
  34. const Eigen::MatrixBase<DerivedF> & F,
  35. const Eigen::MatrixBase<DerivedN> & N,
  36. FileEncoding encoding=FileEncoding::Ascii);
  37. /// \overload
  38. template <typename DerivedV, typename DerivedF>
  39. IGL_INLINE bool writeSTL(
  40. const std::string & filename,
  41. const Eigen::MatrixBase<DerivedV> & V,
  42. const Eigen::MatrixBase<DerivedF> & F,
  43. FileEncoding encoding=FileEncoding::Ascii);
  44. }
  45. #ifndef IGL_STATIC_LIBRARY
  46. # include "writeSTL.cpp"
  47. #endif
  48. #endif