Last active
January 11, 2019 07:40
-
-
Save alecjacobson/b17f309f083a534a558477c065ea3fd7 to your computer and use it in GitHub Desktop.
Revisions
-
alecjacobson revised this gist
Dec 15, 2016 . No changes.There are no files selected for viewing
-
alecjacobson created this gist
Dec 15, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ #include <igl/guess_extension.h> #include <igl/read_triangle_mesh.h> #include <igl/viewer/Viewer.h> #include <Eigen/Core> #include <iostream> #include <string> #include <cstdio> #include <unistd.h> int main(int argc, char * argv[]) { Eigen::MatrixXd V; Eigen::MatrixXi F; if(argc >= 2) { igl::read_triangle_mesh(argv[1],V,F); }else if(isatty(fileno(stdin))) { std::cerr<<R"(Usage: ./viewmesh input.obj ./viewmesh < input.obj cat input.obj | ./viewmesh )"; return EXIT_FAILURE; }else{ FILE * fp = tmpfile(); while(std::cin.good()) { std::vector<char> buf(1024); std::cin.read(&buf[0],buf.size()); fwrite(&buf[0],sizeof(char),std::cin.gcount(),fp); } fp = freopen(NULL,"r",fp); std::string ext = igl::guess_extension(fp); std::cout<<"[treating stdin as ."<<ext<<" file]"<<std::endl; igl::read_triangle_mesh(ext,fp,V,F); } igl::viewer::Viewer v; v.data.set_mesh(V,F); v.launch(); return EXIT_SUCCESS; }