2004-07-13 17:55:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
// stuff to define the mesh
|
|
|
|
#include <vcg/simplex/vertex/with/atvmvn.h>
|
|
|
|
#include <vcg/complex/tetramesh/base.h>
|
|
|
|
#include <vcg/simplex/tetrahedron/with/atavtq.h>
|
|
|
|
|
|
|
|
// io
|
|
|
|
#include <wrap/io_tetramesh/import_ply.h>
|
|
|
|
#include <wrap/io_tetramesh/export_ply.h>
|
|
|
|
#include <wrap/io_tetramesh/import_ts.h>
|
|
|
|
|
|
|
|
|
|
|
|
class MyEdge;
|
|
|
|
class MyTetrahedron;
|
|
|
|
class MyFace;
|
|
|
|
class MyVertex:public vcg::VertexATVMVNf<DUMMYEDGETYPE , MyFace, MyTetrahedron>{} ;
|
|
|
|
class MyTetrahedron : public vcg::TetraATAVTQ<MyVertex,MyTetrahedron>{};
|
|
|
|
|
|
|
|
class MyTMesh: public vcg::tetra::Tetramesh< std::vector<MyVertex>, std::vector<MyTetrahedron > >{};
|
|
|
|
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
#include <vcg/complex/local_optimization.h>
|
2004-07-13 17:55:45 +02:00
|
|
|
#include <vcg/complex/local_optimization/tetra_edge_collapse.h>
|
|
|
|
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
vcg::LocalOptimization<MyTMesh> *loc;
|
|
|
|
//vcg::tetra::TetraEdgeCollapse<MyTMesh> c;
|
2004-07-13 17:55:45 +02:00
|
|
|
MyTMesh mesh;
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
int main(int,char**argv,int num_op){
|
|
|
|
loc=new vcg::LocalOptimization<MyTMesh>(mesh);
|
2004-07-13 17:55:45 +02:00
|
|
|
|
|
|
|
vcg::tetra::io::ImporterTS<MyTMesh>::Open(mesh,argv[1]);
|
2004-09-01 14:08:39 +02:00
|
|
|
//vcg::tetra::io::ImporterTS<MyTMesh>::Open(mesh,"d:/sphere.ts");
|
2004-07-13 17:55:45 +02:00
|
|
|
printf("mesh loaded %d %d \n",mesh.vn,mesh.tn);
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
/*vcg::tetra::TetraEdgeCollapse<MyTMesh> *_ ;
|
|
|
|
bool res;*/
|
2004-07-13 17:55:45 +02:00
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
|
2004-07-13 17:55:45 +02:00
|
|
|
::VTTopology(mesh.vert,mesh.tetra);
|
|
|
|
|
|
|
|
vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
|
|
|
|
::TTTopology(mesh.vert,mesh.tetra);
|
|
|
|
|
|
|
|
vcg::tetra::UpdateTetraTopology<MyTMesh::VertexContainer,MyTMesh::TetraContainer>
|
|
|
|
::setExternalVertices(mesh.vert,mesh.tetra);
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
vcg::tetra::TetraEdgeCollapse<MyTMesh>::Init(mesh,loc->h);
|
|
|
|
|
|
|
|
bool res;
|
|
|
|
do{
|
|
|
|
loc->SetTargetOperations(num_op);
|
2004-07-13 17:55:45 +02:00
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
res = loc->DoOptimization();
|
2004-07-13 17:55:45 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2004-09-01 14:08:39 +02:00
|
|
|
|
2004-07-13 17:55:45 +02:00
|
|
|
vcg::tetra::io::ExporterPLY<MyTMesh>::Save(mesh,"out.ply");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|