writeSTL.h 1.5 KB

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