// mesh definition //#include //#include //#include #include #include #include #include #include #include #include #include #include // input output #include #include // std #include #include #include using namespace vcg; using namespace std; class MyEdge; // dummy prototype never used class MyFace; class MyVertex; class MyVertex : public VertexSimp2< MyVertex, MyEdge, MyFace, vert::Coord3f, vert::Normal3f, vert::BitFlags, vert::Mark>{}; class MyFace : public FaceSimp2 < MyVertex, MyEdge, MyFace, face::VertexRef, face::Normal3f, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; bool callback(int percent, const char *str) { cout << "str: " << str << " " << percent << "%\n"; return true; } int main(int argc, char **argv) { if(argc<3) { printf( "\n trimesh_ball_pivoting ("__DATE__")\n" " Visual Computing Group I.S.T.I. C.N.R.\n" "Usage: trimesh_ball_pivoting filein.ply fileout.ply [opt]\n" "options: \n" "-r radius of the rolling ball\n" "-c clustering radius (as fraction of radius) default: 0.05\n" ); exit(0); } float radius = 0.0f; float clustering = 0.05; int i = 3; while(i::Open(m,argv[1])!=0) { printf("Error reading file %s\n",argv[1]); exit(0); } vcg::tri::UpdateBounding::Box(m); vcg::tri::UpdateNormals::PerFace(m); printf("Input mesh vn:%i fn:%i\n",m.vn,m.fn); int t0=clock(); // Initialization tri::Pivot pivot(m, radius, clustering); printf("Ball radius: %f\nClustering points withing %f radii\n", pivot.radius, clustering); int t1=clock(); // the main processing pivot.buildMesh(callback); int t2=clock(); printf("Output mesh vn:%i fn:%i\n",m.vn,m.fn); printf("Created in :%i msec (%i+%i)\n",t2-t0,t1-t0,t2-t1); vcg::tri::io::PlyInfo pi; vcg::tri::io::ExporterPLY::Save(m,argv[2],pi.mask); return 0; }