matlabinterface.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef IGL_MATLAB_INTERFACE_H
  2. #define IGL_MATLAB_INTERFACE_H
  3. #include "../igl_inline.h"
  4. //
  5. // IGL Lib - Simple C++ mesh library
  6. //
  7. // Copyright 2011, Daniele Panozzo. All rights reserved.
  8. // WARNING: These functions require matlab installed
  9. // Additional header folder required:
  10. // /Applications/MATLAB_R2011a.app/extern/include
  11. // Additional binary lib to be linked with:
  12. // /Applications/MATLAB_R2011a.app/bin/maci64/libeng.dylib
  13. // /Applications/MATLAB_R2011a.app/bin/maci64/libmx.dylib
  14. // MAC ONLY:
  15. // Add to the environment variables:
  16. // DYLD_LIBRARY_PATH = /Applications/MATLAB_R2011a.app/bin/maci64/
  17. // PATH = /opt/local/bin:/opt/local/sbin:/Applications/MATLAB_R2011a.app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin
  18. #include <Eigen/Core>
  19. #include <string>
  20. #include <complex>
  21. #include <cassert>
  22. #include <map>
  23. #include <string>
  24. #include <vector>
  25. #include "engine.h" // Matlab engine header
  26. namespace igl
  27. {
  28. // Init the MATLAB engine
  29. // (no need to call it directly since it is automatically invoked by any other command)
  30. IGL_INLINE void mlinit(Engine** engine);
  31. // Closes the MATLAB engine
  32. IGL_INLINE void mlclose(Engine** engine);
  33. // Send a matrix to MATLAB
  34. IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXd& M);
  35. // Send a matrix to MATLAB
  36. IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXf& M);
  37. // Send a matrix to MATLAB
  38. IGL_INLINE void mlsetmatrix(Engine** engine, std::string name, const Eigen::MatrixXi& M);
  39. // Send a matrix to MATLAB
  40. IGL_INLINE void mlsetmatrix(Engine** mlengine, std::string name, const Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
  41. // Receive a matrix from MATLAB
  42. IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXd& M);
  43. // Receive a matrix from MATLAB
  44. IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXf& M);
  45. // Receive a matrix from MATLAB
  46. IGL_INLINE void mlgetmatrix(Engine** engine, std::string name, Eigen::MatrixXi& M);
  47. // Receive a matrix from MATLAB
  48. IGL_INLINE void mlgetmatrix(Engine** mlengine, std::string name, Eigen::Matrix<unsigned int, Eigen::Dynamic, Eigen::Dynamic >& M);
  49. // Send a single scalar to MATLAB
  50. IGL_INLINE void mlsetscalar(Engine** engine, std::string name, double s);
  51. // Receive a single scalar from MATLAB
  52. IGL_INLINE double mlgetscalar(Engine** engine, std::string name);
  53. // Execute arbitrary MATLAB code and return the MATLAB output
  54. IGL_INLINE std::string mleval(Engine** engine, std::string code);
  55. }
  56. // Be sure that this is not compiled into libigl.a
  57. #ifdef IGL_HEADER_ONLY
  58. # include "matlabinterface.cpp"
  59. #endif
  60. #endif