example2.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // IGL Lib - Simple C++ mesh library
  3. //
  4. // Copyright 2011, Daniele Panozzo. All rights reserved.
  5. //
  6. //
  7. // Example that shows the integration with matlab
  8. //
  9. // IMPORTANT DO NOT REMOVE OR MOVE
  10. #define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
  11. #include <iostream>
  12. #include <string>
  13. #include <read.h>
  14. #include <matlabinterface.h>
  15. using namespace std;
  16. int main (int argc, const char * argv[])
  17. {
  18. // read the header of matlabinterface.h for compilation instructions
  19. Eigen::MatrixXd V,V2;
  20. Eigen::MatrixXi F,F2;
  21. // Read mesh from file
  22. igl::read(string(argv[1]),V,F);
  23. // Send mesh to matlab
  24. igl::mlsetmatrix("V",V);
  25. igl::mlsetmatrix("F",F);
  26. // Plot the mesh from matlab
  27. igl::mleval("trimesh(F,V(:,1),V(:,2),V(:,3))");
  28. // Receive mesh from matlab
  29. igl::mlgetmatrix("V",V2);
  30. igl::mlgetmatrix("F",F2);
  31. // Plot the received mesh
  32. cerr << "V " << endl << V2 << endl;
  33. cerr << "F " << endl << F2 << endl;
  34. // It is also possible to send scalars
  35. igl::mlsetscalar("s", 3);
  36. cerr << "s = " << igl::mlgetscalar("s") << endl;
  37. // If the program closes the matlab session is killed too..
  38. getchar();
  39. return 0;
  40. }