#include // stuff to define the mesh #include #include #include // the trackball #include // io #include #include #include class MyEdge; class MyTetrahedron; class MyFace; class MyVertex:public vcg::VertexATVMVNf{} ; class MyTetrahedron : public vcg::TetraATAVTQ{}; class MyTMesh: public vcg::tetra::Tetramesh< std::vector, std::vector >{}; #include #include vcg::LocalOptimization loc; vcg::tetra::TetraEdgeCollapse c; MyTMesh mesh; int main(int,char**argv){ loc.m = & mesh; vcg::tetra::io::ImporterTS::Open(mesh,argv[1]); printf("mesh loaded %d %d \n",mesh.vn,mesh.tn); // vcg::tetra::io::ExporterPLY::Save(mesh,(string(argv[1])+string(".ply")).c_str()); vcg::tetra::TetraEdgeCollapse *_ ; bool res; do{ vcg::tetra::UpdateTetraTopology ::VTTopology(mesh.vert,mesh.tetra); vcg::tetra::UpdateTetraTopology ::TTTopology(mesh.vert,mesh.tetra); vcg::tetra::UpdateTetraTopology ::setExternalVertices(mesh.vert,mesh.tetra); _=new vcg::tetra::TetraEdgeCollapse(); loc.h.push_back(vcg::LocalOptimization::HeapElem(_)); loc.Init(); loc.SetTargetSimplices(10); res = loc.DoOptimization(); printf("ood %d\n bor %d\n vol %d \n lkv %d \n lke %d \n lkf %d \n", FAIL::OFD(), FAIL::BOR(), FAIL::VOL(), FAIL::LKV(), FAIL::LKE(), FAIL::LKF() ); printf("mesh %d %d \n",mesh.vn,mesh.tn); }while(!res); vcg::tetra::io::ExporterPLY::Save(mesh,"out.ply"); return 0; }