#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Whether medit program is install //#define WITH_MEDIT const char * USAGE= "Usage:\n" " ./bbw_demo shape{.obj|.off|.mesh} skeleton{.tgf|.bf}\n" ; // Read a surface mesh from a {.obj|.off|.mesh} files // Inputs: // mesh_filename path to {.obj|.off|.mesh} file // Outputs: // V #V by 3 list of mesh vertex positions // F #F by 3 list of triangle indices // Returns true only if successfuly able to read file bool load_mesh_from_file( const std::string mesh_filename, Eigen::MatrixXd & V, Eigen::MatrixXi & F) { using namespace std; using namespace igl; using namespace Eigen; string dirname, basename, extension, filename; pathinfo(mesh_filename,dirname,basename,extension,filename); transform(extension.begin(), extension.end(), extension.begin(), ::tolower); bool success = false; if(extension == "obj") { success = readOBJ(mesh_filename,V,F); }else if(extension == "off") { success = readOFF(mesh_filename,V,F); }else if(extension == "mesh") { // Unused Tets read from .mesh file MatrixXi Tets; success = readMESH(mesh_filename,V,Tets,F); // We're not going to use any input tets. Only the surface if(Tets.size() > 0 && F.size() == 0) { // If Tets read, but no faces then use surface of tet volume }else { // Rearrange vertices so that faces come first VectorXi IM; faces_first(V,F,IM); // Dont' bother reordering Tets, but this is how one would: //Tets = // Tets.unaryExpr(bind1st(mem_fun( static_cast(&VectorXi::operator())), // &IM)).eval(); // Don't throw away any interior vertices, since user may want weights // there } }else { cerr<<"Error: Unknown shape file format extension: ."<