// // IGL Lib - Simple C++ mesh library // // Copyright 2011, Daniele Panozzo. All rights reserved. // WARNING: These functions require matlab installed // Additional header folder required: // /Applications/MATLAB_R2010b.app/extern/include // Additional binary lib to be linked with: // /Applications/MATLAB_R2010b.app/bin/maci64/libeng.dylib // /Applications/MATLAB_R2010b.app/bin/maci64/libmx.dylib // MAC ONLY: // Add to the environment variables: // DYLD_LIBRARY_PATH = /Applications/MATLAB_R2010b.app/bin/maci64 // PATH = /opt/local/bin:/opt/local/sbin:/Applications/MATLAB_R2010b.app/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin #ifndef MATLAB_INTERFACE_H #define MATLAB_INTERFACE_H #include #include #include #include #include #include #include #include "engine.h" // Matlab engine header namespace igl { // Global pointer to the matlab engine Engine* mlengine = 0; // Init the MATLAB engine // (no need to call it directly since it is automatically invoked by any other command) void mlinit() { mlengine = engOpen("\0"); } // Closes the MATLAB engine void mlclose(Engine* engine) { engClose(mlengine); mlengine = 0; } // Send a matrix to MATLAB void mlsetmatrix(std::string name, Eigen::MatrixXd& M) { if (mlengine == 0) mlinit(); mxArray *A = mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); double *pM = mxGetPr(A); int c = 0; for(int j=0; j t; mxArray *ary = engGetVariable(mlengine, name.c_str()); if (ary == NULL) { m = 0; n = 0; M = Eigen::MatrixXd(0,0); } else { m = mxGetM(ary); n = mxGetN(ary); M = Eigen::MatrixXd(m,n); double *pM = mxGetPr(ary); int c = 0; for(int j=0; j t; mxArray *ary = engGetVariable(mlengine, name.c_str()); if (ary == NULL) { m = 0; n = 0; M = Eigen::MatrixXi(0,0); } else { m = mxGetM(ary); n = mxGetN(ary); M = Eigen::MatrixXi(m,n); double *pM = mxGetPr(ary); int c = 0; for(int j=0; j' && buf[1] == '>' && buf[2] == ' ') buf += 3; if (buf[0] == '\n') ++buf; return std::string(buf); } } #endif