// mesh definition //#include //#include //#include #include #include #include #include #include #include #include #include // input output #include #include // std #include using namespace vcg; using namespace std; //struct MyFace; //struct MyEdge; //struct MyVertex: public VertexVN{}; //struct MyFace: public FaceAF{}; //struct MyMesh: public tri::TriMesh< vector, vector >{}; class MyEdge; // dummy prototype never used class MyFace; class MyVertex; class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vertex::Coord3f, vertex::Normal3f, vertex::BitFlags >{}; class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::FFAdj, face::VertexRef, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; #define FLAT 0 #define BUTTERFLY 2 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 ref_step [opt] \n" "Commands: \n" " Refinement rules:\n" " -m use simple midpoint subdivision (default) \n" " -b use butterfly subdivision scheme \n" " -l# refine only if the the edge is longer than #(default 0.0)\n" ); exit(0); } int RefMode = FLAT ; int i=4; 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::UpdateFlags::FaceBorderFromFF(m); vcg::tri::UpdateNormals::PerVertexNormalized(m); printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn); n_steps=atoi(argv[3]); for(i=0;i < n_steps;++i) { switch(RefMode){ case FLAT: Refine >(m,MidPoint(),length); break; case BUTTERFLY: Refine >(m,MidPointButterfly(),length); break; } } printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn); vcg::tri::io::PlyInfo pi; vcg::tri::io::ExporterPLY::Save(m,argv[2],pi.mask); return 0; }