// mesh definition #include #include #include #include // input output #include #include #include "nxsexport.h" #include "extraction.h" #include "metric.h" using namespace vcg; using namespace nxs; struct MyFace; struct MyTetra; struct MyEdge; struct MyVertex: public VertexAFVNf{}; struct MyFace: public FaceAF{}; struct MyMesh: public tri::TriMesh< vector, vector >{}; int main(int argc, char *argv[]) { string input; string output; float target_error = 0; int option; while((option = getopt(argc, argv, "e:")) != EOF) { switch(option) { case 'e': target_error = atof(optarg); break; case 'o': output = optarg; break; } } if(optind != argc -1) { cerr << "Usage: " << argv[0] << " [options]\n" << " -e : extraction target error\n" << " -o : output name\n\n"; return -1; } input = argv[optind]; if(!output.size()) output = input + ".ply"; Nexus nexus; if(!nexus.Load(input.c_str())) { cerr << "Could not open file: " << input.c_str() << ".nxs\n"; return -1; } Extraction extr; extr.SetMetric(new FlatMetric); extr.target_error = target_error; extr.Extract(&nexus); vector selected; for(unsigned int i = 0; i < extr.selected.size(); i++) selected.push_back(extr.selected[i].id); MyMesh m; ExportTriMesh(nexus, selected, m); //write to ply: vcg::tri::io::PlyInfo pi; vcg::tri::io::ExporterPLY::Save(m, output.c_str(), pi.mask); return 0; }