matlabinterface.h 2.6 KB

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