// mesh definition #include #include #include #include #include #include // input output #include #include // std #include using namespace vcg; using namespace std; struct MyFace; struct MyTetra; struct MyEdge; struct MyVertex: public VertexAFVNf{}; struct MyFace: public FaceAF{}; struct MyMesh: public tri::TriMesh< vector, vector >{}; #define FLAT 0 #define ARC 1 #define BUTTERFLY 2 //#define BUTTERFLY2 3 //#define PLANE 4 //#define SPHERE 5 #define LENGTH 6 #define ONLY_SEL 7 int main(int argc, char **argv){ if(argc<4) { printf( "\n PlyRefine ("__DATE__")\n" " Visual Computing Group I.S.T.I. C.N.R.\n" "Usage: PlyRefine filein.ply fileout.ply [command list]\n" "Commands: \n" " Refinement rules:\n" " -m# midpoint flat \n" " -a# midpoint arc\n" " -b# butterfly\n" //" -p# clip with plane \n" //" -s# clip with sphere \n" " Selective Refinement\n" " -L# refine only if the the edge is longer than #(default 0.0)\n" " -S(0|1) refine only selected faces\n" ); exit(0); } typedef pair OP_TYPE; vector operations; bool only_selected=false; int i=3; int n_steps;float length=0; while(i::Open(m,argv[1])!=0) { printf("Error reading file %s\n",argv[1]); exit(0); } vcg::tri::UpdateTopology::FaceFace(m); vcg::tri::UpdateTopology::FaceBorderFlags(m); vcg::tri::UpdateNormals::PerVertexNormalized(m); int h; for(i=0;i < operations.size();++i){ switch(operations[i].first){ case FLAT: for(h=0;h(),length,only_selected); } break; case ARC: for(h=0;h(),length,only_selected);} break; case BUTTERFLY: for(h=0;h(),length,only_selected); } break; //case BUTTERFLY2: // for(h=0;h(),length,only_selected); // } // break; /* case PLANE: for(h=0;h(),length,only_selected); } break; case SPHERE: for(h=0;h(),length,only_selected); } break; */ case LENGTH: length = operations[i].second; break; case ONLY_SEL: only_selected = (bool)operations[i].second; break; } } //m.ComputeNormalizedVertexNormal(); //Refine(m,MidPointArc(),0); vcg::tri::io::PlyInfo pi; vcg::tri::io::ExporterPLY::Save(m,argv[2],pi.mask); return 0; }