00001
00002
00003 #include <vector>
00004
00005
00006 #include <vcg/simplex/vertex/with/atvmvn.h>
00007 #include <vcg/complex/tetramesh/base.h>
00008 #include <vcg/simplex/tetrahedron/with/atavtq.h>
00009
00010
00011 #include <wrap/io_tetramesh/import_ply.h>
00012 #include <wrap/io_tetramesh/export_ply.h>
00013 #include <wrap/io_tetramesh/import_ts.h>
00014
00015
00016 class MyEdge;
00017 class MyTetrahedron;
00018 class MyFace;
00019 class MyVertex:public vcg::VertexATVMVNf<DUMMYEDGETYPE , MyFace, MyTetrahedron>{} ;
00020 class MyTetrahedron : public vcg::TetraATAVTQ<MyVertex,MyTetrahedron>{};
00021
00022 class MyTMesh: public vcg::tetra::Tetramesh< std::vector<MyVertex>, std::vector<MyTetrahedron > >{};
00023
00024
00025 #include <vcg/complex/local_optimization.h>
00026 #include <vcg/complex/local_optimization/tetra_edge_collapse.h>
00027
00028
00029 vcg::LocalOptimization<MyTMesh> *loc;
00030
00031 MyTMesh mesh;
00032
00033 int main(int,char**argv,int num_op){
00034 loc=new vcg::LocalOptimization<MyTMesh>(mesh);
00035
00036 vcg::tetra::io::ImporterTS<MyTMesh>::Open(mesh,argv[1]);
00037
00038 printf("mesh loaded %d %d \n",mesh.vn,mesh.tn);
00039
00040
00041
00042
00043 vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
00044 ::VTTopology(mesh.vert,mesh.tetra);
00045
00046 vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
00047 ::TTTopology(mesh.vert,mesh.tetra);
00048
00049 vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
00050 ::setExternalVertices(mesh.vert,mesh.tetra);
00051
00052 vcg::tetra::TetraEdgeCollapse<MyTMesh>::Init(mesh,loc->h);
00053
00054 bool res;
00055 do{
00056 loc->SetTargetOperations(num_op);
00057
00058 res = loc->DoOptimization();
00059
00060 printf("ood %d\n bor %d\n vol %d \n lkv %d \n lke %d \n lkf %d \n",
00061 FAIL::OFD(),
00062 FAIL::BOR(),
00063 FAIL::VOL(),
00064 FAIL::LKV(),
00065 FAIL::LKE(),
00066 FAIL::LKF()
00067 );
00068 printf("mesh %d %d \n",mesh.vn,mesh.tn);
00069 }while(!res);
00070
00071
00072 vcg::tetra::io::ExporterPLY<MyTMesh>::Save(mesh,"out.ply");
00073
00074 return 0;
00075
00076 }