#include #include #include #include #include #include #include #include #include // input output #include #include // std #include using namespace vcg; using namespace std; class MyFace; class MyVertex; struct MyUsedTypes : public UsedTypes< Use ::AsVertexType, Use ::AsFaceType>{}; class MyVertex : public Vertex {}; class MyFace : public Face < MyUsedTypes, face::VertexRef, face::BitFlags > {}; class MyMesh : public vcg::tri::TriMesh< vector, vector > {}; int main(int argc,char **argv ) { if(argc<2) { printf( "\n trimesh_join ("__DATE__")\n" "Visual Computing Group I.S.T.I. C.N.R.\n" "Usage: trimesh_join [opt] filename.ply [filename.ply | *] \n" "where opt can be:\n" " -b xmin ymin zmin xmax ymax zmax : \n" " Returns only mesh composed by faces inside specified bbox\n" " -t Just scan all the input files computing the total bbox\n" ); exit(0); } MyMesh ml,mr; Box3f ClipBB,TotBB; bool ClipFlag=false,MergeFlag=true; int i=1; // Parsing option loop while(argv[i][0]=='-') { switch(argv[i][1]) { case 'b': { if(argc::Open(mr,argv[i])!=0) { printf("Error reading file %s\n",argv[1]); exit(0); } printf("Input mesh %3i vn:%9i fn:%9i\n",i, mr.vn, mr.fn); if(ClipFlag) { tri::Clean::ClipWithBox(mr,ClipBB); printf(" clipped to vn:%9i fn:%9i\n", mr.vn, mr.fn); } tri::UpdateBounding::Box(mr); TotBB.Add(mr.bbox); if(MergeFlag) tri::Append::Mesh(ml,mr); // append mesh mr to ml ++i; } printf("Output mesh vn:%i fn:%i\n",ml.vn,ml.fn); tri::io::ExporterPLY::Save(ml,"joined.ply"); int dv=tri::Clean::RemoveDuplicateVertex(ml); printf("Removed %i duplicated vertices\n",dv); tri::io::ExporterPLY::Save(ml,"joined_unif.ply"); printf("Final BBox of mesh :\n (%7.4f %7.4f %7.4f) - (%7.4f %7.4f %7.4f)\n", TotBB.min[0],TotBB.min[1],TotBB.min[2], TotBB.max[0],TotBB.max[1],TotBB.max[2]); }